[balsa/popover: 36/65] Various: Check GTK_IS_POPOVER() when popping down




commit e16dbae9edfd9d24ebea7c2626f1a79841c79368
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 029ea4735..e749dc903 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -116,6 +116,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 ff5727ca6..ae73627da 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -1953,8 +1953,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 f967fc76f..ad4b91ce2 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 8d492eb91..f3621c739 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 b06b2666e..6de16ed0b 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1372,8 +1372,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);
 }
 
 
@@ -1395,8 +1395,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 ec953d5a7..e83c5e4f9 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -611,9 +611,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]