diff options
author | Christopher Davis <christopherdavis@gnome.org> | 2022-01-24 19:33:06 -0800 |
---|---|---|
committer | Christopher Davis <christopherdavis@gnome.org> | 2022-01-25 11:40:05 -0800 |
commit | c397144a53202e066ecdc85715953034038eb22a (patch) | |
tree | 69fe3c43d20f1074b3d43b0197fbcbac2f085a32 /lib | |
parent | 2216f16c091c6914a00e0b9f276be9a5825e47d9 (diff) | |
download | gnome-bluetooth-c397144a53202e066ecdc85715953034038eb22a.tar.gz |
bluetooth-settings-row: Subclass AdwActionRow
Significantly reduces the size of the UI file
and gives us consistent margins and padding.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bluetooth-settings-row.c | 11 | ||||
-rw-r--r-- | lib/bluetooth-settings-row.h | 3 | ||||
-rw-r--r-- | lib/bluetooth-settings-row.ui | 46 |
3 files changed, 19 insertions, 41 deletions
diff --git a/lib/bluetooth-settings-row.c b/lib/bluetooth-settings-row.c index 12ce79d5..856d1d16 100644 --- a/lib/bluetooth-settings-row.c +++ b/lib/bluetooth-settings-row.c @@ -20,6 +20,7 @@ #include "config.h" +#include <adwaita.h> #include <gtk/gtk.h> #include <glib/gi18n-lib.h> @@ -30,10 +31,9 @@ #include "gnome-bluetooth-enum-types.h" struct _BluetoothSettingsRow { - GtkListBoxRow parent_instance; + AdwActionRow parent_instance; /* Widget */ - GtkWidget *label; GtkWidget *status; GtkWidget *spinner; @@ -69,7 +69,7 @@ enum { PROP_TIME_CREATED }; -G_DEFINE_TYPE(BluetoothSettingsRow, bluetooth_settings_row, GTK_TYPE_LIST_BOX_ROW) +G_DEFINE_TYPE(BluetoothSettingsRow, bluetooth_settings_row, ADW_TYPE_ACTION_ROW) static void label_might_change (BluetoothSettingsRow *self) @@ -170,11 +170,11 @@ static void update_row (BluetoothSettingsRow *self) { if (self->name == NULL) { - gtk_label_set_text (GTK_LABEL (self->label), + adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), bluetooth_type_to_string (self->type)); gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE); } else { - gtk_label_set_text (GTK_LABEL (self->label), self->alias); + adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), self->alias); gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE); } } @@ -302,7 +302,6 @@ bluetooth_settings_row_class_init (BluetoothSettingsRowClass *klass) /* 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 (widget_class, BluetoothSettingsRow, label); gtk_widget_class_bind_template_child (widget_class, BluetoothSettingsRow, spinner); gtk_widget_class_bind_template_child (widget_class, BluetoothSettingsRow, status); } diff --git a/lib/bluetooth-settings-row.h b/lib/bluetooth-settings-row.h index c5e0479c..fb2b4171 100644 --- a/lib/bluetooth-settings-row.h +++ b/lib/bluetooth-settings-row.h @@ -20,10 +20,11 @@ #pragma once +#include <adwaita.h> #include <gtk/gtk.h> #include "bluetooth-device.h" #define BLUETOOTH_TYPE_SETTINGS_ROW (bluetooth_settings_row_get_type()) -G_DECLARE_FINAL_TYPE (BluetoothSettingsRow, bluetooth_settings_row, BLUETOOTH, SETTINGS_ROW, GtkListBoxRow) +G_DECLARE_FINAL_TYPE (BluetoothSettingsRow, bluetooth_settings_row, BLUETOOTH, SETTINGS_ROW, AdwActionRow) GtkWidget *bluetooth_settings_row_new_from_device (BluetoothDevice *device); diff --git a/lib/bluetooth-settings-row.ui b/lib/bluetooth-settings-row.ui index 8bf62388..e5a9297d 100644 --- a/lib/bluetooth-settings-row.ui +++ b/lib/bluetooth-settings-row.ui @@ -1,39 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <template class="BluetoothSettingsRow" parent="GtkListBoxRow"> - <child> - <object class="GtkBox"> - <property name="margin_start">20</property> - <property name="margin_end">20</property> - <property name="margin_top">16</property> - <property name="margin_bottom">16</property> - <child> - <object class="GtkLabel" id="label"> - <property name="halign">start</property> - <property name="valign">center</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="label">Placeholder Name</property> - <property name="ellipsize">end</property> - <property name="xalign">0</property> - </object> - </child> - <child> - <object class="GtkSpinner" id="spinner"> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="margin_start">0</property> - <property name="margin_end">0</property> - </object> - </child> - <child> - <object class="GtkLabel" id="status"> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="vexpand">True</property> - <property name="label" translatable="yes">Not Set Up</property> - </object> - </child> + <template class="BluetoothSettingsRow" parent="AdwActionRow"> + <property name="activatable">True</property> + <child type="suffix"> + <object class="GtkSpinner" id="spinner"> + <property name="valign">center</property> + </object> + </child> + <child type="suffix"> + <object class="GtkLabel" id="status"> + <property name="valign">center</property> + <property name="vexpand">True</property> + <property name="label" translatable="yes">Not Set Up</property> </object> </child> </template> |