[balsa/gtk4: 13/248] balsa-index: Improve context menu placement




commit 21fd8e8ab8159ffd0c99f3a9d42daf9f79897173
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 a1a5b6ecc..36305c58a 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]