Merge lp:~rodrigo-moya/ubuntuone-client/use-a-checkbox-and-an-expander into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: Natalia Bidart
Approved revision: 605
Merged at revision: 606
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/use-a-checkbox-and-an-expander
Merge into: lp:ubuntuone-client
Diff against target: 352 lines (+132/-54)
2 files modified
nautilus/location-widget.c (+125/-52)
nautilus/location-widget.h (+7/-2)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/use-a-checkbox-and-an-expander
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Alejandro J. Cura (community) Approve
John Lenton Pending
Review via email: mp+31028@code.launchpad.net

Commit message

Use a expander and a checkbox in the Nautilus location bar

Description of the change

Use a expander and a checkbox in the Nautilus location bar

To post a comment you must log in.
602. By Rodrigo Moya

Store expander status in GConf

603. By Rodrigo Moya

Always show the checkbox

604. By Rodrigo Moya

Always show the checkbox

605. By Rodrigo Moya

Fixed resizing

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Can you please add some instruction about what to test/see? I'm a bit lost on how to be able to see this in action. What should I do in nautilus?

review: Needs Information
Revision history for this message
John Lenton (chipaca) wrote :

On Wed, Jul 28, 2010 at 05:19:43PM -0000, Naty Bidart wrote:
> Review: Needs Information
> Can you please add some instruction about what to test/see? I'm a bit lost on how to be able to see this in action. What should I do in nautilus?

http://people.gnome.org/~rodrigo/location-bar-with-expander.ogv
:)

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks and works great.

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nautilus/location-widget.c'
--- nautilus/location-widget.c 2010-07-21 11:41:51 +0000
+++ nautilus/location-widget.c 2010-07-27 11:29:41 +0000
@@ -24,6 +24,9 @@
24#include <libsyncdaemon/syncdaemon-shares-interface.h>24#include <libsyncdaemon/syncdaemon-shares-interface.h>
25#include "location-widget.h"25#include "location-widget.h"
2626
27#define EXPANDER_STATUS_SECTION "/apps/ubuntuone/nautilus"
28#define EXPANDER_STATUS_KEY EXPANDER_STATUS_SECTION "/expand-location"
29
27G_DEFINE_TYPE(LocationWidget, location_widget, GTK_TYPE_HBOX)30G_DEFINE_TYPE(LocationWidget, location_widget, GTK_TYPE_HBOX)
2831
29static void32static void
@@ -36,7 +39,8 @@
36 gtk_widget_hide (location->help_label);39 gtk_widget_hide (location->help_label);
37 } else {40 } else {
38 labeltext = g_strdup_printf ("<b>Ubuntu One</b> - %s", _("folder not synchronized"));41 labeltext = g_strdup_printf ("<b>Ubuntu One</b> - %s", _("folder not synchronized"));
39 gtk_widget_show (location->help_label);42 if (location->expander_status == GTK_ARROW_DOWN)
43 gtk_widget_show (location->help_label);
40 }44 }
41 45
42 gtk_label_set_markup (GTK_LABEL (location->info_label), labeltext);46 gtk_label_set_markup (GTK_LABEL (location->info_label), labeltext);
@@ -69,14 +73,11 @@
69 if (g_strcmp0 (path, location->path) == 0) {73 if (g_strcmp0 (path, location->path) == 0) {
70 set_label_text (location, success);74 set_label_text (location, success);
71 if (success) {75 if (success) {
72 gtk_widget_hide (location->enable_button);76 gtk_widget_hide (location->expander);
73 gtk_widget_show (location->disable_button);77 gtk_widget_set_sensitive (location->toggle_button, TRUE);
74 gtk_widget_set_sensitive (location->disable_button, TRUE);
75 gtk_widget_hide (location->help_label);78 gtk_widget_hide (location->help_label);
76 } else {79 } else {
77 gtk_widget_show (location->enable_button);80 gtk_widget_set_sensitive (location->toggle_button, TRUE);
78 gtk_widget_set_sensitive (location->enable_button, TRUE);
79 gtk_widget_hide (location->disable_button);
80 ubuntuone_show_error_dialog (location->uon, _("Error enabling folder"),81 ubuntuone_show_error_dialog (location->uon, _("Error enabling folder"),
81 _("Could not enable folder %s for synchronizing to Ubuntu One"),82 _("Could not enable folder %s for synchronizing to Ubuntu One"),
82 location->path);83 location->path);
@@ -95,16 +96,14 @@
95 path = syncdaemon_folder_info_get_path (folder_info);96 path = syncdaemon_folder_info_get_path (folder_info);
96 if (g_strcmp0 (path, location->path) == 0) {97 if (g_strcmp0 (path, location->path) == 0) {
97 if (success) {98 if (success) {
99 gtk_widget_show (location->expander);
98 set_label_text (location, FALSE);100 set_label_text (location, FALSE);
99 gtk_widget_show (location->enable_button);101 gtk_widget_set_sensitive (location->toggle_button, TRUE);
100 gtk_widget_set_sensitive (location->enable_button, TRUE);102 if (location->expander_status == GTK_ARROW_DOWN)
101 gtk_widget_hide (location->disable_button);103 gtk_widget_show (location->help_label);
102 gtk_widget_show (location->help_label);
103 } else {104 } else {
104 set_label_text (location, TRUE);105 set_label_text (location, TRUE);
105 gtk_widget_hide (location->enable_button);106 gtk_widget_set_sensitive (location->toggle_button, TRUE);
106 gtk_widget_show (location->disable_button);
107 gtk_widget_set_sensitive (location->disable_button, TRUE);
108 ubuntuone_show_error_dialog (location->uon, _("Error disabling folder"),107 ubuntuone_show_error_dialog (location->uon, _("Error disabling folder"),
109 _("Could not disable folder %s for synchronizing to Ubuntu One"),108 _("Could not disable folder %s for synchronizing to Ubuntu One"),
110 location->path);109 location->path);
@@ -122,6 +121,12 @@
122 g_signal_handlers_disconnect_by_func (location->uon->syncdaemon, folder_created_cb, location);121 g_signal_handlers_disconnect_by_func (location->uon->syncdaemon, folder_created_cb, location);
123 g_signal_handlers_disconnect_by_func (location->uon->syncdaemon, folder_deleted_cb, location);122 g_signal_handlers_disconnect_by_func (location->uon->syncdaemon, folder_deleted_cb, location);
124123
124 if (location->conf_notify_id != 0)
125 gconf_client_notify_remove (location->conf_client, location->conf_notify_id);
126
127 if (location->conf_client != NULL)
128 g_object_unref (G_OBJECT (location->conf_client));
129
125 if (location->path != NULL)130 if (location->path != NULL)
126 g_free (location->path);131 g_free (location->path);
127132
@@ -221,7 +226,7 @@
221 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (location))),226 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (location))),
222 0, GTK_MESSAGE_QUESTION,227 0, GTK_MESSAGE_QUESTION,
223 GTK_BUTTONS_YES_NO,228 GTK_BUTTONS_YES_NO,
224 question->str);229 "%s", question->str);
225 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)230 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
226 result = FALSE;231 result = FALSE;
227232
@@ -236,10 +241,9 @@
236}241}
237242
238static void243static void
239disable_u1_cb (GtkButton *button, gpointer user_data)244disable_u1 (LocationWidget *location)
240{245{
241 SyncdaemonInterface *interface;246 SyncdaemonInterface *interface;
242 LocationWidget *location = LOCATION_WIDGET (user_data);
243247
244 /* Perform the removal of this folder */248 /* Perform the removal of this folder */
245 interface = syncdaemon_daemon_get_folders_interface (location->uon->syncdaemon);249 interface = syncdaemon_daemon_get_folders_interface (location->uon->syncdaemon);
@@ -251,9 +255,7 @@
251 location->path);255 location->path);
252 if (folder_info != NULL && check_shared_for_folder (location, folder_info)) {256 if (folder_info != NULL && check_shared_for_folder (location, folder_info)) {
253 set_label_text (location, FALSE);257 set_label_text (location, FALSE);
254 gtk_widget_hide (location->disable_button);258 gtk_widget_set_sensitive (location->toggle_button, FALSE);
255 gtk_widget_show (location->enable_button);
256 gtk_widget_set_sensitive (location->enable_button, FALSE);
257259
258 syncdaemon_folders_interface_delete (260 syncdaemon_folders_interface_delete (
259 SYNCDAEMON_FOLDERS_INTERFACE (interface),261 SYNCDAEMON_FOLDERS_INTERFACE (interface),
@@ -265,10 +267,9 @@
265}267}
266268
267static void269static void
268enable_u1_cb (GtkButton *button, gpointer user_data)270enable_u1 (LocationWidget *location)
269{271{
270 SyncdaemonInterface *interface;272 SyncdaemonInterface *interface;
271 LocationWidget *location = LOCATION_WIDGET (user_data);
272273
273 /* Perform the addition of this folder */274 /* Perform the addition of this folder */
274 interface = syncdaemon_daemon_get_folders_interface (location->uon->syncdaemon);275 interface = syncdaemon_daemon_get_folders_interface (location->uon->syncdaemon);
@@ -281,7 +282,7 @@
281 g_free (labeltext);282 g_free (labeltext);
282283
283 start_spinner (location); 284 start_spinner (location);
284 gtk_widget_set_sensitive (location->enable_button, FALSE);285 gtk_widget_set_sensitive (location->toggle_button, FALSE);
285286
286 syncdaemon_folders_interface_create (SYNCDAEMON_FOLDERS_INTERFACE (interface),287 syncdaemon_folders_interface_create (SYNCDAEMON_FOLDERS_INTERFACE (interface),
287 location->path);288 location->path);
@@ -289,54 +290,114 @@
289}290}
290291
291static void292static void
293sync_toggled_cb (GtkToggleButton *button, gpointer user_data)
294{
295 LocationWidget *location = LOCATION_WIDGET (user_data);
296
297 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (location->toggle_button)))
298 enable_u1 (location);
299 else
300 disable_u1 (location);
301}
302
303static gboolean
304expander_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
305{
306 LocationWidget *location = LOCATION_WIDGET (user_data);
307
308 if (event->button == 1) {
309 switch (location->expander_status) {
310 case GTK_ARROW_DOWN: /* expanded */
311 gconf_client_set_bool (location->conf_client, EXPANDER_STATUS_KEY, FALSE, NULL);
312 break;
313 case GTK_ARROW_RIGHT: /* collapsed */
314 gconf_client_set_bool (location->conf_client, EXPANDER_STATUS_KEY, TRUE, NULL);
315 break;
316 }
317 }
318
319 return FALSE;
320}
321
322static void
323config_changed_cb (GConfClient *client, guint cnx_id, GConfEntry *entry, gpointer user_data)
324{
325 LocationWidget *location = LOCATION_WIDGET (user_data);
326
327 if (g_strcmp0 (gconf_entry_get_key (entry), EXPANDER_STATUS_KEY) == 0) {
328 if (gconf_value_get_bool (gconf_entry_get_value (entry))) {
329 location->expander_status = GTK_ARROW_DOWN;
330 gtk_widget_show (location->help_label);
331 } else {
332 location->expander_status = GTK_ARROW_RIGHT;
333 gtk_widget_hide (location->help_label);
334 }
335
336 gtk_arrow_set (GTK_ARROW (location->expander), location->expander_status, GTK_SHADOW_IN);
337 }
338}
339
340static void
292location_widget_init (LocationWidget *location)341location_widget_init (LocationWidget *location)
293{342{
294 GtkWidget *table, *box;343 GtkWidget *table, *box;
295344
296 location->path = NULL;345 location->path = NULL;
297 location->info_label = location->enable_button = NULL;346 location->info_label = NULL;
347
348 /* Read expander status from GConf */
349 location->conf_client = gconf_client_get_default ();
350 gconf_client_add_dir (location->conf_client, EXPANDER_STATUS_SECTION, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
351 location->conf_notify_id = gconf_client_notify_add (location->conf_client,
352 EXPANDER_STATUS_SECTION,
353 (GConfClientNotifyFunc) config_changed_cb,
354 location,
355 NULL,
356 NULL);
357
358 if (gconf_client_get_bool (location->conf_client, EXPANDER_STATUS_KEY, NULL))
359 location->expander_status = GTK_ARROW_DOWN;
360 else
361 location->expander_status = GTK_ARROW_RIGHT;
298362
299 /* Create the widgets in the interface */363 /* Create the widgets in the interface */
300 table = gtk_table_new (3, 2, FALSE);364 table = gtk_table_new (2, 4, FALSE);
301 gtk_widget_show (table);365 gtk_widget_show (table);
302 gtk_box_pack_start (GTK_BOX (location), table, TRUE, TRUE, 0);366 gtk_box_pack_start (GTK_BOX (location), table, TRUE, TRUE, 0);
303367
368 box = gtk_event_box_new ();
369 g_signal_connect (G_OBJECT (box), "button-press-event",
370 G_CALLBACK (expander_clicked_cb), location);
371 gtk_widget_show (box);
372 gtk_table_attach (GTK_TABLE (table), box, 0, 1, 0, 1,
373 GTK_FILL, GTK_FILL, 3, 3);
374
375 location->expander = gtk_arrow_new (location->expander_status, GTK_SHADOW_IN);
376 gtk_widget_show (location->expander);
377 gtk_container_add (GTK_CONTAINER (box), location->expander);
378
304 location->info_label = gtk_label_new ("<b>Ubuntu One</b>");379 location->info_label = gtk_label_new ("<b>Ubuntu One</b>");
305 gtk_label_set_use_markup (GTK_LABEL (location->info_label), TRUE);380 gtk_label_set_use_markup (GTK_LABEL (location->info_label), TRUE);
306 gtk_misc_set_alignment (GTK_MISC (location->info_label), 0.0, 0.5);381 gtk_misc_set_alignment (GTK_MISC (location->info_label), 0.0, 0.5);
307 gtk_widget_show (location->info_label);382 gtk_widget_show (location->info_label);
308 gtk_table_attach (GTK_TABLE (table), location->info_label, 0, 1, 0, 1,383 gtk_table_attach (GTK_TABLE (table), location->info_label, 1, 2, 0, 1,
309 GTK_EXPAND | GTK_FILL, GTK_FILL, 3, 3);384 GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 3, 3);
310
311 box = gtk_vbox_new (FALSE, 3);
312 gtk_widget_show (box);
313 gtk_table_attach (GTK_TABLE (table), box, 0, 1, 1, 2,
314 GTK_FILL | GTK_EXPAND, GTK_FILL, 3, 3);
315385
316 location->help_label = gtk_label_new (_("These files are not backed up and will not be available in your other computers"));386 location->help_label = gtk_label_new (_("These files are not backed up and will not be available in your other computers"));
317 gtk_label_set_use_markup (GTK_LABEL (location->help_label), TRUE);387 gtk_label_set_use_markup (GTK_LABEL (location->help_label), TRUE);
318 gtk_misc_set_alignment (GTK_MISC (location->help_label), 0.0, 0.5);388 gtk_misc_set_alignment (GTK_MISC (location->help_label), 0.0, 0.5);
319 gtk_box_pack_start (GTK_BOX (box), location->help_label, TRUE, TRUE, 0);389 gtk_table_attach (GTK_TABLE (table), location->help_label, 1, 3, 1, 2,
390 GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL, 3, 3);
320391
321 location->spinner = gtk_spinner_new ();392 location->spinner = gtk_spinner_new ();
322 gtk_table_attach (GTK_TABLE (table), location->spinner, 1, 2, 0, 2,393 gtk_table_attach (GTK_TABLE (table), location->spinner, 2, 3, 0, 1,
323 GTK_SHRINK, GTK_SHRINK, 3, 3);394 GTK_SHRINK, GTK_SHRINK, 3, 3);
324395
325 /* Buttons */396 /* Buttons */
326 box = gtk_vbox_new (FALSE, 3);397 location->toggle_button = gtk_check_button_new_with_label (_("Synchronize folder"));
327 gtk_widget_show (box);398 gtk_widget_show (location->toggle_button);
328 gtk_table_attach (GTK_TABLE (table), box, 2, 3, 0, 2,399 gtk_table_attach (GTK_TABLE (table), location->toggle_button, 3, 4, 0, 1,
329 GTK_FILL, GTK_FILL, 3, 3);400 GTK_FILL, GTK_FILL, 3, 3);
330
331 location->disable_button = gtk_button_new_with_label (_("Cancel Sync"));
332 g_signal_connect (G_OBJECT (location->disable_button), "clicked",
333 G_CALLBACK (disable_u1_cb), location);
334 gtk_box_pack_start (GTK_BOX (box), location->disable_button, FALSE, FALSE, 0);
335
336 location->enable_button = gtk_button_new_with_label (_("Sync now"));
337 g_signal_connect (G_OBJECT (location->enable_button), "clicked",
338 G_CALLBACK (enable_u1_cb), location);
339 gtk_box_pack_start (GTK_BOX (box), location->enable_button, FALSE, FALSE, 0);
340}401}
341402
342static gboolean403static gboolean
@@ -393,13 +454,18 @@
393454
394 if (ubuntuone_is_storagefs (uon, path, &is_root)) {455 if (ubuntuone_is_storagefs (uon, path, &is_root)) {
395 /* Create label and disable button */456 /* Create label and disable button */
457 gtk_widget_hide (location->expander);
396 set_label_text (location, TRUE);458 set_label_text (location, TRUE);
397 if (is_root && !is_special_udf (uon, path))459 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (location->toggle_button), TRUE);
398 gtk_widget_show (location->disable_button);460 if (!is_root || is_special_udf (uon, path))
461 gtk_widget_set_sensitive (location->toggle_button, FALSE);
399 } else {462 } else {
400 /* Check if this is the 'Shared with me' folder */463 /* Check if this is the 'Shared with me' folder */
401 if (is_special_udf (uon, path)) {464 if (is_special_udf (uon, path)) {
465 gtk_widget_hide (location->expander);
402 set_label_text (location, TRUE);466 set_label_text (location, TRUE);
467 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (location->toggle_button), TRUE);
468 gtk_widget_set_sensitive (location->toggle_button, FALSE);
403 } else {469 } else {
404 GSList *udfs, *l;470 GSList *udfs, *l;
405 SyncdaemonInterface *interface;471 SyncdaemonInterface *interface;
@@ -416,10 +482,10 @@
416 }482 }
417483
418 g_slist_free (udfs);484 g_slist_free (udfs);
419485
486 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (location->toggle_button), FALSE);
420 if (allow_enabling) {487 if (allow_enabling) {
421 set_label_text (location, FALSE);488 set_label_text (location, FALSE);
422 gtk_widget_show (location->enable_button);
423 } else {489 } else {
424 gchar *labeltext;490 gchar *labeltext;
425491
@@ -431,11 +497,18 @@
431 gtk_label_set_text (GTK_LABEL (location->help_label),497 gtk_label_set_text (GTK_LABEL (location->help_label),
432 _("This folder cannot be synchronized because it contains "498 _("This folder cannot be synchronized because it contains "
433 "one or more folders that already synchronized"));499 "one or more folders that already synchronized"));
434 gtk_widget_show (location->help_label);500 if (location->expander_status == GTK_ARROW_DOWN)
501 gtk_widget_show (location->help_label);
502
503 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (location->toggle_button), FALSE);
504 gtk_widget_set_sensitive (location->toggle_button, FALSE);
435 }505 }
436 }506 }
437 }507 }
438508
509 g_signal_connect (G_OBJECT (location->toggle_button), "toggled",
510 G_CALLBACK (sync_toggled_cb), location);
511
439 gtk_widget_show (GTK_WIDGET (location));512 gtk_widget_show (GTK_WIDGET (location));
440513
441 return GTK_WIDGET (location);514 return GTK_WIDGET (location);
442515
=== modified file 'nautilus/location-widget.h'
--- nautilus/location-widget.h 2010-07-13 20:46:57 +0000
+++ nautilus/location-widget.h 2010-07-27 11:29:41 +0000
@@ -23,6 +23,7 @@
23#define __LOCATION_WIDGET_H__23#define __LOCATION_WIDGET_H__
2424
25#include <gtk/gtk.h>25#include <gtk/gtk.h>
26#include <gconf/gconf-client.h>
26#include "ubuntuone-nautilus.h"27#include "ubuntuone-nautilus.h"
2728
28#define TYPE_LOCATION_WIDGET (location_widget_get_type ())29#define TYPE_LOCATION_WIDGET (location_widget_get_type ())
@@ -38,11 +39,15 @@
38 /* Private data */39 /* Private data */
39 UbuntuOneNautilus *uon;40 UbuntuOneNautilus *uon;
40 gchar *path;41 gchar *path;
42 GtkWidget *expander;
43 GtkArrowType expander_status;
41 GtkWidget *info_label;44 GtkWidget *info_label;
42 GtkWidget *help_label;45 GtkWidget *help_label;
43 GtkWidget *spinner;46 GtkWidget *spinner;
44 GtkWidget *enable_button;47 GtkWidget *toggle_button;
45 GtkWidget *disable_button;48
49 GConfClient *conf_client;
50 guint conf_notify_id;
46} LocationWidget;51} LocationWidget;
4752
48typedef struct {53typedef struct {

Subscribers

People subscribed via source and target branches