[gnome-initial-setup] timezone: Convert to composite widget templates
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] timezone: Convert to composite widget templates
- Date: Wed, 30 Oct 2013 21:30:46 +0000 (UTC)
commit a783c348a8dcf40670f33a5239f476736dcea2a9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Oct 30 15:51:50 2013 -0400
timezone: Convert to composite widget templates
.../pages/timezone/gis-timezone-page.c | 49 ++++--
.../pages/timezone/gis-timezone-page.ui | 160 ++++++++++----------
2 files changed, 115 insertions(+), 94 deletions(-)
---
diff --git a/gnome-initial-setup/pages/timezone/gis-timezone-page.c
b/gnome-initial-setup/pages/timezone/gis-timezone-page.c
index 192fb30..6a70169 100644
--- a/gnome-initial-setup/pages/timezone/gis-timezone-page.c
+++ b/gnome-initial-setup/pages/timezone/gis-timezone-page.c
@@ -47,6 +47,11 @@
struct _GisTimezonePagePrivate
{
GtkWidget *map;
+ GtkWidget *stack;
+ GtkWidget *auto_result;
+ GtkWidget *search_button;
+ GtkWidget *search_entry;
+
GWeatherLocation *auto_location;
GWeatherLocation *current_location;
Timedate1 *dtm;
@@ -55,9 +60,6 @@ typedef struct _GisTimezonePagePrivate GisTimezonePagePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GisTimezonePage, gis_timezone_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_timezone_cb (GObject *source,
GAsyncResult *res,
@@ -147,7 +149,7 @@ set_auto_location (GisTimezonePage *page,
markup = g_strdup_printf (_("We think that your time zone is <b>%s</b>. Press Next to continue"
" or search for a city to manually set the time zone."),
tzname);
- gtk_label_set_markup (GTK_LABEL (WID ("timezone-auto-result")), markup);
+ gtk_label_set_markup (GTK_LABEL (priv->auto_result), markup);
g_free (tzname);
g_free (markup);
}
@@ -156,11 +158,11 @@ set_auto_location (GisTimezonePage *page,
priv->auto_location = NULL;
/* We have no automatic location; transition to search automatically */
- gtk_widget_hide (WID ("timezone-search-button"));
- gtk_widget_hide (WID ("timezone-auto-result"));
+ gtk_widget_hide (priv->search_button);
+ gtk_widget_hide (priv->auto_result);
}
- gtk_widget_show (WID ("timezone-stack"));
+ gtk_widget_show (priv->stack);
}
static void
@@ -281,9 +283,10 @@ static void
search_button_toggled (GtkToggleButton *button,
GisTimezonePage *page)
{
+ GisTimezonePagePrivate *priv = gis_timezone_page_get_instance_private (page);
gboolean want_search = gtk_toggle_button_get_active (button);
- gtk_stack_set_visible_child_name (GTK_STACK (WID ("timezone-stack")),
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack),
want_search ? "search" : "status");
}
@@ -296,8 +299,6 @@ gis_timezone_page_constructed (GObject *object)
G_OBJECT_CLASS (gis_timezone_page_parent_class)->constructed (object);
- gtk_container_add (GTK_CONTAINER (page), WID ("timezone-page"));
-
error = NULL;
priv->dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
@@ -310,17 +311,15 @@ gis_timezone_page_constructed (GObject *object)
exit (1);
}
- priv->map = WID("timezone-map");
-
get_location_from_geoclue (page);
- g_signal_connect (WID ("timezone-search"), "notify::location",
+ g_signal_connect (priv->search_entry, "notify::location",
G_CALLBACK (entry_location_changed), page);
- g_signal_connect (WID ("timezone-search"), "map",
+ g_signal_connect (priv->search_entry, "map",
G_CALLBACK (entry_mapped), page);
- g_signal_connect (WID ("timezone-stack"), "notify::visible-child",
+ g_signal_connect (priv->stack, "notify::visible-child",
G_CALLBACK (visible_child_changed), page);
- g_signal_connect (WID ("timezone-search-button"), "toggled",
+ g_signal_connect (priv->search_button, "toggled",
G_CALLBACK (search_button_toggled), page);
gis_page_set_complete (GIS_PAGE (page), TRUE);
@@ -345,14 +344,30 @@ gis_timezone_page_locale_changed (GisPage *page)
gis_page_set_title (GIS_PAGE (page), _("Time Zone"));
}
+static GtkBuilder *
+gis_timezone_page_get_builder (GisPage *page)
+{
+ /* handled by widget templates */
+ return NULL;
+}
+
static void
gis_timezone_page_class_init (GisTimezonePageClass *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-timezone-page.ui");
+
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisTimezonePage, map);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisTimezonePage, stack);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisTimezonePage, auto_result);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisTimezonePage, search_button);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisTimezonePage, search_entry);
+
page_class->page_id = PAGE_ID;
page_class->locale_changed = gis_timezone_page_locale_changed;
+ page_class->get_builder = gis_timezone_page_get_builder;
object_class->constructed = gis_timezone_page_constructed;
object_class->dispose = gis_timezone_page_dispose;
}
@@ -363,6 +378,8 @@ gis_timezone_page_init (GisTimezonePage *page)
g_resources_register (timezone_get_resource ());
g_resources_register (datetime_get_resource ());
g_type_ensure (CC_TYPE_TIMEZONE_MAP);
+
+ gtk_widget_init_template (GTK_WIDGET (page));
}
void
diff --git a/gnome-initial-setup/pages/timezone/gis-timezone-page.ui
b/gnome-initial-setup/pages/timezone/gis-timezone-page.ui
index bc5e6e3..ce15a70 100644
--- a/gnome-initial-setup/pages/timezone/gis-timezone-page.ui
+++ b/gnome-initial-setup/pages/timezone/gis-timezone-page.ui
@@ -2,117 +2,121 @@
<!-- Generated with glade 3.16.0 on Tue Oct 22 19:34:41 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkBox" id="timezone-page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
+ <template class="GisTimezonePage" parent="GisPage">
<child>
- <object class="GtkLabel" id="timezone-title">
+ <object class="GtkBox" id="box">
<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">Time Zone</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.6"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="timezone-status-box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">8</property>
+ <property name="orientation">vertical</property>
+ <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">Time Zone</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.6"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
- <object class="GtkStack" id="timezone-stack">
- <property name="transition-type">crossfade</property>
+ <object class="GtkBox" id="status_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
<child>
- <object class="GtkLabel" id="timezone-auto-result">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="wrap">True</property>
+ <object class="GtkStack" id="stack">
+ <property name="transition-type">crossfade</property>
+ <child>
+ <object class="GtkLabel" id="auto_result">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="name">status</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GWeatherLocationEntry" id="search_entry">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="name">search</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="name">status</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GWeatherLocationEntry" id="timezone-search">
+ <object class="GtkToggleButton" id="search_button">
+ <property name="width_request">32</property>
+ <property name="height_request">32</property>
<property name="visible">True</property>
- <property name="hexpand">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">16</property>
+ <property name="icon_name">edit-find-symbolic</property>
+ <property name="icon_size">0</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="name">search</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="timezone-search-button">
- <property name="width_request">32</property>
- <property name="height_request">32</property>
+ <object class="GtkFrame" id="map_frame">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="label_xalign">0</property>
<child>
- <object class="GtkImage" id="image1">
+ <object class="CcTimezoneMap" id="map">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="pixel_size">16</property>
- <property name="icon_name">edit-find-symbolic</property>
- <property name="icon_size">0</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="timezone-map-frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="label_xalign">0</property>
- <child>
- <object class="CcTimezoneMap" id="timezone-map">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
- </object>
+ </template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]