diff options
author | Ignacio Casal Quinteiro <icq@gnome.org> | 2014-12-19 15:17:16 +0100 |
---|---|---|
committer | Ignacio Casal Quinteiro <icq@gnome.org> | 2015-01-05 11:48:35 +0100 |
commit | 88476013e259791c8d8b6f32b2b5319c6a314b73 (patch) | |
tree | 2135b682b351dadaa8f616647ae421e2fb8fdf02 | |
parent | 98b9eb89595fbb23ed534fa93edc59a00be84e46 (diff) | |
download | gnome-bluetooth-88476013e259791c8d8b6f32b2b5319c6a314b73.tar.gz |
settings-row: port to use a template
https://bugzilla.gnome.org/show_bug.cgi?id=742359
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/bluetooth-settings-row.c | 41 | ||||
-rw-r--r-- | lib/bluetooth-settings-row.ui | 60 | ||||
-rw-r--r-- | lib/bluetooth.gresource.xml | 1 |
4 files changed, 70 insertions, 34 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 36e47381..6e7b35dd 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 f1abb6d3..027df4da 100644 --- a/lib/bluetooth-settings-row.c +++ b/lib/bluetooth-settings-row.c @@ -92,44 +92,12 @@ 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); - - /* 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); - g_object_set_data (G_OBJECT (self), "spinner", priv->spinner); + gtk_widget_init_template (GTK_WIDGET (self)); /* 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 +216,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 +260,12 @@ 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 00000000..446d9c45 --- /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 7d238d13..8b3becb0 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> |