This patch adds a submenu item at the Views menu item which allows to hide and show the Menubar. The functionality is also available using Shift+F6 keyboard combination. This feature makes possible a more seamless integration between spice guests and the host's window manager. --- tools/spicy.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/spicy.c b/tools/spicy.c index 263c15f..6c4f1e3 100644 --- a/tools/spicy.c +++ b/tools/spicy.c @@ -469,6 +469,15 @@ static void menu_cb_statusbar(GtkToggleAction *action, gpointer data) g_key_file_set_boolean(keyfile, "ui", "statusbar", state); } +static void menu_cb_menubar(GtkToggleAction *action, gpointer data) +{ + SpiceWindow *win = data; + gboolean state = gtk_toggle_action_get_active(action); + + gtk_widget_set_visible(win->menubar, state); + g_key_file_set_boolean(keyfile, "ui", "menubar", state); +} + static void menu_cb_about(GtkAction *action, void *data) { char *comments = "gtk test client app for the\n" @@ -518,10 +527,14 @@ static gboolean window_state_cb(GtkWidget *widget, GdkEventWindowState *event, gboolean state; GtkAction *toggle; - gtk_widget_show(win->menubar); + toggle = gtk_action_group_get_action(win->ag, "Menubar"); + state = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(toggle)); + gtk_widget_set_visible(win->menubar, state); + toggle = gtk_action_group_get_action(win->ag, "Toolbar"); state = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(toggle)); gtk_widget_set_visible(win->toolbar, state); + toggle = gtk_action_group_get_action(win->ag, "Statusbar"); state = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(toggle)); gtk_widget_set_visible(win->statusbar, state); @@ -677,6 +690,10 @@ static void restore_configuration(SpiceWindow *win) } g_clear_error(&error); + state = g_key_file_get_boolean(keyfile, "ui", "menubar", &error); + if (error == NULL) + gtk_widget_set_visible(win->menubar, state); + g_clear_error(&error); state = g_key_file_get_boolean(keyfile, "ui", "toolbar", &error); if (error == NULL) @@ -850,6 +867,11 @@ static const GtkToggleActionEntry tentries[] = { .name = "Toolbar", .label = "Toolbar", .callback = G_CALLBACK(menu_cb_toolbar), + },{ + .name = "Menubar", + .label = "Menubar", + .callback = G_CALLBACK(menu_cb_menubar), + .accelerator = "<shift>F6", } }; @@ -924,6 +946,7 @@ static char ui_xml[] = " <menuitem action='Fullscreen'/>\n" " <menuitem action='Toolbar'/>\n" " <menuitem action='Statusbar'/>\n" +" <menuitem action='Menubar'/>\n" " </menu>\n" " <menu action='InputMenu'>\n" #ifdef USE_SMARTCARD -- 2.11.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel