[gnome-control-center/wip/network] Implement the 'Forget' button in the connection-editor



commit b4b3315d82a6260c3f76bc97f94f8e412c473456
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 14 20:37:13 2012 -0500

    Implement the 'Forget' button 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 7a91f99..4c73793 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,
                                            GNOMECC_UI_DIR "/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 85d453e..f778e39 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -351,7 +351,7 @@ add_page (NetConnectionEditor *editor, CEPage *page)
 
 static void
 net_connection_editor_set_connection (NetConnectionEditor *editor,
-                              NMConnection        *connection)
+                                      NMConnection        *connection)
 {
         GSList *pages, *l;
 
@@ -365,7 +365,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) {
@@ -415,3 +415,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]