[gnome-control-center/wip/gbsneto/new-network-panel: 8/8] network: Update "Wired" section UI
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-network-panel: 8/8] network: Update "Wired" section UI
- Date: Tue, 18 Jul 2017 15:04:26 +0000 (UTC)
commit 5f2c84f2d1c4577ef0acda79129e70e36233fdb0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jul 17 23:21:08 2017 -0300
network: Update "Wired" section UI
The current "Wired" section UI is still optimized for
the old, multi-page panel layout. Recent work [1],
however, suggest that this should change and the standard
widgets be rearranged.
This commit, then, implements this new UI for the wired
devices UI by using a listbox row when there's only one
profile (ditching out the old info labels), and moving
and deleting the bottom action buttons.
panels/network/net-device-ethernet.c | 66 +++------
panels/network/net-device-ethernet.h | 2 +-
panels/network/network-ethernet.ui | 270 ++++++++++-----------------------
3 files changed, 105 insertions(+), 233 deletions(-)
---
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index 7cc0e43..b7d75e8 100644
--- a/panels/network/net-device-ethernet.c
+++ b/panels/network/net-device-ethernet.c
@@ -209,16 +209,11 @@ device_ethernet_refresh_ui (NetDeviceEthernet *device)
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "label_device"));
gtk_label_set_label (GTK_LABEL (widget), net_object_get_title (NET_OBJECT (device)));
- widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "image_device"));
- gtk_image_set_from_icon_name (GTK_IMAGE (widget),
- panel_device_to_icon_name (nm_device, FALSE),
- GTK_ICON_SIZE_DIALOG);
-
widget = GTK_WIDGET (gtk_builder_get_object (device->builder, "device_off_switch"));
state = nm_device_get_state (nm_device);
- gtk_widget_set_visible (widget,
- state != NM_DEVICE_STATE_UNAVAILABLE
- && state != NM_DEVICE_STATE_UNMANAGED);
+ gtk_widget_set_sensitive (widget,
+ state != NM_DEVICE_STATE_UNAVAILABLE
+ && state != NM_DEVICE_STATE_UNMANAGED);
device->updating_device = TRUE;
gtk_switch_set_active (GTK_SWITCH (widget), device_state_to_off_switch (state));
device->updating_device = FALSE;
@@ -240,7 +235,7 @@ editor_done (NetConnectionEditor *editor,
}
static void
-show_details (GtkButton *button, NetDeviceEthernet *device, const gchar *title)
+show_details (GtkWidget *widget, NetDeviceEthernet *device, const gchar *title)
{
GtkWidget *row;
NMConnection *connection;
@@ -249,9 +244,13 @@ show_details (GtkButton *button, NetDeviceEthernet *device, const gchar *title)
NMClient *client;
NMDevice *nmdev;
- window = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ window = gtk_widget_get_toplevel (GTK_WIDGET (widget));
+
+ if (GTK_IS_LIST_BOX_ROW (widget))
+ row = widget;
+ else
+ row = g_object_get_data (G_OBJECT (widget), "row");
- row = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "row"));
connection = NM_CONNECTION (g_object_get_data (G_OBJECT (row), "connection"));
nmdev = net_device_get_nm_device (NET_DEVICE (device));
@@ -264,20 +263,20 @@ show_details (GtkButton *button, NetDeviceEthernet *device, const gchar *title)
}
static void
-show_details_for_row (GtkButton *button, NetDeviceEthernet *device)
+show_details_for_row (GtkWidget *widget, NetDeviceEthernet *device)
{
- show_details (button, device, NULL);
+ show_details (widget, device, NULL);
}
static void
-show_details_for_wired (GtkButton *button, NetDeviceEthernet *device)
+show_details_for_wired (GtkWidget *listbox, GtkWidget *row, NetDeviceEthernet *device)
{
/* Translators: This is used as the title of the connection
* details window for ethernet, if there is only a single
* profile. It is also used to display ethernet in the
* device list.
*/
- show_details (button, device, _("Wired"));
+ show_details (row, device, _("Wired"));
}
static void
@@ -347,7 +346,6 @@ add_row (NetDeviceEthernet *device, NMConnection *connection)
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
atk_object_set_name (gtk_widget_get_accessible (widget), _("Options…"));
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
- g_object_set_data (G_OBJECT (row), "edit", widget);
g_object_set_data (G_OBJECT (widget), "row", row);
g_signal_connect (widget, "clicked",
G_CALLBACK (show_details_for_row), device);
@@ -382,12 +380,6 @@ populate_ui (NetDeviceEthernet *device)
}
g_list_free (children);
- children = gtk_container_get_children (GTK_CONTAINER (device->details));
- for (c = children; c; c = c->next) {
- gtk_container_remove (GTK_CONTAINER (device->details), c->data);
- }
- g_list_free (children);
-
connections = net_device_get_valid_connections (NET_DEVICE (device));
for (l = connections; l; l = l->next) {
NMConnection *connection = l->data;
@@ -397,21 +389,8 @@ populate_ui (NetDeviceEthernet *device)
}
n_connections = g_slist_length (connections);
- if (n_connections > 4) {
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (device->scrolled_window),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_vexpand (device->scrolled_window, TRUE);
- } else {
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (device->scrolled_window),
- GTK_POLICY_NEVER,
- GTK_POLICY_NEVER);
- gtk_widget_set_vexpand (device->scrolled_window, FALSE);
- }
-
if (n_connections > 1) {
gtk_widget_hide (device->details);
- gtk_widget_hide (device->details_button);
for (l = connections; l; l = l->next) {
NMConnection *connection = l->data;
add_row (device, connection);
@@ -420,16 +399,12 @@ populate_ui (NetDeviceEthernet *device)
} else if (n_connections == 1) {
connection = connections->data;
gtk_widget_hide (device->scrolled_window);
- add_details (device->details, net_device_get_nm_device (NET_DEVICE (device)), connection);
gtk_widget_show_all (device->details);
- gtk_widget_show (device->details_button);
- g_object_set_data (G_OBJECT (device->details_button), "row", device->details_button);
- g_object_set_data (G_OBJECT (device->details_button), "connection", connection);
+ g_object_set_data (G_OBJECT (device->details_row), "connection", connection);
} else {
gtk_widget_hide (device->scrolled_window);
gtk_widget_hide (device->details);
- gtk_widget_hide (device->details_button);
}
g_slist_free (connections);
@@ -557,6 +532,13 @@ device_ethernet_constructed (GObject *object)
g_signal_connect (widget, "notify::active",
G_CALLBACK (device_off_toggled), device);
+ /* Single profile listbox */
+ device->details_row = GTK_WIDGET (gtk_builder_get_object (device->builder, "details_row"));
+ widget = GTK_WIDGET (gtk_builder_get_object (device->builder,
+ "single_profile_listbox"));
+ g_signal_connect (widget, "row-activated",
+ G_CALLBACK (show_details_for_wired), device);
+
device->scrolled_window = swin = GTK_WIDGET (gtk_builder_get_object (device->builder, "list"));
device->list = list = GTK_WIDGET (gtk_list_box_new ());
gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
@@ -568,10 +550,6 @@ device_ethernet_constructed (GObject *object)
device->details = GTK_WIDGET (gtk_builder_get_object (device->builder, "details"));
- device->details_button = GTK_WIDGET (gtk_builder_get_object (device->builder, "details_button"));
- g_signal_connect (device->details_button, "clicked",
- G_CALLBACK (show_details_for_wired), device);
-
device->add_profile_button = GTK_WIDGET (gtk_builder_get_object (device->builder,
"add_profile_button"));
g_signal_connect (device->add_profile_button, "clicked",
G_CALLBACK (add_profile), device);
diff --git a/panels/network/net-device-ethernet.h b/panels/network/net-device-ethernet.h
index 0d92fd1..7ff5733 100644
--- a/panels/network/net-device-ethernet.h
+++ b/panels/network/net-device-ethernet.h
@@ -48,7 +48,7 @@ struct _NetDeviceEthernet
GtkWidget *list;
GtkWidget *scrolled_window;
GtkWidget *details;
- GtkWidget *details_button;
+ GtkWidget *details_row;
GtkWidget *add_profile_button;
gboolean updating_device;
diff --git a/panels/network/network-ethernet.ui b/panels/network/network-ethernet.ui
index 062aa2f..e20dec3 100644
--- a/panels/network/network-ethernet.ui
+++ b/panels/network/network-ethernet.ui
@@ -1,219 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkImage" id="image1">
+ <object class="GtkBox" id="vbox6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">emblem-system-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- <object class="GtkVBox" id="vbox6">
+ <property name="spacing">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="actions">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">12</property>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkLabel" id="label_device">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkImage" id="image_device">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
- <property name="xalign">1</property>
- <property name="pixel_size">48</property>
- <property name="icon_name">network-wired</property>
- <property name="icon-size">6</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkLabel" id="label_device">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Wired</property>
- <property name="ellipsize">end</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.2"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_status">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label">Cable unplugged</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="list">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">12</property>
- <property name="hexpand">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">3</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="details">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">12</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="row_spacing">10</property>
- <property name="column_spacing">10</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- <property name="width">3</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <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" id="add_profile_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="relief">none</property>
<child>
- <object class="GtkSwitch" id="device_off_switch">
+ <object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
+ <property name="icon_name">list-add-symbolic</property>
</object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkBox" id="actions">
+ <object class="GtkScrolledWindow" id="list">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_top">12</property>
+ <property name="hexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ </object>
+ </child>
+
+ <!-- Single profile row -->
+ <child>
+ <object class="GtkFrame" id="details">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">18</property>
- <child>
- <object class="GtkButton" id="add_profile_button">
- <property name="label" translatable="yes">_Add Profile…</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="expand">True</property>
<child>
- <object class="GtkButton" id="details_button">
+ <object class="GtkListBox" id="single_profile_listbox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="halign">end</property>
- <property name="image">image1</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="details_button-accessible">
- <property name="accessible-name" translatable="yes">Options…</property>
+ <property name="can_focus">False</property>
+ <property name="selection_mode">none</property>
+ <child>
+ <object class="GtkListBoxRow" id="details_row">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin">12</property>
+ <child>
+ <object class="GtkLabel" id="label_status">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label">Cable unplugged</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="device_off_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
- <style>
- <class name="image-button"/>
- </style>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
+ </child>
+ </object>
<object class="GtkSizeGroup" id="sizegroup1"/>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]