[balsa/popover: 34/67] Use a BALSA_USE_POPOVER=0 environment variable




commit eafaafa0f1368783b30897b48e4641b9861a2b22
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jun 14 16:43:06 2020 -0400

    Use a BALSA_USE_POPOVER=0 environment variable
    
    Use a BALSA_USE_POPOVER=0 environment variable to switch from GtkPopover back to GtkMenu.
    
    This completes the adaptation to BALSA_USE_POPOVER, but with all the
    changes in-place. Still TODO is pulling it all into libbalsa with
    wrappers.
    
    But...the GtkMenu versions don't actually work!! All actions are
    insensitive. So this may well all finish up being worthless.
    
    * src/balsa-mime-widget-image.c (balsa_image_button_press_cb):
    * src/balsa-mime-widget-text.c (bmwt_html_open_with_change_state),
      (bmwt_html_popup_context_menu):
    * src/mailbox-node.c (create_context_menu):
    * src/pref-manager.c (add_button_to_box), (add_menu_cb),
      (pm_grid_add_remote_mailbox_servers_group),
      (pm_grid_add_address_books_group):
    * src/sendmsg-window.c (change_attach_mode), (attachment_menu_vfs_cb),
      (add_attachment), (add_urlref_attachment), (attachment_button_press_cb),
      (attachment_popup_cb):
    * src/toolbar-factory.c (tm_set_style_changed), (tm_popup_context_menu_cb):

 ChangeLog                     | 26 ++++++++++++
 src/balsa-mime-widget-image.c |  7 +++-
 src/balsa-mime-widget-text.c  | 58 ++++++++++++++++++---------
 src/mailbox-node.c            |  5 ++-
 src/pref-manager.c            | 42 ++++++++++---------
 src/sendmsg-window.c          | 93 +++++++++++++++++++++++++++----------------
 src/toolbar-factory.c         | 79 ++++++++++++++++++++++--------------
 7 files changed, 206 insertions(+), 104 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 778a7e95e..18e54d8df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -143,6 +143,32 @@
 
        * src/main.c (balsa_startup_cb):
 
+2020-06-14  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Use a BALSA_USE_POPOVER=0 environment variable to switch from
+       GtkPopover back to GtkMenu.
+
+       This completes the adaptation to BALSA_USE_POPOVER, but with all
+       the changes in-place. Still TODO is pulling it all into libbalsa
+       with wrappers.
+
+       But...the GtkMenu versions don't actually work!! All actions are
+       insensitive. So this may well all finish up being worthless.
+
+       * src/balsa-mime-widget-image.c (balsa_image_button_press_cb):
+       * src/balsa-mime-widget-text.c (bmwt_html_open_with_change_state),
+       (bmwt_html_popup_context_menu):
+       * src/mailbox-node.c (create_context_menu):
+       * src/pref-manager.c (add_button_to_box), (add_menu_cb),
+       (pm_grid_add_remote_mailbox_servers_group),
+       (pm_grid_add_address_books_group):
+       * src/sendmsg-window.c (change_attach_mode),
+       (attachment_menu_vfs_cb), (add_attachment),
+       (add_urlref_attachment), (attachment_button_press_cb),
+       (attachment_popup_cb):
+       * src/toolbar-factory.c (tm_set_style_changed),
+       (tm_popup_context_menu_cb):
+
 2020-06-13  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Various: Use GtkTreeView's "row-activated" signal instead of
diff --git a/src/balsa-mime-widget-image.c b/src/balsa-mime-widget-image.c
index ee1561057..c3dcf1efc 100644
--- a/src/balsa-mime-widget-image.c
+++ b/src/balsa-mime-widget-image.c
@@ -146,7 +146,7 @@ balsa_image_button_press_cb(GtkGestureMultiPress *multi_press_gesture,
                             gdouble               y,
                             gpointer              user_data)
 {
-    GtkPopover *menu = user_data;
+    GtkWidget *menu = user_data;
     GtkGesture *gesture;
     GdkEventSequence *sequence;
     const GdkEvent *event;
@@ -156,7 +156,10 @@ balsa_image_button_press_cb(GtkGestureMultiPress *multi_press_gesture,
     event    = gtk_gesture_get_last_event(gesture, sequence);
 
     if (gdk_event_triggers_context_menu(event)) {
-        gtk_popover_popup(menu);
+        if (libbalsa_use_popover())
+            gtk_popover_popup(GTK_POPOVER(menu));
+        else
+            gtk_menu_popup_at_pointer(GTK_MENU(menu), event);
         gtk_gesture_set_sequence_state(gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
     }
 }
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 6337e3b38..e503474a0 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1174,11 +1174,13 @@ bmwt_html_open_with_change_state(GSimpleAction *action,
 {
     GtkWidget *html = user_data;
     gpointer mime_body = g_object_get_data(G_OBJECT(html), "mime-body");
-    GtkPopover *popover = g_object_get_data(G_OBJECT(html), "popover");
 
     open_with_change_state(action, parameter, mime_body);
 
-    gtk_popover_popdown(popover);
+    if (libbalsa_use_popover()) {
+        GtkPopover *popover = g_object_get_data(G_OBJECT(html), "popup-menu");
+        gtk_popover_popdown(popover);
+    }
 }
 
 static void
@@ -1280,19 +1282,26 @@ static gboolean
 bmwt_html_popup_context_menu(GtkWidget    *html,
                              BalsaMessage *bm)
 {
-    GtkWidget *popover;
+    GtkWidget *popup_menu;
     const GdkEvent *event;
     GdkEvent *current_event = NULL;
     gdouble x, y;
 
-    popover = g_object_get_data(G_OBJECT(html), "popover");
-    if (popover == NULL) {
+    popup_menu = g_object_get_data(G_OBJECT(html), "popup-menu");
+    if (popup_menu == NULL) {
         GMenu *menu;
 
         menu = g_menu_new();
         bmwt_html_populate_popup_menu(bm, html, menu);
-        popover = gtk_popover_new_from_model(libbalsa_html_get_view_widget(html), G_MENU_MODEL(menu));
-        g_object_set_data(G_OBJECT(html), "popover", popover);
+
+        if (libbalsa_use_popover()) {
+            popup_menu = gtk_popover_new_from_model(libbalsa_html_get_view_widget(html),
+                                                    G_MENU_MODEL(menu));
+        } else {
+            popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        }
+
+        g_object_set_data(G_OBJECT(html), "popup-menu", popup_menu);
     }
 
     /* In WebKit2, the context menu signal is asynchronous, so the
@@ -1302,19 +1311,30 @@ bmwt_html_popup_context_menu(GtkWidget    *html,
     if (event == NULL)
         event = current_event = gtk_get_current_event();
 
-    if (event != NULL &&
-        gdk_event_triggers_context_menu(event) &&
-        gdk_event_get_coords(event, &x, &y)) {
-        GdkRectangle rectangle;
-
-        /* Pop up above the pointer */
-        rectangle.x = (gint) x;
-        rectangle.width = 0;
-        rectangle.y = (gint) y;
-        rectangle.height = 0;
-        gtk_popover_set_pointing_to(GTK_POPOVER(popover), &rectangle);
+    if (libbalsa_use_popover()) {
+        if (event != NULL &&
+            gdk_event_triggers_context_menu(event) &&
+            gdk_event_get_coords(event, &x, &y)) {
+            GdkRectangle rectangle;
+
+            /* Pop up above the pointer */
+            rectangle.x = (gint) x;
+            rectangle.width = 0;
+            rectangle.y = (gint) y;
+            rectangle.height = 0;
+            gtk_popover_set_pointing_to(GTK_POPOVER(popup_menu), &rectangle);
+        }
+        gtk_popover_popup(GTK_POPOVER(popup_menu));
+    } else {
+        if (event != NULL)
+            gtk_menu_popup_at_pointer(GTK_MENU(popup_menu),
+                                     (GdkEvent *) event);
+        else
+            gtk_menu_popup_at_widget(GTK_MENU(popup_menu),
+                                     GTK_WIDGET(bm),
+                                     GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                     NULL);
     }
-    gtk_popover_popup(GTK_POPOVER(popover));
 
     if (current_event != NULL)
         gdk_event_free(current_event);
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 530398f7f..7add81023 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -1187,7 +1187,10 @@ create_context_menu(BalsaMailboxNode *mbnode,
     g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
     g_object_unref(section);
 
-    context_menu = gtk_popover_new_from_model(relative_to, G_MENU_MODEL(menu));
+    if (libbalsa_use_popover())
+        context_menu = gtk_popover_new_from_model(relative_to, G_MENU_MODEL(menu));
+    else
+        context_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
     g_object_unref(menu);
 
     return context_menu;
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 0d5deaffd..4a339a81e 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -1012,6 +1012,9 @@ add_button_to_box(const gchar * label, GCallback cb, gpointer cb_data,
     g_signal_connect_swapped(button, "clicked", cb, cb_data);
     gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
 
+    if (GTK_IS_POPOVER(cb_data))
+        gtk_popover_set_relative_to(cb_data, button);
+
     return button;
 }
 
@@ -1638,7 +1641,14 @@ address_book_set_default_cb(GtkTreeView * tree_view)
 static void
 add_menu_cb(GtkWidget * menu, GtkWidget * widget)
 {
-    gtk_popover_popup(GTK_POPOVER(menu));
+    if (libbalsa_use_popover()) {
+        gtk_popover_popup(GTK_POPOVER(menu));
+    } else {
+        gtk_widget_show_all(menu);
+        gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(widget),
+                                 GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST,
+                                 NULL);
+    }
 }
 
 static void
@@ -1964,7 +1974,6 @@ pm_grid_add_remote_mailbox_servers_group(GtkWidget * grid_widget)
     GtkTreeViewColumn *column;
     GMenuModel *menu_model;
     GtkWidget *server_add_menu;
-    GtkWidget *button;
 
     pm_grid_attach(grid, pm_group_label(_("Remote mailbox servers")), 0, row, 3, 1);
 
@@ -2007,14 +2016,13 @@ pm_grid_add_remote_mailbox_servers_group(GtkWidget * grid_widget)
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, ROW_SPACING);
 
     menu_model = server_add_menu_model(vbox);
-    server_add_menu = gtk_popover_new_from_model(NULL, menu_model);
-    g_object_weak_ref(G_OBJECT(vbox), (GWeakNotify) g_object_unref,
-                      menu_model);
-
-    button = add_button_to_box(_("_Add"), G_CALLBACK(add_menu_cb),
-                               server_add_menu, vbox);
-    gtk_popover_set_relative_to(GTK_POPOVER(server_add_menu), button);
+    if (libbalsa_use_popover())
+        server_add_menu = gtk_popover_new_from_model(NULL, menu_model);
+    else
+        server_add_menu = gtk_menu_new_from_model(menu_model);
 
+    add_button_to_box(_("_Add"), G_CALLBACK(add_menu_cb),
+                      server_add_menu, vbox);
     add_button_to_box(_("_Modify"), G_CALLBACK(server_edit_cb),
                       tree_view, vbox);
     add_button_to_box(_("_Delete"), G_CALLBACK(server_del_cb),
@@ -2716,7 +2724,6 @@ pm_grid_add_address_books_group(GtkWidget * grid_widget)
     GMenuModel *menu_model;
     GtkWidget *address_book_add_menu;
     GtkWidget *vbox;
-    GtkWidget *button;
 
     pm_grid_attach(grid, pm_group_label(_("Address books")), 0, row, 3, 1);
 
@@ -2771,17 +2778,16 @@ pm_grid_add_address_books_group(GtkWidget * grid_widget)
 
     menu_model = balsa_address_book_add_menu(address_book_change,
                                              GTK_WINDOW(property_box));
-    address_book_add_menu = gtk_popover_new_from_model(NULL, menu_model);
-    g_object_weak_ref(G_OBJECT(address_book_add_menu),
-                      (GWeakNotify) g_object_unref, menu_model);
+    if (libbalsa_use_popover())
+        address_book_add_menu = gtk_popover_new_from_model(NULL, menu_model);
+    else
+        address_book_add_menu = gtk_menu_new_from_model(menu_model);
 
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, HIG_PADDING);
 
-    button = add_button_to_box(_("_Add"),
-                               G_CALLBACK(add_menu_cb),
-                               address_book_add_menu, vbox);
-    gtk_popover_set_relative_to(GTK_POPOVER(address_book_add_menu), button);
-
+    add_button_to_box(_("_Add"),
+                      G_CALLBACK(add_menu_cb),
+                      address_book_add_menu, vbox);
     add_button_to_box(_("_Modify"),
                       G_CALLBACK(address_book_edit_cb),
                       tree_view, vbox);
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 91a97ae69..794a6badf 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1318,6 +1318,10 @@ change_attach_mode(GSimpleAction *action,
     GtkTreeModel *model;
     GtkTreeSelection *selection;
     BalsaAttachInfo *test_info;
+    gint result = GTK_RESPONSE_YES;
+
+    if (new_mode == info->mode)
+        return;
 
     /* get the selected element */
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(info->bm->tree_view));
@@ -1334,9 +1338,8 @@ change_attach_mode(GSimpleAction *action,
     g_object_unref(test_info);
 
     /* verify that the user *really* wants to attach as reference */
-    if (info->mode != new_mode && new_mode == LIBBALSA_ATTACH_AS_EXTBODY) {
+    if (new_mode == LIBBALSA_ATTACH_AS_EXTBODY) {
        GtkWidget *extbody_dialog, *parent;
-       gint result;
 
        parent = gtk_widget_get_toplevel(info->bm->window);
        extbody_dialog =
@@ -1360,21 +1363,17 @@ change_attach_mode(GSimpleAction *action,
                             _("Attach as Reference?"));
        result = gtk_dialog_run(GTK_DIALOG(extbody_dialog));
        gtk_widget_destroy(extbody_dialog);
-       if (result != GTK_RESPONSE_YES) {
-            gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
-
-           return;
-        }
     }
 
-    /* change the attachment mode */
-    info->mode = new_mode;
-    gtk_list_store_set(GTK_LIST_STORE(model), &iter, ATTACH_MODE_COLUMN,
-                      info->mode, -1);
-
-    gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+    if (result == GTK_RESPONSE_YES) {
+        /* change the attachment mode */
+        info->mode = new_mode;
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, ATTACH_MODE_COLUMN, info->mode, -1);
+        g_simple_action_set_state(action, parameter);
+    }
 
-    g_simple_action_set_state(action, parameter);
+    if (libbalsa_use_popover())
+        gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
 }
 
 
@@ -1396,7 +1395,8 @@ attachment_menu_vfs_cb(GSimpleAction *action,
                           err ? err->message : "Unknown error");
     g_clear_error(&err);
 
-    gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+    if (libbalsa_use_popover())
+        gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
 }
 
 
@@ -1808,10 +1808,19 @@ add_attachment(BalsaSendmsg * bsmsg, const gchar *filename,
         g_object_unref(section);
     }
 
-    attach_data->popup_menu = gtk_popover_new(bsmsg->tree_view);
-    gtk_popover_bind_model(GTK_POPOVER(attach_data->popup_menu),
-                           G_MENU_MODEL(menu),
-                           attachment_namespace);
+    if (libbalsa_use_popover()) {
+        attach_data->popup_menu = gtk_popover_new(bsmsg->tree_view);
+        gtk_popover_bind_model(GTK_POPOVER(attach_data->popup_menu),
+                               G_MENU_MODEL(menu),
+                               attachment_namespace);
+    } else {
+        attach_data->popup_menu = gtk_menu_new();
+        gtk_menu_shell_bind_model(GTK_MENU_SHELL(attach_data->popup_menu),
+                                  G_MENU_MODEL(menu),
+                                  attachment_namespace,
+                                  TRUE);
+    }
+
     g_object_unref(menu);
     g_free(attachment_namespace);
 
@@ -1896,10 +1905,14 @@ add_urlref_attachment(BalsaSendmsg * bsmsg, const gchar *url)
     g_menu_append_section(menu, NULL, G_MENU_MODEL(open_menu));
     g_object_unref(open_menu);
 
-    attach_data->popup_menu =
-        gtk_popover_new_from_model(bsmsg->window, G_MENU_MODEL(menu));
+    if (libbalsa_use_popover()) {
+        attach_data->popup_menu =
+            gtk_popover_new_from_model(bsmsg->window, G_MENU_MODEL(menu));
+    } else {
+        attach_data->popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        gtk_widget_show_all(attach_data->popup_menu);
+    }
     g_object_unref(menu);
-    gtk_widget_show_all(attach_data->popup_menu);
 
     /* append to the list store */
     gtk_list_store_set(GTK_LIST_STORE(model), &iter,
@@ -2407,16 +2420,20 @@ attachment_button_press_cb(GtkGestureMultiPress *multi_press,
            gtk_tree_model_get(model, &iter, ATTACH_INFO_COLUMN, &attach_info, -1);
            if (attach_info != NULL) {
                if (attach_info->popup_menu != NULL) {
-                    GdkRectangle rectangle;
-
-                    /* Pop up above the pointer */
-                    rectangle.x = (gint) x;
-                    rectangle.width = 0;
-                    rectangle.y = (gint) y;
-                    rectangle.height = 0;
-                    gtk_popover_set_pointing_to(GTK_POPOVER(attach_info->popup_menu),
-                                                &rectangle);
-                    gtk_popover_popup(GTK_POPOVER(attach_info->popup_menu));
+                    if (libbalsa_use_popover()) {
+                        GdkRectangle rectangle;
+
+                        /* Pop up above the pointer */
+                        rectangle.x = (gint) x;
+                        rectangle.width = 0;
+                        rectangle.y = (gint) y;
+                        rectangle.height = 0;
+                        gtk_popover_set_pointing_to(GTK_POPOVER(attach_info->popup_menu),
+                                                    &rectangle);
+                        gtk_popover_popup(GTK_POPOVER(attach_info->popup_menu));
+                    } else {
+                        gtk_menu_popup_at_pointer(GTK_MENU(attach_info->popup_menu), event);
+                    }
                 }
                g_object_unref(attach_info);
            }
@@ -2439,8 +2456,16 @@ attachment_popup_cb(GtkWidget *widget, gpointer user_data)
 
     gtk_tree_model_get(model, &iter, ATTACH_INFO_COLUMN, &attach_info, -1);
     if (attach_info != NULL) {
-       if (attach_info->popup_menu != NULL)
-            gtk_popover_popup(GTK_POPOVER(attach_info->popup_menu));
+       if (attach_info->popup_menu != NULL) {
+            if (libbalsa_use_popover()) {
+                gtk_popover_popup(GTK_POPOVER(attach_info->popup_menu));
+            } else {
+                gtk_menu_popup_at_widget(GTK_MENU(attach_info->popup_menu),
+                                         GTK_WIDGET(widget),
+                                         GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+                                         NULL);
+            }
+        }
        g_object_unref(attach_info);
     }
 
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index 44d7e132d..b8b5fd647 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -612,7 +612,8 @@ tm_set_style_changed(GSimpleAction *action,
     }
 
     if (info->popup_menu != NULL)
-        gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+        if (libbalsa_use_popover())
+            gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
 
     g_simple_action_set_state(action, parameter);
 }
@@ -649,6 +650,7 @@ tm_popup_context_menu_cb(GtkWidget    * toolbar,
     guint i;
     GtkToolbarStyle default_style;
     GtkWidget *popup_menu;
+    GdkEvent *event;
 
     simple = g_simple_action_group_new();
     g_action_map_add_action_entries(G_ACTION_MAP(simple),
@@ -725,42 +727,59 @@ tm_popup_context_menu_cb(GtkWidget    * toolbar,
         g_object_unref(section);
     }
 
-    popup_menu = gtk_popover_new(toolbar);
-    gtk_popover_bind_model(GTK_POPOVER(popup_menu), G_MENU_MODEL(menu), namespace);
+    if (libbalsa_use_popover()) {
+        popup_menu = gtk_popover_new(toolbar);
+        gtk_popover_bind_model(GTK_POPOVER(popup_menu), G_MENU_MODEL(menu), namespace);
+    } else {
+        popup_menu = gtk_menu_new();
+        gtk_menu_shell_bind_model(GTK_MENU_SHELL(popup_menu), G_MENU_MODEL(menu), namespace, TRUE);
+    }
+
     g_object_unref(menu);
     info->popup_menu = popup_menu;
 
-    if (button != -1) {
-        /* We are called with (x, y) coordinates, but they are
-         * "relative to the root of the screen", and we want them
-         * "relative to the window". */
-        GdkEvent *event;
-        gdouble x_win, y_win;
-
-        event = gtk_get_current_event();
-
-        if (event != NULL &&
-            gdk_event_triggers_context_menu(event) &&
-            gdk_event_get_coords(event, &x_win, &y_win)) {
-            GdkRectangle rectangle;
-
-            /* Pop up above the pointer */
-            rectangle.x = (gint) x_win;
-            rectangle.width = 0;
-            rectangle.y = (gint) y_win;
-            rectangle.height = 0;
-            gtk_popover_set_pointing_to(GTK_POPOVER(popup_menu), &rectangle);
+    event = gtk_get_current_event();
+
+    if (libbalsa_use_popover()) {
+        if (button != -1) {
+            /* We are called with (x, y) coordinates, but they are
+             * "relative to the root of the screen", and we want them
+             * "relative to the window". */
+            gdouble x_win, y_win;
+
+            if (event != NULL &&
+                gdk_event_triggers_context_menu(event) &&
+                gdk_event_get_coords(event, &x_win, &y_win)) {
+                GdkRectangle rectangle;
+
+                /* Pop up above the pointer */
+                rectangle.x = (gint) x_win;
+                rectangle.width = 0;
+                rectangle.y = (gint) y_win;
+                rectangle.height = 0;
+                gtk_popover_set_pointing_to(GTK_POPOVER(popup_menu), &rectangle);
+            }
         }
 
-        if (event != NULL)
-            gdk_event_free(event);
-    }
+        /* Apparently, the popover is insensitive if the toolbar is
+         * insensitive, but we always want it to be sensitive. */
+        gtk_widget_set_sensitive(popup_menu, TRUE);
 
-    /* Apparently, the popover is insensitive if the toolbar is
-     * insensitive, but we always want it to be sensitive. */
-    gtk_widget_set_sensitive(popup_menu, TRUE);
+        gtk_popover_popup(GTK_POPOVER(popup_menu));
+    } else {
+        if (event != NULL && gdk_event_get_event_type(event) == GDK_BUTTON_PRESS) {
+            gtk_menu_popup_at_pointer(GTK_MENU(popup_menu), event);
+        } else {
+            gtk_menu_popup_at_widget(GTK_MENU(popup_menu),
+                                     GTK_WIDGET(toolbar),
+                                     GDK_GRAVITY_NORTH,
+                                     GDK_GRAVITY_SOUTH,
+                                     NULL);
+        }
+    }
 
-    gtk_popover_popup(GTK_POPOVER(popup_menu));
+    if (event != NULL)
+        gdk_event_free(event);
 
     return TRUE;
 }


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