Merge lp:~rodrigo-moya/ubuntuone-client/no-enabling-on-special-udfs into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: Tim Cole
Approved revision: 585
Merged at revision: 587
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/no-enabling-on-special-udfs
Merge into: lp:ubuntuone-client
Diff against target: 143 lines (+69/-33)
2 files modified
.bzrignore (+3/-0)
nautilus/location-widget.c (+66/-33)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/no-enabling-on-special-udfs
Reviewer Review Type Date Requested Status
Tim Cole (community) Approve
Chad Miller (community) Approve
Review via email: mp+30082@code.launchpad.net

Commit message

Don't allow enabling/disabling on special UDFs from Nautilus

Description of the change

Don't allow enabling/disabling on special UDFs from Nautilus

To post a comment you must log in.
Revision history for this message
Chad Miller (cmiller) wrote :

51 + tmp = g_build_filename (g_get_home_dir (), special_udfs[i], NULL);
52 + if (g_str_has_prefix (path, tmp))
53 + return TRUE;
54 +
55 + g_free (tmp);
56 + }

This is a memory leak.

ret = FALSE;

...

if
  ret = TRUE;
  break;

free;

return ret;

review: Needs Fixing
584. By Rodrigo Moya

Fix memory leak

Revision history for this message
Chad Miller (cmiller) wrote :

53 + if (g_str_has_prefix (path, tmp))
54 + done = TRUE;

What, no, done = g_str_has_prefix (path, tmp) ?! :)

Ah, alright, approved.

review: Approve
585. By Rodrigo Moya

Merge from trunk

Revision history for this message
Tim Cole (tcole) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-07-14 19:51:54 +0000
3+++ .bzrignore 2010-07-20 15:21:16 +0000
4@@ -53,5 +53,8 @@
5 libsyncdaemon/syncdaemon-marshal.[ch]
6 libsyncdaemon/test-libsyncdaemon
7 libsyncdaemon/libsyncdaemon-1.0.pc
8+libsyncdaemon/SyncDaemon-1.0.gir
9+libsyncdaemon/SyncDaemon-1.0.typelib
10+
11 ubuntuone.gnome-settings-plugin
12 test-gsd-ubuntuone
13
14=== modified file 'nautilus/location-widget.c'
15--- nautilus/location-widget.c 2010-07-15 22:48:32 +0000
16+++ nautilus/location-widget.c 2010-07-20 15:21:16 +0000
17@@ -48,13 +48,13 @@
18 {
19 gtk_widget_hide (location->help_label);
20 gtk_widget_show (location->spinner);
21- gtk_spinner_start (location->spinner);
22+ gtk_spinner_start (GTK_SPINNER (location->spinner));
23 }
24
25 static void
26 stop_spinner (LocationWidget *location)
27 {
28- gtk_spinner_stop (location->spinner);
29+ gtk_spinner_stop (GTK_SPINNER (location->spinner));
30 gtk_widget_hide (location->spinner);
31 }
32
33@@ -240,6 +240,34 @@
34 gtk_box_pack_start (GTK_BOX (box), location->enable_button, FALSE, FALSE, 0);
35 }
36
37+static gboolean
38+is_special_udf (UbuntuOneNautilus *uon, const gchar *path)
39+{
40+ gint i;
41+ gchar *special_udfs[] = {
42+ "Ubuntu One",
43+ "Ubuntu One/Shared With Me",
44+ ".ubuntuone/Purchased from Ubuntu One",
45+ ".local/share/ubuntuone"
46+ };
47+
48+ for (i = 0; i < G_N_ELEMENTS (special_udfs); i++) {
49+ gchar *tmp;
50+ gboolean done = FALSE;
51+
52+ tmp = g_build_filename (g_get_home_dir (), special_udfs[i], NULL);
53+ if (g_str_has_prefix (path, tmp))
54+ done = TRUE;
55+
56+ g_free (tmp);
57+
58+ if (done)
59+ return TRUE;
60+ }
61+
62+ return FALSE;
63+}
64+
65 GtkWidget *
66 location_widget_new (UbuntuOneNautilus *uon, const gchar *path)
67 {
68@@ -267,40 +295,45 @@
69 if (ubuntuone_is_storagefs (uon, path, &is_root)) {
70 /* Create label and disable button */
71 set_label_text (location, TRUE);
72- if (is_root && strcmp (path, uon->managed) != 0)
73+ if (is_root && !is_special_udf (uon, path))
74 gtk_widget_show (location->disable_button);
75 } else {
76- GSList *udfs, *l;
77- SyncdaemonInterface *interface;
78- gboolean allow_enabling = TRUE;
79-
80- /* Check to see if this is the parent of a UDF */
81- interface = syncdaemon_daemon_get_folders_interface (uon->syncdaemon);
82- udfs = syncdaemon_folders_interface_get_folders (SYNCDAEMON_FOLDERS_INTERFACE (interface));
83- for (l = udfs; l != NULL; l = l->next) {
84- SyncdaemonFolderInfo *folder_info = SYNCDAEMON_FOLDER_INFO (l->data);
85-
86- if (g_str_has_prefix (syncdaemon_folder_info_get_path (folder_info), path))
87- allow_enabling = FALSE;
88- }
89-
90- g_slist_free (udfs);
91-
92- if (allow_enabling) {
93- set_label_text (location, FALSE);
94- gtk_widget_show (location->enable_button);
95+ /* Check if this is the 'Shared with me' folder */
96+ if (is_special_udf (uon, path)) {
97+ set_label_text (location, TRUE);
98 } else {
99- gchar *labeltext;
100-
101- labeltext = g_strdup_printf ("<b>Ubuntu One</b> - %s",
102- _("cannot synchronize this folder"));
103- gtk_label_set_markup (GTK_LABEL (location->info_label), labeltext);
104- g_free (labeltext);
105-
106- gtk_label_set_text (GTK_LABEL (location->help_label),
107- _("This folder cannot be synchronized because it contains "
108- "one or more folders that already synchronized"));
109- gtk_widget_show (location->help_label);
110+ GSList *udfs, *l;
111+ SyncdaemonInterface *interface;
112+ gboolean allow_enabling = TRUE;
113+
114+ /* Check to see if this is the parent of a UDF */
115+ interface = syncdaemon_daemon_get_folders_interface (uon->syncdaemon);
116+ udfs = syncdaemon_folders_interface_get_folders (SYNCDAEMON_FOLDERS_INTERFACE (interface));
117+ for (l = udfs; l != NULL; l = l->next) {
118+ SyncdaemonFolderInfo *folder_info = SYNCDAEMON_FOLDER_INFO (l->data);
119+
120+ if (g_str_has_prefix (syncdaemon_folder_info_get_path (folder_info), path))
121+ allow_enabling = FALSE;
122+ }
123+
124+ g_slist_free (udfs);
125+
126+ if (allow_enabling) {
127+ set_label_text (location, FALSE);
128+ gtk_widget_show (location->enable_button);
129+ } else {
130+ gchar *labeltext;
131+
132+ labeltext = g_strdup_printf ("<b>Ubuntu One</b> - %s",
133+ _("cannot synchronize this folder"));
134+ gtk_label_set_markup (GTK_LABEL (location->info_label), labeltext);
135+ g_free (labeltext);
136+
137+ gtk_label_set_text (GTK_LABEL (location->help_label),
138+ _("This folder cannot be synchronized because it contains "
139+ "one or more folders that already synchronized"));
140+ gtk_widget_show (location->help_label);
141+ }
142 }
143 }
144

Subscribers

People subscribed via source and target branches