[balsa/gtk4: 49/276] balsa-message: Restore toggle-all-inline to FALSE




commit b683c38f41955546ad653cc44e20793acb7a6471
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jun 21 18:51:49 2020 -0400

    balsa-message: Restore toggle-all-inline to FALSE
    
    When we show a different message, we create a new context menu, but it
    uses the same GAction collection. Since toggle-all-inline is a toggle
    action, it retains its state from the previous message, and we must
    explicitly restore it to FALSE to match the initial state of the
    message.

 src/balsa-message.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index dff9f3f90..f65ca932c 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -211,6 +211,7 @@ struct _BalsaMessage {
 #endif                         /* HAVE_HTML_WIDGET */
 
         GtkWidget *attach_button;
+        GAction   *toggle_all_inline_action;
 };
 
 G_DEFINE_TYPE(BalsaMessage, balsa_message, GTK_TYPE_BOX)
@@ -876,6 +877,9 @@ balsa_message_init(BalsaMessage * balsa_message)
                                     entries,
                                     G_N_ELEMENTS(entries),
                                     balsa_message);
+    balsa_message->toggle_all_inline_action =
+        g_action_map_lookup_action(G_ACTION_MAP(simple), "toggle-all-inline");
+
     gtk_widget_insert_action_group(GTK_WIDGET(balsa_message),
                                    "message-menu",
                                    G_ACTION_GROUP(simple));
@@ -1754,6 +1758,11 @@ display_content(BalsaMessage * balsa_message)
     display_parts(balsa_message, libbalsa_message_get_body_list(balsa_message->message), NULL, NULL);
     g_clear_object(&balsa_message->parts_menu);
 
+    /* GAction retains its state when switching messages, so we must
+     * return the all-inline toggle to FALSE: */
+    g_simple_action_set_state(G_SIMPLE_ACTION(balsa_message->toggle_all_inline_action),
+                              g_variant_new_boolean(FALSE));
+
     if (balsa_message->info_count > 1) {
        gtk_widget_show_all(balsa_message->attach_button);
     } else {


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