[gnome-control-center/wip/gbsneto/new-network-panel: 20/26] network: Update "Wired" section UI



commit bb7f643cc3517793c45068669c1bb2620374d1a4
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 |   37 +----
 panels/network/network-ethernet.ui   |  291 ++++++++++++----------------------
 2 files changed, 108 insertions(+), 220 deletions(-)
---
diff --git a/panels/network/net-device-ethernet.c b/panels/network/net-device-ethernet.c
index 7cc0e43..86689b2 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;
@@ -251,7 +246,7 @@ show_details (GtkButton *button, NetDeviceEthernet *device, const gchar *title)
 
         window = gtk_widget_get_toplevel (GTK_WIDGET (button));
 
-        row = GTK_WIDGET (g_object_get_data (G_OBJECT (button), "row"));
+        row = 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));
@@ -347,7 +342,7 @@ 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), "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 +377,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 +386,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 +396,13 @@ 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);
 
         } else {
                 gtk_widget_hide (device->scrolled_window);
                 gtk_widget_hide (device->details);
-                gtk_widget_hide (device->details_button);
         }
 
         g_slist_free (connections);
diff --git a/panels/network/network-ethernet.ui b/panels/network/network-ethernet.ui
index 062aa2f..2971e24 100644
--- a/panels/network/network-ethernet.ui
+++ b/panels/network/network-ethernet.ui
@@ -1,219 +1,134 @@
 <?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="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="spacing">12</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>
+                        <child>
+                          <object class="GtkButton" id="details_button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="halign">end</property>
+                            <child>
+                              <object class="GtkImage">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="icon-name">emblem-system-symbolic</property>
+                              </object>
+                            </child>
+
+                            <child internal-child="accessible">
+                              <object class="AtkObject" id="details_button-accessible">
+                                <property name="accessible-name" translatable="yes">Options…</property>
+                              </object>
+                           </child>
+                         </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]