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
1=== modified file 'nautilus/context-menu.c'
2--- nautilus/context-menu.c 2011-02-11 15:20:11 +0000
3+++ nautilus/context-menu.c 2011-04-04 18:02:47 +0000
4@@ -180,19 +180,21 @@
5 NautilusFileInfo *file;
6 NautilusMenu *submenu;
7 NautilusMenuItem *root_item, *menu_item, *urlitem;
8- gchar *path, *item, *homedir_path;
9+ gchar *path, *item, *homedir_path, *path_uri;
10 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
11- gboolean is_shared_to_me, is_inhome, is_dir, is_regular;
12+ gboolean is_shared_to_me, is_inhome, is_dir, is_regular, is_symlink;
13 MenuCallbackData *cb_data;
14
15 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
16- is_shared_to_me = is_inhome = is_dir = is_regular = FALSE;
17+ is_shared_to_me = is_inhome = is_dir = is_regular = is_symlink = FALSE;
18
19 if (g_list_length (files) != 1)
20 return NULL;
21
22 file = NAUTILUS_FILE_INFO (g_list_nth_data (files, 0));
23- path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);
24+ path_uri = nautilus_file_info_get_uri (file);
25+ path = g_filename_from_uri (path_uri, NULL, NULL);
26+ g_free (path_uri);
27
28 if (path == NULL)
29 return NULL;
30@@ -224,6 +226,8 @@
31 is_dir = nautilus_file_info_is_directory (file);
32 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;
33
34+ is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
35+
36 cb_data = g_new0 (MenuCallbackData, 1);
37 cb_data->uon = uon;
38 cb_data->parent = window;
39@@ -240,7 +244,7 @@
40 g_object_weak_ref (G_OBJECT (root_item), (GWeakNotify) free_menu_cb_data, cb_data);
41
42 /* Share/unshare */
43- if ((is_managed || is_udf) && !is_root && is_dir) {
44+ if ((is_managed || is_udf) && !is_root && is_dir && !is_symlink) {
45
46 menu_item = nautilus_menu_item_new ("ubuntuone-share",
47 _("_Share..."),
48@@ -274,7 +278,7 @@
49
50 nautilus_menu_append_item (submenu, menu_item);
51
52- if ((is_managed && is_shared) && !is_root && is_dir) {
53+ if ((is_managed && is_shared) && !is_root && is_dir && !is_symlink) {
54 menu_item = nautilus_menu_item_new ("ubuntuone-unshare",
55 _("Stop _Sharing"),
56 _("Stop sharing this folder on Ubuntu One"),
57@@ -294,7 +298,7 @@
58 */
59 menu_item = NULL;
60
61- if (is_dir && is_inhome) {
62+ if (is_dir && is_inhome && !is_symlink) {
63 /* UDFs could be happening */
64 if (is_managed) {
65 if (strcmp (path, uon->managed) == 0) {
66@@ -354,7 +358,7 @@
67 /* public files */
68 menu_item = urlitem = NULL;
69
70- if (!is_shared_to_me && is_managed && is_regular) {
71+ if (!is_shared_to_me && is_managed && is_regular && !is_symlink) {
72 if (is_public) {
73 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
74 _("Copy Web _Link"),
75@@ -422,5 +426,6 @@
76 G_CALLBACK (toggle_location_cb), cb_data);
77 nautilus_menu_append_item (submenu, menu_item);
78
79+ g_free (path);
80 return root_item;
81 }

Subscribers

People subscribed via source and target branches