network: Add an 'Ignore Hosts' entry to the proxy page
This is needed in many situations where proxies are set up manually. https://bugzilla.gnome.org/show_bug.cgi?id=658155
This commit is contained in:
parent
85dbe01725
commit
56f3f84e19
2 changed files with 86 additions and 0 deletions
|
@ -141,6 +141,12 @@ panel_proxy_mode_combo_setup_widgets (NetProxy *proxy, guint value)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
|
||||
"spinbutton_proxy_socks"));
|
||||
gtk_widget_set_visible (widget, value == 1);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
|
||||
"heading_proxy_ignore"));
|
||||
gtk_widget_set_visible (widget, value == 1);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
|
||||
"entry_proxy_ignore"));
|
||||
gtk_widget_set_visible (widget, value == 1);
|
||||
|
||||
/* perhaps show the wpad warning */
|
||||
check_wpad_warning (proxy);
|
||||
|
@ -250,6 +256,45 @@ net_proxy_class_init (NetProxyClass *klass)
|
|||
g_type_class_add_private (klass, sizeof (NetProxyPrivate));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_ignore_hosts (GValue *value,
|
||||
GVariant *variant,
|
||||
gpointer user_data)
|
||||
{
|
||||
int i;
|
||||
gsize n = 0, avlen;
|
||||
gchar buffer[10240];
|
||||
gchar *p = buffer;
|
||||
const gchar **av = g_variant_get_strv (variant, &avlen);
|
||||
|
||||
if (avlen > 0) {
|
||||
n = g_strlcpy (p, av[0], sizeof buffer);
|
||||
for (i = 1; i < avlen; i ++)
|
||||
n += g_snprintf (p + n, sizeof (buffer) - n, ", %s", av[i]);
|
||||
}
|
||||
g_free (av);
|
||||
g_value_set_string (value, buffer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
set_ignore_hosts (const GValue *value,
|
||||
const GVariantType *expected_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
GVariant *result;
|
||||
const gchar *sv;
|
||||
gchar **av;
|
||||
|
||||
sv = g_value_get_string (value);
|
||||
av = g_strsplit (sv, ",", 0);
|
||||
result = g_variant_new_strv ((const gchar * const *)av, -1);
|
||||
g_strfreev (av);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
net_proxy_init (NetProxy *proxy)
|
||||
{
|
||||
|
@ -369,6 +414,14 @@ net_proxy_init (NetProxy *proxy)
|
|||
"label_proxy_status"));
|
||||
gtk_label_set_label (GTK_LABEL (widget), "");
|
||||
|
||||
/* bind the proxy ignore hosts */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
|
||||
"entry_proxy_ignore"));
|
||||
g_settings_bind_with_mapping (proxy->priv->settings, "ignore-hosts",
|
||||
widget, "text",
|
||||
G_SETTINGS_BIND_DEFAULT, get_ignore_hosts, set_ignore_hosts,
|
||||
NULL, NULL);
|
||||
|
||||
/* hide the switch until we get some more detail in the mockup */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (proxy->priv->builder,
|
||||
"device_proxy_off_switch"));
|
||||
|
|
|
@ -279,6 +279,25 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_proxy_ignore">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">_Ignore Hosts</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">entry_proxy_ignore</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_proxy_warning">
|
||||
<property name="visible">True</property>
|
||||
|
@ -367,6 +386,20 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_proxy_ignore">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="width">2</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spinbutton_proxy_https">
|
||||
<property name="visible">True</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue