[gnome-initial-setup] gis-assistant: Use composite widget templates
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] gis-assistant: Use composite widget templates
- Date: Thu, 26 Sep 2013 00:05:26 +0000 (UTC)
commit 826d8bc64c0f87b0244d80670f0261ea456abe54
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Sep 24 16:56:52 2013 -0400
gis-assistant: Use composite widget templates
.gitignore | 1 +
gnome-initial-setup/Makefile.am | 12 ++++-
gnome-initial-setup/gis-assistant.c | 58 +++++-----------------
gnome-initial-setup/gis-assistant.gresource.xml | 6 ++
gnome-initial-setup/gis-assistant.ui | 61 +++++++++++++++++++++++
5 files changed, 91 insertions(+), 47 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 2f0fbbd..4207ad6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ gnome-initial-setup-*.tar.xz
gnome-initial-setup/gnome-initial-setup
gnome-initial-setup/gnome-initial-setup-copy-worker
+gnome-initial-setup/gis-assistant-resources.[ch]
gnome-initial-setup/pages/welcome/welcome-resources.[ch]
gnome-initial-setup/pages/language/language-resources.[ch]
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index f9138c9..b3e97a3 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -1,5 +1,7 @@
SUBDIRS = pages
+BUILT_SOURCES =
+
uidir = $(datadir)/gnome-initial-setup
AM_CPPFLAGS = \
@@ -11,7 +13,15 @@ AM_CPPFLAGS = \
libexec_PROGRAMS = gnome-initial-setup gnome-initial-setup-copy-worker
-gnome_initial_setup_SOURCES = \
+resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/gis-assistant.gresource.xml)
+gis-assistant-resources.c: gis-assistant.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
+gis-assistant-resources.h: gis-assistant.gresource.xml $(resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-header $<
+BUILT_SOURCES += gis-assistant-resources.c gis-assistant-resources.h
+
+gnome_initial_setup_SOURCES = \
+ $(BUILT_SOURCES) \
gnome-initial-setup.c gnome-initial-setup.h \
gis-assistant.c gis-assistant.h \
gis-page.c gis-page.h \
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 59477aa..a97b91e 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -415,63 +415,18 @@ static void
gis_assistant_init (GisAssistant *assistant)
{
GisAssistantPrivate *priv = gis_assistant_get_instance_private (assistant);
- GtkWidget *widget;
- priv->titlebar = gtk_header_bar_new ();
- gtk_widget_show (priv->titlebar);
-
- priv->main_layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
- gtk_box_pack_start (GTK_BOX (assistant), priv->main_layout, TRUE, TRUE, 0);
-
- priv->stack = gtk_stack_new ();
- gtk_stack_set_transition_type (GTK_STACK (priv->stack),
- GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
- gtk_container_add (GTK_CONTAINER (priv->main_layout), priv->stack);
+ gtk_widget_init_template (GTK_WIDGET (assistant));
g_signal_connect (priv->stack, "notify::visible-child",
G_CALLBACK (current_page_changed), assistant);
- priv->forward = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (priv->forward),
- gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
- gtk_button_set_use_underline (GTK_BUTTON (priv->forward), TRUE);
- gtk_widget_set_can_default (priv->forward, TRUE);
-
- priv->back = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (priv->back),
- gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
- gtk_button_set_use_underline (GTK_BUTTON (priv->back), TRUE);
-
- priv->cancel = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (priv->cancel),
- gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
- gtk_button_set_use_underline (GTK_BUTTON (priv->cancel), TRUE);
-
- gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->titlebar), priv->cancel);
- gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->titlebar), priv->back);
-
- priv->spinner = gtk_spinner_new ();
- widget = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 6);
- gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->titlebar), widget);
- gtk_container_add (GTK_CONTAINER (widget), priv->spinner);
- gtk_widget_show (widget);
-
- gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->titlebar), priv->forward);
-
g_signal_connect (priv->forward, "clicked", G_CALLBACK (go_forward), assistant);
g_signal_connect (priv->back, "clicked", G_CALLBACK (go_backward), assistant);
g_signal_connect (priv->cancel, "clicked", G_CALLBACK (do_cancel), assistant);
- priv->progress_indicator = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_widget_set_halign (priv->progress_indicator, GTK_ALIGN_CENTER);
-
- gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->progress_indicator, FALSE, TRUE, 0);
-
gis_assistant_locale_changed (assistant);
update_applying_state (assistant);
-
- gtk_widget_show_all (GTK_WIDGET (assistant));
}
static void
@@ -499,6 +454,17 @@ gis_assistant_class_init (GisAssistantClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
"/org/gnome/initial-setup/gis-assistant.ui");
+
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, forward);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, back);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, cancel);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, progress_indicator);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, main_layout);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, spinner);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, titlebar);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAssistant, stack);
+
gobject_class->get_property = gis_assistant_get_property;
klass->next_page = gis_assistant_real_next_page;
diff --git a/gnome-initial-setup/gis-assistant.gresource.xml b/gnome-initial-setup/gis-assistant.gresource.xml
new file mode 100644
index 0000000..0640c24
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/initial-setup">
+ <file preprocess="xml-stripblanks">gis-assistant.ui</file>
+ </gresource>
+</gresources>
diff --git a/gnome-initial-setup/gis-assistant.ui b/gnome-initial-setup/gis-assistant.ui
new file mode 100644
index 0000000..2d7dd83
--- /dev/null
+++ b/gnome-initial-setup/gis-assistant.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk30">
+ <!-- interface-requires gtk+ 3.10 -->
+ <object class="GtkHeaderBar" id="titlebar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="back">
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="forward">
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ <property name="can-default">True</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+
+ <template class="GisAssistant" parent="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="main_layout">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">20</property>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="progress_indicator">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="halign">center</property>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]