Updating branch refs/heads/master to d6dcddd3afdd0247c531818089abb878b2b4f73e (commit) from 372d5d61b987c7fd1dfd5eed67955f90db9f125e (commit)
commit d6dcddd3afdd0247c531818089abb878b2b4f73e Author: Nick Schermer <n...@xfce.org> Date: Sat Sep 29 19:22:02 2012 +0200 Add menu item to hide the menu bar. Option to hide the menu bar. You can temporarily toggle the visibility with F10, which is also the key to focus the first item (unfortunatly gtk_menu_shell_select_first is broken). thunar/thunar-preferences.c | 14 ++++++ thunar/thunar-window-ui.xml | 1 + thunar/thunar-window.c | 99 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 108 insertions(+), 6 deletions(-) diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c index 7e6acc6..d558221 100644 --- a/thunar/thunar-preferences.c +++ b/thunar/thunar-preferences.c @@ -58,6 +58,7 @@ enum PROP_LAST_DETAILS_VIEW_ZOOM_LEVEL, PROP_LAST_ICON_VIEW_ZOOM_LEVEL, PROP_LAST_LOCATION_BAR, + PROP_LAST_MENUBAR_VISIBLE, PROP_LAST_SEPARATOR_POSITION, PROP_LAST_SHOW_HIDDEN, PROP_LAST_SIDE_PANE, @@ -279,6 +280,19 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) EXO_PARAM_READWRITE)); /** + * ThunarPreferences:last-menubar-visible: + * + * Whether to display a menubar in new windows by default. + **/ + g_object_class_install_property (gobject_class, + PROP_LAST_MENUBAR_VISIBLE, + g_param_spec_boolean ("last-menubar-visible", + "LastMenubarVisible", + "last-menubar-visible", + TRUE, + EXO_PARAM_READWRITE)); + + /** * ThunarPreferences:last-separator-position: * * The last position of the gutter in the main window, diff --git a/thunar/thunar-window-ui.xml b/thunar/thunar-window-ui.xml index f88332e..017c8d6 100644 --- a/thunar/thunar-window-ui.xml +++ b/thunar/thunar-window-ui.xml @@ -53,6 +53,7 @@ <menuitem action="view-side-pane-tree" /> </menu> <menuitem action="view-statusbar" /> + <menuitem action="view-menubar" /> <separator /> <menuitem action="show-hidden" /> <separator /> diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 5908713..b1071e4 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -81,6 +81,7 @@ enum BACK, RELOAD, TOGGLE_SIDEPANE, + TOGGLE_MENUBAR, ZOOM_IN, ZOOM_OUT, ZOOM_RESET, @@ -102,6 +103,9 @@ static void thunar_window_set_property (GObject static gboolean thunar_window_back (ThunarWindow *window); static gboolean thunar_window_reload (ThunarWindow *window); static gboolean thunar_window_toggle_sidepane (ThunarWindow *window); +static gboolean thunar_window_toggle_menubar (ThunarWindow *window); +static void thunar_window_toggle_menubar_deactivate (GtkWidget *menubar, + ThunarWindow *window); static gboolean thunar_window_zoom_in (ThunarWindow *window); static gboolean thunar_window_zoom_out (ThunarWindow *window); static gboolean thunar_window_zoom_reset (ThunarWindow *window); @@ -139,6 +143,8 @@ static void thunar_window_action_tree_changed (GtkToggleAction ThunarWindow *window); static void thunar_window_action_statusbar_changed (GtkToggleAction *action, ThunarWindow *window); +static void thunar_window_action_menubar_changed (GtkToggleAction *action, + ThunarWindow *window); static void thunar_window_action_zoom_in (GtkAction *action, ThunarWindow *window); static void thunar_window_action_zoom_out (GtkAction *action, @@ -219,6 +225,7 @@ struct _ThunarWindowClass gboolean (*back) (ThunarWindow *window); gboolean (*reload) (ThunarWindow *window); gboolean (*toggle_sidepane) (ThunarWindow *window); + gboolean (*toggle_menubar) (ThunarWindow *window); gboolean (*zoom_in) (ThunarWindow *window); gboolean (*zoom_out) (ThunarWindow *window); gboolean (*zoom_reset) (ThunarWindow *window); @@ -252,6 +259,7 @@ struct _ThunarWindow GClosure *menu_item_deselected_closure; GtkWidget *table; + GtkWidget *menubar; GtkWidget *spinner; GtkWidget *paned; GtkWidget *sidepane; @@ -331,6 +339,7 @@ static const GtkToggleActionEntry toggle_action_entries[] = { "view-side-pane-shortcuts", NULL, N_ ("_Shortcuts"), "<control>B", N_ ("Toggles the visibility of the shortcuts pane"), G_CALLBACK (thunar_window_action_shortcuts_changed), FALSE, }, { "view-side-pane-tree", NULL, N_ ("_Tree"), "<control>T", N_ ("Toggles the visibility of the tree pane"), G_CALLBACK (thunar_window_action_tree_changed), FALSE, }, { "view-statusbar", NULL, N_ ("St_atusbar"), NULL, N_ ("Change the visibility of this window's statusbar"), G_CALLBACK (thunar_window_action_statusbar_changed), FALSE, }, + { "view-menubar", NULL, N_ ("_Menubar"), "<control>M", N_ ("Change the visibility of this window's menubar"), G_CALLBACK (thunar_window_action_menubar_changed), TRUE, }, }; @@ -365,6 +374,7 @@ thunar_window_class_init (ThunarWindowClass *klass) klass->back = thunar_window_back; klass->reload = thunar_window_reload; klass->toggle_sidepane = thunar_window_toggle_sidepane; + klass->toggle_menubar = thunar_window_toggle_menubar; klass->zoom_in = thunar_window_zoom_in; klass->zoom_out = thunar_window_zoom_out; klass->zoom_reset = thunar_window_zoom_reset; @@ -461,7 +471,7 @@ thunar_window_class_init (ThunarWindowClass *klass) G_TYPE_BOOLEAN, 0); /** - * ThunarWindow::reload: + * ThunarWindow::toggle-sidepane: * @window : a #ThunarWindow instance. * * Emitted whenever the user toggles the visibility of the @@ -478,6 +488,23 @@ thunar_window_class_init (ThunarWindowClass *klass) G_TYPE_BOOLEAN, 0); /** + * ThunarWindow::toggle-sidepane: + * @window : a #ThunarWindow instance. + * + * Emitted whenever the user toggles the visibility of the + * sidepane. This is an internal signal used to bind the + * action to keys. + **/ + window_signals[TOGGLE_MENUBAR] = + g_signal_new (I_("toggle-menubar"), + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ThunarWindowClass, toggle_menubar), + g_signal_accumulator_true_handled, NULL, + _thunar_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); + + /** * ThunarWindow::zoom-in: * @window : a #ThunarWindow instance. * @@ -530,6 +557,7 @@ thunar_window_class_init (ThunarWindowClass *klass) gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0, "back", 0); gtk_binding_entry_add_signal (binding_set, GDK_F5, 0, "reload", 0); gtk_binding_entry_add_signal (binding_set, GDK_F9, 0, "toggle-sidepane", 0); + gtk_binding_entry_add_signal (binding_set, GDK_F10, 0, "toggle-menubar", 0); gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_CONTROL_MASK, "zoom-in", 0); gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, GDK_CONTROL_MASK, "zoom-out", 0); gtk_binding_entry_add_signal (binding_set, GDK_KP_0, GDK_CONTROL_MASK, "zoom-reset", 0); @@ -666,7 +694,6 @@ thunar_window_init (ThunarWindow *window) GtkRadioAction *radio_action; GtkAccelGroup *accel_group; GtkWidget *separator; - GtkWidget *menubar; GtkWidget *label; GtkWidget *ebox; GtkWidget *item; @@ -780,15 +807,20 @@ thunar_window_init (ThunarWindow *window) gtk_container_add (GTK_CONTAINER (window), window->table); gtk_widget_show (window->table); - menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu"); - gtk_table_attach (GTK_TABLE (window->table), menubar, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (menubar); + window->menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu"); + gtk_table_attach (GTK_TABLE (window->table), window->menubar, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + + /* update menubar visibiliy */ + g_object_get (G_OBJECT (window->preferences), "last-menubar-visible", &visible, NULL); + action = gtk_action_group_get_action (window->action_group, "view-menubar"); + g_signal_connect (G_OBJECT (window->menubar), "deactivate", G_CALLBACK (thunar_window_toggle_menubar_deactivate), window); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible); /* append the menu item for the spinner */ item = gtk_menu_item_new (); gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); gtk_menu_item_set_right_justified (GTK_MENU_ITEM (item), TRUE); - gtk_menu_shell_append (GTK_MENU_SHELL (menubar), item); + gtk_menu_shell_append (GTK_MENU_SHELL (window->menubar), item); gtk_widget_show (item); /* place the spinner into the menu item */ @@ -1141,6 +1173,40 @@ thunar_window_toggle_sidepane (ThunarWindow *window) static gboolean +thunar_window_toggle_menubar (ThunarWindow *window) +{ + _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); + + if (!gtk_widget_get_visible (window->menubar)) + { + /* temporarily show menu bar */ + gtk_widget_show (window->menubar); + return TRUE; + } + + return FALSE; +} + + + +static void +thunar_window_toggle_menubar_deactivate (GtkWidget *menubar, + ThunarWindow *window) +{ + GtkAction *action; + + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + _thunar_return_if_fail (window->menubar == menubar); + + /* this was a temporarily show, hide the bar */ + action = gtk_action_group_get_action (window->action_group, "view-menubar"); + if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) + gtk_widget_hide (menubar); +} + + + +static gboolean thunar_window_zoom_in (ThunarWindow *window) { _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), FALSE); @@ -1846,6 +1912,27 @@ thunar_window_action_statusbar_changed (GtkToggleAction *action, static void +thunar_window_action_menubar_changed (GtkToggleAction *action, + ThunarWindow *window) +{ + gboolean active; + + _thunar_return_if_fail (GTK_IS_TOGGLE_ACTION (action)); + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); + + /* determine the new state of the action */ + active = gtk_toggle_action_get_active (action); + + /* show or hide the bar */ + gtk_widget_set_visible (window->menubar, active); + + /* remember the setting */ + g_object_set (G_OBJECT (window->preferences), "last-menubar-visible", active, NULL); +} + + + +static void thunar_window_action_zoom_in (GtkAction *action, ThunarWindow *window) { _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits