[gnome-bluetooth/wip/fixes] settings-row: port to use a template
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/fixes] settings-row: port to use a template
- Date: Sat, 20 Dec 2014 15:39:29 +0000 (UTC)
commit 9b6ab211632b5d674568cccf9a431b63ac9409b0
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Dec 19 15:17:16 2014 +0100
settings-row: port to use a template
lib/Makefile.am | 2 +-
lib/bluetooth-settings-row.c | 40 +++++++--------------------
lib/bluetooth-settings-row.ui | 60 +++++++++++++++++++++++++++++++++++++++++
lib/bluetooth.gresource.xml | 1 +
4 files changed, 72 insertions(+), 31 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 36e4738..6e7b35d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -10,7 +10,7 @@ bluetooth-settings-resources.c: bluetooth.gresource.xml $(resource_files)
bluetooth-settings-resources.h: bluetooth.gresource.xml $(resource_files)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name
bluetooth_settings $<
-EXTRA_DIST += bluetooth.gresource.xml settings.ui bluetooth-paring-dialog.ui
+EXTRA_DIST += bluetooth.gresource.xml settings.ui bluetooth-paring-dialog.ui bluetooth-settings-row.ui
BUILT_SOURCES += bluetooth-settings-resources.c bluetooth-settings-resources.h
# will be scanned for introspection annotation, but won't be installed
diff --git a/lib/bluetooth-settings-row.c b/lib/bluetooth-settings-row.c
index f1abb6d..44d6e27 100644
--- a/lib/bluetooth-settings-row.c
+++ b/lib/bluetooth-settings-row.c
@@ -92,44 +92,16 @@ static void
bluetooth_settings_row_init (BluetoothSettingsRow *self)
{
BluetoothSettingsRowPrivate *priv = BLUETOOTH_SETTINGS_ROW_GET_PRIVATE (self);
- GtkWidget *box;
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 50);
- gtk_container_add (GTK_CONTAINER (self), box);
-
- /* Name is already escaped */
- priv->label = gtk_label_new ("Placeholder Name");
- gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (priv->label), 0, 0.5);
- gtk_widget_set_margin_start (priv->label, 20);
- gtk_widget_set_margin_end (priv->label, 20);
- gtk_widget_set_margin_top (priv->label, 6);
- gtk_widget_set_margin_bottom (priv->label, 6);
- gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
+ gtk_widget_init_template (GTK_WIDGET (self));
/* Spinner */
- priv->spinner = gtk_spinner_new ();
- g_object_bind_property (priv->spinner, "visible",
- priv->spinner, "active", 0);
- gtk_widget_set_margin_start (priv->spinner, 24);
- gtk_widget_set_margin_end (priv->spinner, 24);
- gtk_box_pack_start (GTK_BOX (box), priv->spinner, FALSE, TRUE, 0);
- gtk_widget_set_no_show_all (priv->spinner, TRUE);
+ /* FIXME: why do we need this? */
g_object_set_data (G_OBJECT (self), "spinner", priv->spinner);
/* Placeholder text */
- priv->status = gtk_label_new (_("Not Set Up"));
-
- gtk_widget_set_no_show_all (priv->status, TRUE);
- gtk_misc_set_alignment (GTK_MISC (priv->status), 1, 0.5);
- gtk_widget_set_margin_start (priv->status, 24);
- gtk_widget_set_margin_end (priv->status, 24);
- gtk_box_pack_start (GTK_BOX (box), priv->status, FALSE, TRUE, 0);
g_object_bind_property (priv->spinner, "visible",
priv->status, "visible", G_BINDING_INVERT_BOOLEAN | G_BINDING_BIDIRECTIONAL);
-
- gtk_widget_show (priv->status);
- gtk_widget_show_all (GTK_WIDGET (self));
}
static void
@@ -248,6 +220,7 @@ static void
bluetooth_settings_row_class_init (BluetoothSettingsRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -291,6 +264,13 @@ bluetooth_settings_row_class_init (BluetoothSettingsRowClass *klass)
g_param_spec_boolean ("legacy-pairing", NULL,
"Legacy pairing",
FALSE, G_PARAM_READWRITE));
+
+ /* Bind class to template */
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/bluetooth/bluetooth-settings-row.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, BluetoothSettingsRow, label);
+ gtk_widget_class_bind_template_child_private (widget_class, BluetoothSettingsRow, spinner);
+ gtk_widget_class_bind_template_child_private (widget_class, BluetoothSettingsRow, status);
}
/**
diff --git a/lib/bluetooth-settings-row.ui b/lib/bluetooth-settings-row.ui
new file mode 100644
index 0000000..446d9c4
--- /dev/null
+++ b/lib/bluetooth-settings-row.ui
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template class="BluetoothSettingsRow" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">20</property>
+ <property name="margin_end">20</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="label">Placeholder Name</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="status">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">Not Set Up</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_start">24</property>
+ <property name="margin_end">24</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/lib/bluetooth.gresource.xml b/lib/bluetooth.gresource.xml
index 7d238d1..8b3becb 100644
--- a/lib/bluetooth.gresource.xml
+++ b/lib/bluetooth.gresource.xml
@@ -3,5 +3,6 @@
<gresource prefix="/org/gnome/bluetooth">
<file preprocess="xml-stripblanks">settings.ui</file>
<file preprocess="xml-stripblanks">bluetooth-pairing-dialog.ui</file>
+ <file preprocess="xml-stripblanks">bluetooth-settings-row.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]