2006-02-15 Robert Love <rml@novell.com>

* gnome/vpn-properties/Makefile.am: Define SYSCONFDIR preprocessor
	  define to $sysconfdir.
	* gnome/vpn-properties/nm-vpn-properties.c: Make sure we hide the VPN
	  editing dialog, vpn_edit_widget, which fixes a bug where editing one
	  type of VPN and then editing another results in a mangled dialog
	  box containing the widgets from both VPNs (fixes Novell #150854).
	  Also, some misc. cleanup and use SYSCONFDIR not open coded directory.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1473 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Robert Love
2006-02-15 16:34:21 +00:00
committed by Robert Love
parent 7eb0e146b2
commit 22659f34a6
3 changed files with 39 additions and 49 deletions

View File

@@ -1,3 +1,13 @@
2006-02-15 Robert Love <rml@novell.com>
* gnome/vpn-properties/Makefile.am: Define SYSCONFDIR preprocessor
define to $sysconfdir.
* gnome/vpn-properties/nm-vpn-properties.c: Make sure we hide the VPN
editing dialog, vpn_edit_widget, which fixes a bug where editing one
type of VPN and then editing another results in a mangled dialog
box containing the widgets from both VPNs (fixes Novell #150854).
Also, some misc. cleanup and use SYSCONFDIR not open coded directory.
2006-02-14 Robert Love <rml@novell.com> 2006-02-14 Robert Love <rml@novell.com>
* src/NetworkManager.c: Call closelog() on daemon shutdown to close * src/NetworkManager.c: Call closelog() on daemon shutdown to close

View File

@@ -19,6 +19,7 @@ nm_vpn_properties_CFLAGS = \
$(GCONF_CFLAGS) \ $(GCONF_CFLAGS) \
$(GMODULE_CFLAGS) \ $(GMODULE_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \ $(LIBGNOMEUI_CFLAGS) \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DICONDIR=\""$(datadir)/pixmaps"\" \ -DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \ -DGLADEDIR=\""$(gladedir)"\" \
-DG_DISABLE_DEPRECATED \ -DG_DISABLE_DEPRECATED \

View File

@@ -48,7 +48,6 @@
static GladeXML *xml; static GladeXML *xml;
static GConfClient *gconf_client; static GConfClient *gconf_client;
static GtkWidget *dialog; static GtkWidget *dialog;
static GtkWindow *druid_window; static GtkWindow *druid_window;
static GtkTreeView *vpn_conn_view; static GtkTreeView *vpn_conn_view;
@@ -61,7 +60,6 @@ static GnomeDruidPageEdge *druid_confirm_page;
static GtkComboBox *vpn_type_combo_box; static GtkComboBox *vpn_type_combo_box;
static GtkVBox *vpn_type_details; static GtkVBox *vpn_type_details;
static GtkDialog *edit_dialog; static GtkDialog *edit_dialog;
static GSList *vpn_types; static GSList *vpn_types;
static NetworkManagerVpnUI * static NetworkManagerVpnUI *
@@ -152,16 +150,19 @@ add_vpn_connection (const char *conn_name, const char *service_name, GSList *con
/* routes */ /* routes */
gconf_key = g_strdup_printf ("%s/routes", conn_gconf_path); gconf_key = g_strdup_printf ("%s/routes", conn_gconf_path);
#if 0
{ {
/*
GSList *i; GSList *i;
i = NULL; i = NULL;
i = g_slist_append (i, "172.16.0.0/16"); i = g_slist_append (i, "172.16.0.0/16");
*/
gconf_client_set_list (gconf_client, gconf_key, GCONF_VALUE_STRING, routes, NULL); gconf_client_set_list (gconf_client, gconf_key, GCONF_VALUE_STRING, routes, NULL);
/*g_slist_free (i);*/ g_slist_free (i);
} }
#else
gconf_client_set_list (gconf_client, gconf_key, GCONF_VALUE_STRING, routes, NULL);
#endif
gconf_client_suggest_sync (gconf_client, NULL); gconf_client_suggest_sync (gconf_client, NULL);
@@ -262,8 +263,8 @@ static gboolean vpn_druid_vpn_type_page_next (GnomeDruidPage *druidpage,
} }
static void vpn_druid_vpn_details_page_prepare (GnomeDruidPage *druidpage, static void vpn_druid_vpn_details_page_prepare (GnomeDruidPage *druidpage,
GtkWidget *widget, GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, FALSE); gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, FALSE);
} }
@@ -281,9 +282,8 @@ static gboolean vpn_druid_vpn_details_page_next (GnomeDruidPage *druidpage,
/* validate input */ /* validate input */
vpn_ui = (NetworkManagerVpnUI *) g_slist_nth_data (vpn_types, gtk_combo_box_get_active (vpn_type_combo_box)); vpn_ui = (NetworkManagerVpnUI *) g_slist_nth_data (vpn_types, gtk_combo_box_get_active (vpn_type_combo_box));
if (vpn_ui != NULL) { if (vpn_ui != NULL)
is_valid = vpn_ui->is_valid (vpn_ui); is_valid = vpn_ui->is_valid (vpn_ui);
}
return !is_valid; return !is_valid;
} }
@@ -363,7 +363,6 @@ add_cb (GtkButton *button, gpointer user_data)
goto out; goto out;
} }
/* remove existing VPN widget */ /* remove existing VPN widget */
children = gtk_container_get_children (GTK_CONTAINER (vpn_type_details)); children = gtk_container_get_children (GTK_CONTAINER (vpn_type_details));
for (i = children; i != NULL; i = g_list_next (i)) { for (i = children; i != NULL; i = g_list_next (i)) {
@@ -441,9 +440,9 @@ import_settings (const char *svc_name, const char *name)
gtk_container_remove (GTK_CONTAINER (old_parent), w); gtk_container_remove (GTK_CONTAINER (old_parent), w);
gtk_container_add (GTK_CONTAINER (vpn_type_details), w); gtk_container_add (GTK_CONTAINER (vpn_type_details), w);
gtk_widget_unref (w); gtk_widget_unref (w);
gtk_widget_show_all (w); gtk_widget_show_all (w);
} }
vpn_ui->set_validity_changed_callback (vpn_ui, vpn_druid_vpn_validity_changed, NULL); vpn_ui->set_validity_changed_callback (vpn_ui, vpn_druid_vpn_validity_changed, NULL);
vpn_ui->import_file (vpn_ui, name); vpn_ui->import_file (vpn_ui, name);
@@ -642,7 +641,6 @@ edit_cb (GtkButton *button, gpointer user_data)
new_conn_routes = vpn_ui->get_routes (vpn_ui); new_conn_routes = vpn_ui->get_routes (vpn_ui);
if (strcmp (new_conn_name, conn_name) == 0) { if (strcmp (new_conn_name, conn_name) == 0) {
/* same name, just update properties and routes */ /* same name, just update properties and routes */
g_snprintf (key, sizeof (key), "%s/vpn_data", conn_gconf_path); g_snprintf (key, sizeof (key), "%s/vpn_data", conn_gconf_path);
gconf_client_set_list (gconf_client, key, GCONF_VALUE_STRING, new_conn_data, NULL); gconf_client_set_list (gconf_client, key, GCONF_VALUE_STRING, new_conn_data, NULL);
@@ -651,7 +649,6 @@ edit_cb (GtkButton *button, gpointer user_data)
gconf_client_suggest_sync (gconf_client, NULL); gconf_client_suggest_sync (gconf_client, NULL);
} else { } else {
/* remove old entry */ /* remove old entry */
g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path);
gconf_client_unset (gconf_client, key, NULL); gconf_client_unset (gconf_client, key, NULL);
@@ -681,10 +678,9 @@ edit_cb (GtkButton *button, gpointer user_data)
g_slist_foreach (new_conn_routes, (GFunc)g_free, NULL); g_slist_foreach (new_conn_routes, (GFunc)g_free, NULL);
g_slist_free (new_conn_routes); g_slist_free (new_conn_routes);
} }
} }
gtk_widget_hide (GTK_WIDGET (vpn_edit_widget));
gtk_widget_hide (GTK_WIDGET (edit_dialog)); gtk_widget_hide (GTK_WIDGET (edit_dialog));
out: out:
@@ -826,7 +822,7 @@ static void get_all_vpn_connections (void)
VPNCONN_USER_CAN_EDIT_COLUMN, conn_user_can_edit, VPNCONN_USER_CAN_EDIT_COLUMN, conn_user_can_edit,
-1); -1);
/* #if 0
printf ("conn_name = '%s'\n", conn_name); printf ("conn_name = '%s'\n", conn_name);
printf ("conn_service_name = '%s'\n", conn_service_name); printf ("conn_service_name = '%s'\n", conn_service_name);
printf ("conn_vpn_data = {"); printf ("conn_vpn_data = {");
@@ -839,7 +835,7 @@ static void get_all_vpn_connections (void)
} }
printf ("}\n"); printf ("}\n");
} }
*/ #endif
error: error:
g_free (vpn_conn->data); g_free (vpn_conn->data);
@@ -874,7 +870,6 @@ load_properties_module (GSList **vpn_types_list, const char *path)
if (!g_module_symbol (module, "nm_vpn_properties_factory", if (!g_module_symbol (module, "nm_vpn_properties_factory",
(gpointer) &nm_vpn_properties_factory)) { (gpointer) &nm_vpn_properties_factory)) {
g_warning ("Cannot locate function 'nm_vpn_properties_factory' in '%s': %s", g_warning ("Cannot locate function 'nm_vpn_properties_factory' in '%s': %s",
path, g_module_error ()); path, g_module_error ());
g_module_close (module); g_module_close (module);
@@ -894,7 +889,7 @@ out:
; ;
} }
#define VPN_NAME_FILES_DIR "/etc/NetworkManager/VPN" #define VPN_NAME_FILES_DIR SYSCONFDIR"/NetworkManager/VPN"
static gboolean static gboolean
init_app (void) init_app (void)
@@ -981,7 +976,6 @@ init_app (void)
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
GTK_SIGNAL_FUNC (close_cb), NULL); GTK_SIGNAL_FUNC (close_cb), NULL);
vpn_conn_view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "vpnlist")); vpn_conn_view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "vpnlist"));
vpn_conn_list = gtk_list_store_new (VPNCONN_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); vpn_conn_list = gtk_list_store_new (VPNCONN_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
@@ -1001,7 +995,6 @@ init_app (void)
gtk_tree_view_set_model (vpn_conn_view, GTK_TREE_MODEL (vpn_conn_list)); gtk_tree_view_set_model (vpn_conn_view, GTK_TREE_MODEL (vpn_conn_list));
gtk_tree_view_expand_all (vpn_conn_view); gtk_tree_view_expand_all (vpn_conn_view);
gtk_widget_show_all (dialog); gtk_widget_show_all (dialog);
/* fill in possibly choices in the druid when adding a connection */ /* fill in possibly choices in the druid when adding a connection */
@@ -1010,12 +1003,10 @@ init_app (void)
for (i = vpn_types; i != NULL; i = g_slist_next (i)) { for (i = vpn_types; i != NULL; i = g_slist_next (i)) {
NetworkManagerVpnUI *vpn_ui = i->data; NetworkManagerVpnUI *vpn_ui = i->data;
gtk_combo_box_append_text (vpn_type_combo_box, vpn_ui->get_display_name (vpn_ui)); gtk_combo_box_append_text (vpn_type_combo_box, vpn_ui->get_display_name (vpn_ui));
} }
gtk_combo_box_set_active (vpn_type_combo_box, 0); gtk_combo_box_set_active (vpn_type_combo_box, 0);
gtk_box_pack_end (GTK_BOX (vpn_type_hbox1), GTK_WIDGET (vpn_type_combo_box), TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (vpn_type_hbox1), GTK_WIDGET (vpn_type_combo_box), TRUE, TRUE, 0);
/* Druid */ /* Druid */
druid = GNOME_DRUID (glade_xml_get_widget (xml, "vpn-create-connection-druid")); druid = GNOME_DRUID (glade_xml_get_widget (xml, "vpn-create-connection-druid"));
gtk_signal_connect (GTK_OBJECT (druid), "cancel", GTK_SIGNAL_FUNC (vpn_druid_cancel), NULL); gtk_signal_connect (GTK_OBJECT (druid), "cancel", GTK_SIGNAL_FUNC (vpn_druid_cancel), NULL);
@@ -1031,14 +1022,11 @@ init_app (void)
gtk_signal_connect_after (GTK_OBJECT (w), "finish", GTK_SIGNAL_FUNC (vpn_druid_vpn_confirm_page_finish), NULL); gtk_signal_connect_after (GTK_OBJECT (w), "finish", GTK_SIGNAL_FUNC (vpn_druid_vpn_confirm_page_finish), NULL);
druid_window = GTK_WINDOW (glade_xml_get_widget (xml, "vpn-create-connection")); druid_window = GTK_WINDOW (glade_xml_get_widget (xml, "vpn-create-connection"));
/* reuse the widget */
gtk_signal_connect (GTK_OBJECT (druid_window), "delete-event",
GTK_SIGNAL_FUNC (gtk_widget_hide_on_delete), NULL);
/* make the druid window modal wrt. our main window */ /* make the druid window modal wrt. our main window */
gtk_window_set_modal (druid_window, TRUE); gtk_window_set_modal (druid_window, TRUE);
gtk_window_set_transient_for (druid_window, GTK_WINDOW (dialog)); gtk_window_set_transient_for (druid_window, GTK_WINDOW (dialog));
/* Edit dialog */ /* Edit dialog */
edit_dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Edit VPN Connection"), edit_dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Edit VPN Connection"),
NULL, NULL,
@@ -1048,9 +1036,6 @@ init_app (void)
GTK_STOCK_APPLY, GTK_STOCK_APPLY,
GTK_RESPONSE_ACCEPT, GTK_RESPONSE_ACCEPT,
NULL)); NULL));
/* reuse the widget */
gtk_signal_connect (GTK_OBJECT (edit_dialog), "delete-event",
GTK_SIGNAL_FUNC (gtk_widget_hide_on_delete), NULL);
/* update "Edit" and "Delete" for current selection */ /* update "Edit" and "Delete" for current selection */
update_edit_del_sensitivity (); update_edit_del_sensitivity ();
@@ -1058,23 +1043,21 @@ init_app (void)
return TRUE; return TRUE;
} }
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
GOptionContext *context; GOptionContext *context;
int ret = 1; int ret;
gboolean bad_opts; gboolean bad_opts;
gboolean do_import; gboolean do_import;
GError *error = NULL; GError *error = NULL;
static gchar *import_svc = NULL; gchar *import_svc = NULL;
static gchar *import_file = NULL; gchar *import_file = NULL;
static GOptionEntry entries[] = GOptionEntry entries[] = {
{
{ "import-service", 's', 0, G_OPTION_ARG_STRING, &import_svc, "VPN Service for importing", NULL}, { "import-service", 's', 0, G_OPTION_ARG_STRING, &import_svc, "VPN Service for importing", NULL},
{ "import-file", 'f', 0, G_OPTION_ARG_STRING, &import_file, "File to import", NULL}, { "import-file", 'f', 0, G_OPTION_ARG_STRING, &import_file, "File to import", NULL},
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
}; };
bindtextdomain (GETTEXT_PACKAGE, NULL); bindtextdomain (GETTEXT_PACKAGE, NULL);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -1088,19 +1071,16 @@ main (int argc, char *argv[])
bad_opts = FALSE; bad_opts = FALSE;
do_import = FALSE; do_import = FALSE;
if (import_svc != NULL) { if (import_svc != NULL) {
if (import_file != NULL) { if (import_file != NULL)
do_import = TRUE; do_import = TRUE;
} else { else
bad_opts = TRUE; bad_opts = TRUE;
} } else if (import_file != NULL)
} else {
if (import_file != NULL) {
bad_opts = TRUE; bad_opts = TRUE;
}
}
if (bad_opts) { if (bad_opts) {
fprintf (stderr, "Have to supply both service and file\n"); fprintf (stderr, "Have to supply both service and file\n");
ret = EXIT_FAILURE;
goto out; goto out;
} }
@@ -1110,17 +1090,16 @@ main (int argc, char *argv[])
glade_gnome_init (); glade_gnome_init ();
if (init_app () == FALSE) { if (init_app () == FALSE) {
ret = 1; ret = EXIT_FAILURE;
goto out; goto out;
} }
if (do_import) { if (do_import)
import_settings (import_svc, import_file); import_settings (import_svc, import_file);
}
gtk_main (); gtk_main ();
ret = 0; ret = EXIT_SUCCESS;
out: out:
return ret; return ret;