[gtk/matthiasc/for-master: 3/4] widgetfactory: Create the dialog every time




commit c8f40f52d243911fbb9aaf0ecefa5007faf6e108
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 8 09:36:05 2020 -0400

    widgetfactory: Create the dialog every time
    
    Trying to work around gtk_show_about_dialog() is
    not worth it, just recreate the dialog from scratch.
    
    Fixes: #3047

 demos/widget-factory/widget-factory.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 4265cf5322..612ba462eb 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -263,6 +263,7 @@ activate_about (GSimpleAction *action,
   char *os_name;
   char *os_version;
   GString *s;
+  GtkWidget *dialog;
 
   s = g_string_new ("");
 
@@ -289,7 +290,8 @@ activate_about (GSimpleAction *action,
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
 
-  gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
+  dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
+                         "transient-for", gtk_application_get_active_window (app),
                          "program-name", "GTK Widget Factory",
                          "version", version,
                          "copyright", "© 1997—2020 The GTK Team",
@@ -302,9 +304,11 @@ activate_about (GSimpleAction *action,
                          "system-information", s->str,
                          NULL);
 
-  gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (g_object_get_data (G_OBJECT 
(gtk_application_get_active_window (app)), "gtk-about-dialog")),
+  gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
                                        _("Maintained by"), maintainers);
 
+  gtk_window_present (GTK_WINDOW (dialog));
+
   g_string_free (s, TRUE);
   g_free (version);
   g_free (os_name);


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