[balsa/gtk4: 49/311] Various: Check GTK_IS_POPOVER() when popping down




commit 6b1c2543bfdcc355adb33a96be5433bd718aee57
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 16 11:18:31 2020 -0400

    Various: Check GTK_IS_POPOVER() when popping down
    
    Check GTK_IS_POPOVER() instead of libbalsa_use_popover() when popping down a popover.
    
    * libbalsa/libbalsa.c (libbalsa_use_popover):
    * src/balsa-index.c (move_to_change_state):
    * src/balsa-message.c (open_with_change_state), (copy_part_change_state):
    * src/balsa-mime-widget-text.c (bmwt_html_open_with_change_state):
    * src/sendmsg-window.c (change_attach_mode), (attachment_menu_vfs_cb):
    * src/toolbar-factory.c (tm_set_style_changed):

 ChangeLog                    | 12 ++++++++++++
 libbalsa/libbalsa.c          | 23 ++++++++++++-----------
 src/balsa-index.c            |  4 ++--
 src/balsa-message.c          |  8 ++++----
 src/balsa-mime-widget-text.c |  2 +-
 src/sendmsg-window.c         |  8 ++++----
 src/toolbar-factory.c        |  5 ++---
 7 files changed, 37 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3295a5843..044bb750c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -337,6 +337,18 @@
 
        * src/main.c (balsa_startup_cb):
 
+       Various: Check GTK_IS_POPOVER() instead of
+       libbalsa_use_popover() when popping down a popover.
+
+       * libbalsa/libbalsa.c (libbalsa_use_popover):
+       * src/balsa-index.c (move_to_change_state):
+       * src/balsa-message.c (open_with_change_state),
+       (copy_part_change_state):
+       * src/balsa-mime-widget-text.c (bmwt_html_open_with_change_state):
+       * src/sendmsg-window.c (change_attach_mode),
+       (attachment_menu_vfs_cb):
+       * src/toolbar-factory.c (tm_set_style_changed):
+
 2020-06-15  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Various: Implement libbalsa_popup_widget_new() as a wrapper for
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index 6c25a266e..d7660471f 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -756,19 +756,20 @@ libbalsa_dialog_flags(void)
 gboolean
 libbalsa_use_popover(void)
 {
-       static gboolean use_popover = TRUE;
-       static gint check_done = 0;
+    static gboolean use_popover = TRUE;
+    static gint check_done = 0;
 
-       if (g_atomic_int_get(&check_done) == 0) {
-               const gchar *popover_env;
+    if (g_atomic_int_get(&check_done) == 0) {
+        const gchar *popover_env;
 
-               popover_env = g_getenv("BALSA_USE_POPOVER");
-               if ((popover_env != NULL) && (atoi(popover_env) == 0)) {
-                       use_popover = FALSE;
-               }
-               g_atomic_int_set(&check_done, 1);
-       }
-       return use_popover;
+        popover_env = g_getenv("BALSA_USE_POPOVER");
+        if ((popover_env != NULL) && (atoi(popover_env) == 0))
+            use_popover = FALSE;
+
+        g_atomic_int_set(&check_done, 1);
+    }
+
+    return use_popover;
 }
 
 /*
diff --git a/src/balsa-index.c b/src/balsa-index.c
index b76a773f1..5ac8991e7 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2051,8 +2051,8 @@ move_to_change_state(GSimpleAction *action,
         }
     }
 
-    if (libbalsa_use_popover())
-        gtk_popover_popdown(GTK_POPOVER(bindex->popup_widget));
+    if (GTK_IS_POPOVER(bindex->popup_widget))
+        gtk_popover_popdown((GtkPopover *) bindex->popup_widget);
 }
 
 /*
diff --git a/src/balsa-message.c b/src/balsa-message.c
index bee60adc0..8aa8c4587 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1849,8 +1849,8 @@ open_with_change_state(GSimpleAction *action,
     balsa_mime_widget_ctx_menu_cb(app, info->body);
 
     g_simple_action_set_state(action, parameter);
-    if (libbalsa_use_popover())
-        gtk_popover_popdown(GTK_POPOVER(info->popup_widget));
+    if (GTK_IS_POPOVER(info->popup_widget))
+        gtk_popover_popdown((GtkPopover *) info->popup_widget);
 }
 
 static void
@@ -1869,8 +1869,8 @@ copy_part_change_state(GSimpleAction *action,
     }
 
     g_simple_action_set_state(action, parameter);
-    if (libbalsa_use_popover())
-        gtk_popover_popdown(GTK_POPOVER(info->popup_widget));
+    if (GTK_IS_POPOVER(info->popup_widget))
+        gtk_popover_popdown((GtkPopover *) info->popup_widget);
 }
 
 static void
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 2e3906fd4..404f01aef 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1178,7 +1178,7 @@ bmwt_html_open_with_change_state(GSimpleAction *action,
     open_with_change_state(action, parameter, mime_body);
 
     if (libbalsa_use_popover()) {
-        GtkPopover *popover = g_object_get_data(G_OBJECT(html), "popup-menu");
+        GtkPopover *popover = g_object_get_data(G_OBJECT(html), "popup-widget");
         gtk_popover_popdown(popover);
     }
 }
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 4e13a47fe..d5306dce5 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1365,8 +1365,8 @@ change_attach_mode(GSimpleAction *action,
         g_simple_action_set_state(action, parameter);
     }
 
-    if (libbalsa_use_popover())
-        gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+    if (GTK_IS_POPOVER(info->popup_menu))
+        gtk_popover_popdown((GtkPopover *) info->popup_menu);
 }
 
 
@@ -1388,8 +1388,8 @@ attachment_menu_vfs_cb(GSimpleAction *action,
                           err ? err->message : "Unknown error");
     g_clear_error(&err);
 
-    if (libbalsa_use_popover())
-        gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+    if (GTK_IS_POPOVER(info->popup_menu))
+        gtk_popover_popdown((GtkPopover *) info->popup_menu);
 }
 
 
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index 5efe452a3..c8f6db040 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -642,9 +642,8 @@ tm_set_style_changed(GSimpleAction *action,
         balsa_toolbar_model_changed(info->model);
     }
 
-    if (info->popup_menu != NULL)
-        if (libbalsa_use_popover())
-            gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+    if (GTK_IS_POPOVER(info->popup_menu))
+        gtk_popover_popdown((GtkPopover *) info->popup_menu);
 
     g_simple_action_set_state(action, parameter);
 }


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