[balsa/gtk4: 16/193] balsa-index: Improve context menu placement




commit ebc53d1bde94295e5038eb2dd6cebc9b9ad22b16
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu May 7 15:22:42 2020 -0400

    balsa-index: Improve context menu placement
    
    Also pop-down the menu after moving message(s).

 src/balsa-index.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 9f17e1833..97133e833 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2055,6 +2055,8 @@ move_to_change_state(GSimpleAction *action,
             balsa_index_selected_msgnos_free(bindex, selected);
         }
     }
+
+    gtk_popover_popdown(GTK_POPOVER(bindex->popup_popover));
 }
 
 /*
@@ -2131,8 +2133,9 @@ bndx_popup_menu_create(BalsaIndex * bindex)
     g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
     g_object_unref(section);
 
-    bindex->popup_popover = gtk_popover_new_from_model(GTK_WIDGET(bindex), G_MENU_MODEL(menu));
     bindex->popup_menu = menu;
+    bindex->popup_popover = gtk_popover_new_from_model(GTK_WIDGET(bindex), G_MENU_MODEL(menu));
+    gtk_popover_set_position(GTK_POPOVER(bindex->popup_popover), GTK_POS_RIGHT);
 }
 
 /* bndx_do_popup: common code for the popup menu;
@@ -2168,6 +2171,7 @@ bndx_do_popup(BalsaIndex * index)
     gboolean readonly;
     GMenu *mru_menu;
     GMenuItem *item;
+    GtkAllocation allocation;
 
     g_debug("%s:%s", __FILE__, __func__);
 
@@ -2201,6 +2205,7 @@ bndx_do_popup(BalsaIndex * index)
     bndx_action_set_enabled(index, "popup", "trash", any && !readonly && mailbox != balsa_app.trash);
     bndx_action_set_enabled(index, "popup", "toggle-flagged", any && !readonly);
     bndx_action_set_enabled(index, "popup", "toggle-unread", any && !readonly);
+    bndx_action_set_enabled(index, "popup", "move-to", any && !readonly);
 
     /* The move-to submenu */
     item = g_menu_item_new_from_model(G_MENU_MODEL(index->popup_menu),
@@ -2211,10 +2216,24 @@ bndx_do_popup(BalsaIndex * index)
     g_menu_item_set_submenu(item, G_MENU_MODEL(mru_menu));
     g_object_unref(mru_menu);
 
-    /* Replace the existing item */
+    /* Replace the existing submenu */
     g_menu_remove(index->popup_menu, index->move_position);
     g_menu_insert_item(index->popup_menu, index->move_position, item);
 
+    gtk_widget_get_allocation(GTK_WIDGET(index), &allocation);
+    if (event != NULL) {
+        /* Pop up to the right of the pointer */
+        allocation.width = event->x;
+    } else {
+        /* Pop up to the right of the "From" column */
+        allocation.width = balsa_app.index_num_width +
+                           balsa_app.index_status_width +
+                           balsa_app.index_attachment_width +
+                           balsa_app.index_from_width;
+    }
+    gtk_popover_set_pointing_to(GTK_POPOVER(index->popup_popover),
+                                (GdkRectangle *) &allocation);
+
     gtk_popover_popup(GTK_POPOVER(index->popup_popover));
 }
 


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