[gnome-initial-setup/mcatanzaro/software-page-updates] software: update to match new design




commit cca7bf8c876514384ad8128c08b66908d93eeea1
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Tue Oct 19 16:38:54 2021 -0500

    software: update to match new design
    
    This replaces the toggle switch with a button that changes state.
    
    Fixes #128

 .../pages/software/gis-software-page.c             | 40 +++++++++++++++++-----
 .../pages/software/gis-software-page.ui            | 26 +++-----------
 2 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/gnome-initial-setup/pages/software/gis-software-page.c 
b/gnome-initial-setup/pages/software/gis-software-page.c
index 28f807b1..26b710ef 100644
--- a/gnome-initial-setup/pages/software/gis-software-page.c
+++ b/gnome-initial-setup/pages/software/gis-software-page.c
@@ -37,8 +37,9 @@
 
 struct _GisSoftwarePagePrivate
 {
-  GtkWidget *proprietary_switch;
   GtkWidget *header;
+  GtkWidget *enable_disable_button;
+  gboolean enabled;
 };
 
 typedef struct _GisSoftwarePagePrivate GisSoftwarePagePrivate;
@@ -90,7 +91,7 @@ gis_software_page_apply (GisPage      *gis_page,
     {
       const char *arg1;
 
-      if (gtk_switch_get_state (GTK_SWITCH (priv->proprietary_switch)))
+      if (priv->enabled)
         arg1 = "enable";
       else
         arg1 = "disable";
@@ -114,13 +115,33 @@ gis_software_page_locale_changed (GisPage *gis_page)
 }
 
 static gboolean
-state_set (GtkSwitch *sw,
-           gboolean   state,
-           gpointer   data)
+enabled_state_changed (GisSoftwarePage *page)
 {
-  gtk_switch_set_state (sw, state);
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+  GtkStyleContext *style;
+
+  style = gtk_widget_get_style_context (priv->enable_disable_button);
 
-  return TRUE;
+  if (priv->enabled)
+    {
+      gtk_button_set_label (GTK_BUTTON (priv->enable_disable_button), _("_Disable Third-Party 
Repositories"));
+      gtk_style_context_remove_class (style, "suggested-action");
+    }
+  else
+    {
+      gtk_button_set_label (GTK_BUTTON (priv->enable_disable_button), _("_Enable Third-Party Repositories"));
+      gtk_style_context_add_class (style, "suggested-action");
+    }
+}
+
+static gboolean
+enable_disable_button_clicked_cb (GtkButton       *button,
+                                  GisSoftwarePage *page)
+{
+  GisSoftwarePagePrivate *priv = gis_software_page_get_instance_private (page);
+  priv->enabled = !priv->enabled;
+  enabled_state_changed (page);
+  return GDK_EVENT_STOP;
 }
 
 static void
@@ -130,9 +151,9 @@ gis_software_page_class_init (GisSoftwarePageClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 
"/org/gnome/initial-setup/gis-software-page.ui");
-  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, 
proprietary_switch);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, header);
-  gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), state_set);
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisSoftwarePage, 
enable_disable_button);
+  gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), enable_disable_button_clicked_cb);
 
   page_class->page_id = PAGE_ID;
   page_class->locale_changed = gis_software_page_locale_changed;
@@ -147,6 +168,7 @@ gis_software_page_init (GisSoftwarePage *page)
   g_type_ensure (GIS_TYPE_PAGE_HEADER);
 
   gtk_widget_init_template (GTK_WIDGET (page));
+  enabled_state_changed (page);
 }
 
 GisPage *
diff --git a/gnome-initial-setup/pages/software/gis-software-page.ui 
b/gnome-initial-setup/pages/software/gis-software-page.ui
index d8a14fd8..23ab9342 100644
--- a/gnome-initial-setup/pages/software/gis-software-page.ui
+++ b/gnome-initial-setup/pages/software/gis-software-page.ui
@@ -19,28 +19,12 @@
           </object>
         </child>
         <child>
-          <object class="GtkBox">
+          <object class="GtkButton" id="enable_disable_button">
+            <property name="halign">center</property>
+            <property name="margin">36</property>
+            <property name="use-underline">True</property>
             <property name="visible">True</property>
-            <property name="margin-top">40</property>
-            <property name="orientation">horizontal</property>
-            <property name="homogeneous">True</property>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">True</property>
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">Third-Party Repositories</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-            </child>
-            <child>
-              <object class="GtkSwitch" id="proprietary_switch">
-                <property name="halign">end</property>
-                <property name="visible">True</property>
-                <signal name="state-set" handler="state_set"/>
-              </object>
-            </child>
+            <signal name="clicked" handler="enable_disable_button_clicked_cb"/>
           </object>
         </child>
       </object>


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