diff --git a/ChangeLog b/ChangeLog index 53c6c80b7..1a94aa6bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-04-19 Mark McLoughlin + + * capplets/Makefile.am, configure.in: add + capplets/gnome-network-preferences. + 2002-04-21 Rachel Hestilow * *.c: s/Richard/Rachel diff --git a/capplets/Makefile.am b/capplets/Makefile.am index 305511a82..8b04406d4 100644 --- a/capplets/Makefile.am +++ b/capplets/Makefile.am @@ -3,6 +3,6 @@ always_built_SUBDIRS = \ desktop-links \ background keyboard mouse sound \ file-types theme-switcher ui-properties \ - keybindings + keybindings network SUBDIRS = $(always_built_SUBDIRS) diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index 84943c561..158e770b3 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,10 @@ +2002-04-19 Mark McLoughlin + + * gconf-property-editor.[ch]: (peditor_integer_value_changed), + (peditor_integer_widget_changed), (gconf_peditor_new_integer_valist), + (gconf_peditor_new_integer): implement GtkEntry based integer + peditor. + 2002-04-21 Rachel Hestilow * gconf-property-editor.c diff --git a/capplets/common/gconf-property-editor.c b/capplets/common/gconf-property-editor.c index 6f1268bd9..be96ed135 100644 --- a/capplets/common/gconf-property-editor.c +++ b/capplets/common/gconf-property-editor.c @@ -463,6 +463,102 @@ gconf_peditor_new_boolean (GConfChangeSet *changeset, return peditor; } +static void +peditor_integer_value_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + GConfPropertyEditor *peditor) +{ + GConfValue *value, *value_wid; + const char *entry_current_text; + int entry_current_integer; + + if (peditor->p->changeset != NULL) + gconf_change_set_remove (peditor->p->changeset, peditor->p->key); + + value = gconf_entry_get_value (entry); + + if (value != NULL) { + value_wid = peditor->p->conv_to_widget_cb (peditor, value); + entry_current_text = gtk_entry_get_text (GTK_ENTRY (peditor->p->ui_control)); + entry_current_integer = strtol (entry_current_text, NULL, 10); + if (entry_current_integer != gconf_value_get_int (value)) { + char *buf = g_strdup_printf ("%d", gconf_value_get_int (value_wid)); + gtk_entry_set_text (GTK_ENTRY (peditor->p->ui_control), buf); + g_free (buf); + } + gconf_value_free (value_wid); + } +} + +static void +peditor_integer_widget_changed (GConfPropertyEditor *peditor, + GtkEntry *entry) +{ + GConfValue *value, *value_wid; + + if (!peditor->p->inited) return; + + value_wid = gconf_value_new (GCONF_VALUE_INT); + + gconf_value_set_int (value_wid, strtol (gtk_entry_get_text (entry), NULL, 10)); + value = peditor->p->conv_from_widget_cb (peditor, value_wid); + + peditor_set_gconf_value (peditor, peditor->p->key, value); + + g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value); + gconf_value_free (value_wid); + gconf_value_free (value); +} + +static GObject * +gconf_peditor_new_integer_valist (GConfChangeSet *changeset, + gchar *key, + GtkWidget *entry, + gchar *first_property_name, + va_list var_args) +{ + GObject *peditor; + + peditor = gconf_peditor_new + (key, + (GConfClientNotifyFunc) peditor_integer_value_changed, + changeset, + G_OBJECT (entry), + first_property_name, + var_args, NULL); + + g_signal_connect_swapped (G_OBJECT (entry), "changed", + (GCallback) peditor_integer_widget_changed, peditor); + + return peditor; +} + +GObject * +gconf_peditor_new_integer (GConfChangeSet *changeset, + gchar *key, + GtkWidget *entry, + gchar *first_property_name, + ...) +{ + GObject *peditor; + va_list var_args; + + g_return_val_if_fail (key != NULL, NULL); + g_return_val_if_fail (entry != NULL, NULL); + g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL); + + va_start (var_args, first_property_name); + + peditor = gconf_peditor_new_integer_valist + (changeset, key, entry, + first_property_name, var_args); + + va_end (var_args); + + return peditor; +} + static void peditor_string_value_changed (GConfClient *client, guint cnxn_id, diff --git a/capplets/common/gconf-property-editor.h b/capplets/common/gconf-property-editor.h index c0e45cd91..136daacc1 100644 --- a/capplets/common/gconf-property-editor.h +++ b/capplets/common/gconf-property-editor.h @@ -83,6 +83,11 @@ GObject *gconf_peditor_new_enum_toggle (GConfChangeSet *changeset, gchar *first_property_name, ...); +GObject *gconf_peditor_new_integer (GConfChangeSet *changeset, + gchar *key, + GtkWidget *entry, + gchar *first_property_name, + ...); GObject *gconf_peditor_new_string (GConfChangeSet *changeset, gchar *key, GtkWidget *entry, diff --git a/capplets/network/Makefile.am b/capplets/network/Makefile.am new file mode 100644 index 000000000..589f84733 --- /dev/null +++ b/capplets/network/Makefile.am @@ -0,0 +1,18 @@ +bin_PROGRAMS = gnome-network-preferences + +gnome_network_preferences_SOURCES = gnome-network-preferences.c +gnome_network_preferences_LDADD = \ + $(GNOMECC_CAPPLETS_LIBS) + +@INTLTOOL_DESKTOP_RULE@ + +gladedir = $(GNOMECC_GLADE_DIR) +glade_DATA = gnome-network-preferences.glade + +desktopdir = $(GNOMECC_DESKTOP_DIR) +desktop_in_files = gnome-network-preferences.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) + +INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) +CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) +EXTRA_DIST = $(glade_DATA) $(desktop_in_files) diff --git a/capplets/network/gnome-network-preferences.c b/capplets/network/gnome-network-preferences.c new file mode 100644 index 000000000..3930647ae --- /dev/null +++ b/capplets/network/gnome-network-preferences.c @@ -0,0 +1,116 @@ + +/* gnome-network-preferences.c: network preferences capplet + * + * Copyright (C) 2002 Sun Microsystems Inc. + * + * Written by: Mark McLoughlin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include + +#include "capplet-util.h" +#include "gconf-property-editor.h" + +#define USE_PROXY_KEY "/system/gnome-vfs/use-http-proxy" +#define PROXY_HOST_KEY "/system/gnome-vfs/http-proxy-host" +#define PROXY_PORT_KEY "/system/gnome-vfs/http-proxy-port" +#define USE_AUTH_KEY "/system/gnome-vfs/use-http-proxy-authorization" +#define AUTH_USER_KEY "/system/gnome-vfs/http-proxy-authorization-user" +#define AUTH_PASSWD_KEY "/system/gnome-vfs/http-proxy-authorization-password" + +static void +dialog_response (GtkWidget *widget, + int response_id) +{ + switch (response_id) + { + case GTK_RESPONSE_CLOSE: + case GTK_RESPONSE_DELETE_EVENT: + default: + gtk_main_quit (); + break; + } +} + +static void +setup_dialog (GladeXML *dialog) +{ + GConfPropertyEditor *peditor; + + peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_boolean ( + NULL, USE_PROXY_KEY, WID ("proxy_toggle"), NULL)); + 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)); + + peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_integer ( + NULL, PROXY_PORT_KEY, WID ("port_entry"), NULL)); + + peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_boolean ( + NULL, USE_AUTH_KEY, WID ("proxy_auth_toggle"), NULL)); + gconf_peditor_widget_set_guard (peditor, WID ("username_password_table")); + + peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_string ( + NULL, AUTH_USER_KEY, WID ("user_entry"), NULL)); + + peditor = GCONF_PROPERTY_EDITOR (gconf_peditor_new_string ( + NULL, AUTH_PASSWD_KEY, WID ("passwd_entry"), NULL)); + + /* FIXME: remove when I fix libglade */ + gtk_entry_set_invisible_char (GTK_ENTRY (WID ("passwd_entry")), '*'); + + g_signal_connect (WID ("network_dialog"), "response", + G_CALLBACK (dialog_response), NULL); +} + +int +main (int argc, char **argv) +{ + GladeXML *dialog; + GConfClient *client; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + gnome_program_init (argv [0], VERSION, LIBGNOMEUI_MODULE, + argc, argv, GNOME_PARAM_NONE); + + client = gconf_client_get_default (); + gconf_client_add_dir (client, "/system/gnome-vfs", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-network-preferences.glade", + "network_dialog", NULL); + + setup_dialog (dialog); + + gtk_widget_show_all (WID ("network_dialog")); + gtk_main (); + + g_object_unref (client); + + return 0; +} diff --git a/capplets/network/gnome-network-preferences.desktop.in b/capplets/network/gnome-network-preferences.desktop.in new file mode 100644 index 000000000..935a46bca --- /dev/null +++ b/capplets/network/gnome-network-preferences.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +_Name=Network +_Comment=Network Preferences +Exec=gnome-network-preferences +Icon=gnome-networktool.png +Terminal=0 +Type=Application +Categories=Application;Settings; diff --git a/capplets/network/gnome-network-preferences.glade b/capplets/network/gnome-network-preferences.glade new file mode 100644 index 000000000..e6623d88e --- /dev/null +++ b/capplets/network/gnome-network-preferences.glade @@ -0,0 +1,329 @@ + + + + + + + Network Preferences + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + False + + Network Preferences + + + + + 2 + True + False + 8 + + + + 5 + True + GTK_BUTTONBOX_END + 10 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 4 + True + HTTP Proxy Settings + 0 + GTK_SHADOW_ETCHED_IN + + + + 8 + True + False + 2 + + + + True + True + _Use HTTP proxy + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + 2 + 2 + False + 4 + 4 + + + + True + _Location: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + P_ort: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + 0 + False + False + + + + + + True + True + Pro_xy requires a username and password + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + 2 + 2 + False + 4 + 4 + + + + True + User_name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + user_entry + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Pass_word: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + passwd_entry + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + True + True + False + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + + diff --git a/configure.in b/configure.in index 3f5be025d..8adf2a66f 100644 --- a/configure.in +++ b/configure.in @@ -207,6 +207,7 @@ capplets/theme-switcher/Makefile capplets/ui-properties/Makefile capplets/accessibility/Makefile capplets/accessibility/keyboard/Makefile +capplets/network/Makefile schemas/Makefile help/Makefile help/C/Makefile diff --git a/po/ChangeLog b/po/ChangeLog index bf2b7eba0..3132da069 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,8 @@ +2002-04-22 Mark McLoughlin + + * POTFILES.in: add network preferences capplet + files. + 2002-04-23 Abel Cheung * zh_TW.po: Recommit an error-free file. diff --git a/po/POTFILES.in b/po/POTFILES.in index d7a392125..bca15abc0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -84,6 +84,9 @@ capplets/wm-properties/wm-desktops/Scwm.desktop.in.in capplets/wm-properties/wm-desktops/twm.desktop.in.in capplets/wm-properties/wm-desktops/WindowMaker.desktop.in.in capplets/wm-properties/wm-properties-capplet.c +capplets/network/gnome-network-preferences.c +capplets/network/gnome-network-preferences.glade +capplets/network/gnome-network-preferences.desktop.in control-center/capplet-dir.c control-center/capplet-dir-view.c control-center/capplet-dir-view-list.c