[nautilus] window-menus: hide actions from menus when using app menu
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] window-menus: hide actions from menus when using app menu
- Date: Tue, 24 Apr 2012 16:01:34 +0000 (UTC)
commit ddd36b7f3a159a57c2284a980b31a111ebb16a3b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Apr 23 21:16:43 2012 -0400
window-menus: hide actions from menus when using app menu
When using the application menu (i.e. when the gtk-shell-show-app-menu
is TRUE), hide the same actions from the menubar.
src/nautilus-actions.h | 5 ++++
src/nautilus-window-menus.c | 45 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-actions.h b/src/nautilus-actions.h
index 8b1a5e1..d74b9f6 100644
--- a/src/nautilus-actions.h
+++ b/src/nautilus-actions.h
@@ -52,6 +52,10 @@
#define NAUTILUS_ACTION_SEARCH "Search"
#define NAUTILUS_ACTION_FOLDER_WINDOW "Folder Window"
#define NAUTILUS_ACTION_NEW_TAB "New Tab"
+#define NAUTILUS_ACTION_NEW_WINDOW "New Window"
+#define NAUTILUS_ACTION_PREFERENCES "Preferences"
+#define NAUTILUS_ACTION_ABOUT "About Nautilus"
+#define NAUTILUS_ACTION_HELP "NautilusHelp"
#define NAUTILUS_ACTION_OPEN "Open"
#define NAUTILUS_ACTION_OPEN_ALTERNATE "OpenAlternate"
@@ -94,6 +98,7 @@
#define NAUTILUS_ACTION_RESTORE_FROM_TRASH "Restore From Trash"
#define NAUTILUS_ACTION_LOCATION_RESTORE_FROM_TRASH "LocationRestoreFromTrash"
#define NAUTILUS_ACTION_SHOW_HIDDEN_FILES "Show Hidden Files"
+#define NAUTILUS_ACTION_CONNECT_TO_SERVER "Connect to Server"
#define NAUTILUS_ACTION_CONNECT_TO_SERVER_LINK "Connect To Server Link"
#define NAUTILUS_ACTION_MOUNT_VOLUME "Mount Volume"
#define NAUTILUS_ACTION_UNMOUNT_VOLUME "Unmount Volume"
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 1d2de1b..23156db 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -819,7 +819,7 @@ static const GtkActionEntry main_entries[] = {
/* label, accelerator */ N_("_Close"), "<control>W",
/* tooltip */ N_("Close this folder"),
G_CALLBACK (action_close_window_slot_callback) },
- { "Preferences", GTK_STOCK_PREFERENCES,
+ { NAUTILUS_ACTION_PREFERENCES, GTK_STOCK_PREFERENCES,
N_("Prefere_nces"),
NULL, N_("Edit Nautilus preferences"),
G_CALLBACK (action_preferences_callback) },
@@ -842,7 +842,7 @@ static const GtkActionEntry main_entries[] = {
/* label, accelerator */ N_("_Reload"), "<control>R",
/* tooltip */ N_("Reload the current location"),
G_CALLBACK (action_reload_callback) },
- /* name, stock id */ { "NautilusHelp", GTK_STOCK_HELP,
+ /* name, stock id */ { NAUTILUS_ACTION_HELP, GTK_STOCK_HELP,
/* label, accelerator */ N_("_All Topics"), "F1",
/* tooltip */ N_("Display Nautilus help"),
G_CALLBACK (action_nautilus_manual_callback) },
@@ -862,7 +862,7 @@ static const GtkActionEntry main_entries[] = {
/* label, accelerator */ N_("Share and transfer files"), NULL,
/* tooltip */ N_("Easily transfer files to your contacts and devices from the file manager."),
G_CALLBACK (action_nautilus_manual_callback) },
- /* name, stock id */ { "About Nautilus", GTK_STOCK_ABOUT,
+ /* name, stock id */ { NAUTILUS_ACTION_ABOUT, GTK_STOCK_ABOUT,
/* label, accelerator */ N_("_About"), NULL,
/* tooltip */ N_("Display credits for the creators of Nautilus"),
G_CALLBACK (action_about_nautilus_callback) },
@@ -890,7 +890,7 @@ static const GtkActionEntry main_entries[] = {
/* label, accelerator */ N_("Normal Si_ze"), "<control>0",
/* tooltip */ N_("Use the normal view size"),
G_CALLBACK (action_zoom_normal_callback) },
- /* name, stock id */ { "Connect to Server", NULL,
+ /* name, stock id */ { NAUTILUS_ACTION_CONNECT_TO_SERVER, NULL,
/* label, accelerator */ N_("Connect to _Server..."), NULL,
/* tooltip */ N_("Connect to a remote computer or shared disk"),
G_CALLBACK (action_connect_to_server_callback) },
@@ -917,7 +917,7 @@ static const GtkActionEntry main_entries[] = {
/* name, stock id, label */ { "Go", NULL, N_("_Go") },
/* name, stock id, label */ { "Bookmarks", NULL, N_("_Bookmarks") },
/* name, stock id, label */ { "Tabs", NULL, N_("_Tabs") },
- /* name, stock id, label */ { "New Window", "window-new", N_("New _Window"),
+ /* name, stock id, label */ { NAUTILUS_ACTION_NEW_WINDOW, "window-new", N_("New _Window"),
"<control>N", N_("Open another Nautilus window for the displayed location"),
G_CALLBACK (action_new_window_callback) },
/* name, stock id, label */ { "New Tab", "tab-new", N_("New _Tab"),
@@ -1004,6 +1004,14 @@ static const GtkRadioActionEntry main_radio_entries[] = {
SIDEBAR_TREE }
};
+static const gchar* app_actions[] = {
+ NAUTILUS_ACTION_NEW_WINDOW,
+ NAUTILUS_ACTION_CONNECT_TO_SERVER,
+ NAUTILUS_ACTION_PREFERENCES,
+ NAUTILUS_ACTION_HELP,
+ NAUTILUS_ACTION_ABOUT
+};
+
GtkActionGroup *
nautilus_window_create_toolbar_action_group (NautilusWindow *window)
{
@@ -1120,6 +1128,28 @@ nautilus_window_initialize_actions (NautilusWindow *window)
NULL);
}
+static void
+nautilus_window_menus_set_visibility_for_app_menu (NautilusWindow *window)
+{
+ const gchar *action_name;
+ gboolean shows_app_menu;
+ GtkSettings *settings;
+ GtkAction *action;
+ gint idx;
+
+ settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
+ g_object_get (settings,
+ "gtk-shell-shows-app-menu", &shows_app_menu,
+ NULL);
+
+ for (idx = 0; idx < G_N_ELEMENTS (app_actions); idx++) {
+ action_name = app_actions[idx];
+ action = gtk_action_group_get_action (window->details->main_action_group, action_name);
+
+ gtk_action_set_visible (action, !shows_app_menu);
+ }
+}
+
/**
* nautilus_window_initialize_menus
*
@@ -1152,6 +1182,11 @@ nautilus_window_initialize_menus (NautilusWindow *window)
0, G_CALLBACK (sidebar_radio_entry_changed_cb),
window);
+ nautilus_window_menus_set_visibility_for_app_menu (window);
+ g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+ "notify::gtk-shell-shows-app-menu",
+ G_CALLBACK (nautilus_window_menus_set_visibility_for_app_menu), window);
+
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
g_object_set (action, "short_label", _("_Up"), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]