aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/profile_dlg.c
diff options
context:
space:
mode:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2008-02-01 18:42:59 +0000
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2008-02-01 18:42:59 +0000
commit529278ddcd35aa63c8acbe1f8c6478c03dba333b (patch)
tree43361be784755ce13e9677dd5934fc0d71ccc336 /gtk/profile_dlg.c
parent29f357db13b8575becfa8f60345c0dcd490ce2b2 (diff)
Disallow ending space was not such a good idea, chop it of before save instead.
Also disallow '/' in profilename for !win32. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24243 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk/profile_dlg.c')
-rw-r--r--gtk/profile_dlg.c37
1 files changed, 24 insertions, 13 deletions
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 */
- gtk_entry_set_text(GTK_ENTRY(name_te), profile->name);
- return;
+ if (name[0] == ' ') {
+ /* Profile name cannot start with space */
+ revert = TRUE;
}
- g_free(profile->name);
- profile->name = g_strdup(name);
- if (profile->status != PROF_STAT_NEW) {
- profile->status = PROF_STAT_CHANGED;
+ if (revert) {
+ gint pos = gtk_editable_get_position(GTK_EDITABLE(name_te));
+ gtk_entry_set_text(GTK_ENTRY(name_te), profile->name);
+ 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);
}
- 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);