mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 07:08:02 +02:00
tui: simplify DSL page handling
Rather than having NmtEditor need to know that DSL requires a DSL page, and Ethernet page, and a PPP page, just have the DSL page itself return multiple sections.
This commit is contained in:
parent
2afb1acb2d
commit
5f6b0be525
3 changed files with 76 additions and 30 deletions
|
|
@ -299,6 +299,7 @@ nmt_editor_constructed (GObject *object)
|
|||
NmtDeviceEntry *deventry;
|
||||
GType hardware_type;
|
||||
const char *slave_type;
|
||||
NmtEditorPage *page;
|
||||
|
||||
if (G_OBJECT_CLASS (nmt_editor_parent_class)->constructed)
|
||||
G_OBJECT_CLASS (nmt_editor_parent_class)->constructed (object);
|
||||
|
|
@ -345,24 +346,23 @@ nmt_editor_constructed (GObject *object)
|
|||
/* Now add the various pages... */
|
||||
|
||||
if (nm_connection_is_type (priv->edit_connection, NM_SETTING_BOND_SETTING_NAME))
|
||||
add_sections_for_page (editor, grid, nmt_page_bond_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_bond_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_BRIDGE_SETTING_NAME))
|
||||
add_sections_for_page (editor, grid, nmt_page_bridge_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_bridge_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_INFINIBAND_SETTING_NAME))
|
||||
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_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_sections_for_page (editor, grid, nmt_page_team_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_infiniband_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_PPPOE_SETTING_NAME))
|
||||
page = nmt_page_dsl_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_TEAM_SETTING_NAME))
|
||||
page = nmt_page_team_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_VLAN_SETTING_NAME))
|
||||
add_sections_for_page (editor, grid, nmt_page_vlan_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_vlan_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_WIRED_SETTING_NAME))
|
||||
add_sections_for_page (editor, grid, nmt_page_ethernet_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_ethernet_new (priv->edit_connection, deventry);
|
||||
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_WIRELESS_SETTING_NAME))
|
||||
add_sections_for_page (editor, grid, nmt_page_wifi_new (priv->edit_connection, deventry));
|
||||
page = nmt_page_wifi_new (priv->edit_connection, deventry);
|
||||
|
||||
add_sections_for_page (editor, grid, page);
|
||||
nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
|
||||
|
||||
slave_type = nm_setting_connection_get_slave_type (s_con);
|
||||
|
|
|
|||
|
|
@ -27,15 +27,26 @@
|
|||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "nmt-page-dsl.h"
|
||||
#include "nmt-page-ethernet.h"
|
||||
#include "nmt-page-ppp.h"
|
||||
#include "nmt-password-fields.h"
|
||||
|
||||
G_DEFINE_TYPE (NmtPageDsl, nmt_page_dsl, NMT_TYPE_EDITOR_PAGE)
|
||||
G_DEFINE_TYPE (NmtPageDsl, nmt_page_dsl, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
||||
|
||||
#define NMT_PAGE_DSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_DSL, NmtPageDslPrivate))
|
||||
|
||||
typedef struct {
|
||||
NmtEditorPage *ethernet_page, *ppp_page;
|
||||
|
||||
} NmtPageDslPrivate;
|
||||
|
||||
NmtEditorPage *
|
||||
nmt_page_dsl_new (NMConnection *conn)
|
||||
nmt_page_dsl_new (NMConnection *conn,
|
||||
NmtDeviceEntry *deventry)
|
||||
{
|
||||
return g_object_new (NMT_TYPE_PAGE_DSL,
|
||||
"connection", conn,
|
||||
"device-entry", deventry,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -44,22 +55,12 @@ nmt_page_dsl_init (NmtPageDsl *dsl)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
nmt_page_dsl_constructed (GObject *object)
|
||||
static NmtEditorSection *
|
||||
build_dsl_section (NmtPageDsl *dsl, NMSettingPppoe *s_pppoe)
|
||||
{
|
||||
NmtPageDsl *dsl = NMT_PAGE_DSL (object);
|
||||
NmtEditorSection *section;
|
||||
NmtEditorGrid *grid;
|
||||
NMSettingPppoe *s_pppoe;
|
||||
NmtNewtWidget *widget;
|
||||
NMConnection *conn;
|
||||
|
||||
conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (dsl));
|
||||
s_pppoe = nm_connection_get_setting_pppoe (conn);
|
||||
if (!s_pppoe) {
|
||||
nm_connection_add_setting (conn, nm_setting_pppoe_new ());
|
||||
s_pppoe = nm_connection_get_setting_pppoe (conn);
|
||||
}
|
||||
|
||||
section = nmt_editor_section_new (_("DSL"), NULL, TRUE);
|
||||
grid = nmt_editor_section_get_body (section);
|
||||
|
|
@ -82,15 +83,59 @@ nmt_page_dsl_constructed (GObject *object)
|
|||
widget, "text",
|
||||
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
static void
|
||||
nmt_page_dsl_constructed (GObject *object)
|
||||
{
|
||||
NmtPageDsl *dsl = NMT_PAGE_DSL (object);
|
||||
NmtPageDslPrivate *priv = NMT_PAGE_DSL_GET_PRIVATE (dsl);
|
||||
NMConnection *conn;
|
||||
NMSettingPppoe *s_pppoe;
|
||||
NmtEditorSection *section;
|
||||
const GSList *sections, *iter;
|
||||
|
||||
conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (dsl));
|
||||
s_pppoe = nm_connection_get_setting_pppoe (conn);
|
||||
if (!s_pppoe) {
|
||||
nm_connection_add_setting (conn, nm_setting_pppoe_new ());
|
||||
s_pppoe = nm_connection_get_setting_pppoe (conn);
|
||||
}
|
||||
|
||||
section = build_dsl_section (dsl, s_pppoe);
|
||||
nmt_editor_page_add_section (NMT_EDITOR_PAGE (dsl), section);
|
||||
|
||||
priv->ethernet_page = nmt_page_ethernet_new (conn, nmt_editor_page_device_get_device_entry (NMT_EDITOR_PAGE_DEVICE (dsl)));
|
||||
sections = nmt_editor_page_get_sections (priv->ethernet_page);
|
||||
for (iter = sections; iter; iter = iter->next)
|
||||
nmt_editor_page_add_section (NMT_EDITOR_PAGE (dsl), iter->data);
|
||||
|
||||
priv->ppp_page = nmt_page_ppp_new (conn);
|
||||
sections = nmt_editor_page_get_sections (priv->ppp_page);
|
||||
for (iter = sections; iter; iter = iter->next)
|
||||
nmt_editor_page_add_section (NMT_EDITOR_PAGE (dsl), iter->data);
|
||||
|
||||
G_OBJECT_CLASS (nmt_page_dsl_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nmt_page_dsl_finalize (GObject *object)
|
||||
{
|
||||
NmtPageDsl *dsl = NMT_PAGE_DSL (object);
|
||||
NmtPageDslPrivate *priv = NMT_PAGE_DSL_GET_PRIVATE (dsl);
|
||||
|
||||
g_clear_object (&priv->ethernet_page);
|
||||
g_clear_object (&priv->ppp_page);
|
||||
|
||||
G_OBJECT_CLASS (nmt_page_dsl_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nmt_page_dsl_class_init (NmtPageDslClass *dsl_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (dsl_class);
|
||||
|
||||
object_class->constructed = nmt_page_dsl_constructed;
|
||||
object_class->finalize = nmt_page_dsl_finalize;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NMT_PAGE_DSL_H
|
||||
#define NMT_PAGE_DSL_H
|
||||
|
||||
#include "nmt-editor-page.h"
|
||||
#include "nmt-editor-page-device.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
@ -31,18 +31,19 @@ G_BEGIN_DECLS
|
|||
#define NMT_PAGE_DSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMT_TYPE_PAGE_DSL, NmtPageDslClass))
|
||||
|
||||
typedef struct {
|
||||
NmtEditorPage parent;
|
||||
NmtEditorPageDevice parent;
|
||||
|
||||
} NmtPageDsl;
|
||||
|
||||
typedef struct {
|
||||
NmtEditorPageClass parent;
|
||||
NmtEditorPageDeviceClass parent;
|
||||
|
||||
} NmtPageDslClass;
|
||||
|
||||
GType nmt_page_dsl_get_type (void);
|
||||
|
||||
NmtEditorPage *nmt_page_dsl_new (NMConnection *conn);
|
||||
NmtEditorPage *nmt_page_dsl_new (NMConnection *conn,
|
||||
NmtDeviceEntry *deventry);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue