[gtk+/bgo593793-filechooser-recent-folders-master: 836/837] Factor out functions to create contextual menu items for the file list
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/bgo593793-filechooser-recent-folders-master: 836/837] Factor out functions to create contextual menu items for the file list
- Date: Mon, 5 Sep 2011 19:35:05 +0000 (UTC)
commit 668287b9401e6b508e6164cd5b2bab2613857d6a
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Sep 5 13:19:17 2011 -0500
Factor out functions to create contextual menu items for the file list
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkfilechooserdefault.c | 69 +++++++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 28 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 7eaaef2..8ff8196 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4100,6 +4100,39 @@ check_copy_file_location_sensitivity (GtkFileChooserDefault *impl)
gtk_widget_set_sensitive (impl->browse_files_popup_menu_copy_file_location_item, active);
}
+static GtkWidget *
+file_list_add_image_menu_item (GtkFileChooserDefault *impl,
+ const char *stock_name,
+ const char *mnemonic_label,
+ GCallback callback)
+{
+ GtkWidget *item;
+
+ item = gtk_image_menu_item_new_with_mnemonic (mnemonic_label);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
+ gtk_image_new_from_stock (stock_name, GTK_ICON_SIZE_MENU));
+ g_signal_connect (item, "activate", callback, impl);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+
+ return item;
+}
+
+static GtkWidget *
+file_list_add_check_menu_item (GtkFileChooserDefault *impl,
+ const char *mnemonic_label,
+ GCallback callback)
+{
+ GtkWidget *item;
+
+ item = gtk_check_menu_item_new_with_mnemonic (mnemonic_label);
+ g_signal_connect (item, "toggled", callback, impl);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+
+ return item;
+}
+
/* Constructs the popup menu for the file list if needed */
static void
file_list_build_popup_menu (GtkFileChooserDefault *impl)
@@ -4114,41 +4147,21 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
impl->browse_files_tree_view,
popup_menu_detach_cb);
- item = gtk_image_menu_item_new_with_mnemonic (_("_Copy file's location"));
- impl->browse_files_popup_menu_copy_file_location_item = item;
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
- gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU));
- g_signal_connect (item, "activate",
- G_CALLBACK (copy_file_location_cb), impl);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+ impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy file's location"),
+ G_CALLBACK (copy_file_location_cb));
- item = gtk_image_menu_item_new_with_mnemonic (_("_Add to Bookmarks"));
- impl->browse_files_popup_menu_add_shortcut_item = item;
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
- gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
- g_signal_connect (item, "activate",
- G_CALLBACK (add_to_shortcuts_cb), impl);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+ impl->browse_files_popup_menu_add_shortcut_item = file_list_add_image_menu_item (impl, GTK_STOCK_ADD, _("_Add to Bookmarks"),
+ G_CALLBACK (add_to_shortcuts_cb));
item = gtk_separator_menu_item_new ();
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
- item = gtk_check_menu_item_new_with_mnemonic (_("Show _Hidden Files"));
- impl->browse_files_popup_menu_hidden_files_item = item;
- g_signal_connect (item, "toggled",
- G_CALLBACK (show_hidden_toggled_cb), impl);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+ impl->browse_files_popup_menu_hidden_files_item = file_list_add_check_menu_item (impl, _("Show _Hidden Files"),
+ G_CALLBACK (show_hidden_toggled_cb));
- item = gtk_check_menu_item_new_with_mnemonic (_("Show _Size Column"));
- impl->browse_files_popup_menu_size_column_item = item;
- g_signal_connect (item, "toggled",
- G_CALLBACK (show_size_column_toggled_cb), impl);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+ impl->browse_files_popup_menu_size_column_item = file_list_add_check_menu_item (impl, _("Show _Size Column"),
+ G_CALLBACK (show_size_column_toggled_cb));
bookmarks_check_add_sensitivity (impl);
check_copy_file_location_sensitivity (impl);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]