[virt-tools-list] [PATCH virt-viewer] Fix key-combo menu not showing up with Gtk3
Hans de Goede
hdegoede at redhat.com
Sat Mar 24 18:31:07 UTC 2012
Looks good, ACK.
On 03/23/2012 06:20 PM, Marc-André Lureau wrote:
> For some reason, the behaviour changed between gtk2 and gtk3, the menu
> is removed from display when we unref it with gtk3. Keep a ref on
> built menu and reuse it until the window is disposed.
> ---
> src/virt-viewer-window.c | 15 +++++++++++++--
> 1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index ec96532..0763481 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -98,6 +98,7 @@ struct _VirtViewerWindowPrivate {
> GtkWidget *toolbar_usb_device_selection;
> GtkWidget *toolbar_send_key;
> GtkAccelGroup *accel_group;
> + GtkMenu *keycombo_menu;
> VirtViewerNotebook *notebook;
> VirtViewerDisplay *display;
>
> @@ -187,6 +188,11 @@ virt_viewer_window_dispose (GObject *object)
> priv->display = NULL;
> }
>
> + if (priv->keycombo_menu) {
> + g_object_unref(priv->keycombo_menu);
> + priv->keycombo_menu = NULL;
> + }
> +
> g_free(priv->subtitle);
> priv->subtitle = NULL;
> }
> @@ -568,6 +574,10 @@ virt_viewer_window_menu_send(GtkWidget *menu,
> static GtkMenu*
> virt_viewer_window_get_keycombo_menu(VirtViewerWindow *self)
> {
> + if (self->priv->keycombo_menu != NULL) {
> + return self->priv->keycombo_menu;
> + }
> +
> gint i;
> GtkMenu *menu = GTK_MENU(gtk_menu_new());
>
> @@ -583,7 +593,9 @@ virt_viewer_window_get_keycombo_menu(VirtViewerWindow *self)
> }
>
> gtk_widget_show_all(GTK_WIDGET(menu));
> - return g_object_ref_sink(menu);
> + self->priv->keycombo_menu = g_object_ref_sink(menu);
> +
> + return self->priv->keycombo_menu;
> }
>
> static gboolean
> @@ -713,7 +725,6 @@ virt_viewer_window_toolbar_send_key(GtkWidget *button G_GNUC_UNUSED,
> GtkMenu *menu = virt_viewer_window_get_keycombo_menu(self);
> gtk_menu_popup(menu, NULL, NULL, keycombo_menu_location, self,
> 0, gtk_get_current_event_time());
> - g_object_unref(menu);
> }
>
>
More information about the virt-tools-list
mailing list