[balsa/popover: 50/63] balsa-message: Use a GtkMenuButton for attachments
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/popover: 50/63] balsa-message: Use a GtkMenuButton for attachments
- Date: Sat, 4 Jul 2020 15:12:32 +0000 (UTC)
commit 0df9d4a71cb7ce4e9afe89f745db9580a7e45ede
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Jun 22 18:17:53 2020 -0400
balsa-message: Use a GtkMenuButton for attachments
src/balsa-message.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index b7fe9b705..afe1dfba1 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -237,13 +237,6 @@ 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
@@ -253,28 +246,24 @@ bm_header_tl_buttons(BalsaMessage * balsa_message)
{
GPtrArray *array;
GtkWidget *button;
+ GtkWidget *image;
GtkEventController *key_controller;
array = g_ptr_array_new();
- balsa_message->attach_button = button =
- gtk_button_new_from_icon_name(balsa_icon_id(BALSA_PIXMAP_ATTACHMENT),
- GTK_ICON_SIZE_BUTTON);
- gtk_widget_set_tooltip_text(button,
- _("Select message part to display"));
+ balsa_message->attach_button = button = gtk_menu_button_new();
+ gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+
+ image = gtk_image_new_from_icon_name(balsa_icon_id(BALSA_PIXMAP_ATTACHMENT), GTK_ICON_SIZE_BUTTON);
+ gtk_container_add(GTK_CONTAINER(button), image);
+
+ gtk_widget_set_tooltip_text(button, _("Select message part to display"));
key_controller = gtk_event_controller_key_new(button);
g_signal_connect(key_controller, "focus-in",
G_CALLBACK(balsa_mime_widget_limit_focus), balsa_message);
g_signal_connect(key_controller, "focus-out",
G_CALLBACK(balsa_mime_widget_unlimit_focus), balsa_message);
- gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
- g_signal_connect(button, "clicked",
- G_CALLBACK(balsa_headers_attachments_popup), balsa_message);
-
- key_controller = gtk_event_controller_key_new(button);
- g_signal_connect(key_controller, "key-pressed",
- G_CALLBACK(balsa_mime_widget_key_pressed), balsa_message);
g_ptr_array_add(array, button);
@@ -1738,6 +1727,15 @@ display_content(BalsaMessage * balsa_message)
G_MENU_MODEL(balsa_message->parts_menu),
"message-menu");
+ if (GTK_IS_POPOVER(balsa_message->parts_popup)) {
+ gtk_menu_button_set_popover(GTK_MENU_BUTTON(balsa_message->attach_button),
+ balsa_message->parts_popup);
+ } else {
+ gtk_menu_detach(GTK_MENU(g_object_ref(balsa_message->parts_popup)));
+ gtk_menu_button_set_popup(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]