[gnome-control-center/wip/benzea/wifi-panel-with-editor-changes: 10/19] connection-editor: Add the Edit page
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/benzea/wifi-panel-with-editor-changes: 10/19] connection-editor: Add the Edit page
- Date: Thu, 13 Dec 2018 17:10:07 +0000 (UTC)
commit 8a419afa13e43a66ab84f38e52a1bce77f65f28f
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Dec 3 09:11:44 2018 +0100
connection-editor: Add the Edit page
Add the Edit page containing the inputs from the Details page.
panels/network/connection-editor/ce-page-edit.c | 181 +++++++++++++++++
panels/network/connection-editor/ce-page-edit.h | 66 ++++++
.../connection-editor.gresource.xml | 1 +
panels/network/connection-editor/edit-page.ui | 222 +++++++++++++++++++++
panels/network/connection-editor/meson.build | 2 +
.../connection-editor/net-connection-editor.c | 4 +
po/POTFILES.in | 2 +
7 files changed, 478 insertions(+)
---
diff --git a/panels/network/connection-editor/ce-page-edit.c b/panels/network/connection-editor/ce-page-edit.c
new file mode 100644
index 000000000..f01ccfcd8
--- /dev/null
+++ b/panels/network/connection-editor/ce-page-edit.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more edit.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include <NetworkManager.h>
+
+#include "../panel-common.h"
+#include "ce-page-edit.h"
+#include "list-box-helper.h"
+
+G_DEFINE_TYPE (CEPageEdit, ce_page_edit, CE_TYPE_PAGE)
+
+static void
+forget_cb (GtkButton *button, CEPageEdit *page)
+{
+ net_connection_editor_forget (page->editor);
+}
+
+static void
+all_user_changed (GtkSwitch *s, GParamSpec *pspec, CEPageEdit *page)
+{
+ gboolean all_users;
+ NMSettingConnection *sc;
+
+ sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
+ all_users = gtk_switch_get_active (s);
+
+ g_object_set (sc, "permissions", NULL, NULL);
+ if (!all_users)
+ nm_setting_connection_add_permission (sc, "user", g_get_user_name (), NULL);
+}
+
+static void
+restrict_data_changed (GtkSwitch *s, GParamSpec *pspec, CEPageEdit *page)
+{
+ NMSettingConnection *s_con;
+ NMMetered metered;
+
+ s_con = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
+
+ if (gtk_switch_get_active (s))
+ metered = NM_METERED_YES;
+ else
+ metered = NM_METERED_NO;
+
+ g_object_set (s_con, "metered", metered, NULL);
+}
+
+static void
+update_restrict_data (CEPageEdit *page)
+{
+ NMSettingConnection *s_con;
+ NMMetered metered;
+ GtkWidget *widget;
+ const gchar *type;
+
+ s_con = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
+
+ if (s_con == NULL)
+ return;
+
+ /* Disable for VPN; NetworkManager does not implement that yet (see
+ * bug https://bugzilla.gnome.org/show_bug.cgi?id=792618) */
+ type = nm_setting_connection_get_connection_type (s_con);
+ if (g_str_equal (type, NM_SETTING_VPN_SETTING_NAME))
+ return;
+
+ metered = nm_setting_connection_get_metered (s_con);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "restrict_data_switch"));
+ gtk_switch_set_active (GTK_SWITCH (widget),
+ metered == NM_METERED_YES || metered == NM_METERED_GUESS_YES);
+ gtk_widget_show (widget);
+
+ g_signal_connect (widget, "notify::active", G_CALLBACK (restrict_data_changed), page);
+ g_signal_connect_swapped (widget, "notify::active", G_CALLBACK (ce_page_changed), page);
+}
+
+static void
+connect_edit_page (CEPageEdit *page)
+{
+ NMSettingConnection *sc;
+ GtkWidget *widget;
+ const gchar *type;
+
+ sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
+ type = nm_setting_connection_get_connection_type (sc);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
+ "list_box"));
+ gtk_list_box_set_header_func (GTK_LIST_BOX (widget), cc_list_box_update_header_func, NULL, NULL);
+
+ /* Auto connect check */
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
+ "auto_connect_switch"));
+ if (g_str_equal (type, NM_SETTING_VPN_SETTING_NAME)) {
+ gtk_widget_hide (widget);
+ } else {
+ g_object_bind_property (sc, "autoconnect",
+ widget, "active",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ g_signal_connect_swapped (widget, "notify::active", G_CALLBACK (ce_page_changed), page);
+ }
+
+ /* All users check */
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder,
+ "all_user_switch"));
+ gtk_switch_set_active (GTK_SWITCH (widget),
+ nm_setting_connection_get_num_permissions (sc) == 0);
+ g_signal_connect (widget, "notify::active",
+ G_CALLBACK (all_user_changed), page);
+ g_signal_connect_swapped (widget, "notify::active", G_CALLBACK (ce_page_changed), page);
+
+ /* Restrict Data check */
+ update_restrict_data (page);
+
+ /* Forget button */
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "button_forget"));
+ g_signal_connect (widget, "clicked", G_CALLBACK (forget_cb), page);
+
+ if (g_str_equal (type, NM_SETTING_WIRELESS_SETTING_NAME))
+ gtk_button_set_label (GTK_BUTTON (widget), _("Forget Connection"));
+ else if (g_str_equal (type, NM_SETTING_WIRED_SETTING_NAME))
+ gtk_button_set_label (GTK_BUTTON (widget), _("Remove Connection Profile"));
+ else if (g_str_equal (type, NM_SETTING_VPN_SETTING_NAME))
+ gtk_button_set_label (GTK_BUTTON (widget), _("Remove VPN"));
+ else
+ gtk_widget_hide (widget);
+}
+
+static void
+ce_page_edit_init (CEPageEdit *page)
+{
+}
+
+static void
+ce_page_edit_class_init (CEPageEditClass *class)
+{
+}
+
+CEPage *
+ce_page_edit_new (NMConnection *connection,
+ NMClient *client,
+ NetConnectionEditor *editor)
+{
+ CEPageEdit *page;
+
+ page = CE_PAGE_EDIT (ce_page_new (CE_TYPE_PAGE_EDIT,
+ connection,
+ client,
+ "/org/gnome/control-center/network/edit-page.ui",
+ _("Edit")));
+
+ page->editor = editor;
+
+ connect_edit_page (page);
+
+ return CE_PAGE (page);
+}
diff --git a/panels/network/connection-editor/ce-page-edit.h b/panels/network/connection-editor/ce-page-edit.h
new file mode 100644
index 000000000..c02652721
--- /dev/null
+++ b/panels/network/connection-editor/ce-page-edit.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CE_PAGE_EDIT_H
+#define __CE_PAGE_EDIT_H
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+#include "net-connection-editor.h"
+#include "ce-page.h"
+
+G_BEGIN_DECLS
+
+#define CE_TYPE_PAGE_EDIT (ce_page_edit_get_type ())
+#define CE_PAGE_EDIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CE_TYPE_PAGE_EDIT, CEPageEdit))
+#define CE_PAGE_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CE_TYPE_PAGE_EDIT, CEPageEditClass))
+#define CE_IS_PAGE_EDIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CE_TYPE_PAGE_EDIT))
+#define CE_IS_PAGE_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CE_TYPE_PAGE_EDIT))
+#define CE_PAGE_EDIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CE_TYPE_PAGE_EDIT, CEPageEditClass))
+
+typedef struct _CEPageEdit CEPageEdit;
+typedef struct _CEPageEditClass CEPageEditClass;
+
+struct _CEPageEdit
+{
+ CEPage parent;
+
+ NMDevice *device;
+ NMAccessPoint *ap;
+ NetConnectionEditor *editor;
+};
+
+struct _CEPageEditClass
+{
+ CEPageClass parent_class;
+};
+
+GType ce_page_edit_get_type (void);
+
+CEPage *ce_page_edit_new (NMConnection *connection,
+ NMClient *client,
+ NetConnectionEditor *editor);
+
+G_END_DECLS
+
+#endif /* __CE_PAGE_EDIT_H */
+
diff --git a/panels/network/connection-editor/connection-editor.gresource.xml
b/panels/network/connection-editor/connection-editor.gresource.xml
index 3d06f5a77..2504afa9f 100644
--- a/panels/network/connection-editor/connection-editor.gresource.xml
+++ b/panels/network/connection-editor/connection-editor.gresource.xml
@@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">8021x-security-page.ui</file>
<file preprocess="xml-stripblanks">connection-editor.ui</file>
<file preprocess="xml-stripblanks">details-page.ui</file>
+ <file preprocess="xml-stripblanks">edit-page.ui</file>
<file preprocess="xml-stripblanks">ethernet-page.ui</file>
<file preprocess="xml-stripblanks">ip4-page.ui</file>
<file preprocess="xml-stripblanks">ip6-page.ui</file>
diff --git a/panels/network/connection-editor/edit-page.ui b/panels/network/connection-editor/edit-page.ui
new file mode 100644
index 000000000..31b412963
--- /dev/null
+++ b/panels/network/connection-editor/edit-page.ui
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkBox" id="page">
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="view" />
+ </style>
+ <child>
+ <object class="GtkListBox" id="list_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="selection_mode">none</property>
+ <property name="activate_on_single_click">False</property>
+ <signal name="keynav-failed" handler="keynav_failed" object="CcNotificationsPanel" swapped="yes"
/>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activatable">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="height_request">32</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="ellipsize">end</property>
+ <property name="label" translatable="yes">Connect _automatically</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">auto_connect_switch</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="auto_connect_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin_end">12</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activatable">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="height_request">32</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="ellipsize">end</property>
+ <property name="label" translatable="yes">Make available to _other users</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">all_user_switch</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="all_user_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin_end">12</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activatable">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox">
+ <property name="height_request">32</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin_start">12</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <property name="valign">center</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="ellipsize">end</property>
+ <property name="label" translatable="yes">Restrict background data
usage</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">restrict_data_switch</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="ellipsize">end</property>
+ <property name="label" translatable="yes">Appropriate for connections that have
data charges or limits.</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">restrict_data_switch</property>
+ <style>
+ <class name="dim-label" />
+ </style>
+ <attributes>
+ <attribute name="scale" value="0.8" />
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="restrict_data_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin_end">12</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_forget">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="use_underline">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="halign">end</property>
+ <property name="valign">end</property>
+ <style>
+ <class name="destructive-action" />
+ </style>
+ </object>
+ </child>
+ </object>
+</interface>
+
+
diff --git a/panels/network/connection-editor/meson.build b/panels/network/connection-editor/meson.build
index 9ba9b3784..7834f111d 100644
--- a/panels/network/connection-editor/meson.build
+++ b/panels/network/connection-editor/meson.build
@@ -3,6 +3,7 @@ name = 'connection-editor'
sources = files(
'ce-page-8021x-security.c',
'ce-page-details.c',
+ 'ce-page-edit.c',
'ce-page-ethernet.c',
'ce-page-ip4.c',
'ce-page-ip6.c',
@@ -19,6 +20,7 @@ resource_data = files(
'8021x-security-page.ui',
'connection-editor.ui',
'details-page.ui',
+ 'edit-page.ui',
'ethernet-page.ui',
'ip4-page.ui',
'ip6-page.ui',
diff --git a/panels/network/connection-editor/net-connection-editor.c
b/panels/network/connection-editor/net-connection-editor.c
index 06fbd488c..37964e7d9 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -30,6 +30,7 @@
#include "net-connection-editor.h"
#include "net-connection-editor-resources.h"
#include "ce-page-details.h"
+#include "ce-page-edit.h"
#include "ce-page-wifi.h"
#include "ce-page-ip4.h"
#include "ce-page-ip6.h"
@@ -622,6 +623,9 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
else if (is_wired)
add_titled_page (editor, ce_page_8021x_security_new (editor->connection, editor->client));
+ if (!editor->is_new_connection)
+ add_page (editor, ce_page_edit_new (editor->connection, editor->client, editor));
+
if (!editor->is_new_connection)
add_advanced_page (editor, ce_page_details_new (editor->connection, editor->client,
editor->device, editor->ap, editor));
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a49a7a0a7..60f885df8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -69,6 +69,7 @@ panels/network/connection-editor/8021x-security-page.ui
panels/network/connection-editor/ce-page-8021x-security.c
panels/network/connection-editor/ce-page.c
panels/network/connection-editor/ce-page-details.c
+panels/network/connection-editor/ce-page-edit.c
panels/network/connection-editor/ce-page-ethernet.c
panels/network/connection-editor/ce-page-ip4.c
panels/network/connection-editor/ce-page-ip6.c
@@ -77,6 +78,7 @@ panels/network/connection-editor/ce-page-vpn.c
panels/network/connection-editor/ce-page-wifi.c
panels/network/connection-editor/connection-editor.ui
panels/network/connection-editor/details-page.ui
+panels/network/connection-editor/edit-page.ui
panels/network/connection-editor/ethernet-page.ui
panels/network/connection-editor/ip4-page.ui
panels/network/connection-editor/ip6-page.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]