Commit 137ec047 authored by Jiří Klimeš's avatar Jiří Klimeš
Browse files

editor: allow editing connection priority (bgo #774107)

https://bugzilla.gnome.org/show_bug.cgi?id=774107
parent 75cac9f9
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.4"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">-999</property>
<property name="upper">999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="dependent_vpn_model">
<columns>
<!-- column-name gchararray -->
......@@ -13,7 +19,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="n_rows">5</property>
<property name="n_rows">6</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
......@@ -26,8 +32,8 @@
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
......@@ -47,8 +53,8 @@
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"/>
</packing>
</child>
......@@ -63,8 +69,8 @@
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
......@@ -82,6 +88,51 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="autoconnect_prio_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Connection _priority for auto-activation:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">autoconnect_prio</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="autoconnect_prio">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Connection priority for automatic activation. Connections with higher numbers are preferred when selecting profiles for automatic activation. Default value is 0.</property>
<property name="invisible_char"></property>
<property name="text">0</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">12</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
......@@ -116,8 +167,8 @@
</child>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
</packing>
</child>
</object>
......
......@@ -43,6 +43,8 @@ typedef struct {
GtkListStore *dependent_vpn_store;
GtkWidget *autoconnect;
GtkWidget *autoconnect_prio_label;
GtkSpinButton *autoconnect_prio;
GtkWidget *all_checkbutton;
gboolean setup_finished;
......@@ -163,6 +165,8 @@ general_private_init (CEPageGeneral *self)
priv->dependent_vpn_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "dependent_vpn_model"));
priv->autoconnect = GTK_WIDGET (gtk_builder_get_object (builder, "connection_autoconnect"));
priv->autoconnect_prio_label = GTK_WIDGET (gtk_builder_get_object (builder, "autoconnect_prio_label"));
priv->autoconnect_prio = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "autoconnect_prio"));
priv->all_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "system_checkbutton"));
}
......@@ -197,6 +201,16 @@ vpn_checkbox_toggled (GtkToggleButton *button, gpointer user_data)
ce_page_changed (CE_PAGE (user_data));
}
static void
autoconnect_checkbox_toggled (GtkToggleButton *button, gpointer user_data)
{
CEPageGeneralPrivate *priv = CE_PAGE_GENERAL_GET_PRIVATE (user_data);
gtk_widget_set_sensitive (GTK_WIDGET (priv->autoconnect_prio),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->autoconnect)));
ce_page_changed (CE_PAGE (user_data));
}
static void
populate_firewall_zones_ui (CEPageGeneral *self)
{
......@@ -283,12 +297,19 @@ populate_ui (CEPageGeneral *self)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autoconnect),
nm_setting_connection_get_autoconnect (priv->setting));
/* Connection priority */
gtk_spin_button_set_value (priv->autoconnect_prio,
nm_setting_connection_get_autoconnect_priority(priv->setting));
/* VPN connections don't have a blanket "autoconnect" as that is too coarse
* a behavior, instead the user configures another connection to start the
* VPN on success.
*/
if (priv->is_vpn)
if (priv->is_vpn) {
gtk_widget_hide (priv->autoconnect);
gtk_widget_hide (priv->autoconnect_prio_label);
gtk_widget_hide (GTK_WIDGET (priv->autoconnect_prio));
}
/* 'All users may connect to this network' checkbox */
if (nm_setting_connection_get_num_permissions (priv->setting))
......@@ -319,7 +340,9 @@ finish_setup (CEPageGeneral *self, gpointer unused, GError *error, gpointer user
gtk_widget_set_sensitive (GTK_WIDGET (priv->dependent_vpn), any_dependent_vpn);
g_signal_connect (priv->dependent_vpn, "changed", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->autoconnect, "toggled", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->autoconnect, "toggled", G_CALLBACK (autoconnect_checkbox_toggled), self);
g_signal_connect (priv->autoconnect_prio, "value-changed", G_CALLBACK (stuff_changed), self);
gtk_widget_set_sensitive (GTK_WIDGET (priv->autoconnect_prio), nm_setting_connection_get_autoconnect (priv->setting));
g_signal_connect (priv->all_checkbutton, "toggled", G_CALLBACK (stuff_changed), self);
}
......@@ -371,6 +394,7 @@ ui_to_setting (CEPageGeneral *self)
char *uuid = NULL;
GtkTreeIter iter;
gboolean autoconnect = FALSE, everyone = FALSE;
int prio;
/* We can't take and save zone until the combo was properly initialized. Zones
* are received from FirewallD asynchronously; got_zones indicates we are ready.
......@@ -396,7 +420,11 @@ ui_to_setting (CEPageGeneral *self)
g_free (uuid);
autoconnect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->autoconnect));
g_object_set (G_OBJECT (priv->setting), NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect, NULL);
prio = gtk_spin_button_get_value_as_int (priv->autoconnect_prio);
g_object_set (G_OBJECT (priv->setting),
NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect,
NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, prio,
NULL);
/* Handle visibility */
everyone = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->all_checkbutton));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment