[gtk] about dialog: Adapt to new stack visiblity handling



commit 52b83ac5530940bf17bcfd620c5faea1c57b820b
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 12 00:10:00 2019 -0500

    about dialog: Adapt to new stack visiblity handling
    
    We need to set the visible property of the stack pages
    now.

 gtk/gtkaboutdialog.c     | 51 +++++++++++++++++++++++++++++++-----------------
 gtk/ui/gtkaboutdialog.ui |  3 ---
 2 files changed, 33 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index 3af89576ed..ab344cc71b 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -627,24 +627,37 @@ static void
 update_stack_switcher_visibility (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = gtk_about_dialog_get_instance_private (about);
+  GtkStackPage *page;
+  gboolean visible;
+  gboolean any_visible;
 
-  if (gtk_widget_get_visible (priv->credits_page) ||
-      gtk_widget_get_visible (priv->license_page) ||
-      gtk_widget_get_visible (priv->system_page))
-    gtk_widget_show (priv->stack_switcher);
-  else
-    gtk_widget_hide (priv->stack_switcher);
+  any_visible = FALSE;
+  
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->credits_page);
+  g_object_get (page, "visible", &visible, NULL);
+  any_visible |= visible;
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->license_page);
+  g_object_get (page, "visible", &visible, NULL);
+  any_visible |= visible;
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->system_page);
+  g_object_get (page, "visible", &visible, NULL);
+  any_visible |= visible;
+
+  gtk_widget_set_visible (priv->stack_switcher, any_visible);
 }
 
 static void
 update_license_button_visibility (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = gtk_about_dialog_get_instance_private (about);
+  GtkStackPage *page;
 
-  if (priv->license_type == GTK_LICENSE_CUSTOM && priv->license != NULL && priv->license[0] != '\0')
-    gtk_widget_show (priv->license_page);
-  else
-    gtk_widget_hide (priv->license_page);
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->license_page);
+  g_object_set (page, "visible",
+                priv->license_type == GTK_LICENSE_CUSTOM &&
+                priv->license != NULL &&
+                priv->license[0] != '\0',
+                NULL);
 
   update_stack_switcher_visibility (about);
 }
@@ -653,11 +666,13 @@ static void
 update_system_button_visibility (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = gtk_about_dialog_get_instance_private (about);
+  GtkStackPage *page;
 
-  if (priv->system_information != NULL && priv->system_information[0] != '\0')
-    gtk_widget_show (priv->system_page);
-  else
-    gtk_widget_hide (priv->system_page);
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->system_page);
+  g_object_set (page, "visible",
+                priv->system_information != NULL &&
+                priv->system_information[0] != '\0',
+                NULL);
 
   update_stack_switcher_visibility (about);
 }
@@ -667,6 +682,9 @@ update_credits_button_visibility (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = gtk_about_dialog_get_instance_private (about);
   gboolean show;
+  GtkStackPage *page;
+
+  page = gtk_stack_get_page (GTK_STACK (priv->stack), priv->system_page);
 
   show = (priv->authors != NULL ||
           priv->documenters != NULL ||
@@ -675,10 +693,7 @@ update_credits_button_visibility (GtkAboutDialog *about)
           (priv->translator_credits != NULL &&
            strcmp (priv->translator_credits, "translator_credits") &&
            strcmp (priv->translator_credits, "translator-credits")));
-  if (show)
-    gtk_widget_show (priv->credits_page);
-  else
-    gtk_widget_hide (priv->credits_page);
+  g_object_set (page, "visible", show, NULL);
 
   update_stack_switcher_visibility (about);
 }
diff --git a/gtk/ui/gtkaboutdialog.ui b/gtk/ui/gtkaboutdialog.ui
index 7fe6da1351..4d96454521 100644
--- a/gtk/ui/gtkaboutdialog.ui
+++ b/gtk/ui/gtkaboutdialog.ui
@@ -110,7 +110,6 @@
                     <property name="title" translatable="yes">Credits</property>
                     <property name="child">
                       <object class="GtkBox" id="credits_page">
-                        <property name="visible">0</property>
                         <property name="orientation">vertical</property>
                         <property name="spacing">8</property>
                         <child>
@@ -147,7 +146,6 @@
                     <property name="title" translatable="yes">License</property>
                     <property name="child">
                       <object class="GtkBox" id="license_page">
-                        <property name="visible">0</property>
                         <property name="orientation">vertical</property>
                         <property name="spacing">8</property>
                         <child>
@@ -190,7 +188,6 @@
                     <property name="title" translatable="yes">System</property>
                     <property name="child">
                       <object class="GtkBox" id="system_page">
-                        <property name="visible">0</property>
                         <property name="orientation">vertical</property>
                         <property name="spacing">8</property>
                         <child>


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