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



commit cdbfc0c8fa469b0d73de33b0a4d540c4e21bd8ee
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Oct 30 15:58:50 2013 -0400

    language: Convert to composite widget templates

 .../pages/language/gis-language-page.c             |   23 +++++++++++++------
 .../pages/language/gis-language-page.ui            |   20 ++++++++++-------
 2 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/gnome-initial-setup/pages/language/gis-language-page.c 
b/gnome-initial-setup/pages/language/gis-language-page.c
index d7f6bb7..4da367b 100644
--- a/gnome-initial-setup/pages/language/gis-language-page.c
+++ b/gnome-initial-setup/pages/language/gis-language-page.c
@@ -41,6 +41,7 @@
 struct _GisLanguagePagePrivate
 {
   GtkWidget *language_chooser;
+
   GDBusProxy *localed;
   GPermission *permission;
   const gchar *new_locale_id;
@@ -52,9 +53,6 @@ typedef struct _GisLanguagePagePrivate GisLanguagePagePrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GisLanguagePage, gis_language_page, GIS_TYPE_PAGE);
 
-#define OBJ(type,name) ((type)gtk_builder_get_object(GIS_PAGE (page)->builder,(name)))
-#define WID(name) OBJ(GtkWidget*,name)
-
 static void
 set_localed_locale (GisLanguagePage *self)
 {
@@ -198,13 +196,9 @@ gis_language_page_constructed (GObject *object)
 
   G_OBJECT_CLASS (gis_language_page_parent_class)->constructed (object);
 
-  gtk_container_add (GTK_CONTAINER (page), WID ("language-page"));
-
-  priv->language_chooser = WID ("language-chooser");
   g_signal_connect (priv->language_chooser, "notify::language",
                     G_CALLBACK (language_changed), page);
 
-
   /* If we're in new user mode then we're manipulating system settings */
   if (gis_driver_get_mode (GIS_PAGE (page)->driver) == GIS_DRIVER_MODE_NEW_USER)
     {
@@ -233,6 +227,13 @@ gis_language_page_locale_changed (GisPage *page)
   gis_page_set_title (GIS_PAGE (page), _("Welcome"));
 }
 
+static GtkBuilder *
+gis_language_page_get_builder (GisPage *page)
+{
+  /* handled by widget templates */
+  return NULL;
+}
+
 static void
 gis_language_page_dispose (GObject *object)
 {
@@ -251,8 +252,13 @@ gis_language_page_class_init (GisLanguagePageClass *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-language-page.ui");
+
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisLanguagePage, language_chooser);
+
   page_class->page_id = PAGE_ID;
   page_class->locale_changed = gis_language_page_locale_changed;
+  page_class->get_builder = gis_language_page_get_builder;
   object_class->constructed = gis_language_page_constructed;
   object_class->dispose = gis_language_page_dispose;
 }
@@ -261,6 +267,9 @@ static void
 gis_language_page_init (GisLanguagePage *page)
 {
   g_resources_register (language_get_resource ());
+  g_type_ensure (CC_TYPE_LANGUAGE_CHOOSER);
+
+  gtk_widget_init_template (GTK_WIDGET (page));
 }
 
 void
diff --git a/gnome-initial-setup/pages/language/gis-language-page.ui 
b/gnome-initial-setup/pages/language/gis-language-page.ui
index 2951464..a8259cf 100644
--- a/gnome-initial-setup/pages/language/gis-language-page.ui
+++ b/gnome-initial-setup/pages/language/gis-language-page.ui
@@ -1,16 +1,20 @@
 <?xml version="1.0"?>
 <interface>
   <requires lib="gtk+" version="3.0"/>
-  <object class="GtkBox" id="language-page">
-    <property name="name">language-page</property>
-    <property name="visible">True</property>
-    <property name="orientation">vertical</property>
-    <property name="margin-left">80</property>
-    <property name="margin-right">80</property>
+  <template class="GisLanguagePage" parent="GisPage">
     <child>
-      <object class="CcLanguageChooser" id="language-chooser">
+      <object class="GtkBox" id="box">
+        <property name="name">language-page</property>
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="margin-left">80</property>
+        <property name="margin-right">80</property>
+        <child>
+          <object class="CcLanguageChooser" id="language_chooser">
+            <property name="visible">True</property>
+          </object>
+        </child>
       </object>
     </child>
-  </object>
+  </template>
 </interface>


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