[balsa/popover: 6/6] Fix more bugs



commit c7ca8c72c0e95f6399d58ccc89ea7d44698647f5
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun May 3 13:15:37 2020 -0400

    Fix more bugs

 src/balsa-index.c   | 15 ++++++---------
 src/balsa-mblist.c  | 12 ++++++++----
 src/balsa-message.c | 23 +++++++++++++----------
 3 files changed, 27 insertions(+), 23 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index caaaf41f3..cdc422084 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -46,6 +46,7 @@
 #include "sendmsg-window.h"
 #include "store-address.h"
 
+#include "application-helpers.h"
 #include "filter-funcs.h"
 #include "misc.h"
 #include <glib/gi18n.h>
@@ -1929,16 +1930,14 @@ bndx_popup_position_func(GtkMenu * menu, gint * x, gint * y,
 #endif                          /*GTK_CHECK_VERSION(3, 22, 0) */
 
 static void
-move_to_cb(GSimpleAction *action,
-           GVariant      *parameter,
-           gpointer       user_data)
+move_to_change_state(GSimpleAction *action,
+                     GVariant      *parameter,
+                     gpointer       user_data)
 {
     BalsaIndex *index = user_data;
     const gchar *url = g_variant_get_string(parameter, NULL);
     LibBalsaMailbox *mailbox = balsa_find_mailbox_by_url(url);
 
-    g_return_if_fail(mailbox != NULL);
-
     if (balsa_mailbox_node_get_mailbox(index->mailbox_node) != mailbox) {
         GArray *selected = balsa_index_selected_msgnos_new(index);
         balsa_index_transfer(index, selected, mailbox, FALSE);
@@ -1961,7 +1960,7 @@ bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
     gboolean readonly;
     GSimpleActionGroup *simple;
     static const GActionEntry bndx_popup_entries[] = {
-        {"move-to", move_to_cb},
+        {"move-to", libbalsa_radio_activated, "s", "''", move_to_change_state},
     };
     GMenu *mru_menu;
 
@@ -2003,9 +2002,7 @@ bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
                                     bndx_popup_entries,
                                     G_N_ELEMENTS(bndx_popup_entries),
                                     index);
-    gtk_widget_insert_action_group(GTK_WIDGET(index),
-                                   "bndx-popup",
-                                   G_ACTION_GROUP(simple));
+    gtk_widget_insert_action_group(menu, "bndx-popup", G_ACTION_GROUP(simple));
     g_object_unref(simple);
 
     mru_menu =
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index 4aabe5d49..d634246ae 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -1700,7 +1700,7 @@ balsa_mblist_mru_menu(GtkWindow * window,
     GMenu *menu;
     GMenu *other_menu;
     GList *list;
-    GMenuItem *item;
+    GMenuItem *other_item;
 
     g_return_val_if_fail(GTK_IS_WINDOW(window), NULL);
     g_return_val_if_fail(url_list != NULL, NULL);
@@ -1713,19 +1713,23 @@ balsa_mblist_mru_menu(GtkWindow * window,
 
         if (mailbox != NULL) {
             const gchar *name = libbalsa_mailbox_get_name(mailbox);
+            GMenuItem *item;
 
             item = g_menu_item_new(name, NULL);
             g_menu_item_set_action_and_target(item, action, "s", url);
             g_menu_append_item(menu, item);
+            g_object_unref(item);
         }
     }
 
+    other_item = g_menu_item_new(_("_Other…"), NULL);
+    g_menu_item_set_action_and_target(other_item, action, "s", "");
     other_menu = g_menu_new();
-    item = g_menu_item_new(_("_Other…"), NULL);
-    g_menu_item_set_action_and_target(item, action, "s", "");
-    g_menu_append_item(other_menu, item);
+    g_menu_append_item(other_menu, other_item);
+    g_object_unref(other_item);
 
     g_menu_append_section(menu, NULL, G_MENU_MODEL(other_menu));
+    g_object_unref(other_menu);
 
     return menu;
 }
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 2713261df..ae82803d5 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -28,6 +28,7 @@
 #include <ctype.h>
 #include <sys/utsname.h>
 
+#include "application-helpers.h"
 #include "balsa-app.h"
 #include "balsa-icons.h"
 #include "mime.h"
@@ -1602,25 +1603,29 @@ save_cb(GSimpleAction *action,
 }
 
 static void
-open_with_cb(GSimpleAction *action,
-             GVariant      *parameter,
-             gpointer       user_data)
+open_with_change_state(GSimpleAction *action,
+                       GVariant      *parameter,
+                       gpointer       user_data)
 {
     const gchar *app = g_variant_get_string(parameter, NULL);
     BalsaPartInfo *info = user_data;
 
     balsa_mime_widget_ctx_menu_cb(app, info->body);
+
+    g_simple_action_set_state(action, parameter);
 }
 
 static void
-copy_part_cb(GSimpleAction *action,
-             GVariant      *parameter,
-             gpointer       user_data)
+copy_part_change_state(GSimpleAction *action,
+                       GVariant      *parameter,
+                       gpointer       user_data)
 {
     const gchar *url = g_variant_get_string(parameter, NULL);
     BalsaPartInfo *info = user_data;
 
     balsa_message_copy_part(url, info->body);
+
+    g_simple_action_set_state(action, parameter);
 }
 
 static void
@@ -1635,8 +1640,8 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
     GSimpleActionGroup *simple;
     static const GActionEntry part_menu_entries[] = {
         {"save", save_cb},
-        {"open-with", open_with_cb},
-        {"copy-part", copy_part_cb}
+        {"open-with", libbalsa_radio_activated, "s", "''", open_with_change_state},
+        {"copy-part", libbalsa_radio_activated, "s", "''", copy_part_change_state}
     };
     GMenu *menu;
     gchar *content_type;
@@ -1674,7 +1679,6 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
 
     info->popup_menu =
         gtk_popover_new_from_model(GTK_WIDGET(info->mime_widget), G_MENU_MODEL(menu));
-    g_object_ref_sink(info->popup_menu);
 }
 
 static void
@@ -1702,7 +1706,6 @@ balsa_part_info_dispose(GObject * object)
     BalsaPartInfo *info = (BalsaPartInfo *) object;
 
     g_clear_object(&info->mime_widget);
-    g_clear_object(&info->popup_menu);
 
     G_OBJECT_CLASS(balsa_part_info_parent_class)->dispose(object);
 }


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