diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-12-17 23:20:34 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-12-17 23:21:54 -0500 |
commit | ad8a97b45792bf3ad32853eff7b00ab0fe5546cf (patch) | |
tree | 18498410ececa009c1c706a48cfc9642ed83c28d /gtk/gtkappchooserwidget.c | |
parent | 37d074da538e5167b0c60d7eeaad05c4af8fdbb8 (diff) | |
download | gtk+-ad8a97b45792bf3ad32853eff7b00ab0fe5546cf.tar.gz |
GtkAppChoserWidget: Don't leak the context menu
This was pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=720401
Diffstat (limited to 'gtk/gtkappchooserwidget.c')
-rw-r--r-- | gtk/gtkappchooserwidget.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c index 648e9871a3..c1675d1cfd 100644 --- a/gtk/gtkappchooserwidget.c +++ b/gtk/gtkappchooserwidget.c @@ -87,6 +87,8 @@ struct _GtkAppChooserWidgetPrivate { GtkCellRenderer *secondary_padding; GAppInfoMonitor *monitor; + + GtkWidget *popup_menu; }; enum { @@ -204,6 +206,15 @@ get_app_info_for_event (GtkAppChooserWidget *self, return info; } +static void +popup_menu_detach (GtkWidget *attach_widget, + GtkMenu *menu) +{ + GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (attach_widget); + + self->priv->popup_menu = NULL; +} + static gboolean widget_button_press_event_cb (GtkWidget *widget, GdkEventButton *event, @@ -223,10 +234,13 @@ widget_button_press_event_cb (GtkWidget *widget, if (info == NULL) return FALSE; - menu = gtk_menu_new (); + if (self->priv->popup_menu) + gtk_widget_destroy (self->priv->popup_menu); + + self->priv->popup_menu = menu = gtk_menu_new (); + gtk_menu_attach_to_widget (GTK_MENU (menu), self, popup_menu_detach); - g_signal_emit (self, signals[SIGNAL_POPULATE_POPUP], 0, - menu, info); + g_signal_emit (self, signals[SIGNAL_POPULATE_POPUP], 0, menu, info); g_object_unref (info); @@ -235,12 +249,9 @@ widget_button_press_event_cb (GtkWidget *widget, n_children = g_list_length (children); if (n_children > 0) - { - /* actually popup the menu */ - gtk_menu_attach_to_widget (GTK_MENU (menu), self->priv->program_list, NULL); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - event->button, event->time); - } + /* actually popup the menu */ + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, + event->button, event->time); g_list_free (children); } |