[gnome-initial-setup] goa: Convert to composite widget templates
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] goa: Convert to composite widget templates
- Date: Wed, 30 Oct 2013 21:30:51 +0000 (UTC)
commit feb53866f366ad29d4e20e77f192064f3dabcb94
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Oct 30 15:55:16 2013 -0400
goa: Convert to composite widget templates
gnome-initial-setup/pages/goa/gis-goa-page.c | 31 +++--
gnome-initial-setup/pages/goa/gis-goa-page.ui | 166 +++++++++++++------------
2 files changed, 104 insertions(+), 93 deletions(-)
---
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.c b/gnome-initial-setup/pages/goa/gis-goa-page.c
index b008717..c467f25 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.c
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.c
@@ -38,6 +38,8 @@
#include <gio/gio.h>
struct _GisGoaPagePrivate {
+ GtkWidget *accounts_list;
+
GoaClient *goa_client;
GHashTable *providers;
gboolean accounts_exist;
@@ -46,9 +48,6 @@ typedef struct _GisGoaPagePrivate GisGoaPagePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GisGoaPage, gis_goa_page, GIS_TYPE_PAGE);
-#define OBJ(type,name) ((type)gtk_builder_get_object(GIS_PAGE(page)->builder,(name)))
-#define WID(name) OBJ(GtkWidget*,name)
-
struct _ProviderWidget {
GisGoaPage *page;
GoaProvider *provider;
@@ -117,7 +116,6 @@ static void
add_provider_to_list (GisGoaPage *page, const char *provider_type)
{
GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
- GtkWidget *list;
GtkWidget *row;
GtkWidget *box;
GtkWidget *image;
@@ -172,8 +170,7 @@ add_provider_to_list (GisGoaPage *page, const char *provider_type)
g_hash_table_insert (priv->providers, (char *) provider_type, provider_widget);
- list = WID ("online-accounts-list");
- gtk_container_add (GTK_CONTAINER (list), row);
+ gtk_container_add (GTK_CONTAINER (priv->accounts_list), row);
}
static void
@@ -285,12 +282,9 @@ gis_goa_page_constructed (GObject *object)
GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
GError *error = NULL;
GNetworkMonitor *network_monitor = g_network_monitor_get_default ();
- GtkWidget *list;
G_OBJECT_CLASS (gis_goa_page_parent_class)->constructed (object);
- gtk_container_add (GTK_CONTAINER (page), WID ("goa-page"));
-
priv->goa_client = goa_client_new_sync (NULL, &error);
if (priv->goa_client == NULL) {
@@ -308,11 +302,10 @@ gis_goa_page_constructed (GObject *object)
g_signal_connect (network_monitor, "network-changed",
G_CALLBACK (network_status_changed), page);
- list = WID ("online-accounts-list");
- gtk_list_box_set_header_func (GTK_LIST_BOX (list),
+ gtk_list_box_set_header_func (GTK_LIST_BOX (priv->accounts_list),
update_header_func,
NULL, NULL);
- g_signal_connect (list, "row-activated",
+ g_signal_connect (priv->accounts_list, "row-activated",
G_CALLBACK (row_activated), page);
populate_provider_list (page);
@@ -341,14 +334,26 @@ gis_goa_page_locale_changed (GisPage *page)
gis_page_set_title (GIS_PAGE (page), _("Online Accounts"));
}
+static GtkBuilder *
+gis_goa_page_get_builder (GisPage *page)
+{
+ /* handled by widget templates */
+ return NULL;
+}
+
static void
gis_goa_page_class_init (GisGoaPageClass *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-goa-page.ui");
+
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisGoaPage, accounts_list);
+
page_class->page_id = PAGE_ID;
page_class->locale_changed = gis_goa_page_locale_changed;
+ page_class->get_builder = gis_goa_page_get_builder;
object_class->constructed = gis_goa_page_constructed;
object_class->dispose = gis_goa_page_dispose;
}
@@ -357,6 +362,8 @@ static void
gis_goa_page_init (GisGoaPage *page)
{
g_resources_register (goa_get_resource ());
+
+ gtk_widget_init_template (GTK_WIDGET (page));
}
void
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.ui b/gnome-initial-setup/pages/goa/gis-goa-page.ui
index f310347..bf9f51f 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.ui
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.ui
@@ -2,95 +2,99 @@
<!-- Generated with glade 3.16.0 on Wed Oct 23 11:13:34 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkBox" id="goa-page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">80</property>
- <property name="margin_right">80</property>
- <property name="orientation">vertical</property>
+ <template class="GisGoaPage" parent="GisPage">
<child>
- <object class="GtkImage" id="image1">
+ <object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="pixel_size">128</property>
- <property name="icon_name">goa-panel-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="online-title">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
- <property name="margin_bottom">18</property>
- <property name="label" translatable="yes">Connect Your Online Accounts</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.6000000000000001"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="online-accounts-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_bottom">18</property>
- <property name="label" translatable="yes">Connecting your accounts will allow you to easily access
your email, online calendar, contacts, documents and photos.</property>
- <property name="justify">center</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="online-accounts-frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
+ <property name="margin_left">80</property>
+ <property name="margin_right">80</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkListBox" id="online-accounts-list">
+ <object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="selection_mode">none</property>
+ <property name="pixel_size">128</property>
+ <property name="icon_name">goa-panel-symbolic</property>
+ <property name="icon_size">1</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="margin_bottom">18</property>
+ <property name="label" translatable="yes">Connect Your Online Accounts</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.6000000000000001"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="margin_bottom">18</property>
+ <property name="label" translatable="yes">Connecting your accounts will allow you to easily
access your email, online calendar, contacts, documents and photos.</property>
+ <property name="justify">center</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkListBox" id="accounts_list">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="footer_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">You can review your online accounts (and add others)
after setup.</property>
+ <property name="justify">center</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">4</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="footer-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">You can review your online accounts (and add others) after
setup.</property>
- <property name="justify">center</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">4</property>
- </packing>
</child>
- </object>
+ </template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]