[gnome-control-center/wip/gbsneto/connection-editor: 1/8] network: Rely on notebook tabs to switch connection editor pages



commit ffdbbc5b0b987c973dc0335d458be419edc0e0e4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun May 21 13:13:06 2017 -0300

    network: Rely on notebook tabs to switch connection editor pages
    
    Instead of using a sidebar, which is what the current implementation
    uses to switch pages, the latest mockups [1] rely on the notebook
    tabs.
    
    This patch then updates the connection editor dialog to use the
    notebook tabs as the page switcher widget.
    
    [1] 
https://github.com/gnome-design-team/gnome-mockups/blob/master/system-settings/network/aday2/network-wires.png
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779841

 .../network/connection-editor/connection-editor.ui |   62 +-------------------
 .../connection-editor/net-connection-editor.c      |   47 ++-------------
 2 files changed, 9 insertions(+), 100 deletions(-)
---
diff --git a/panels/network/connection-editor/connection-editor.ui 
b/panels/network/connection-editor/connection-editor.ui
index 4629461..6e3e1f7 100644
--- a/panels/network/connection-editor/connection-editor.ui
+++ b/panels/network/connection-editor/connection-editor.ui
@@ -3,7 +3,7 @@
   <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkDialog" id="details_dialog">
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
+    <property name="border_width">0</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="default_width">600</property>
@@ -33,7 +33,8 @@
       <object class="GtkBox" id="dialog-vbox">
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
+        <property name="spacing">0</property>
+        <property name="border_width">0</property>
         <child>
           <object class="GtkNotebook" id="details_toplevel_notebook">
             <property name="visible">True</property>
@@ -45,60 +46,11 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkScrolledWindow" id="details_sidebar">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">never</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <object class="GtkTreeView" id="details_page_list">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="model">details_store</property>
-                        <property name="headers_visible">False</property>
-                        <property name="headers_clickable">False</property>
-                        <property name="enable-search">False</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="details_page_list_selection"/>
-                        </child>
-                        <child>
-                          <object class="GtkTreeViewColumn" id="details_column">
-                            <child>
-                              <object class="GtkCellRendererText" id="details_cell">
-                                <property name="xpad">10</property>
-                              </object>
-                              <attributes>
-                                <attribute name="text">0</attribute>
-                              </attributes>
-                            </child>
-                            <child>
-                              <object class="GtkCellRendererText" id="padding_cell">
-                                <property name="xpad">20</property>
-                              </object>
-                            </child>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
                   <object class="GtkNotebook" id="details_notebook">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="show_tabs">False</property>
                     <property name="show_border">False</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
                 </child>
               </object>
             </child>
@@ -175,12 +127,4 @@
       <action-widget response="apply" default="true">details_apply_button</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkListStore" id="details_store">
-    <columns>
-      <!-- column-name name -->
-      <column type="gchararray"/>
-      <!-- column-name page -->
-      <column type="gint"/>
-    </columns>
-  </object>
 </interface>
diff --git a/panels/network/connection-editor/net-connection-editor.c 
b/panels/network/connection-editor/net-connection-editor.c
index 7d7f1ca..203644b 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -53,23 +53,6 @@ G_DEFINE_TYPE (NetConnectionEditor, net_connection_editor, G_TYPE_OBJECT)
 static void page_changed (CEPage *page, gpointer user_data);
 
 static void
-selection_changed (GtkTreeSelection *selection, NetConnectionEditor *editor)
-{
-        GtkWidget *widget;
-        GtkTreeModel *model;
-        GtkTreeIter iter;
-        gint page;
-
-        if (!gtk_tree_selection_get_selected (selection, &model, &iter))
-                return;
-        gtk_tree_model_get (model, &iter, 1, &page, -1);
-
-        widget = GTK_WIDGET (gtk_builder_get_object (editor->builder,
-                                                     "details_notebook"));
-        gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), page);
-}
-
-static void
 cancel_editing (NetConnectionEditor *editor)
 {
         gtk_widget_hide (editor->window);
@@ -164,7 +147,6 @@ static void
 net_connection_editor_init (NetConnectionEditor *editor)
 {
         GError *error = NULL;
-        GtkTreeSelection *selection;
 
         editor->builder = gtk_builder_new ();
 
@@ -178,10 +160,6 @@ net_connection_editor_init (NetConnectionEditor *editor)
         }
 
         editor->window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_dialog"));
-        selection = GTK_TREE_SELECTION (gtk_builder_get_object (editor->builder,
-                                                                "details_page_list_selection"));
-        g_signal_connect (selection, "changed",
-                          G_CALLBACK (selection_changed), editor);
 }
 
 void
@@ -431,6 +409,7 @@ page_initialized (CEPage *page, GError *error, NetConnectionEditor *editor)
 {
         GtkNotebook *notebook;
         GtkWidget *widget;
+        GtkWidget *label;
         gint position;
         GList *children, *l;
         gint i;
@@ -446,7 +425,10 @@ page_initialized (CEPage *page, GError *error, NetConnectionEditor *editor)
                         break;
         }
         g_list_free (children);
-        gtk_notebook_insert_page (notebook, widget, NULL, i);
+
+        label = gtk_label_new (ce_page_get_title (page));
+
+        gtk_notebook_insert_page (notebook, widget, label, i);
 
         editor->initializing_pages = g_slist_remove (editor->initializing_pages, page);
         editor->pages = g_slist_append (editor->pages, page);
@@ -506,20 +488,11 @@ get_secrets_for_page (NetConnectionEditor *editor,
 static void
 add_page (NetConnectionEditor *editor, CEPage *page)
 {
-        GtkListStore *store;
-        GtkTreeIter iter;
-        const gchar *title;
         gint position;
 
-        store = GTK_LIST_STORE (gtk_builder_get_object (editor->builder,
-                                                "details_store"));
-        title = ce_page_get_title (page);
         position = g_slist_length (editor->initializing_pages);
         g_object_set_data (G_OBJECT (page), "position", GINT_TO_POINTER (position));
-        gtk_list_store_insert_with_values (store, &iter, -1,
-                                           0, title,
-                                           1, position,
-                                           -1);
+
         editor->initializing_pages = g_slist_append (editor->initializing_pages, page);
 
         g_signal_connect (page, "changed", G_CALLBACK (page_changed), editor);
@@ -533,8 +506,6 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
         GSList *pages, *l;
         NMSettingConnection *sc;
         const gchar *type;
-        GtkTreeSelection *selection;
-        GtkTreePath *path;
 
         editor->is_new_connection = !nm_client_get_connection_by_uuid (editor->client,
                                                                        nm_connection_get_uuid (connection));
@@ -596,12 +567,6 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
                 }
         }
         g_slist_free (pages);
-
-        selection = GTK_TREE_SELECTION (gtk_builder_get_object (editor->builder,
-                                                                "details_page_list_selection"));
-        path = gtk_tree_path_new_first ();
-        gtk_tree_selection_select_path (selection, path);
-        gtk_tree_path_free (path);
 }
 
 static NMConnection *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]