[gnome-control-center] network: Use AdwActionRow for NetDeviceBluetooth
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Use AdwActionRow for NetDeviceBluetooth
- Date: Fri, 4 Feb 2022 18:01:47 +0000 (UTC)
commit ffeec81f0e1df7651f34124e84539d1144eace18
Author: Christopher Davis <christopherdavis gnome org>
Date: Thu Jan 27 04:35:07 2022 -0800
network: Use AdwActionRow for NetDeviceBluetooth
Similar to the last commit, we can use a regular
GtkListBox and make the device widget an AdwActionRow.
panels/network/cc-network-panel.c | 11 ++-----
panels/network/cc-network-panel.ui | 10 ++++--
panels/network/net-device-bluetooth.c | 24 ++-------------
panels/network/net-device-bluetooth.h | 9 ++----
panels/network/network-bluetooth.ui | 57 ++++++++++++-----------------------
5 files changed, 33 insertions(+), 78 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index f7b019742..4bfc63a04 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -269,7 +269,7 @@ panel_refresh_device_titles (CcNetworkPanel *self)
titles = nm_device_disambiguate_names (nm_devices, num_devices);
for (i = 0; i < num_devices; i++) {
if (NM_IS_DEVICE_BT (nm_devices[i]))
- net_device_bluetooth_set_title (NET_DEVICE_BLUETOOTH (devices[i]),
nm_device_bt_get_name (NM_DEVICE_BT (nm_devices[i])));
+ adw_preferences_row_set_title (ADW_PREFERENCES_ROW (devices[i]),
nm_device_bt_get_name (NM_DEVICE_BT (nm_devices[i])));
else if (NET_IS_DEVICE_ETHERNET (devices[i]))
net_device_ethernet_set_title (NET_DEVICE_ETHERNET (devices[i]), titles[i]);
else if (NET_IS_DEVICE_MOBILE (devices[i]))
@@ -361,13 +361,6 @@ update_vpn_section (CcNetworkPanel *self)
static void
update_bluetooth_section (CcNetworkPanel *self)
{
- guint i;
-
- for (i = 0; i < self->bluetooth_devices->len; i++) {
- NetDeviceBluetooth *device = g_ptr_array_index (self->bluetooth_devices, i);
- net_device_bluetooth_set_show_separator (device, i > 0);
- }
-
gtk_widget_set_visible (self->container_bluetooth, self->bluetooth_devices->len > 0);
}
@@ -447,7 +440,7 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
break;
case NM_DEVICE_TYPE_BT:
device_bluetooth = net_device_bluetooth_new (self->client, device);
- gtk_box_append (GTK_BOX (self->box_bluetooth), GTK_WIDGET (device_bluetooth));
+ gtk_list_box_append (GTK_LIST_BOX (self->box_bluetooth), GTK_WIDGET (device_bluetooth));
g_ptr_array_add (self->bluetooth_devices, device_bluetooth);
g_hash_table_insert (self->nm_device_to_device, device, device_bluetooth);
diff --git a/panels/network/cc-network-panel.ui b/panels/network/cc-network-panel.ui
index 53d0215d8..e914f0a82 100644
--- a/panels/network/cc-network-panel.ui
+++ b/panels/network/cc-network-panel.ui
@@ -53,8 +53,14 @@
</object>
</child>
<child>
- <object class="GtkBox" id="box_bluetooth">
- <property name="orientation">vertical</property>
+ <object class="GtkListBox" id="box_bluetooth">
+ <property name="selection_mode">none</property>
+ <accessibility>
+ <property name="label" translatable="yes">Other Devices</property>
+ </accessibility>
+ <style>
+ <class name="boxed-list" />
+ </style>
</object>
</child>
</object>
diff --git a/panels/network/net-device-bluetooth.c b/panels/network/net-device-bluetooth.c
index 350d8b8f9..7dff45b29 100644
--- a/panels/network/net-device-bluetooth.c
+++ b/panels/network/net-device-bluetooth.c
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <glib/gi18n.h>
-#include <adwaita.h>
#include <NetworkManager.h>
@@ -34,27 +33,17 @@
struct _NetDeviceBluetooth
{
- GtkBox parent;
+ AdwActionRow parent;
- AdwActionRow *row;
GtkSwitch *device_off_switch;
GtkButton *options_button;
- GtkSeparator *separator;
NMClient *client;
NMDevice *device;
gboolean updating_device;
};
-G_DEFINE_TYPE (NetDeviceBluetooth, net_device_bluetooth, GTK_TYPE_BOX)
-
-void
-net_device_bluetooth_set_show_separator (NetDeviceBluetooth *self,
- gboolean show_separator)
-{
- /* add widgets to size group */
- gtk_widget_set_visible (GTK_WIDGET (self->separator), show_separator);
-}
+G_DEFINE_TYPE (NetDeviceBluetooth, net_device_bluetooth, ADW_TYPE_ACTION_ROW)
static void
update_off_switch_from_device_state (GtkSwitch *sw,
@@ -169,10 +158,8 @@ net_device_bluetooth_class_init (NetDeviceBluetoothClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/network/network-bluetooth.ui");
- gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, row);
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, device_off_switch);
gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, options_button);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceBluetooth, separator);
gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, options_button_clicked_cb);
@@ -212,10 +199,3 @@ net_device_bluetooth_get_device (NetDeviceBluetooth *self)
g_return_val_if_fail (NET_IS_DEVICE_BLUETOOTH (self), NULL);
return self->device;
}
-
-void
-net_device_bluetooth_set_title (NetDeviceBluetooth *self, const gchar *title)
-{
- g_return_if_fail (NET_IS_DEVICE_BLUETOOTH (self));
- adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self->row), title);
-}
diff --git a/panels/network/net-device-bluetooth.h b/panels/network/net-device-bluetooth.h
index d87752e82..b0ce5aeaf 100644
--- a/panels/network/net-device-bluetooth.h
+++ b/panels/network/net-device-bluetooth.h
@@ -22,22 +22,17 @@
#pragma once
+#include <adwaita.h>
#include <gtk/gtk.h>
#include <NetworkManager.h>
G_BEGIN_DECLS
-G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, GtkBox)
+G_DECLARE_FINAL_TYPE (NetDeviceBluetooth, net_device_bluetooth, NET, DEVICE_BLUETOOTH, AdwActionRow)
NetDeviceBluetooth *net_device_bluetooth_new (NMClient *client,
NMDevice *device);
NMDevice *net_device_bluetooth_get_device (NetDeviceBluetooth *device);
-void net_device_bluetooth_set_title (NetDeviceBluetooth *device,
- const gchar *title);
-
-void net_device_bluetooth_set_show_separator (NetDeviceBluetooth *device,
- gboolean show_separator);
-
G_END_DECLS
diff --git a/panels/network/network-bluetooth.ui b/panels/network/network-bluetooth.ui
index 216c95c8d..fe3f8c10f 100644
--- a/panels/network/network-bluetooth.ui
+++ b/panels/network/network-bluetooth.ui
@@ -1,45 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.0 -->
- <template class="NetDeviceBluetooth" parent="GtkBox">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkSeparator" id="separator">
- <property name="orientation">horizontal</property>
+ <template class="NetDeviceBluetooth" parent="AdwActionRow">
+ <property name="activatable_widget">device_off_switch</property>
+ <property name="title" translatable="yes">Wired</property>
+ <child type="suffix">
+ <object class="GtkSwitch" id="device_off_switch">
+ <property name="valign">center</property>
+ <signal name="notify::active" handler="device_off_switch_changed_cb" object="NetDeviceBluetooth"
swapped="yes"/>
+ <accessibility>
+ <property name="label" translatable="yes">Turn device off</property>
+ </accessibility>
</object>
</child>
- <child>
- <object class="GtkListBox">
- <property name="selection_mode">none</property>
- <child>
- <object class="AdwActionRow" id="row">
- <property name="activatable_widget">device_off_switch</property>
- <property name="title" translatable="yes">Wired</property>
- <child type="suffix">
- <object class="GtkSwitch" id="device_off_switch">
- <property name="valign">center</property>
- <signal name="notify::active" handler="device_off_switch_changed_cb"
object="NetDeviceBluetooth" swapped="yes"/>
- <accessibility>
- <property name="label" translatable="yes">Turn device off</property>
- </accessibility>
- </object>
- </child>
- <child type="suffix">
- <object class="GtkButton" id="options_button">
- <property name="valign">center</property>
- <property name="use_underline">True</property>
- <property name="icon_name">emblem-system-symbolic</property>
- <signal name="clicked" handler="options_button_clicked_cb" object="NetDeviceBluetooth"
swapped="yes"/>
- <accessibility>
- <property name="label" translatable="yes">Options…</property>
- </accessibility>
- </object>
- </child>
- </object>
- </child>
- <style>
- <class name="boxed-list"/>
- </style>
+ <child type="suffix">
+ <object class="GtkButton" id="options_button">
+ <property name="valign">center</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">emblem-system-symbolic</property>
+ <signal name="clicked" handler="options_button_clicked_cb" object="NetDeviceBluetooth"
swapped="yes"/>
+ <accessibility>
+ <property name="label" translatable="yes">Options…</property>
+ </accessibility>
</object>
</child>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]