[gnome-initial-setup] eula: Convert to composite widget templates



commit 220d9789647850464e98d90700417e7c7fa7dbbd
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Oct 30 16:02:04 2013 -0400

    eula: Convert to composite widget templates

 gnome-initial-setup/pages/eulas/gis-eula-page.c  |   27 ++++---
 gnome-initial-setup/pages/eulas/gis-eula-page.ui |   94 +++++++++++----------
 2 files changed, 66 insertions(+), 55 deletions(-)
---
diff --git a/gnome-initial-setup/pages/eulas/gis-eula-page.c b/gnome-initial-setup/pages/eulas/gis-eula-page.c
index 25e9249..9922749 100644
--- a/gnome-initial-setup/pages/eulas/gis-eula-page.c
+++ b/gnome-initial-setup/pages/eulas/gis-eula-page.c
@@ -36,11 +36,11 @@
 
 struct _GisEulaPagePrivate
 {
-  GFile *eula;
-
   GtkWidget *checkbox;
   GtkWidget *scrolled_window;
 
+  GFile *eula;
+
   gboolean require_checkbox;
   gboolean require_scroll;
 };
@@ -48,9 +48,6 @@ typedef struct _GisEulaPagePrivate GisEulaPagePrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GisEulaPage, gis_eula_page, GIS_TYPE_PAGE);
 
-#define OBJ(type,name) ((type)gtk_builder_get_object(GIS_PAGE(page)->builder,(name)))
-#define WID(name) OBJ(GtkWidget*,name)
-
 enum
 {
   PROP_0,
@@ -236,9 +233,7 @@ gis_eula_page_constructed (GObject *object)
   if (text_view == NULL)
     return;
 
-  priv->scrolled_window = WID ("scrolledwindow");
   gtk_container_add (GTK_CONTAINER (priv->scrolled_window), text_view);
-
   gtk_widget_show (text_view);
 
   get_config (eula, &require_checkbox, &require_scroll);
@@ -246,7 +241,6 @@ gis_eula_page_constructed (GObject *object)
   priv->require_checkbox = require_checkbox;
   priv->require_scroll = require_scroll;
 
-  priv->checkbox = WID ("checkbox");
   gtk_widget_set_visible (priv->checkbox, require_checkbox);
 
   if (require_scroll) {
@@ -262,8 +256,6 @@ gis_eula_page_constructed (GObject *object)
 
   sync_page_complete (page);
 
-  gtk_container_add (GTK_CONTAINER (page), WID ("eula-page"));
-
   gtk_widget_show (GTK_WIDGET (page));
 }
 
@@ -324,14 +316,27 @@ gis_eula_page_locale_changed (GisPage *page)
   gis_page_set_title (GIS_PAGE (page), _("License Agreements"));
 }
 
+static GtkBuilder *
+gis_eula_page_get_builder (GisPage *page)
+{
+  /* handled by widget templates */
+  return NULL;
+}
+
 static void
 gis_eula_page_class_init (GisEulaPageClass *klass)
 {
   GisPageClass *page_class = GIS_PAGE_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 
"/org/gnome/initial-setup/gis-eula-page.ui");
+
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisEulaPage, checkbox);
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisEulaPage, scrolled_window);
+
   page_class->page_id = PAGE_ID;
   page_class->locale_changed = gis_eula_page_locale_changed;
+  page_class->get_builder = gis_eula_page_get_builder;
   object_class->get_property = gis_eula_page_get_property;
   object_class->set_property = gis_eula_page_set_property;
   object_class->constructed = gis_eula_page_constructed;
@@ -349,4 +354,6 @@ static void
 gis_eula_page_init (GisEulaPage *page)
 {
   g_resources_register (eulas_get_resource ());
+
+  gtk_widget_init_template (GTK_WIDGET (page));
 }
diff --git a/gnome-initial-setup/pages/eulas/gis-eula-page.ui 
b/gnome-initial-setup/pages/eulas/gis-eula-page.ui
index ab4e9f2..f55601b 100644
--- a/gnome-initial-setup/pages/eulas/gis-eula-page.ui
+++ b/gnome-initial-setup/pages/eulas/gis-eula-page.ui
@@ -1,63 +1,67 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkGrid" id="eula-page">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="halign">fill</property>
-    <property name="margin_left">80</property>
-    <property name="margin_right">80</property>
+  <template class="GisEulaPage" parent="GisPage">
     <child>
-      <object class="GtkLabel" id="eula-title">
+      <object class="GtkGrid" id="box">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="halign">start</property>
-        <property name="valign">start</property>
-        <property name="margin_bottom">18</property>
-        <property name="label" translatable="yes">License Agreements</property>
-        <attributes>
-          <attribute name="weight" value="bold"/>
-          <attribute name="scale" value="1.2"/>
-        </attributes>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkBox" id="vbox">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="can_focus">False</property>
+        <property name="halign">fill</property>
+        <property name="margin_left">80</property>
+        <property name="margin_right">80</property>
         <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow">
+          <object class="GtkLabel" id="title">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="shadow_type">etched-in</property>
-            <property name="hscrollbar_policy">never</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="vexpand">True</property>
-            <property name="hexpand">True</property>
+            <property name="halign">start</property>
+            <property name="valign">start</property>
+            <property name="margin_bottom">18</property>
+            <property name="label" translatable="yes">License Agreements</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+              <attribute name="scale" value="1.2"/>
+            </attributes>
           </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="checkbox">
-            <property name="visible">False</property>
+          <object class="GtkBox" id="vbox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">I have _agreed to the terms and conditions in this end 
user license agreement.</property>
-            <property name="use_underline">True</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolled_window">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="shadow_type">etched-in</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="vexpand">True</property>
+                <property name="hexpand">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="checkbox">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">I have _agreed to the terms and conditions in this 
end user license agreement.</property>
+                <property name="use_underline">True</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
         </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
-      </packing>
     </child>
-  </object>
+  </template>
 </interface>


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