2002-07-10  Jody Goldberg <jody@gnome.org>

	http://bugzilla.gnome.org/show_bug.cgi?id=85929
	* gnome-network-preferences.c (extract_proxy_host) : validate.
	  This is not the prettiest way to do this, but it is effective.
This commit is contained in:
Jody Goldberg 2002-07-10 16:37:46 +00:00 committed by Jody Goldberg
parent 19558b6f24
commit fa081bdc60
4 changed files with 268 additions and 241 deletions

View file

@ -1,3 +1,9 @@
2002-07-10 Jody Goldberg <jody@gnome.org>
http://bugzilla.gnome.org/show_bug.cgi?id=85929
* gnome-network-preferences.c (extract_proxy_host) : validate.
This is not the prettiest way to do this, but it is effective.
2002-06-17 Jody Goldberg <jody@gnome.org>
* Release 2.0.0

View file

@ -28,6 +28,7 @@
#include <libgnome/libgnome.h>
#include <gconf/gconf-client.h>
#include <glade/glade.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include "capplet-util.h"
#include "gconf-property-editor.h"
@ -50,6 +51,29 @@ cb_dialog_response (GtkDialog *dialog, gint response_id)
gtk_main_quit ();
}
static GConfValue *
extract_proxy_host (GConfPropertyEditor *peditor, const GConfValue *orig)
{
char const *entered_text = gconf_value_get_string (orig);
GConfValue *res = NULL;
if (entered_text != NULL) {
GnomeVFSURI *uri = gnome_vfs_uri_new (entered_text);
if (uri != NULL) {
char const *host = gnome_vfs_uri_get_host_name (uri);
if (host != NULL) {
res = gconf_value_new (GCONF_VALUE_STRING);
gconf_value_set_string (res, host);
}
gnome_vfs_uri_unref (uri);
}
}
if (res != NULL)
return res;
return gconf_value_copy (orig);
}
static void
setup_dialog (GladeXML *dialog)
{
@ -60,7 +84,9 @@ setup_dialog (GladeXML *dialog)
gconf_peditor_widget_set_guard (peditor, WID ("host_port_table"));
peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_string (
NULL, PROXY_HOST_KEY, WID ("host_entry"), NULL));
NULL, PROXY_HOST_KEY, WID ("host_entry"),
"conv-from-widget-cb", extract_proxy_host,
NULL));
peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_integer (
NULL, PROXY_PORT_KEY, WID ("port_entry"), NULL));
@ -84,6 +110,7 @@ main (int argc, char **argv)
{
GladeXML *dialog;
GConfClient *client;
GtkWidget *widget;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@ -101,8 +128,9 @@ main (int argc, char **argv)
"network_dialog", NULL);
setup_dialog (dialog);
gtk_widget_show_all (WID ("network_dialog"));
widget = WID ("network_dialog");
capplet_set_icon (widget, "gnome-globe.png");
gtk_widget_show_all (widget);
gtk_main ();
g_object_unref (client);

View file

@ -1,6 +1,6 @@
[Desktop Entry]
_Name=Network
_Comment=Network Preferences
_Name=Network Proxy
_Comment=Network Proxy Preferences
Exec=gnome-network-preferences
Icon=gnome-globe.png
Terminal=0

View file

@ -4,7 +4,7 @@
<glade-interface>
<widget class="GtkDialog" id="network_dialog">
<property name="title" translatable="yes">Network Preferences</property>
<property name="title" translatable="yes">Network Proxy Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@ -45,6 +45,7 @@
<widget class="GtkButton" id="button3">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
@ -61,14 +62,6 @@
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<property name="border_width">4</property>
<property name="visible">True</property>
<property name="label" translatable="yes">HTTP Proxy Settings</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkVBox" id="vbox12">
<property name="border_width">8</property>
@ -116,6 +109,7 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">host_entry</property>
</widget>
<packing>
<property name="left_attach">0</property>
@ -157,10 +151,11 @@
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">port_entry</property>
</widget>
<packing>
<property name="left_attach">0</property>
@ -204,7 +199,7 @@
<widget class="GtkCheckButton" id="proxy_auth_toggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Pro_xy requires a username and password</property>
<property name="label" translatable="yes">Pro_xy requires username and password</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
@ -326,8 +321,6 @@
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>