diff --git a/clients/tui/Makefile.am b/clients/tui/Makefile.am index 18f2b37b9..ad9335daf 100644 --- a/clients/tui/Makefile.am +++ b/clients/tui/Makefile.am @@ -61,6 +61,8 @@ nmtui_SOURCES = \ nmt-editor-page.h \ nmt-editor-page-device.c \ nmt-editor-page-device.h \ + nmt-editor-section.c \ + nmt-editor-section.h \ nmt-editor.c \ nmt-editor.h \ nmt-ip-entry.c \ diff --git a/clients/tui/nmt-editor-page-device.c b/clients/tui/nmt-editor-page-device.c index 091e9fb46..0a9b18e0b 100644 --- a/clients/tui/nmt-editor-page-device.c +++ b/clients/tui/nmt-editor-page-device.c @@ -45,7 +45,6 @@ enum { PROP_0, PROP_DEVICE_ENTRY, - PROP_SHOW_BY_DEFAULT, LAST_PROP }; @@ -73,14 +72,6 @@ nmt_editor_page_device_get_device_entry (NmtEditorPageDevice *page) return priv->device_entry; } -static gboolean -nmt_editor_page_device_show_by_default (NmtEditorPage *page) -{ - NmtEditorPageDevicePrivate *priv = NMT_EDITOR_PAGE_DEVICE_GET_PRIVATE (page); - - return priv->show_by_default; -} - static void nmt_editor_page_device_set_property (GObject *object, guint prop_id, @@ -93,9 +84,6 @@ nmt_editor_page_device_set_property (GObject *object, case PROP_DEVICE_ENTRY: priv->device_entry = g_value_dup_object (value); break; - case PROP_SHOW_BY_DEFAULT: - priv->show_by_default = g_value_get_boolean (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -114,9 +102,6 @@ nmt_editor_page_device_get_property (GObject *object, case PROP_DEVICE_ENTRY: g_value_set_object (value, priv->device_entry); break; - case PROP_SHOW_BY_DEFAULT: - g_value_set_boolean (value, priv->show_by_default); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -127,7 +112,6 @@ static void nmt_editor_page_device_class_init (NmtEditorPageDeviceClass *page_device_class) { GObjectClass *object_class = G_OBJECT_CLASS (page_device_class); - NmtEditorPageClass *page_class = NMT_EDITOR_PAGE_CLASS (page_device_class); g_type_class_add_private (page_device_class, sizeof (NmtEditorPageDevicePrivate)); @@ -136,8 +120,6 @@ nmt_editor_page_device_class_init (NmtEditorPageDeviceClass *page_device_class) object_class->get_property = nmt_editor_page_device_get_property; object_class->finalize = nmt_editor_page_device_finalize; - page_class->show_by_default = nmt_editor_page_device_show_by_default; - /* properties */ g_object_class_install_property (object_class, PROP_DEVICE_ENTRY, @@ -146,11 +128,4 @@ nmt_editor_page_device_class_init (NmtEditorPageDeviceClass *page_device_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property - (object_class, PROP_SHOW_BY_DEFAULT, - g_param_spec_boolean ("show-by-default", "", "", - TRUE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); } diff --git a/clients/tui/nmt-editor-page.c b/clients/tui/nmt-editor-page.c index cce9cc3de..a46d0ed43 100644 --- a/clients/tui/nmt-editor-page.c +++ b/clients/tui/nmt-editor-page.c @@ -21,9 +21,7 @@ * @short_description: An #NmtEditor "page" * * #NmtEditorPage is the abstract base class for #NmtEditor "pages". - * Note that despite the name, currently all "page" types except - * #NmtPageMain are actually displayed as collapsible sections, not - * separate tabs/forms. + * A "page" is a set of related #NmtEditorSections. */ #include "config.h" @@ -32,14 +30,13 @@ #include "nmt-editor-page.h" -G_DEFINE_ABSTRACT_TYPE (NmtEditorPage, nmt_editor_page, NMT_TYPE_EDITOR_GRID) +G_DEFINE_ABSTRACT_TYPE (NmtEditorPage, nmt_editor_page, G_TYPE_OBJECT) #define NMT_EDITOR_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_EDITOR_PAGE, NmtEditorPagePrivate)) typedef struct { - char *title; - NmtNewtWidget *header_widget; NMConnection *connection; + GSList *sections; } NmtEditorPagePrivate; @@ -47,7 +44,6 @@ enum { PROP_0, PROP_CONNECTION, - PROP_TITLE, LAST_PROP }; @@ -55,9 +51,6 @@ enum { static void nmt_editor_page_init (NmtEditorPage *page) { - NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (page); - - priv->header_widget = g_object_ref_sink (nmt_newt_separator_new ()); } static void @@ -65,9 +58,8 @@ nmt_editor_page_finalize (GObject *object) { NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (object); - g_free (priv->title); - g_clear_object (&priv->header_widget); g_clear_object (&priv->connection); + g_slist_free_full (priv->sections, g_object_unref); G_OBJECT_CLASS (nmt_editor_page_parent_class)->finalize (object); } @@ -89,81 +81,37 @@ nmt_editor_page_get_connection (NmtEditorPage *page) } /** - * nmt_editor_page_set_header_widget: + * nmt_editor_page_get_sections: * @page: the #NmtEditorPage - * @widget: an #NmtNewtWidget * - * Sets the page's header widget. When displayed as a subpage of - * #NmtPageMain, this widget will be put into the corresponding - * #NmtNewtSection's header. + * Gets the page's list of sections to display. * - * FIXME: for consistency, this should be a property as well. + * Returns: (transfer none): the list of sections; this is the internal list + * used by the page and must not be modified or freed. + */ +GSList * +nmt_editor_page_get_sections (NmtEditorPage *page) +{ + NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (page); + + return priv->sections; +} + +/** + * nmt_editor_page_add_section: + * @page: the #NmtEditorPage + * @section: the #NmtEditorSection + * + * Adds a section to the page. This should only be called by #NmtEditorPage + * subclasses. */ void -nmt_editor_page_set_header_widget (NmtEditorPage *page, - NmtNewtWidget *widget) +nmt_editor_page_add_section (NmtEditorPage *page, + NmtEditorSection *section) { NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (page); - g_clear_object (&priv->header_widget); - - if (!widget) - widget = nmt_newt_separator_new (); - priv->header_widget = g_object_ref_sink (widget); -} - -/** - * nmt_editor_page_get_header_widget: - * @page: the #NmtEditorPage - * - * Gets the page's header widget. When displayed as a subpage of - * #NmtPageMain, this widget will be put into the corresponding - * #NmtNewtSection's header. - * - * Returns: (transfer none): the page's header widget. - */ -NmtNewtWidget * -nmt_editor_page_get_header_widget (NmtEditorPage *page) -{ - NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (page); - - return priv->header_widget; -} - -/** - * nmt_editor_page_get_title: - * @page: the #NmtEditorPage - * - * Gets the page's title. - * - * Returns: the page's title - */ -const char * -nmt_editor_page_get_title (NmtEditorPage *page) -{ - NmtEditorPagePrivate *priv = NMT_EDITOR_PAGE_GET_PRIVATE (page); - - return priv->title; -} - -static gboolean -nmt_editor_page_real_show_by_default (NmtEditorPage *page) -{ - return TRUE; -} - -/** - * nmt_editor_page_show_by_default: - * @page: the #NmtEditorPage - * - * Checks if @page should be shown expanded by default - * - * Returns: %TRUE or %FALSE - */ -gboolean -nmt_editor_page_show_by_default (NmtEditorPage *page) -{ - return NMT_EDITOR_PAGE_GET_CLASS (page)->show_by_default (page); + priv->sections = g_slist_append (priv->sections, g_object_ref_sink (section)); } static void @@ -178,9 +126,6 @@ nmt_editor_page_set_property (GObject *object, case PROP_CONNECTION: priv->connection = g_value_dup_object (value); break; - case PROP_TITLE: - priv->title = g_value_dup_string (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -199,9 +144,6 @@ nmt_editor_page_get_property (GObject *object, case PROP_CONNECTION: g_value_set_object (value, priv->connection); break; - case PROP_TITLE: - g_value_set_string (value, priv->title); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -220,8 +162,6 @@ nmt_editor_page_class_init (NmtEditorPageClass *page_class) object_class->get_property = nmt_editor_page_get_property; object_class->finalize = nmt_editor_page_finalize; - page_class->show_by_default = nmt_editor_page_real_show_by_default; - /* properties */ /** @@ -236,16 +176,4 @@ nmt_editor_page_class_init (NmtEditorPageClass *page_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - /** - * NmtEditorPage:title: - * - * The page's title. - */ - g_object_class_install_property - (object_class, PROP_TITLE, - g_param_spec_string ("title", "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); } diff --git a/clients/tui/nmt-editor-page.h b/clients/tui/nmt-editor-page.h index 440e66482..bbc0d9e35 100644 --- a/clients/tui/nmt-editor-page.h +++ b/clients/tui/nmt-editor-page.h @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright 2013 Red Hat, Inc. + * Copyright 2013-2014 Red Hat, Inc. */ #ifndef NMT_EDITOR_PAGE_H @@ -22,6 +22,7 @@ #include #include "nmt-editor-grid.h" +#include "nmt-editor-section.h" G_BEGIN_DECLS @@ -33,27 +34,24 @@ G_BEGIN_DECLS #define NMT_EDITOR_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMT_TYPE_EDITOR_PAGE, NmtEditorPageClass)) typedef struct { - NmtEditorGrid parent; + GObject parent; } NmtEditorPage; typedef struct { - NmtEditorGridClass parent; + GObjectClass parent; - gboolean (*show_by_default) (NmtEditorPage *); } NmtEditorPageClass; GType nmt_editor_page_get_type (void); NMConnection *nmt_editor_page_get_connection (NmtEditorPage *page); -void nmt_editor_page_set_header_widget (NmtEditorPage *page, - NmtNewtWidget *widget); -NmtNewtWidget *nmt_editor_page_get_header_widget (NmtEditorPage *page); +GSList *nmt_editor_page_get_sections (NmtEditorPage *page); -const char *nmt_editor_page_get_title (NmtEditorPage *page); - -gboolean nmt_editor_page_show_by_default (NmtEditorPage *page); +/*< protected >*/ +void nmt_editor_page_add_section (NmtEditorPage *page, + NmtEditorSection *section); G_END_DECLS diff --git a/clients/tui/nmt-editor-section.c b/clients/tui/nmt-editor-section.c new file mode 100644 index 000000000..9d892cc52 --- /dev/null +++ b/clients/tui/nmt-editor-section.c @@ -0,0 +1,281 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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, see . + * + * Copyright 2013 Red Hat, Inc. + */ + +/** + * SECTION:nmt-editor-section: + * @short_description: A section of the #NmtEditor + * + * #NmtEditorSection is the abstract base class for #NmtEditor sections. + */ + +#include "config.h" + +#include + +#include "nmt-editor-section.h" +#include "nmt-newt-toggle-button.h" + +G_DEFINE_TYPE (NmtEditorSection, nmt_editor_section, NMT_TYPE_NEWT_SECTION) + +#define NMT_EDITOR_SECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_EDITOR_SECTION, NmtEditorSectionPrivate)) + +typedef struct { + NmtEditorGrid *header, *body; + char *title; + NmtNewtWidget *header_widget; + NmtNewtWidget *toggle; + + gboolean show_by_default; +} NmtEditorSectionPrivate; + +enum { + PROP_0, + + PROP_TITLE, + PROP_SHOW_BY_DEFAULT, + PROP_HEADER_WIDGET, + + LAST_PROP +}; + +/** + * nmt_editor_section_new: + * @title: the section title + * @header_widget: (allow-none): the widget to show next to the title + * @show_by_default: whether the section should be open by default + * + * Creates a new #NmtEditorSection. + * + * Returns: a new #NmtEditorSection + */ +NmtEditorSection * +nmt_editor_section_new (const char *title, + NmtNewtWidget *header_widget, + gboolean show_by_default) +{ + return g_object_new (NMT_TYPE_EDITOR_SECTION, + "title", title, + "header-widget", header_widget, + "show-by-default", show_by_default, + NULL); +} + +static void +rebuild_header (NmtEditorSection *section) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + /* Removing any widget in an NmtEditorGrid removes its whole row, so we can + * remove the existing title/widget/toggle by asking to remove toggle. + */ + nmt_newt_container_remove (NMT_NEWT_CONTAINER (priv->header), priv->toggle); + + nmt_editor_grid_append (priv->header, + priv->title, + priv->header_widget ? priv->header_widget : nmt_newt_separator_new (), + priv->toggle); + nmt_editor_grid_set_row_flags (priv->header, + priv->toggle, + NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT | + NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT); +} + +static void +nmt_editor_section_init (NmtEditorSection *section) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + priv->header = NMT_EDITOR_GRID (nmt_editor_grid_new ()); + priv->body = NMT_EDITOR_GRID (nmt_editor_grid_new ()); + priv->toggle = nmt_newt_toggle_button_new (_("Hide"), _("Show")); + g_object_ref_sink (priv->toggle); + + nmt_newt_section_set_header (NMT_NEWT_SECTION (section), NMT_NEWT_WIDGET (priv->header)); + nmt_newt_section_set_body (NMT_NEWT_SECTION (section), NMT_NEWT_WIDGET (priv->body)); + + g_object_bind_property (priv->toggle, "active", + section, "open", + G_BINDING_SYNC_CREATE); +} + +static void +nmt_editor_section_finalize (GObject *object) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (object); + + g_free (priv->title); + g_clear_object (&priv->header_widget); + g_clear_object (&priv->toggle); + + G_OBJECT_CLASS (nmt_editor_section_parent_class)->finalize (object); +} + +/** + * nmt_editor_section_get_header_widget: + * @section: the #NmtEditorSection + * + * Gets the section's header widget. + * + * Returns: the section's header widget. + */ +NmtNewtWidget * +nmt_editor_section_get_header_widget (NmtEditorSection *section) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + return priv->header_widget; +} + +/** + * nmt_editor_section_get_body: + * @section: the #NmtEditorSection + * + * Gets the section's body grid, so that you can add things to it. + * + * Returns: the #NmtEditorGrid used for the section body + */ +NmtEditorGrid * +nmt_editor_section_get_body (NmtEditorSection *section) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + return priv->body; +} + +/** + * nmt_editor_section_get_title: + * @section: the #NmtEditorSection + * + * Gets the section's title. + * + * Returns: the section's title + */ +const char * +nmt_editor_section_get_title (NmtEditorSection *section) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + return priv->title; +} + +static void +nmt_editor_section_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NmtEditorSection *section = NMT_EDITOR_SECTION (object); + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (section); + + switch (prop_id) { + case PROP_TITLE: + priv->title = g_value_dup_string (value); + rebuild_header (section); + break; + case PROP_SHOW_BY_DEFAULT: + priv->show_by_default = g_value_get_boolean (value); + nmt_newt_toggle_button_set_active (NMT_NEWT_TOGGLE_BUTTON (priv->toggle), + priv->show_by_default); + break; + case PROP_HEADER_WIDGET: + priv->header_widget = g_value_get_object (value); + if (priv->header_widget) + g_object_ref_sink (priv->header_widget); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nmt_editor_section_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NmtEditorSectionPrivate *priv = NMT_EDITOR_SECTION_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_TITLE: + g_value_set_string (value, priv->title); + break; + case PROP_SHOW_BY_DEFAULT: + g_value_set_boolean (value, priv->show_by_default); + break; + case PROP_HEADER_WIDGET: + g_value_set_object (value, priv->header_widget); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nmt_editor_section_class_init (NmtEditorSectionClass *section_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (section_class); + + g_type_class_add_private (section_class, sizeof (NmtEditorSectionPrivate)); + + /* virtual methods */ + object_class->set_property = nmt_editor_section_set_property; + object_class->get_property = nmt_editor_section_get_property; + object_class->finalize = nmt_editor_section_finalize; + + /* properties */ + + /** + * NmtEditorSection:title: + * + * The section's title. + */ + g_object_class_install_property + (object_class, PROP_TITLE, + g_param_spec_string ("title", "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + /** + * NmtEditorSection:show-by-default: + * + * Whether the section should be expanded by default. + */ + g_object_class_install_property + (object_class, PROP_SHOW_BY_DEFAULT, + g_param_spec_boolean ("show-by-default", "", "", + TRUE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** + * NmtEditorSection:header-widget: + * + * The widget (if any) that appears between the section title and its toggle + * button. + */ + g_object_class_install_property + (object_class, PROP_HEADER_WIDGET, + g_param_spec_object ("header-widget", "", "", + NMT_TYPE_NEWT_WIDGET, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); +} diff --git a/clients/tui/nmt-editor-section.h b/clients/tui/nmt-editor-section.h new file mode 100644 index 000000000..67410c717 --- /dev/null +++ b/clients/tui/nmt-editor-section.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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, see . + * + * Copyright 2013 Red Hat, Inc. + */ + +#ifndef NMT_EDITOR_SECTION_H +#define NMT_EDITOR_SECTION_H + +#include "nmt-newt-section.h" +#include "nmt-editor-grid.h" + +G_BEGIN_DECLS + +#define NMT_TYPE_EDITOR_SECTION (nmt_editor_section_get_type ()) +#define NMT_EDITOR_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMT_TYPE_EDITOR_SECTION, NmtEditorSection)) +#define NMT_EDITOR_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMT_TYPE_EDITOR_SECTION, NmtEditorSectionClass)) +#define NMT_IS_EDITOR_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMT_TYPE_EDITOR_SECTION)) +#define NMT_IS_EDITOR_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMT_TYPE_EDITOR_SECTION)) +#define NMT_EDITOR_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMT_TYPE_EDITOR_SECTION, NmtEditorSectionClass)) + +typedef struct { + NmtNewtSection parent; + +} NmtEditorSection; + +typedef struct { + NmtNewtSectionClass parent; + +} NmtEditorSectionClass; + +GType nmt_editor_section_get_type (void); + +NmtEditorSection *nmt_editor_section_new (const char *title, + NmtNewtWidget *header_widget, + gboolean show_by_default); + +const char *nmt_editor_section_get_title (NmtEditorSection *section); +NmtNewtWidget *nmt_editor_section_get_header_widget (NmtEditorSection *section); +NmtEditorGrid *nmt_editor_section_get_body (NmtEditorSection *section); + +G_END_DECLS + +#endif /* NMT_EDITOR_SECTION_H */ diff --git a/clients/tui/nmt-editor.c b/clients/tui/nmt-editor.c index 29fb529e7..a6b0a60c2 100644 --- a/clients/tui/nmt-editor.c +++ b/clients/tui/nmt-editor.c @@ -64,6 +64,7 @@ typedef struct { NMEditorConnectionTypeData *type_data; + GSList *pages; NmtNewtWidget *ok, *cancel; gboolean running; } NmtEditorPrivate; @@ -266,42 +267,24 @@ permissions_transform_from_allusers (GBinding *binding, } static NmtNewtWidget * -add_section_for_page (NmtEditorGrid *grid, NmtNewtWidget *widget) +add_sections_for_page (NmtEditor *editor, NmtEditorGrid *grid, NmtEditorPage *page) { - NmtEditorPage *page; - NmtNewtWidget *section, *header, *toggle; + NmtEditorPrivate *priv = NMT_EDITOR_GET_PRIVATE (editor); + NmtNewtWidget *first_section = NULL; + const GSList *sections, *iter; - g_return_val_if_fail (NMT_IS_EDITOR_PAGE (widget), NULL); - g_return_val_if_fail (nmt_newt_widget_get_parent (widget) == NULL, NULL); + g_return_val_if_fail (NMT_IS_EDITOR_PAGE (page), NULL); - page = NMT_EDITOR_PAGE (widget); + priv->pages = g_slist_prepend (priv->pages, page); - section = nmt_newt_section_new (TRUE); + sections = nmt_editor_page_get_sections (page); + for (iter = sections; iter; iter = iter->next) { + if (!first_section) + first_section = iter->data; + nmt_editor_grid_append (grid, NULL, iter->data, NULL); + } - toggle = nmt_newt_toggle_button_new (_("Hide"), _("Show")); - - header = nmt_editor_grid_new (); - nmt_editor_grid_append (NMT_EDITOR_GRID (header), - nmt_editor_page_get_title (page), - nmt_editor_page_get_header_widget (page), - toggle); - nmt_editor_grid_set_row_flags (NMT_EDITOR_GRID (header), - nmt_editor_page_get_header_widget (page), - NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT | - NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT); - nmt_newt_section_set_header (NMT_NEWT_SECTION (section), header); - - nmt_newt_section_set_body (NMT_NEWT_SECTION (section), widget); - - g_object_bind_property (toggle, "active", - section, "open", - G_BINDING_SYNC_CREATE); - - if (nmt_editor_page_show_by_default (page) || !nmt_newt_widget_get_valid (section)) - nmt_newt_toggle_button_set_active (NMT_NEWT_TOGGLE_BUTTON (toggle), TRUE); - - nmt_editor_grid_append (grid, NULL, section, NULL); - return section; + return first_section; } static void @@ -362,43 +345,43 @@ nmt_editor_constructed (GObject *object) /* Now add the various pages... */ if (nm_connection_is_type (priv->edit_connection, NM_SETTING_BOND_SETTING_NAME)) - add_section_for_page (grid, nmt_page_bond_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_bond_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_BRIDGE_SETTING_NAME)) - add_section_for_page (grid, nmt_page_bridge_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_bridge_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_INFINIBAND_SETTING_NAME)) - add_section_for_page (grid, nmt_page_infiniband_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_infiniband_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_PPPOE_SETTING_NAME)) { - add_section_for_page (grid, nmt_page_dsl_new (priv->edit_connection)); - add_section_for_page (grid, nmt_page_ethernet_new (priv->edit_connection, deventry)); - add_section_for_page (grid, nmt_page_ppp_new (priv->edit_connection)); + add_sections_for_page (editor, grid, nmt_page_dsl_new (priv->edit_connection)); + add_sections_for_page (editor, grid, nmt_page_ethernet_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_ppp_new (priv->edit_connection)); } else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_TEAM_SETTING_NAME)) - add_section_for_page (grid, nmt_page_team_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_team_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_VLAN_SETTING_NAME)) - add_section_for_page (grid, nmt_page_vlan_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_vlan_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_WIRED_SETTING_NAME)) - add_section_for_page (grid, nmt_page_ethernet_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_ethernet_new (priv->edit_connection, deventry)); else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_WIRELESS_SETTING_NAME)) - add_section_for_page (grid, nmt_page_wifi_new (priv->edit_connection, deventry)); + add_sections_for_page (editor, grid, nmt_page_wifi_new (priv->edit_connection, deventry)); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); slave_type = nm_setting_connection_get_slave_type (s_con); if (slave_type) { if (!strcmp (slave_type, NM_SETTING_BRIDGE_SETTING_NAME)) - add_section_for_page (grid, nmt_page_bridge_port_new (priv->edit_connection)); + add_sections_for_page (editor, grid, nmt_page_bridge_port_new (priv->edit_connection)); else if (!strcmp (slave_type, NM_SETTING_TEAM_SETTING_NAME)) - add_section_for_page (grid, nmt_page_team_port_new (priv->edit_connection)); + add_sections_for_page (editor, grid, nmt_page_team_port_new (priv->edit_connection)); } else { NmtNewtWidget *section; - section = add_section_for_page (grid, nmt_page_ip4_new (priv->edit_connection)); + section = add_sections_for_page (editor, grid, nmt_page_ip4_new (priv->edit_connection)); /* Add a separator between ip4 and ip6 that's only visible if ip4 is open */ widget = nmt_newt_separator_new (); g_object_bind_property (section, "open", widget, "visible", G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, widget, NULL); - add_section_for_page (grid, nmt_page_ip6_new (priv->edit_connection)); + add_sections_for_page (editor, grid, nmt_page_ip6_new (priv->edit_connection)); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); } @@ -446,6 +429,8 @@ nmt_editor_finalize (GObject *object) g_clear_object (&priv->orig_connection); g_clear_object (&priv->edit_connection); + g_slist_free_full (priv->pages, g_object_unref); + g_clear_object (&priv->ok); g_clear_object (&priv->cancel); diff --git a/clients/tui/nmt-page-bond.c b/clients/tui/nmt-page-bond.c index be4e281d0..b043b513d 100644 --- a/clients/tui/nmt-page-bond.c +++ b/clients/tui/nmt-page-bond.c @@ -64,13 +64,12 @@ typedef struct { gboolean updating; } NmtPageBondPrivate; -NmtNewtWidget * +NmtEditorPage * nmt_page_bond_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_BOND, "connection", conn, - "title", _("BOND"), "device-entry", deventry, NULL); } @@ -338,6 +337,7 @@ nmt_page_bond_constructed (GObject *object) { NmtPageBond *bond = NMT_PAGE_BOND (object); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingBond *s_bond; NmtNewtWidget *widget, *label; @@ -351,7 +351,8 @@ nmt_page_bond_constructed (GObject *object) } priv->s_bond = s_bond; - grid = NMT_EDITOR_GRID (bond); + section = nmt_editor_section_new (_("BOND"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_separator_new (); nmt_editor_grid_append (grid, _("Slaves"), widget, NULL); @@ -420,6 +421,8 @@ nmt_page_bond_constructed (GObject *object) bond_options_changed (G_OBJECT (s_bond), NULL, bond); slaves_changed (G_OBJECT (priv->slaves), NULL, bond); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (bond), section); + G_OBJECT_CLASS (nmt_page_bond_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-bond.h b/clients/tui/nmt-page-bond.h index 970b7576a..b77477db2 100644 --- a/clients/tui/nmt-page-bond.h +++ b/clients/tui/nmt-page-bond.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_bond_get_type (void); -NmtNewtWidget *nmt_page_bond_new (NMConnection *conn, +NmtEditorPage *nmt_page_bond_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-bridge-port.c b/clients/tui/nmt-page-bridge-port.c index c7ea82fab..c9ef14ed8 100644 --- a/clients/tui/nmt-page-bridge-port.c +++ b/clients/tui/nmt-page-bridge-port.c @@ -30,12 +30,11 @@ G_DEFINE_TYPE (NmtPageBridgePort, nmt_page_bridge_port, NMT_TYPE_EDITOR_PAGE) -NmtNewtWidget * +NmtEditorPage * nmt_page_bridge_port_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_BRIDGE_PORT, "connection", conn, - "title", _("BRIDGE PORT"), NULL); } @@ -48,6 +47,7 @@ static void nmt_page_bridge_port_constructed (GObject *object) { NmtPageBridgePort *bridge = NMT_PAGE_BRIDGE_PORT (object); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingBridgePort *s_port; NmtNewtWidget *widget; @@ -60,7 +60,8 @@ nmt_page_bridge_port_constructed (GObject *object) s_port = nm_connection_get_setting_bridge_port (conn); } - grid = NMT_EDITOR_GRID (bridge); + section = nmt_editor_section_new (_("BRIDGE PORT"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_entry_numeric_new (10, 0, 63); g_object_bind_property (s_port, NM_SETTING_BRIDGE_PORT_PRIORITY, @@ -80,6 +81,8 @@ nmt_page_bridge_port_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (bridge), section); + G_OBJECT_CLASS (nmt_page_bridge_port_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-bridge-port.h b/clients/tui/nmt-page-bridge-port.h index 7fe3a92c4..c566dbc09 100644 --- a/clients/tui/nmt-page-bridge-port.h +++ b/clients/tui/nmt-page-bridge-port.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_bridge_port_get_type (void); -NmtNewtWidget *nmt_page_bridge_port_new (NMConnection *conn); +NmtEditorPage *nmt_page_bridge_port_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-bridge.c b/clients/tui/nmt-page-bridge.c index c77b90e5e..460be60b4 100644 --- a/clients/tui/nmt-page-bridge.c +++ b/clients/tui/nmt-page-bridge.c @@ -33,13 +33,12 @@ G_DEFINE_TYPE (NmtPageBridge, nmt_page_bridge, NMT_TYPE_EDITOR_PAGE_DEVICE) -NmtNewtWidget * +NmtEditorPage * nmt_page_bridge_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_BRIDGE, "connection", conn, - "title", _("BRIDGE"), "device-entry", deventry, NULL); } @@ -62,6 +61,7 @@ static void nmt_page_bridge_constructed (GObject *object) { NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingBridge *s_bridge; NmtNewtWidget *widget, *label, *stp; @@ -74,7 +74,8 @@ nmt_page_bridge_constructed (GObject *object) s_bridge = nm_connection_get_setting_bridge (conn); } - grid = NMT_EDITOR_GRID (bridge); + section = nmt_editor_section_new (_("BRIDGE"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_separator_new (); nmt_editor_grid_append (grid, _("Slaves"), widget, NULL); @@ -135,6 +136,8 @@ nmt_page_bridge_constructed (GObject *object) label = nmt_newt_label_new (_("seconds")); nmt_editor_grid_append (grid, _("Max age"), widget, label); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (bridge), section); + G_OBJECT_CLASS (nmt_page_bridge_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-bridge.h b/clients/tui/nmt-page-bridge.h index a17a6b768..60cbdea23 100644 --- a/clients/tui/nmt-page-bridge.h +++ b/clients/tui/nmt-page-bridge.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_bridge_get_type (void); -NmtNewtWidget *nmt_page_bridge_new (NMConnection *conn, +NmtEditorPage *nmt_page_bridge_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-dsl.c b/clients/tui/nmt-page-dsl.c index 8ecf312b6..d1d33969c 100644 --- a/clients/tui/nmt-page-dsl.c +++ b/clients/tui/nmt-page-dsl.c @@ -31,12 +31,11 @@ G_DEFINE_TYPE (NmtPageDsl, nmt_page_dsl, NMT_TYPE_EDITOR_PAGE) -NmtNewtWidget * +NmtEditorPage * nmt_page_dsl_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_DSL, "connection", conn, - "title", _("DSL"), NULL); } @@ -49,6 +48,7 @@ static void nmt_page_dsl_constructed (GObject *object) { NmtPageDsl *dsl = NMT_PAGE_DSL (object); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingPppoe *s_pppoe; NmtNewtWidget *widget; @@ -61,7 +61,8 @@ nmt_page_dsl_constructed (GObject *object) s_pppoe = nm_connection_get_setting_pppoe (conn); } - grid = NMT_EDITOR_GRID (dsl); + section = nmt_editor_section_new (_("DSL"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_entry_new (40, 0); nmt_editor_grid_append (grid, _("Username"), widget, NULL); @@ -81,6 +82,8 @@ nmt_page_dsl_constructed (GObject *object) widget, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (dsl), section); + G_OBJECT_CLASS (nmt_page_dsl_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-dsl.h b/clients/tui/nmt-page-dsl.h index 61fc23a8f..7a27fd0a0 100644 --- a/clients/tui/nmt-page-dsl.h +++ b/clients/tui/nmt-page-dsl.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_dsl_get_type (void); -NmtNewtWidget *nmt_page_dsl_new (NMConnection *conn); +NmtEditorPage *nmt_page_dsl_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-ethernet.c b/clients/tui/nmt-page-ethernet.c index 53907bbe1..cf4ef2c45 100644 --- a/clients/tui/nmt-page-ethernet.c +++ b/clients/tui/nmt-page-ethernet.c @@ -32,15 +32,13 @@ G_DEFINE_TYPE (NmtPageEthernet, nmt_page_ethernet, NMT_TYPE_EDITOR_PAGE_DEVICE) -NmtNewtWidget * +NmtEditorPage * nmt_page_ethernet_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_ETHERNET, "connection", conn, - "title", _("ETHERNET"), "device-entry", deventry, - "show-by-default", FALSE, NULL); } @@ -54,6 +52,7 @@ nmt_page_ethernet_constructed (GObject *object) { NmtPageEthernet *ethernet = NMT_PAGE_ETHERNET (object); NmtDeviceEntry *deventry; + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingWired *s_wired; NmtNewtWidget *widget; @@ -71,7 +70,8 @@ nmt_page_ethernet_constructed (GObject *object) deventry, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - grid = NMT_EDITOR_GRID (ethernet); + section = nmt_editor_section_new (_("ETHERNET"), NULL, FALSE); + grid = nmt_editor_section_get_body (section); widget = nmt_mac_entry_new (40, ETH_ALEN); g_object_bind_property (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, @@ -85,6 +85,8 @@ nmt_page_ethernet_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("MTU"), widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (ethernet), section); + G_OBJECT_CLASS (nmt_page_ethernet_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-ethernet.h b/clients/tui/nmt-page-ethernet.h index 8b11bf949..bdf3d6773 100644 --- a/clients/tui/nmt-page-ethernet.h +++ b/clients/tui/nmt-page-ethernet.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_ethernet_get_type (void); -NmtNewtWidget *nmt_page_ethernet_new (NMConnection *conn, +NmtEditorPage *nmt_page_ethernet_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-infiniband.c b/clients/tui/nmt-page-infiniband.c index 5ffb73340..f39b0b84f 100644 --- a/clients/tui/nmt-page-infiniband.c +++ b/clients/tui/nmt-page-infiniband.c @@ -31,13 +31,12 @@ G_DEFINE_TYPE (NmtPageInfiniband, nmt_page_infiniband, NMT_TYPE_EDITOR_PAGE_DEVICE) -NmtNewtWidget * +NmtEditorPage * nmt_page_infiniband_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_INFINIBAND, "connection", conn, - "title", _("INFINIBAND"), "device-entry", deventry, NULL); } @@ -58,6 +57,7 @@ nmt_page_infiniband_constructed (GObject *object) { NmtPageInfiniband *infiniband = NMT_PAGE_INFINIBAND (object); NmtDeviceEntry *deventry; + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingInfiniband *s_ib; NmtNewtWidget *widget; @@ -81,7 +81,8 @@ nmt_page_infiniband_constructed (GObject *object) deventry, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - grid = NMT_EDITOR_GRID (infiniband); + section = nmt_editor_section_new (_("INFINIBAND"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_popup_new (transport_mode); g_object_bind_property (s_ib, NM_SETTING_INFINIBAND_TRANSPORT_MODE, @@ -95,6 +96,8 @@ nmt_page_infiniband_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("MTU"), widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (infiniband), section); + G_OBJECT_CLASS (nmt_page_infiniband_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-infiniband.h b/clients/tui/nmt-page-infiniband.h index faa5adfb2..f51e0874e 100644 --- a/clients/tui/nmt-page-infiniband.h +++ b/clients/tui/nmt-page-infiniband.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_infiniband_get_type (void); -NmtNewtWidget *nmt_page_infiniband_new (NMConnection *conn, +NmtEditorPage *nmt_page_infiniband_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-ip4.c b/clients/tui/nmt-page-ip4.c index b7d6c3228..df3f0b647 100644 --- a/clients/tui/nmt-page-ip4.c +++ b/clients/tui/nmt-page-ip4.c @@ -46,29 +46,14 @@ static NmtNewtPopupEntry ip4methods[] = { { NULL, NULL } }; -NmtNewtWidget * +NmtEditorPage * nmt_page_ip4_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_IP4, "connection", conn, - "title", _("IPv4 CONFIGURATION"), NULL); } -static gboolean -nmt_page_ip4_show_by_default (NmtEditorPage *page) -{ - NMConnection *conn; - NMSettingIPConfig *s_ip4; - - conn = nmt_editor_page_get_connection (page); - s_ip4 = nm_connection_get_setting_ip4_config (conn); - if ( !g_strcmp0 (nm_setting_ip_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL) - || nm_setting_ip_config_get_num_addresses (s_ip4)) - return TRUE; - return FALSE; -} - static void nmt_page_ip4_init (NmtPageIP4 *ip4) { @@ -114,6 +99,8 @@ static void nmt_page_ip4_constructed (GObject *object) { NmtPageIP4 *ip4 = NMT_PAGE_IP4 (object); + gboolean show_by_default; + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingIPConfig *s_ip4; NmtNewtWidget *widget, *button; @@ -133,9 +120,16 @@ nmt_page_ip4_constructed (GObject *object) g_object_bind_property (s_ip4, NM_SETTING_IP_CONFIG_METHOD, widget, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - nmt_editor_page_set_header_widget (NMT_EDITOR_PAGE (ip4), widget); - grid = NMT_EDITOR_GRID (ip4); + if (!g_strcmp0 (nm_setting_ip_config_get_method (s_ip4), NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) + show_by_default = TRUE; + else if (nm_setting_ip_config_get_num_addresses (s_ip4)) + show_by_default = TRUE; + else + show_by_default = FALSE; + + section = nmt_editor_section_new (_("IPv4 CONFIGURATION"), widget, show_by_default); + grid = nmt_editor_section_get_body (section); widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP4_WITH_PREFIX); nm_editor_bind_ip_addresses_with_prefix_to_strv (AF_INET, @@ -194,6 +188,8 @@ nmt_page_ip4_constructed (GObject *object) G_BINDING_INVERT_BOOLEAN); nmt_editor_grid_append (grid, NULL, widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (ip4), section); + G_OBJECT_CLASS (nmt_page_ip4_parent_class)->constructed (object); } @@ -201,9 +197,6 @@ static void nmt_page_ip4_class_init (NmtPageIP4Class *ip4_class) { GObjectClass *object_class = G_OBJECT_CLASS (ip4_class); - NmtEditorPageClass *page_class = NMT_EDITOR_PAGE_CLASS (ip4_class); object_class->constructed = nmt_page_ip4_constructed; - - page_class->show_by_default = nmt_page_ip4_show_by_default; } diff --git a/clients/tui/nmt-page-ip4.h b/clients/tui/nmt-page-ip4.h index f631a9132..e3c5a0034 100644 --- a/clients/tui/nmt-page-ip4.h +++ b/clients/tui/nmt-page-ip4.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_ip4_get_type (void); -NmtNewtWidget *nmt_page_ip4_new (NMConnection *conn); +NmtEditorPage *nmt_page_ip4_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-ip6.c b/clients/tui/nmt-page-ip6.c index 9d34e65c5..1513dbfa0 100644 --- a/clients/tui/nmt-page-ip6.c +++ b/clients/tui/nmt-page-ip6.c @@ -46,29 +46,14 @@ static NmtNewtPopupEntry ip6methods[] = { { NULL, NULL } }; -NmtNewtWidget * +NmtEditorPage * nmt_page_ip6_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_IP6, "connection", conn, - "title", _("IPv6 CONFIGURATION"), NULL); } -static gboolean -nmt_page_ip6_show_by_default (NmtEditorPage *page) -{ - NMConnection *conn; - NMSettingIPConfig *s_ip6; - - conn = nmt_editor_page_get_connection (page); - s_ip6 = nm_connection_get_setting_ip6_config (conn); - if ( !g_strcmp0 (nm_setting_ip_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_MANUAL) - || nm_setting_ip_config_get_num_addresses (s_ip6)) - return TRUE; - return FALSE; -} - static void nmt_page_ip6_init (NmtPageIP6 *ip6) { @@ -114,6 +99,8 @@ static void nmt_page_ip6_constructed (GObject *object) { NmtPageIP6 *ip6 = NMT_PAGE_IP6 (object); + gboolean show_by_default; + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingIPConfig *s_ip6; NmtNewtWidget *widget, *button; @@ -133,9 +120,16 @@ nmt_page_ip6_constructed (GObject *object) g_object_bind_property (s_ip6, NM_SETTING_IP_CONFIG_METHOD, widget, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - nmt_editor_page_set_header_widget (NMT_EDITOR_PAGE (ip6), widget); - grid = NMT_EDITOR_GRID (ip6); + if (!g_strcmp0 (nm_setting_ip_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) + show_by_default = TRUE; + else if (nm_setting_ip_config_get_num_addresses (s_ip6)) + show_by_default = TRUE; + else + show_by_default = FALSE; + + section = nmt_editor_section_new (_("IPv6 CONFIGURATION"), widget, show_by_default); + grid = nmt_editor_section_get_body (section); widget = nmt_address_list_new (NMT_ADDRESS_LIST_IP6_WITH_PREFIX); nm_editor_bind_ip_addresses_with_prefix_to_strv (AF_INET6, @@ -192,6 +186,8 @@ nmt_page_ip6_constructed (GObject *object) G_BINDING_INVERT_BOOLEAN); nmt_editor_grid_append (grid, NULL, widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (ip6), section); + G_OBJECT_CLASS (nmt_page_ip6_parent_class)->constructed (object); } @@ -199,9 +195,6 @@ static void nmt_page_ip6_class_init (NmtPageIP6Class *ip6_class) { GObjectClass *object_class = G_OBJECT_CLASS (ip6_class); - NmtEditorPageClass *page_class = NMT_EDITOR_PAGE_CLASS (ip6_class); object_class->constructed = nmt_page_ip6_constructed; - - page_class->show_by_default = nmt_page_ip6_show_by_default; } diff --git a/clients/tui/nmt-page-ip6.h b/clients/tui/nmt-page-ip6.h index 7ea4a578c..498261e16 100644 --- a/clients/tui/nmt-page-ip6.h +++ b/clients/tui/nmt-page-ip6.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_ip6_get_type (void); -NmtNewtWidget *nmt_page_ip6_new (NMConnection *conn); +NmtEditorPage *nmt_page_ip6_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-ppp.c b/clients/tui/nmt-page-ppp.c index 983e42dab..cec36549d 100644 --- a/clients/tui/nmt-page-ppp.c +++ b/clients/tui/nmt-page-ppp.c @@ -41,12 +41,11 @@ typedef struct { #define NMT_PAGE_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_PPP, NmtPagePppPrivate)) -NmtNewtWidget * +NmtEditorPage * nmt_page_ppp_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_PPP, "connection", conn, - "title", _("PPP CONFIGURATION"), NULL); } @@ -111,11 +110,12 @@ nmt_page_ppp_constructed (GObject *object) { NmtPagePpp *ppp = NMT_PAGE_PPP (object); NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingPpp *s_ppp; NmtNewtWidget *widget, *use_mppe; NmtNewtGrid *auth_grid, *mppe_grid; - NmtNewtSection *section; + NmtNewtSection *auth_section, *mppe_section; NMConnection *conn; conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ppp)); @@ -131,20 +131,21 @@ nmt_page_ppp_constructed (GObject *object) priv->lcp_echo_failure = 5; } - grid = NMT_EDITOR_GRID (ppp); + section = nmt_editor_section_new (_("PPP CONFIGURATION"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); /* Auth methods */ widget = nmt_newt_section_new (FALSE); - section = NMT_NEWT_SECTION (widget); - g_object_set (section, "open", TRUE, NULL); + auth_section = NMT_NEWT_SECTION (widget); + g_object_set (auth_section, "open", TRUE, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_label_new (_("Allowed authentication methods:")); - nmt_newt_section_set_header (section, widget); + nmt_newt_section_set_header (auth_section, widget); widget = nmt_newt_grid_new (); auth_grid = NMT_NEWT_GRID (widget); - nmt_newt_section_set_body (section, widget); + nmt_newt_section_set_body (auth_section, widget); widget = nmt_newt_checkbox_new (_("EAP")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_EAP, @@ -190,8 +191,8 @@ nmt_page_ppp_constructed (GObject *object) /* MPPE */ widget = nmt_newt_section_new (FALSE); - section = NMT_NEWT_SECTION (widget); - g_object_set (section, "open", TRUE, NULL); + mppe_section = NMT_NEWT_SECTION (widget); + g_object_set (mppe_section, "open", TRUE, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_checkbox_new (_("Use point-to-point encryption (MPPE)")); @@ -200,11 +201,11 @@ nmt_page_ppp_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); use_mppe = widget; - nmt_newt_section_set_header (section, widget); + nmt_newt_section_set_header (mppe_section, widget); widget = nmt_newt_grid_new (); mppe_grid = NMT_NEWT_GRID (widget); - nmt_newt_section_set_body (section, widget); + nmt_newt_section_set_body (mppe_section, widget); widget = nmt_newt_checkbox_new (_("Require 128-bit encryption")); g_object_bind_property (use_mppe, "active", @@ -271,6 +272,8 @@ nmt_page_ppp_constructed (GObject *object) ppp, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (ppp), section); + G_OBJECT_CLASS (nmt_page_ppp_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-ppp.h b/clients/tui/nmt-page-ppp.h index 4bc04d88f..79103232f 100644 --- a/clients/tui/nmt-page-ppp.h +++ b/clients/tui/nmt-page-ppp.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_ppp_get_type (void); -NmtNewtWidget *nmt_page_ppp_new (NMConnection *conn); +NmtEditorPage *nmt_page_ppp_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-team-port.c b/clients/tui/nmt-page-team-port.c index 786fc1f57..645dc9d37 100644 --- a/clients/tui/nmt-page-team-port.c +++ b/clients/tui/nmt-page-team-port.c @@ -37,12 +37,11 @@ typedef struct { } NmtPageTeamPortPrivate; -NmtNewtWidget * +NmtEditorPage * nmt_page_team_port_new (NMConnection *conn) { return g_object_new (NMT_TYPE_PAGE_TEAM_PORT, "connection", conn, - "title", _("TEAM PORT"), NULL); } @@ -79,6 +78,7 @@ nmt_page_team_port_constructed (GObject *object) { NmtPageTeamPort *team = NMT_PAGE_TEAM_PORT (object); NmtPageTeamPortPrivate *priv = NMT_PAGE_TEAM_PORT_GET_PRIVATE (team); + NmtEditorSection *section; NmtNewtGrid *grid; NMSettingTeamPort *s_port; NmtNewtWidget *widget; @@ -92,8 +92,10 @@ nmt_page_team_port_constructed (GObject *object) } priv->s_port = s_port; + section = nmt_editor_section_new (_("TEAM PORT"), NULL, TRUE); + widget = nmt_newt_grid_new (); - nmt_editor_grid_append (NMT_EDITOR_GRID (team), NULL, widget, NULL); + nmt_editor_grid_append (nmt_editor_section_get_body (section), NULL, widget, NULL); grid = NMT_NEWT_GRID (widget); @@ -111,6 +113,8 @@ nmt_page_team_port_constructed (GObject *object) g_signal_connect (widget, "clicked", G_CALLBACK (edit_clicked), team); nmt_newt_grid_add (grid, widget, 0, 4); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (team), section); + G_OBJECT_CLASS (nmt_page_team_port_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-team-port.h b/clients/tui/nmt-page-team-port.h index 89381c0bf..2d8fa1218 100644 --- a/clients/tui/nmt-page-team-port.h +++ b/clients/tui/nmt-page-team-port.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_team_port_get_type (void); -NmtNewtWidget *nmt_page_team_port_new (NMConnection *conn); +NmtEditorPage *nmt_page_team_port_new (NMConnection *conn); G_END_DECLS diff --git a/clients/tui/nmt-page-team.c b/clients/tui/nmt-page-team.c index e378bbcea..e520b02a3 100644 --- a/clients/tui/nmt-page-team.c +++ b/clients/tui/nmt-page-team.c @@ -42,13 +42,12 @@ typedef struct { } NmtPageTeamPrivate; -NmtNewtWidget * +NmtEditorPage * nmt_page_team_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_TEAM, "connection", conn, - "title", _("TEAM"), "device-entry", deventry, NULL); } @@ -132,6 +131,7 @@ nmt_page_team_constructed (GObject *object) { NmtPageTeam *team = NMT_PAGE_TEAM (object); NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (team); + NmtEditorSection *section; NmtNewtGrid *grid; NMSettingTeam *s_team; NmtNewtWidget *widget; @@ -145,8 +145,10 @@ nmt_page_team_constructed (GObject *object) } priv->s_team = s_team; + section = nmt_editor_section_new (_("TEAM"), NULL, TRUE); + widget = nmt_newt_grid_new (); - nmt_editor_grid_append (NMT_EDITOR_GRID (team), NULL, widget, NULL); + nmt_editor_grid_append (nmt_editor_section_get_body (section), NULL, widget, NULL); grid = NMT_NEWT_GRID (widget); @@ -175,6 +177,8 @@ nmt_page_team_constructed (GObject *object) g_signal_connect (widget, "clicked", G_CALLBACK (edit_clicked), team); nmt_newt_grid_add (grid, widget, 0, 4); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (team), section); + G_OBJECT_CLASS (nmt_page_team_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-team.h b/clients/tui/nmt-page-team.h index 4c0ca6a0c..2d8bf07ad 100644 --- a/clients/tui/nmt-page-team.h +++ b/clients/tui/nmt-page-team.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_team_get_type (void); -NmtNewtWidget *nmt_page_team_new (NMConnection *conn, +NmtEditorPage *nmt_page_team_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-vlan.c b/clients/tui/nmt-page-vlan.c index b9e714696..9b9c8f52a 100644 --- a/clients/tui/nmt-page-vlan.c +++ b/clients/tui/nmt-page-vlan.c @@ -42,13 +42,12 @@ typedef struct { } NmtPageVlanPrivate; -NmtNewtWidget * +NmtEditorPage * nmt_page_vlan_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_VLAN, "connection", conn, - "title", _("VLAN"), "device-entry", deventry, NULL); } @@ -72,6 +71,7 @@ nmt_page_vlan_constructed (GObject *object) { NmtPageVlan *vlan = NMT_PAGE_VLAN (object); NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (vlan); + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingWired *s_wired; NMSettingVlan *s_vlan; @@ -94,7 +94,8 @@ nmt_page_vlan_constructed (GObject *object) } priv->s_wired = g_object_ref_sink (s_wired); - grid = NMT_EDITOR_GRID (vlan); + section = nmt_editor_section_new (_("VLAN"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); nm_editor_bind_vlan_name (s_vlan, nm_connection_get_setting_connection (conn)); @@ -129,6 +130,8 @@ nmt_page_vlan_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("MTU"), widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (vlan), section); + G_OBJECT_CLASS (nmt_page_vlan_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-vlan.h b/clients/tui/nmt-page-vlan.h index 3b87b2a11..db7c40981 100644 --- a/clients/tui/nmt-page-vlan.h +++ b/clients/tui/nmt-page-vlan.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_vlan_get_type (void); -NmtNewtWidget *nmt_page_vlan_new (NMConnection *conn, +NmtEditorPage *nmt_page_vlan_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/clients/tui/nmt-page-wifi.c b/clients/tui/nmt-page-wifi.c index ac6dd5b25..9cd20abf3 100644 --- a/clients/tui/nmt-page-wifi.c +++ b/clients/tui/nmt-page-wifi.c @@ -48,13 +48,12 @@ typedef struct { } NmtPageWifiPrivate; -NmtNewtWidget * +NmtEditorPage * nmt_page_wifi_new (NMConnection *conn, NmtDeviceEntry *deventry) { return g_object_new (NMT_TYPE_PAGE_WIFI, "connection", conn, - "title", _("WI-FI"), "device-entry", deventry, NULL); } @@ -184,6 +183,7 @@ nmt_page_wifi_constructed (GObject *object) NmtPageWifiPrivate *priv = NMT_PAGE_WIFI_GET_PRIVATE (object); NmtPageWifi *wifi = NMT_PAGE_WIFI (object); NmtDeviceEntry *deventry; + NmtEditorSection *section; NmtEditorGrid *grid; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; @@ -214,7 +214,8 @@ nmt_page_wifi_constructed (GObject *object) deventry, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); - grid = NMT_EDITOR_GRID (wifi); + section = nmt_editor_section_new (_("WI-FI"), NULL, TRUE); + grid = nmt_editor_section_get_body (section); widget = nmt_newt_entry_new (40, NMT_NEWT_ENTRY_NONEMPTY); g_object_bind_property_full (s_wireless, NM_SETTING_WIRELESS_SSID, @@ -371,6 +372,8 @@ nmt_page_wifi_constructed (GObject *object) G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("MTU"), widget, NULL); + nmt_editor_page_add_section (NMT_EDITOR_PAGE (wifi), section); + G_OBJECT_CLASS (nmt_page_wifi_parent_class)->constructed (object); } diff --git a/clients/tui/nmt-page-wifi.h b/clients/tui/nmt-page-wifi.h index 826f340ff..7ce505846 100644 --- a/clients/tui/nmt-page-wifi.h +++ b/clients/tui/nmt-page-wifi.h @@ -42,7 +42,7 @@ typedef struct { GType nmt_page_wifi_get_type (void); -NmtNewtWidget *nmt_page_wifi_new (NMConnection *conn, +NmtEditorPage *nmt_page_wifi_new (NMConnection *conn, NmtDeviceEntry *deventry); G_END_DECLS diff --git a/po/POTFILES.in b/po/POTFILES.in index 7234e54bf..1bc1ccb24 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -18,6 +18,7 @@ clients/tui/nm-editor-utils.c clients/tui/nmt-connect-connection-list.c clients/tui/nmt-device-entry.c clients/tui/nmt-edit-connection-list.c +clients/tui/nmt-editor-section.c clients/tui/nmt-editor.c clients/tui/nmt-mtu-entry.c clients/tui/nmt-page-bond.c