[gnome-control-center] network: Use AdwPreferences{Page, Group} for network panel
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Use AdwPreferences{Page, Group} for network panel
- Date: Fri, 4 Feb 2022 18:01:47 +0000 (UTC)
commit 41cc6087215fb615026739d7ea51afeaf7377e54
Author: Christopher Davis <christopherdavis gnome org>
Date: Thu Jan 27 14:52:21 2022 -0800
network: Use AdwPreferences{Page,Group} for network panel
Uses AdwPreferences{Page,Group} where possible.
net-device-ethernet has been changed into an
AdwPreferencesGroup subclass itself.
panels/network/cc-network-panel.c | 2 +-
panels/network/cc-network-panel.ui | 196 +++++++++++++----------------------
panels/network/net-device-ethernet.c | 38 +++----
panels/network/net-device-ethernet.h | 6 +-
panels/network/network-ethernet.ui | 36 ++-----
5 files changed, 97 insertions(+), 181 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 4bfc63a04..aa271fd1e 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -271,7 +271,7 @@ panel_refresh_device_titles (CcNetworkPanel *self)
if (NM_IS_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]);
+ adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (devices[i]), titles[i]);
else if (NET_IS_DEVICE_MOBILE (devices[i]))
net_device_mobile_set_title (NET_DEVICE_MOBILE (devices[i]), titles[i]);
}
diff --git a/panels/network/cc-network-panel.ui b/panels/network/cc-network-panel.ui
index e914f0a82..2f2830442 100644
--- a/panels/network/cc-network-panel.ui
+++ b/panels/network/cc-network-panel.ui
@@ -3,136 +3,71 @@
<template class="CcNetworkPanel" parent="CcPanel">
<child type="content">
- <object class="GtkScrolledWindow">
- <property name="hscrollbar_policy">never</property>
+ <object class="AdwPreferencesPage">
+ <!-- Each group below will contain GtkStacks from the NetDevices -->
<child>
- <object class="GtkViewport">
+ <object class="AdwPreferencesGroup">
<child>
- <object class="AdwClamp">
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
+ <object class="GtkBox" id="box_wired">
+ <property name="orientation">vertical</property>
+ <property name="spacing">24</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup" id="container_bluetooth">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Other Devices</property>
+ <child>
+ <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>
+ </child>
+ <child>
+ <object class="AdwPreferencesGRoup">
+ <property name="title" translatable="yes">VPN</property>
+ <property name="header-suffix">
+ <object class="GtkButton">
+ <property name="icon_name">list-add-symbolic</property>
+ <style>
+ <class name="flat" />
+ </style>
+ <signal name="clicked" handler="create_connection_cb" object="CcNetworkPanel" swapped="no" />
+ </object>
+ </property>
+ <child>
+ <object class="GtkStack" id="vpn_stack">
<child>
- <object class="GtkBox">
- <property name="hexpand">True</property>
- <property name="spacing">12</property>
- <property name="orientation">vertical</property>
- <property name="valign">start</property>
-
- <!-- Each GtkBox below will contain GtkStacks from the NetDevices -->
+ <object class="GtkListBox" id="box_vpn">
+ <property name="selection_mode">none</property>
+ <accessibility>
+ <property name="label" translatable="yes">VPN</property>
+ </accessibility>
+ <style>
+ <class name="boxed-list" />
+ </style>
+ </object>
+ </child>
+ <child>
+ <!-- "Not set up" row -->
+ <object class="GtkListBox" id="empty_listbox">
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="boxed-list" />
+ </style>
<child>
- <object class="GtkBox">
- <property name="spacing">24</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox" id="box_wired">
- <property name="orientation">vertical</property>
- <property name="spacing">24</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="container_bluetooth">
- <property name="visible">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
-
- <!-- "Other Devices" header -->
- <child>
- <object class="GtkBox">
- <child>
- <object class="GtkLabel">
- <property name="hexpand">True</property>
- <property name="xalign">0.0</property>
- <property name="label" translatable="yes">Other Devices</property>
- <attributes>
- <attribute name="weight" value="bold" />
- </attributes>
- </object>
- </child>
- </object>
- </child>
- <child>
- <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>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
-
- <!-- VPN header -->
- <child>
- <object class="GtkBox">
- <child>
- <object class="GtkLabel">
- <property name="hexpand">True</property>
- <property name="xalign">0.0</property>
- <property name="label" translatable="yes">VPN</property>
- <attributes>
- <attribute name="weight" value="bold" />
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="icon_name">list-add-symbolic</property>
- <style>
- <class name="flat" />
- </style>
- <signal name="clicked" handler="create_connection_cb"
object="CcNetworkPanel" swapped="no" />
- </object>
- </child>
- </object>
- </child>
-
- <child>
- <object class="GtkStack" id="vpn_stack">
- <child>
- <object class="GtkListBox" id="box_vpn">
- <property name="selection_mode">none</property>
- <accessibility>
- <property name="label" translatable="yes">VPN</property>
- </accessibility>
- <style>
- <class name="boxed-list" />
- </style>
- </object>
- </child>
- <child>
- <!-- "Not set up" row -->
- <object class="GtkListBox" id="empty_listbox">
- <property name="selection_mode">none</property>
- <style>
- <class name="boxed-list" />
- </style>
- <child>
- <object class="AdwActionRow">
- <property name="activatable">False</property>
- <property name="title" translatable="yes">Not set up</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
-
- </object>
- </child>
- <child>
- <object class="GtkBox" id="box_proxy">
- <property name="orientation">vertical</property>
- </object>
- </child>
+ <object class="AdwActionRow">
+ <property name="activatable">False</property>
+ <property name="title" translatable="yes">Not set up</property>
</object>
</child>
</object>
@@ -141,6 +76,15 @@
</child>
</object>
</child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="GtkBox" id="box_proxy">
+ <property name="orientation">vertical</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index e6b0d0ae7..ead711cf1 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -23,7 +23,6 @@
#include <glib-object.h>
#include <glib/gi18n.h>
-#include <adwaita.h>
#include <NetworkManager.h>
#include "panel-common.h"
@@ -35,23 +34,22 @@
struct _NetDeviceEthernet
{
- GtkBox parent;
-
- GtkListBox *connection_list;
- GtkStack *connection_stack;
- GtkButton *details_button;
- GtkListBox *details_listbox;
- AdwActionRow *details_row;
- GtkLabel *device_label;
- GtkSwitch *device_off_switch;
-
- NMClient *client;
- NMDevice *device;
- gboolean updating_device;
- GHashTable *connections;
+ AdwPreferencesGroup parent;
+
+ GtkListBox *connection_list;
+ GtkStack *connection_stack;
+ GtkButton *details_button;
+ GtkListBox *details_listbox;
+ AdwActionRow *details_row;
+ GtkSwitch *device_off_switch;
+
+ NMClient *client;
+ NMDevice *device;
+ gboolean updating_device;
+ GHashTable *connections;
};
-G_DEFINE_TYPE (NetDeviceEthernet, net_device_ethernet, GTK_TYPE_BOX)
+G_DEFINE_TYPE (NetDeviceEthernet, net_device_ethernet, ADW_TYPE_PREFERENCES_GROUP)
static void
add_details_row (GtkWidget *details, gint top, const gchar *heading, const gchar *value)
@@ -491,7 +489,6 @@ net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_button);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_listbox);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, details_row);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_label);
gtk_widget_class_bind_template_child (widget_class, NetDeviceEthernet, device_off_switch);
gtk_widget_class_bind_template_callback (widget_class, connection_list_row_activated_cb);
@@ -535,10 +532,3 @@ net_device_ethernet_get_device (NetDeviceEthernet *self)
g_return_val_if_fail (NET_IS_DEVICE_ETHERNET (self), NULL);
return self->device;
}
-
-void
-net_device_ethernet_set_title (NetDeviceEthernet *self, const gchar *title)
-{
- g_return_if_fail (NET_IS_DEVICE_ETHERNET (self));
- gtk_label_set_label (self->device_label, title);
-}
diff --git a/panels/network/net-device-ethernet.h b/panels/network/net-device-ethernet.h
index e05358859..8a6acb8fd 100644
--- a/panels/network/net-device-ethernet.h
+++ b/panels/network/net-device-ethernet.h
@@ -21,19 +21,17 @@
#pragma once
+#include <adwaita.h>
#include <gtk/gtk.h>
#include <NetworkManager.h>
G_BEGIN_DECLS
-G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, GtkBox)
+G_DECLARE_FINAL_TYPE (NetDeviceEthernet, net_device_ethernet, NET, DEVICE_ETHERNET, AdwPreferencesGroup)
NetDeviceEthernet *net_device_ethernet_new (NMClient *client,
NMDevice *device);
NMDevice *net_device_ethernet_get_device (NetDeviceEthernet *device);
-void net_device_ethernet_set_title (NetDeviceEthernet *device,
- const gchar *title);
-
G_END_DECLS
diff --git a/panels/network/network-ethernet.ui b/panels/network/network-ethernet.ui
index 89bbe91af..a716fe0b5 100644
--- a/panels/network/network-ethernet.ui
+++ b/panels/network/network-ethernet.ui
@@ -1,33 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <template class="NetDeviceEthernet" parent="GtkBox">
- <property name="spacing">6</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkBox">
- <child>
- <object class="GtkLabel" id="device_label">
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Wired</property>
- <property name="ellipsize">end</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="icon_name">list-add-symbolic</property>
- <signal name="clicked" handler="add_profile_button_clicked_cb" object="NetDeviceEthernet"
swapped="yes"/>
- <style>
- <class name="flat" />
- </style>
- </object>
- </child>
+ <template class="NetDeviceEthernet" parent="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Wired</property>
+ <property name="header-suffix">
+ <object class="GtkButton">
+ <property name="icon_name">list-add-symbolic</property>
+ <signal name="clicked" handler="add_profile_button_clicked_cb" object="NetDeviceEthernet"
swapped="yes"/>
+ <style>
+ <class name="flat" />
+ </style>
</object>
- </child>
+ </property>
<child>
<object class="GtkStack" id="connection_stack">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]