From c8969dbf8068d7e930fe1f556e1ff3c899c61cc2 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 20 Feb 2017 19:06:37 +0100 Subject: tui/editor: notify the pages after the connection is saved This will make it possible for the pages to commit slave connections when the master connection is saved. --- clients/tui/nmt-editor-page.c | 17 +++++++++++++++++ clients/tui/nmt-editor-page.h | 3 +++ clients/tui/nmt-editor.c | 12 ++++++++++++ 3 files changed, 32 insertions(+) diff --git a/clients/tui/nmt-editor-page.c b/clients/tui/nmt-editor-page.c index 44abe27317..99475a9199 100644 --- a/clients/tui/nmt-editor-page.c +++ b/clients/tui/nmt-editor-page.c @@ -112,6 +112,23 @@ nmt_editor_page_add_section (NmtEditorPage *page, priv->sections = g_slist_append (priv->sections, g_object_ref_sink (section)); } +/** + * nmt_editor_page_saved: + * @page: the #NmtEditorPage + * + * This method is called when the user saves the connection. It gives + * the page a chance to do save its data outside the connections (such as + * recommit the slave connections). + */ +void +nmt_editor_page_saved (NmtEditorPage *page) +{ + NmtEditorPageClass *editor_page_class = NMT_EDITOR_PAGE_GET_CLASS (page); + + if (editor_page_class->saved) + editor_page_class->saved (page); +} + static void nmt_editor_page_set_property (GObject *object, guint prop_id, diff --git a/clients/tui/nmt-editor-page.h b/clients/tui/nmt-editor-page.h index 8da5ea9f51..ae55128ac6 100644 --- a/clients/tui/nmt-editor-page.h +++ b/clients/tui/nmt-editor-page.h @@ -39,6 +39,7 @@ typedef struct { typedef struct { GObjectClass parent; + void (*saved) (NmtEditorPage *page); } NmtEditorPageClass; GType nmt_editor_page_get_type (void); @@ -47,6 +48,8 @@ NMConnection *nmt_editor_page_get_connection (NmtEditorPage *page); GSList *nmt_editor_page_get_sections (NmtEditorPage *page); +void nmt_editor_page_saved (NmtEditorPage *page); + /*< protected >*/ void nmt_editor_page_add_section (NmtEditorPage *page, NmtEditorSection *section); diff --git a/clients/tui/nmt-editor.c b/clients/tui/nmt-editor.c index 395e661ae4..515e347171 100644 --- a/clients/tui/nmt-editor.c +++ b/clients/tui/nmt-editor.c @@ -145,6 +145,15 @@ connection_added (GObject *client, g_clear_error (&error); } +static void +page_saved (gpointer data, gpointer user_data) +{ + NmtEditorPage *page = data; + + nmt_editor_page_saved (page); +} + + static void save_connection_and_exit (NmtNewtButton *button, gpointer user_data) @@ -183,6 +192,9 @@ save_connection_and_exit (NmtNewtButton *button, } } + /* Let the page know that it was saved. */ + g_slist_foreach (priv->pages, page_saved, NULL); + nmt_newt_form_quit (NMT_NEWT_FORM (editor)); } -- cgit v1.2.1