network: Add option for connection sharing
Introduce a new IP{4,6} config method to allow sharing the default network (usually the Internet) through the wired interface. This is needed because the control-panel is lacking this feature backed by nm and currently the only way to enable the connection sharing is by using nm-connection-editor.
This commit is contained in:
parent
408f2775ec
commit
dfb54d0cad
4 changed files with 57 additions and 3 deletions
|
@ -53,6 +53,7 @@ struct _CEPageIP4
|
||||||
GtkBox *routes_box;
|
GtkBox *routes_box;
|
||||||
GtkSizeGroup *routes_metric_sizegroup;
|
GtkSizeGroup *routes_metric_sizegroup;
|
||||||
GtkSizeGroup *routes_sizegroup;
|
GtkSizeGroup *routes_sizegroup;
|
||||||
|
GtkRadioButton *shared_radio;
|
||||||
|
|
||||||
NMSettingIPConfig *setting;
|
NMSettingIPConfig *setting;
|
||||||
|
|
||||||
|
@ -85,7 +86,8 @@ method_changed (CEPageIP4 *self)
|
||||||
gboolean dns_enabled;
|
gboolean dns_enabled;
|
||||||
gboolean routes_enabled;
|
gboolean routes_enabled;
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->disabled_radio))) {
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->disabled_radio)) ||
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->shared_radio))) {
|
||||||
addr_enabled = FALSE;
|
addr_enabled = FALSE;
|
||||||
dns_enabled = FALSE;
|
dns_enabled = FALSE;
|
||||||
routes_enabled = FALSE;
|
routes_enabled = FALSE;
|
||||||
|
@ -521,6 +523,11 @@ connect_ip4_page (CEPageIP4 *self)
|
||||||
self->content_box, "sensitive",
|
self->content_box, "sensitive",
|
||||||
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (self->shared_radio, "notify::active", G_CALLBACK (ce_page_changed), self);
|
||||||
|
g_object_bind_property (self->shared_radio, "active",
|
||||||
|
self->content_box, "sensitive",
|
||||||
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
||||||
|
|
||||||
method = IP4_METHOD_AUTO;
|
method = IP4_METHOD_AUTO;
|
||||||
if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) {
|
if (g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0) {
|
||||||
method = IP4_METHOD_LINK_LOCAL;
|
method = IP4_METHOD_LINK_LOCAL;
|
||||||
|
@ -551,6 +558,9 @@ connect_ip4_page (CEPageIP4 *self)
|
||||||
case IP4_METHOD_MANUAL:
|
case IP4_METHOD_MANUAL:
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->manual_radio), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->manual_radio), TRUE);
|
||||||
break;
|
break;
|
||||||
|
case IP4_METHOD_SHARED:
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->shared_radio), TRUE);
|
||||||
|
break;
|
||||||
case IP4_METHOD_DISABLED:
|
case IP4_METHOD_DISABLED:
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->disabled_radio), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->disabled_radio), TRUE);
|
||||||
break;
|
break;
|
||||||
|
@ -612,6 +622,8 @@ ui_to_setting (CEPageIP4 *self)
|
||||||
method = NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL;
|
method = NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL;
|
||||||
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->manual_radio)))
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->manual_radio)))
|
||||||
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
|
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
|
||||||
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->shared_radio)))
|
||||||
|
method = NM_SETTING_IP4_CONFIG_METHOD_SHARED;
|
||||||
|
|
||||||
addresses = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip_address_unref);
|
addresses = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip_address_unref);
|
||||||
if (g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
|
if (g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
|
||||||
|
@ -887,6 +899,7 @@ ce_page_ip4_class_init (CEPageIP4Class *klass)
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_box);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_box);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_metric_sizegroup);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_metric_sizegroup);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_sizegroup);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, routes_sizegroup);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP4, shared_radio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct _CEPageIP6
|
||||||
GtkBox *routes_box;
|
GtkBox *routes_box;
|
||||||
GtkSizeGroup *routes_metric_sizegroup;
|
GtkSizeGroup *routes_metric_sizegroup;
|
||||||
GtkSizeGroup *routes_sizegroup;
|
GtkSizeGroup *routes_sizegroup;
|
||||||
|
GtkRadioButton *shared_radio;
|
||||||
|
|
||||||
NMSettingIPConfig *setting;
|
NMSettingIPConfig *setting;
|
||||||
|
|
||||||
|
@ -88,7 +89,8 @@ method_changed (CEPageIP6 *self)
|
||||||
gboolean dns_enabled;
|
gboolean dns_enabled;
|
||||||
gboolean routes_enabled;
|
gboolean routes_enabled;
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->disabled_radio))) {
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->disabled_radio)) ||
|
||||||
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->shared_radio))) {
|
||||||
addr_enabled = FALSE;
|
addr_enabled = FALSE;
|
||||||
dns_enabled = FALSE;
|
dns_enabled = FALSE;
|
||||||
routes_enabled = FALSE;
|
routes_enabled = FALSE;
|
||||||
|
@ -482,6 +484,11 @@ connect_ip6_page (CEPageIP6 *self)
|
||||||
self->content_box, "sensitive",
|
self->content_box, "sensitive",
|
||||||
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (self->shared_radio, "notify::active", G_CALLBACK (ce_page_changed), self);
|
||||||
|
g_object_bind_property (self->shared_radio, "active",
|
||||||
|
self->content_box, "sensitive",
|
||||||
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
||||||
|
|
||||||
method = IP6_METHOD_AUTO;
|
method = IP6_METHOD_AUTO;
|
||||||
if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
|
if (g_strcmp0 (str_method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
|
||||||
method = IP6_METHOD_DHCP;
|
method = IP6_METHOD_DHCP;
|
||||||
|
@ -519,6 +526,9 @@ connect_ip6_page (CEPageIP6 *self)
|
||||||
case IP6_METHOD_MANUAL:
|
case IP6_METHOD_MANUAL:
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->manual_radio), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->manual_radio), TRUE);
|
||||||
break;
|
break;
|
||||||
|
case IP6_METHOD_SHARED:
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->shared_radio), TRUE);
|
||||||
|
break;
|
||||||
case IP6_METHOD_IGNORE:
|
case IP6_METHOD_IGNORE:
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->disabled_radio), TRUE);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->disabled_radio), TRUE);
|
||||||
break;
|
break;
|
||||||
|
@ -552,6 +562,8 @@ ui_to_setting (CEPageIP6 *self)
|
||||||
method = NM_SETTING_IP6_CONFIG_METHOD_DHCP;
|
method = NM_SETTING_IP6_CONFIG_METHOD_DHCP;
|
||||||
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->automatic_radio)))
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->automatic_radio)))
|
||||||
method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
||||||
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->shared_radio)))
|
||||||
|
method = NM_SETTING_IP6_CONFIG_METHOD_SHARED;
|
||||||
|
|
||||||
nm_setting_ip_config_clear_addresses (self->setting);
|
nm_setting_ip_config_clear_addresses (self->setting);
|
||||||
if (g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
|
if (g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
|
||||||
|
@ -810,6 +822,7 @@ ce_page_ip6_class_init (CEPageIP6Class *klass)
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_box);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_box);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_metric_sizegroup);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_metric_sizegroup);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_sizegroup);
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, routes_sizegroup);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, CEPageIP6, shared_radio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -92,6 +92,20 @@
|
||||||
<property name="left-attach">2</property>
|
<property name="left-attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="shared_radio">
|
||||||
|
<property name="label" translatable="yes">Shared to other computers</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<property name="group">automatic_radio</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">2</property>
|
||||||
|
<property name="left-attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="content_box">
|
<object class="GtkBox" id="content_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -397,7 +411,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top-attach">2</property>
|
<property name="top-attach">3</property>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
<property name="width">3</property>
|
<property name="width">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
|
|
|
@ -106,6 +106,20 @@
|
||||||
<property name="left-attach">1</property>
|
<property name="left-attach">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="shared_radio">
|
||||||
|
<property name="label" translatable="yes">Shared to other computers</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<property name="group">automatic_radio</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top-attach">2</property>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="content_box">
|
<object class="GtkBox" id="content_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue