[balsa/popover: 16/66] balsa-message: Improve the GtkPopover popup




commit 8cad38139836068dbee289905f19a798b013fd04
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri May 8 15:42:01 2020 -0400

    balsa-message: Improve the GtkPopover popup
    
    • Actually pop it up, by setting it relative to the tree-view, not the
      (hidden) mime-widget.
    • When it is popped up in response to a click, position it above the
      pointer.

 src/balsa-message.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 85dc6fa5f..da0863f6d 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -933,8 +933,20 @@ tree_mult_selection_popup(BalsaMessage     *balsa_message,
     selected = g_list_length(balsa_message->save_all_list);
     if (selected == 1) {
         BalsaPartInfo *info = BALSA_PART_INFO(balsa_message->save_all_list->data);
-        if (info->popup_menu != NULL)
+        if (info->popup_menu != NULL) {
+            if (event != NULL) {
+                GdkRectangle rectangle;
+
+                /* Pop up above the pointer */
+                rectangle.x = event->x;
+                rectangle.width = 0;
+                rectangle.y = event->y;
+                rectangle.height = 0;
+                gtk_popover_set_pointing_to(GTK_POPOVER(info->popup_menu), &rectangle);
+            }
+
             gtk_popover_popup(GTK_POPOVER(info->popup_menu));
+        }
         g_list_free(balsa_message->save_all_list);
         balsa_message->save_all_list = NULL;
     } else if (selected > 1) {
@@ -1028,13 +1040,25 @@ tree_button_press_cb(GtkGestureMultiPress *multi_press_gesture,
             if (gtk_tree_model_get_iter (model, &iter, path)) {
                 gtk_tree_model_get(model, &iter, PART_INFO_COLUMN, &info, -1);
                 if (info != NULL) {
-                    if (info->popup_menu != NULL)
+                    if (info->popup_menu != NULL) {
+                        GdkRectangle rectangle;
+
+                        /* Pop up above the pointer */
+                        rectangle.x = event->x;
+                        rectangle.width = 0;
+                        rectangle.y = event->y;
+                        rectangle.height = 0;
+                        gtk_popover_set_pointing_to(GTK_POPOVER(info->popup_menu),
+                                                    &rectangle);
+
                         gtk_popover_popup(GTK_POPOVER(info->popup_menu));
+                    }
                     g_object_unref(info);
                 }
             }
-        } else
+        } else {
             tree_mult_selection_popup(balsa_message, event, selection);
+        }
         gtk_tree_path_free(path);
     }
 }
@@ -1702,7 +1726,7 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
     g_free(content_type);
 
     info->popup_menu =
-        gtk_popover_new_from_model(GTK_WIDGET(info->mime_widget), G_MENU_MODEL(menu));
+        gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
 }
 
 static void


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