[gthumb] selections: added 'Remove from Selection' to the context menu
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] selections: added 'Remove from Selection' to the context menu
- Date: Sun, 13 Apr 2014 14:48:57 +0000 (UTC)
commit 70a66bfb9fb6d4a28bc8caefb128b43347301c2d
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Apr 13 15:04:18 2014 +0200
selections: added 'Remove from Selection' to the context menu
extensions/selections/actions.c | 22 ++++++++++++++++++----
extensions/selections/actions.h | 1 +
extensions/selections/callbacks.c | 32 +++++++++++++++++++++++---------
3 files changed, 42 insertions(+), 13 deletions(-)
---
diff --git a/extensions/selections/actions.c b/extensions/selections/actions.c
index f01eb21..ea457cd 100644
--- a/extensions/selections/actions.c
+++ b/extensions/selections/actions.c
@@ -52,8 +52,8 @@ gth_browser_activate_show_selection (GthBrowser *browser,
void
gth_browser_activate_go_to_selection_1 (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
gth_browser_activate_show_selection (GTH_BROWSER (user_data), 1);
}
@@ -61,8 +61,8 @@ gth_browser_activate_go_to_selection_1 (GSimpleAction *action,
void
gth_browser_activate_go_to_selection_2 (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+ GVariant *parameter,
+ gpointer user_data)
{
gth_browser_activate_show_selection (GTH_BROWSER (user_data), 2);
}
@@ -178,3 +178,17 @@ gth_browser_activate_remove_from_selection (GthBrowser *browser,
g_object_unref (folder);
g_free (uri);
}
+
+
+void
+gth_browser_activate_remove_from_current_selection (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GthBrowser *browser = user_data;
+ int n_selection;
+
+ n_selection = _g_file_get_n_selection (gth_browser_get_location (browser));
+ if (n_selection >= 0)
+ gth_browser_activate_remove_from_selection (browser, n_selection);
+}
diff --git a/extensions/selections/actions.h b/extensions/selections/actions.h
index 7924783..8e558bf 100644
--- a/extensions/selections/actions.h
+++ b/extensions/selections/actions.h
@@ -38,5 +38,6 @@ DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_1)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_2)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_3)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_file_container)
+DEF_ACTION_CALLBACK (gth_browser_activate_remove_from_current_selection)
#endif /* ACTIONS_H */
diff --git a/extensions/selections/callbacks.c b/extensions/selections/callbacks.c
index 0617499..f9d12c3 100644
--- a/extensions/selections/callbacks.c
+++ b/extensions/selections/callbacks.c
@@ -41,7 +41,8 @@ static const GActionEntry actions[] = {
{ "go-to-selection-1", gth_browser_activate_go_to_selection_1 },
{ "go-to-selection-2", gth_browser_activate_go_to_selection_2 },
{ "go-to-selection-3", gth_browser_activate_go_to_selection_3 },
- { "go-to-file-container", gth_browser_activate_go_to_file_container }
+ { "go-to-file-container", gth_browser_activate_go_to_file_container },
+ { "remove-from-selection", gth_browser_activate_remove_from_current_selection }
};
@@ -52,14 +53,20 @@ static const GthAccelerator accelerators[] = {
};
-static const GthMenuEntry file_list_popup_entries[] = {
+static const GthMenuEntry file_list_popup_open_entries[] = {
{ N_("Open Folder"), "win.go-to-container-from-selection", "<Alt>end" },
};
+static const GthMenuEntry file_list_popup_delete_entries[] = {
+ { N_("Remove from Selection"), "win.remove-from-selection", "Delete" },
+};
+
+
typedef struct {
GthBrowser *browser;
- guint vfs_merge_id;
+ guint vfs_merge_open_id;
+ guint vfs_merge_delete_id;
GtkWidget *selection_buttons[N_SELECTIONS];
gulong folder_changed_id;
} BrowserData;
@@ -279,15 +286,22 @@ selections__gth_browser_load_location_after_cb (GthBrowser *browser,
data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
if (GTH_IS_FILE_SOURCE_SELECTIONS (gth_browser_get_location_source (browser))) {
- if (data->vfs_merge_id == 0)
- data->vfs_merge_id =
+ if (data->vfs_merge_open_id == 0)
+ data->vfs_merge_open_id =
gth_menu_manager_append_entries (gth_browser_get_menu_manager
(browser, GTH_BROWSER_MENU_MANAGER_FILE_LIST_OPEN_ACTIONS),
- file_list_popup_entries,
- G_N_ELEMENTS
(file_list_popup_entries));
+ file_list_popup_open_entries,
+ G_N_ELEMENTS
(file_list_popup_open_entries));
+ if (data->vfs_merge_delete_id == 0)
+ data->vfs_merge_delete_id =
+ gth_menu_manager_append_entries (gth_browser_get_menu_manager
(browser, GTH_BROWSER_MENU_MANAGER_FILE_LIST_DELETE_ACTIONS),
+ file_list_popup_delete_entries,
+ G_N_ELEMENTS
(file_list_popup_delete_entries));
}
else {
- gth_menu_manager_remove_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_FILE_LIST_OPEN_ACTIONS), data->vfs_merge_id);
- data->vfs_merge_id = 0;
+ gth_menu_manager_remove_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_FILE_LIST_OPEN_ACTIONS), data->vfs_merge_open_id);
+ gth_menu_manager_remove_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_FILE_LIST_DELETE_ACTIONS), data->vfs_merge_delete_id);
+ data->vfs_merge_open_id = 0;
+ data->vfs_merge_delete_id = 0;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]