[balsa/gtk4: 290/298] balsa-message: Use GtkButton for the attach button




commit 2b9dd9a518da543df8f30b437a5bba3302e1e4f1
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Nov 25 13:29:32 2020 -0500

    balsa-message: Use GtkButton for the attach button
    
    That way, we can put our paper-clip image in it; it's a bit less
    convenient than GtkMenuButton (we need a "clicked" signal handler), but
    it looks so much better--well, at least more familiar.

 src/balsa-message.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index a6d150e30..1b997b954 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -244,6 +244,12 @@ balsa_message_class_init(BalsaMessageClass * klass)
 
 /* Helpers for balsa_message_init. */
 
+static void
+balsa_headers_attachments_popup(GtkButton * button, BalsaMessage * balsa_message)
+{
+    if (balsa_message->parts_popup != NULL)
+        libbalsa_popup_widget_popup(balsa_message->parts_popup, NULL);
+}
 
 /* Note: this function returns a NULL-terminated array of buttons for a top-level headers widget.  
Currently, we return just a
  * single item (the button for showing the menu for switching between attachments) so we /could/ change the 
return type to
@@ -257,8 +263,9 @@ bm_header_tl_buttons(BalsaMessage * balsa_message)
 
     array = g_ptr_array_new();
 
-    balsa_message->attach_button = button = gtk_menu_button_new();
-    gtk_menu_button_set_has_frame(GTK_MENU_BUTTON(button), FALSE);
+    balsa_message->attach_button = button =
+        gtk_button_new_from_icon_name(balsa_icon_id(BALSA_PIXMAP_ATTACHMENT));
+    g_signal_connect(button, "clicked", G_CALLBACK(balsa_headers_attachments_popup), balsa_message);
 
     gtk_widget_set_tooltip_text(button, _("Select message part to display"));
 
@@ -1745,13 +1752,10 @@ display_content(BalsaMessage * balsa_message)
 
     balsa_message->parts_menu = g_menu_new();
 
-    balsa_message->parts_popup = libbalsa_popup_widget_new(NULL,
+    balsa_message->parts_popup = libbalsa_popup_widget_new(balsa_message->attach_button,
                                                            G_MENU_MODEL(balsa_message->parts_menu),
                                                            "message-menu");
 
-    gtk_menu_button_set_popover(GTK_MENU_BUTTON(balsa_message->attach_button),
-                                balsa_message->parts_popup);
-
     /* Populate the parts-menu */
     display_parts(balsa_message, libbalsa_message_get_body_list(balsa_message->message), NULL, NULL);
     g_clear_object(&balsa_message->parts_menu);


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