Merge lp:~alecu/ubuntuone-client/fix-nautilus-symlinks-udfs into lp:ubuntuone-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 934
Merged at revision: 933
Proposed branch: lp:~alecu/ubuntuone-client/fix-nautilus-symlinks-udfs
Merge into: lp:ubuntuone-client
Diff against target: 81 lines (+13/-8)
1 file modified
nautilus/context-menu.c (+13/-8)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/fix-nautilus-symlinks-udfs
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
dobey (community) Approve
Review via email: mp+56225@code.launchpad.net

Commit message

Do not show share/synchronize/publish options on symlinks (LP: #747299)

Description of the change

Do not show share/synchronize/publish options on symlinks (LP: #747299)

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

+ gfile = g_file_new_for_uri (nautilus_file_info_get_uri (file));

This will leak memory. You need to assign the result of nautilus_file_info_get_uri () to a gchar *, and then g_free () it when done using it, as it does not return a const. I think.

review: Needs Fixing
934. By Alejandro J. Cura

replace g_file_info_get_file_type with the much simpler g_file_test; freed two strings

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

To test this:

1) install the nautilus plugin from this branch
2) create a symlink in your home directory from a folder in your home directory
3) right click on both. The Ubuntu One pop-up menu should gray out the "Synchronize this folder" option only for the symlink
4) create a symlink in your Ubuntu One directory from a folder in your Ubuntu One directory
5) right click on both. The Ubuntu One pop-up menu should gray out the "Share..." option only for the symlink
6) create a symlink in your Ubuntu One directory from a file in your Ubuntu One directory
7) right click on both. The Ubuntu One pop-up menu should gray out the "Publish" option only for the symlink

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

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nautilus/context-menu.c'
--- nautilus/context-menu.c 2011-02-11 15:20:11 +0000
+++ nautilus/context-menu.c 2011-04-04 18:02:47 +0000
@@ -180,19 +180,21 @@
180 NautilusFileInfo *file;180 NautilusFileInfo *file;
181 NautilusMenu *submenu;181 NautilusMenu *submenu;
182 NautilusMenuItem *root_item, *menu_item, *urlitem;182 NautilusMenuItem *root_item, *menu_item, *urlitem;
183 gchar *path, *item, *homedir_path;183 gchar *path, *item, *homedir_path, *path_uri;
184 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;184 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
185 gboolean is_shared_to_me, is_inhome, is_dir, is_regular;185 gboolean is_shared_to_me, is_inhome, is_dir, is_regular, is_symlink;
186 MenuCallbackData *cb_data;186 MenuCallbackData *cb_data;
187187
188 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;188 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
189 is_shared_to_me = is_inhome = is_dir = is_regular = FALSE;189 is_shared_to_me = is_inhome = is_dir = is_regular = is_symlink = FALSE;
190190
191 if (g_list_length (files) != 1)191 if (g_list_length (files) != 1)
192 return NULL;192 return NULL;
193193
194 file = NAUTILUS_FILE_INFO (g_list_nth_data (files, 0));194 file = NAUTILUS_FILE_INFO (g_list_nth_data (files, 0));
195 path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);195 path_uri = nautilus_file_info_get_uri (file);
196 path = g_filename_from_uri (path_uri, NULL, NULL);
197 g_free (path_uri);
196198
197 if (path == NULL)199 if (path == NULL)
198 return NULL;200 return NULL;
@@ -224,6 +226,8 @@
224 is_dir = nautilus_file_info_is_directory (file);226 is_dir = nautilus_file_info_is_directory (file);
225 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;227 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;
226228
229 is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
230
227 cb_data = g_new0 (MenuCallbackData, 1);231 cb_data = g_new0 (MenuCallbackData, 1);
228 cb_data->uon = uon;232 cb_data->uon = uon;
229 cb_data->parent = window;233 cb_data->parent = window;
@@ -240,7 +244,7 @@
240 g_object_weak_ref (G_OBJECT (root_item), (GWeakNotify) free_menu_cb_data, cb_data);244 g_object_weak_ref (G_OBJECT (root_item), (GWeakNotify) free_menu_cb_data, cb_data);
241245
242 /* Share/unshare */246 /* Share/unshare */
243 if ((is_managed || is_udf) && !is_root && is_dir) {247 if ((is_managed || is_udf) && !is_root && is_dir && !is_symlink) {
244248
245 menu_item = nautilus_menu_item_new ("ubuntuone-share",249 menu_item = nautilus_menu_item_new ("ubuntuone-share",
246 _("_Share..."),250 _("_Share..."),
@@ -274,7 +278,7 @@
274278
275 nautilus_menu_append_item (submenu, menu_item);279 nautilus_menu_append_item (submenu, menu_item);
276280
277 if ((is_managed && is_shared) && !is_root && is_dir) {281 if ((is_managed && is_shared) && !is_root && is_dir && !is_symlink) {
278 menu_item = nautilus_menu_item_new ("ubuntuone-unshare",282 menu_item = nautilus_menu_item_new ("ubuntuone-unshare",
279 _("Stop _Sharing"),283 _("Stop _Sharing"),
280 _("Stop sharing this folder on Ubuntu One"),284 _("Stop sharing this folder on Ubuntu One"),
@@ -294,7 +298,7 @@
294 */298 */
295 menu_item = NULL;299 menu_item = NULL;
296300
297 if (is_dir && is_inhome) {301 if (is_dir && is_inhome && !is_symlink) {
298 /* UDFs could be happening */302 /* UDFs could be happening */
299 if (is_managed) {303 if (is_managed) {
300 if (strcmp (path, uon->managed) == 0) {304 if (strcmp (path, uon->managed) == 0) {
@@ -354,7 +358,7 @@
354 /* public files */358 /* public files */
355 menu_item = urlitem = NULL;359 menu_item = urlitem = NULL;
356360
357 if (!is_shared_to_me && is_managed && is_regular) {361 if (!is_shared_to_me && is_managed && is_regular && !is_symlink) {
358 if (is_public) {362 if (is_public) {
359 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",363 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
360 _("Copy Web _Link"),364 _("Copy Web _Link"),
@@ -422,5 +426,6 @@
422 G_CALLBACK (toggle_location_cb), cb_data);426 G_CALLBACK (toggle_location_cb), cb_data);
423 nautilus_menu_append_item (submenu, menu_item);427 nautilus_menu_append_item (submenu, menu_item);
424428
429 g_free (path);
425 return root_item;430 return root_item;
426}431}

Subscribers

People subscribed via source and target branches