[gnome-bluetooth/wip/cdavis/adw-consistency: 1/2] bluetooth-settings-row: Subclass AdwActionRow
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/cdavis/adw-consistency: 1/2] bluetooth-settings-row: Subclass AdwActionRow
- Date: Tue, 25 Jan 2022 04:23:30 +0000 (UTC)
commit cc1e9fb017d42c50acbd9f338fba93b34329f1d9
Author: Christopher Davis <christopherdavis gnome org>
Date: Mon Jan 24 19:33:06 2022 -0800
bluetooth-settings-row: Subclass AdwActionRow
Significantly reduces the side of the UI file
and gives us consistent margins and padding.
lib/bluetooth-settings-row.c | 11 +++++------
lib/bluetooth-settings-row.h | 3 ++-
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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]