[gnome-initial-setup] cc-language-chooser: Use new composite widget templates
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] cc-language-chooser: Use new composite widget templates
- Date: Thu, 31 Oct 2013 18:34:59 +0000 (UTC)
commit 083666a51a9b5e5ec411237e10d5460a7bf20270
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Oct 31 09:11:40 2013 -0400
cc-language-chooser: Use new composite widget templates
.../pages/language/cc-language-chooser.c | 30 +++++++------------
.../pages/language/cc-language-chooser.h | 4 +-
.../pages/language/language-chooser.ui | 15 ++++------
3 files changed, 19 insertions(+), 30 deletions(-)
---
diff --git a/gnome-initial-setup/pages/language/cc-language-chooser.c
b/gnome-initial-setup/pages/language/cc-language-chooser.c
index f8a3dad..7f3cddb 100644
--- a/gnome-initial-setup/pages/language/cc-language-chooser.c
+++ b/gnome-initial-setup/pages/language/cc-language-chooser.c
@@ -41,16 +41,18 @@
struct _CcLanguageChooserPrivate
{
- GtkWidget *no_results;
- GtkWidget *more_item;
GtkWidget *filter_entry;
GtkWidget *language_list;
+
+ GtkWidget *no_results;
+ GtkWidget *more_item;
+
gboolean showing_extra;
gchar **filter_words;
gchar *language;
};
typedef struct _CcLanguageChooserPrivate CcLanguageChooserPrivate;
-G_DEFINE_TYPE_WITH_PRIVATE (CcLanguageChooser, cc_language_chooser, GTK_TYPE_BIN);
+G_DEFINE_TYPE_WITH_PRIVATE (CcLanguageChooser, cc_language_chooser, GTK_TYPE_BOX);
enum {
PROP_0,
@@ -410,30 +412,14 @@ update_header_func (GtkListBoxRow *child,
gtk_widget_show (header);
}
-#define WID(name) ((GtkWidget *) gtk_builder_get_object (builder, name))
-
static void
cc_language_chooser_constructed (GObject *object)
{
CcLanguageChooser *chooser = CC_LANGUAGE_CHOOSER (object);
CcLanguageChooserPrivate *priv = cc_language_chooser_get_instance_private (chooser);
- GtkBuilder *builder;
- GError *error = NULL;
G_OBJECT_CLASS (cc_language_chooser_parent_class)->constructed (object);
- builder = gtk_builder_new ();
- if (gtk_builder_add_from_resource (builder, "/org/gnome/control-center/language-chooser.ui", &error)
== 0) {
- g_object_unref (builder);
- g_warning ("failed to load language chooser: %s", error->message);
- g_error_free (error);
- return;
- }
-
- gtk_container_add (GTK_CONTAINER (chooser), WID ("language-chooser"));
-
- priv->filter_entry = WID ("language-filter-entry");
- priv->language_list = WID ("language-list");
priv->more_item = more_widget_new ();
priv->no_results = no_results_widget_new ();
@@ -511,6 +497,11 @@ cc_language_chooser_class_init (CcLanguageChooserClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
"/org/gnome/control-center/language-chooser.ui");
+
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), CcLanguageChooser,
filter_entry);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), CcLanguageChooser,
language_list);
+
object_class->get_property = cc_language_chooser_get_property;
object_class->set_property = cc_language_chooser_set_property;
object_class->finalize = cc_language_chooser_finalize;
@@ -530,6 +521,7 @@ cc_language_chooser_class_init (CcLanguageChooserClass *klass)
static void
cc_language_chooser_init (CcLanguageChooser *chooser)
{
+ gtk_widget_init_template (GTK_WIDGET (chooser));
}
void
diff --git a/gnome-initial-setup/pages/language/cc-language-chooser.h
b/gnome-initial-setup/pages/language/cc-language-chooser.h
index 3d788a4..e4ce7de 100644
--- a/gnome-initial-setup/pages/language/cc-language-chooser.h
+++ b/gnome-initial-setup/pages/language/cc-language-chooser.h
@@ -42,12 +42,12 @@ typedef struct _CcLanguageChooserClass CcLanguageChooserClass;
struct _CcLanguageChooser
{
- GtkBin parent;
+ GtkBox parent;
};
struct _CcLanguageChooserClass
{
- GtkBinClass parent_class;
+ GtkBoxClass parent_class;
};
GType cc_language_chooser_get_type (void);
diff --git a/gnome-initial-setup/pages/language/language-chooser.ui
b/gnome-initial-setup/pages/language/language-chooser.ui
index fbe220e..f6d80ab 100644
--- a/gnome-initial-setup/pages/language/language-chooser.ui
+++ b/gnome-initial-setup/pages/language/language-chooser.ui
@@ -1,22 +1,21 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="3.0"/>
- <object class="GtkBox" id="language-chooser">
- <property name="name">language-chooser</property>
+ <template class="CcLanguageChooser" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
- <object class="GtkScrolledWindow" id="language-scrolledwindow">
+ <object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="shadow-type">in</property>
<child>
- <object class="GtkViewport" id="language-viewport">
+ <object class="GtkViewport" id="viewport">
<property name="visible">True</property>
<child>
- <object class="GtkListBox" id="language-list">
+ <object class="GtkListBox" id="language_list">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="vexpand">True</property>
@@ -29,12 +28,10 @@
</object>
</child>
<child>
- </child>
- <child>
- <object class="GtkSearchEntry" id="language-filter-entry">
+ <object class="GtkSearchEntry" id="filter_entry">
<property name="visible">False</property>
<property name="hexpand">True</property>
</object>
</child>
- </object>
+ </template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]