[gnome-control-center/wip/gbsneto/new-network-panel: 32/34] network: Add header to VPN section



commit 03a82a54e7bbaecb321dcede994980492b11e7f1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jul 21 11:52:57 2017 -0300

    network: Add header to VPN section
    
    Since each VPN will be a row in a listbox, we
    can't rely on NetVPN:add_to_stack() to handle
    the header.
    
    This header must, then, be handled by the panel
    itself. For now, we just open the already available
    dialog to add connections, when the ideal approach
    (to be implemented yet) is to move the contents
    of this dialog in a built-in popover.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785581

 panels/network/cc-network-panel.c |   23 +++++++++++++++++++++++
 panels/network/network.ui         |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index db1841c..072c619 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -737,6 +737,27 @@ panel_check_network_manager_version (CcNetworkPanel *panel)
 }
 
 static void
+editor_done (NetConnectionEditor *editor,
+             gboolean             success,
+             gpointer             user_data)
+{
+        g_object_unref (editor);
+}
+
+static void
+create_connection_cb (GtkWidget      *button,
+                      CcNetworkPanel *self)
+{
+        NetConnectionEditor *editor;
+        GtkWindow *toplevel;
+
+        toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
+        editor = net_connection_editor_new (toplevel, NULL, NULL, NULL, self->client);
+        g_signal_connect (editor, "done", G_CALLBACK (editor_done), self);
+        net_connection_editor_run (editor);
+}
+
+static void
 on_toplevel_map (GtkWidget      *widget,
                  CcNetworkPanel *panel)
 {
@@ -768,6 +789,8 @@ cc_network_panel_class_init (CcNetworkPanelClass *klass)
         gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_vpn);
         gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, box_wired);
         gtk_widget_class_bind_template_child (widget_class, CcNetworkPanel, sizegroup);
+
+        gtk_widget_class_bind_template_callback (widget_class, create_connection_cb);
 }
 
 static void
diff --git a/panels/network/network.ui b/panels/network/network.ui
index 2f6071d..52691fa 100644
--- a/panels/network/network.ui
+++ b/panels/network/network.ui
@@ -62,6 +62,7 @@
                       <object class="GtkBox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="spacing">24</property>
                         <property name="orientation">vertical</property>
                         <child>
                           <object class="GtkBox" id="box_wired">
@@ -75,6 +76,41 @@
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="orientation">vertical</property>
+
+                            <!-- VPN header -->
+                            <child>
+                              <object class="GtkBox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <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="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="relief">none</property>
+                                    <signal name="clicked" handler="create_connection_cb" 
object="CcNetworkPanel" swapped="no" />
+                                    <child>
+                                      <object class="GtkImage">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="icon_name">list-add-symbolic</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                         <child>


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