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.
This commit is contained in:
Lubomir Rintel 2017-02-20 19:06:37 +01:00
parent 8fce72360e
commit c8969dbf80
3 changed files with 32 additions and 0 deletions

View file

@ -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,

View file

@ -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);

View file

@ -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));
}