[gnome-control-center/wip/networking2: 65/101] network: Implement 'Forget' in the connection-editor
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/networking2: 65/101] network: Implement 'Forget' in the connection-editor
- Date: Wed, 23 Jan 2013 19:38:30 +0000 (UTC)
commit 3f57e92adcd7e550bf54ccfa3c379b6457ba1f4f
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 14 20:37:13 2012 -0500
network: Implement 'Forget' in the connection-editor
panels/network/connection-editor/ce-page-reset.c | 30 +++++++++++++++++--
panels/network/connection-editor/ce-page-reset.h | 10 ++++--
.../connection-editor/net-connection-editor.c | 29 ++++++++++++++++++-
.../connection-editor/net-connection-editor.h | 3 +-
4 files changed, 62 insertions(+), 10 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-reset.c b/panels/network/connection-editor/ce-page-reset.c
index 6112024..575b781 100644
--- a/panels/network/connection-editor/ce-page-reset.c
+++ b/panels/network/connection-editor/ce-page-reset.c
@@ -24,14 +24,34 @@
#include <glib-object.h>
#include <glib/gi18n.h>
+#include "net-connection-editor.h"
#include "ce-page-reset.h"
G_DEFINE_TYPE (CEPageReset, ce_page_reset, CE_TYPE_PAGE)
+
+static void
+forget_cb (GtkButton *button, CEPageReset *page)
+{
+ net_connection_editor_forget (page->editor);
+}
+
+static void
+reset_cb (GtkButton *button, CEPageReset *page)
+{
+ g_print ("Reset is not implemented yet\n");
+}
+
static void
connect_reset_page (CEPageReset *page)
{
- /* FIXME */
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "button_forget"));
+ g_signal_connect (widget, "clicked", G_CALLBACK (forget_cb), page);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "button_reset"));
+ g_signal_connect (widget, "clicked", G_CALLBACK (reset_cb), page);
}
static gboolean
@@ -56,9 +76,10 @@ ce_page_reset_class_init (CEPageResetClass *class)
}
CEPage *
-ce_page_reset_new (NMConnection *connection,
- NMClient *client,
- NMRemoteSettings *settings)
+ce_page_reset_new (NMConnection *connection,
+ NMClient *client,
+ NMRemoteSettings *settings,
+ NetConnectionEditor *editor)
{
CEPageReset *page;
@@ -68,6 +89,7 @@ ce_page_reset_new (NMConnection *connection,
settings,
"/org/gnome/control-center/network/reset-page.ui",
_("Reset")));
+ page->editor = editor;
connect_reset_page (page);
diff --git a/panels/network/connection-editor/ce-page-reset.h b/panels/network/connection-editor/ce-page-reset.h
index 3e9582a..be221c7 100644
--- a/panels/network/connection-editor/ce-page-reset.h
+++ b/panels/network/connection-editor/ce-page-reset.h
@@ -25,6 +25,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#include "net-connection-editor.h"
#include "ce-page.h"
G_BEGIN_DECLS
@@ -42,6 +43,8 @@ typedef struct _CEPageResetClass CEPageResetClass;
struct _CEPageReset
{
CEPage parent;
+
+ NetConnectionEditor *editor;
};
struct _CEPageResetClass
@@ -51,9 +54,10 @@ struct _CEPageResetClass
GType ce_page_reset_get_type (void);
-CEPage *ce_page_reset_new (NMConnection *connection,
- NMClient *client,
- NMRemoteSettings *settings);
+CEPage *ce_page_reset_new (NMConnection *connection,
+ NMClient *client,
+ NMRemoteSettings *settings,
+ NetConnectionEditor *editor);
G_END_DECLS
diff --git a/panels/network/connection-editor/net-connection-editor.c b/panels/network/connection-editor/net-connection-editor.c
index 5faafb0..e334d99 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -354,7 +354,7 @@ add_page (NetConnectionEditor *editor, CEPage *page)
static void
net_connection_editor_set_connection (NetConnectionEditor *editor,
- NMConnection *connection)
+ NMConnection *connection)
{
GSList *pages, *l;
@@ -368,7 +368,7 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
add_page (editor, ce_page_ip4_new (editor->connection, editor->client, editor->settings));
add_page (editor, ce_page_ip6_new (editor->connection, editor->client, editor->settings));
add_page (editor, ce_page_security_new (editor->connection, editor->client, editor->settings));
- add_page (editor, ce_page_reset_new (editor->connection, editor->client, editor->settings));
+ add_page (editor, ce_page_reset_new (editor->connection, editor->client, editor->settings, editor));
pages = g_slist_copy (editor->initializing_pages);
for (l = pages; l; l = l->next) {
@@ -418,3 +418,28 @@ net_connection_editor_present (NetConnectionEditor *editor)
{
gtk_window_present (GTK_WINDOW (editor->window));
}
+
+static void
+forgotten_cb (NMRemoteConnection *connection,
+ GError *error,
+ gpointer data)
+{
+ NetConnectionEditor *editor = data;
+
+ if (error != NULL) {
+ g_warning ("Failed to delete conneciton %s: %s",
+ nm_connection_get_id (NM_CONNECTION (connection)),
+ error->message);
+ }
+
+ cancel_editing (editor);
+}
+
+void
+net_connection_editor_forget (NetConnectionEditor *editor)
+{
+ if (NM_IS_REMOTE_CONNECTION (editor->orig_connection))
+ nm_remote_connection_delete (NM_REMOTE_CONNECTION (editor->orig_connection), forgotten_cb, editor);
+ else
+ g_print ("why u no remote connection ?!\n");
+}
diff --git a/panels/network/connection-editor/net-connection-editor.h b/panels/network/connection-editor/net-connection-editor.h
index 274c2c1..15f60f1 100644
--- a/panels/network/connection-editor/net-connection-editor.h
+++ b/panels/network/connection-editor/net-connection-editor.h
@@ -75,7 +75,8 @@ NetConnectionEditor *net_connection_editor_new (GtkWindow *parent_wi
NMAccessPoint *ap,
NMClient *client,
NMRemoteSettings *settings);
-void net_connection_editor_present (NetConnectionEditor *details);
+void net_connection_editor_present (NetConnectionEditor *editor);
+void net_connection_editor_forget (NetConnectionEditor *editor);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]