diff --git a/gtk/profile_dlg.c b/gtk/profile_dlg.c index d554abfc01..b127346bd3 100644 --- a/gtk/profile_dlg.c +++ b/gtk/profile_dlg.c @@ -258,6 +258,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy) while (fl1) { found = FALSE; profile1 = (profile_def *) fl1->data; + g_strstrip(profile1->name); if (profile1->status == PROF_STAT_NEW) { /* We do not create a directory for the default profile */ if (strcmp(profile1->name, DEFAULT_PROFILE)!=0) { @@ -536,28 +537,38 @@ profile_name_te_changed_cb(GtkWidget *w, gpointer data _U_) if (strlen(name) > 0 && profile) { if (profile->status != PROF_STAT_DEFAULT) { + gboolean revert = FALSE; #ifdef _WIN32 char *invalid_dir_char = "\\/:*?\"<>|"; int i; for (i = 0; i < 9; i++) { if (strchr(name, invalid_dir_char[i])) { /* Invalid character in directory */ - gtk_entry_set_text(GTK_ENTRY(name_te), profile->name); - return; + revert = TRUE; } } +#else + if (strchr(name, '/')) { + /* Invalid character in directory */ + revert = TRUE; + } #endif - if (name[0] == ' ' || name[strlen(name)-1] == ' ') { - /* Profile name cannot start or end with space */ + if (name[0] == ' ') { + /* Profile name cannot start with space */ + revert = TRUE; + } + if (revert) { + gint pos = gtk_editable_get_position(GTK_EDITABLE(name_te)); gtk_entry_set_text(GTK_ENTRY(name_te), profile->name); - return; + gtk_editable_set_position(GTK_EDITABLE(name_te), pos - 1); + } else { + g_free(profile->name); + profile->name = g_strdup(name); + if (profile->status != PROF_STAT_NEW) { + profile->status = PROF_STAT_CHANGED; + } + gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, name, -1); } - g_free(profile->name); - profile->name = g_strdup(name); - if (profile->status != PROF_STAT_NEW) { - profile->status = PROF_STAT_CHANGED; - } - gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, name, -1); } } } @@ -741,9 +752,9 @@ profile_dialog_new(void) OBJECT_SET_DATA(main_w, E_PROF_NAME_TE_KEY, name_te); SIGNAL_CONNECT(name_te, "changed", profile_name_te_changed_cb, NULL); #ifdef _WIN32 - gtk_tooltips_set_tip (tooltips, name_te, "A profile name cannot start or end with a space, and cannot contain any of the following characters: \\ / : * ? \" < > |", NULL); + gtk_tooltips_set_tip (tooltips, name_te, "A profile name cannot start with a space, and cannot contain any of the following characters:\n \\ / : * ? \" < > |", NULL); #else - gtk_tooltips_set_tip (tooltips, name_te, "A profile name cannot start or end with a space", NULL); + gtk_tooltips_set_tip (tooltips, name_te, "A profile name cannot start with a space or contain '/'", NULL); #endif gtk_widget_show(name_te);