Re: [PATCH] Support for toggling Menubar visibility on spicy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

spicy really is a test tool for the spice-gtk widget. As such, we
usually don't add such UI polishing patches to it as we don't want to
encourage its use outside of spice development.
If you need something similar based on spice-gtk, I'd recommend looking
at virt-viewer/remote-viewer.

Thanks,

Christophe

On Mon, Nov 19, 2018 at 02:10:08PM -0200, Silvio Rhatto wrote:
> 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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]