[gthumb] fixed rename from file context menu not working



commit 87ec4eba2fc0b70fb70cfea662294265895ae9c0
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Mar 23 11:02:37 2014 +0100

    fixed rename from file context menu not working

 extensions/file_manager/actions.c   |   23 +++++++++++++++++++----
 extensions/file_manager/actions.h   |    1 +
 extensions/file_manager/callbacks.c |    6 ++++--
 3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/extensions/file_manager/actions.c b/extensions/file_manager/actions.c
index d24a3dc..629fc96 100644
--- a/extensions/file_manager/actions.c
+++ b/extensions/file_manager/actions.c
@@ -542,10 +542,12 @@ gth_browser_activate_rename (GSimpleAction *action,
                GthFileData *file_data;
 
                file_data = gth_folder_tree_get_selected (GTH_FOLDER_TREE (folder_tree));
-               if ((file_data != NULL) && g_file_info_get_attribute_boolean (file_data->info, 
G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME))
-                       gth_folder_tree_start_editing (GTH_FOLDER_TREE (folder_tree), file_data->file);
-
-               _g_object_unref (file_data);
+               if (file_data == NULL)
+                       return;
+               if (! g_file_info_get_attribute_boolean (file_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME))
+                       return;
+               gth_folder_tree_start_editing (GTH_FOLDER_TREE (gth_browser_get_folder_tree (browser)), 
file_data->file);
+               g_object_unref (file_data);
 
                return;
        }
@@ -563,6 +565,16 @@ gth_browser_activate_rename (GSimpleAction *action,
 }
 
 
+void
+gth_browser_activate_file_list_rename (GSimpleAction *action,
+                                      GVariant      *parameter,
+                                      gpointer       user_data)
+{
+       GthBrowser *browser = GTH_BROWSER (user_data);
+       gth_hook_invoke ("gth-browser-file-list-rename", browser);
+}
+
+
 /* -- gth_browser_activate_copy_to_folder / gth_browser_activate_move_to_folder -- */
 
 
@@ -811,6 +823,9 @@ gth_browser_activate_folder_context_rename (GSimpleAction *action,
        if (file_data == NULL)
                return;
 
+       if (! g_file_info_get_attribute_boolean (file_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME))
+               return;
+
        gth_folder_tree_start_editing (GTH_FOLDER_TREE (gth_browser_get_folder_tree (browser)), 
file_data->file);
 
        g_object_unref (file_data);
diff --git a/extensions/file_manager/actions.h b/extensions/file_manager/actions.h
index d750775..cfd1316 100644
--- a/extensions/file_manager/actions.h
+++ b/extensions/file_manager/actions.h
@@ -32,6 +32,7 @@ DEF_ACTION_CALLBACK (gth_browser_activate_duplicate)
 DEF_ACTION_CALLBACK (gth_browser_activate_trash)
 DEF_ACTION_CALLBACK (gth_browser_activate_delete)
 DEF_ACTION_CALLBACK (gth_browser_activate_rename)
+DEF_ACTION_CALLBACK (gth_browser_activate_file_list_rename)
 DEF_ACTION_CALLBACK (gth_browser_activate_copy_to_folder)
 DEF_ACTION_CALLBACK (gth_browser_activate_move_to_folder)
 
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index d6e77ac..4968b3d 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -45,6 +45,7 @@ static const GActionEntry actions[] = {
        { "trash", gth_browser_activate_trash },
        { "delete", gth_browser_activate_delete },
        { "rename", gth_browser_activate_rename },
+       { "file-list-rename", gth_browser_activate_file_list_rename },
        { "duplicate", gth_browser_activate_duplicate },
        { "copy-to-folder", gth_browser_activate_copy_to_folder },
        { "move-to-folder", gth_browser_activate_move_to_folder },
@@ -73,7 +74,7 @@ static const GthMenuEntry fixed_menu_entries_edit[] = {
 static const GthMenuEntry fixed_menu_entries_file[] = {
        { N_("Copy to…"), "win.copy-to-folder" },
        { N_("Move to…"), "win.move-to-folder" },
-       { N_("Rename"), "win.rename", "F2" },
+       { N_("Rename"), "win.file-list-rename", "F2" },
 };
 
 
@@ -821,7 +822,7 @@ fm__gth_browser_update_sensitivity_cb (GthBrowser *browser)
        gth_window_enable_action (GTH_WINDOW (browser), "duplicate", sensitive);
        gth_window_enable_action (GTH_WINDOW (browser), "move-to-folder", sensitive);
        gth_window_enable_action (GTH_WINDOW (browser), "copy-to-folder", sensitive);
-       gth_window_enable_action (GTH_WINDOW (browser), "rename", n_selected > 0);
+       gth_window_enable_action (GTH_WINDOW (browser), "file-list-rename", n_selected > 0);
 
        folder = gth_browser_get_folder_popup_file_data (browser);
        gth_window_enable_action (GTH_WINDOW (browser), "folder-context-create", (folder != NULL) && 
g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE));
@@ -829,6 +830,7 @@ fm__gth_browser_update_sensitivity_cb (GthBrowser *browser)
        gth_window_enable_action (GTH_WINDOW (browser), "folder-context-delete", (folder != NULL) && 
g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE));
        gth_window_enable_action (GTH_WINDOW (browser), "folder-context-trash", (folder != NULL) && 
g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH));
        gth_window_enable_action (GTH_WINDOW (browser), "folder-context-cut", (folder != NULL) && 
g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE));
+       gth_window_enable_action (GTH_WINDOW (browser), "rename", ((folder != NULL) && 
g_file_info_get_attribute_boolean (folder->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) || (n_selected > 0));
        _g_object_unref (folder);
 
        _gth_browser_update_paste_command_sensitivity (browser, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]