[balsa/gtk4: 276/288] libbalsa: Allow NULL parent
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk4: 276/288] libbalsa: Allow NULL parent
- Date: Fri, 15 Jan 2021 22:20:40 +0000 (UTC)
commit ff1b6184862af1ca55067d0a9856215bec7b8146
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Nov 23 18:04:59 2020 -0500
libbalsa: Allow NULL parent
in libbalsa_popup_widget_new(). A GtkPopoverMenu that will be owned by a
GtkMenuButton must not be parented.
libbalsa/libbalsa.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 650531e80..e397a9e2a 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -834,21 +834,27 @@ libbalsa_popup_widget_new(GtkWidget *parent,
GMenuModel *model,
const char *action_namespace)
{
- GMenu *menu;
GMenuItem *menu_item;
+ GMenu *menu;
GtkWidget *popup_widget;
- menu = g_menu_new();
menu_item = g_menu_item_new(NULL, NULL);
g_menu_item_set_attribute(menu_item, G_MENU_ATTRIBUTE_ACTION_NAMESPACE, "s", action_namespace);
g_menu_item_set_link(menu_item, G_MENU_LINK_SECTION, model);
+
+ menu = g_menu_new();
g_menu_append_item(menu, menu_item);
g_object_unref(menu_item);
- popup_widget = gtk_popover_menu_new_from_model_full(G_MENU_MODEL(menu), (GtkPopoverMenuFlags) 0);
+ popup_widget = gtk_popover_menu_new_from_model(G_MENU_MODEL(menu));
g_object_unref(menu);
- g_signal_connect(parent, "realize", G_CALLBACK(set_parent_cb), popup_widget);
+ if (parent != NULL) {
+ if (gtk_widget_get_realized(parent))
+ gtk_widget_set_parent(popup_widget, parent);
+ else
+ g_signal_connect(parent, "realize", G_CALLBACK(set_parent_cb), popup_widget);
+ }
return popup_widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]