Ethereal-dev: [Ethereal-dev] last_open_dir usage incorrect
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Gilbert Ramirez <gilramir@xxxxxxxxx>
Date: Mon, 09 Apr 2001 16:29:48 -0500
I noticed the following problem when using Ethereal with gtk+-1.2.9 on Linux. If I do a File|Open and then do a File|Save As, the directory shown in the file-selection dialogue for "Save As" is the *parent* directory of the directory from where I opened the file. I don't remember this happening before. The following patch fixes it by appending a "/" to the directory passed to the file section dialogue, but does this happen for anyone that's using an earlier version of gtk+ ? --gilbert
? debugdata.gz ? tcpdump_log ? http.cap ? small.cap ? test.grj ? dir.diff ? problems1.cap ? problems2.cap ? problems3.cap Index: gtk/file_dlg.c =================================================================== RCS file: /usr/local/cvsroot/ethereal/gtk/file_dlg.c,v retrieving revision 1.36 diff -u -r1.36 gtk/file_dlg.c --- gtk/file_dlg.c 2001/02/01 20:21:21 1.36 +++ gtk/file_dlg.c 2001/04/09 21:27:02 @@ -48,6 +48,7 @@ #include "file_dlg.h" #include "dlg_utils.h" #include "util.h" +#include "main.h" static void file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs); static void file_open_destroy_cb(GtkWidget *win, gpointer user_data); @@ -92,7 +93,7 @@ /* If we've opened a file, start out by showing the files in the directory in which that file resided. */ if (last_open_dir) - gtk_file_selection_complete(GTK_FILE_SELECTION(file_open_w), last_open_dir); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_open_w), last_open_dir); resolv_cb = dlg_check_button_new_with_label_with_mnemonic( "Enable name resolution", NULL); @@ -165,9 +166,8 @@ if (test_for_directory(cf_name) == EISDIR) { /* It's a directory - set the file selection box to display that directory, don't try to open the directory as a capture file. */ - g_free(last_open_dir); - last_open_dir = cf_name; - gtk_file_selection_complete(GTK_FILE_SELECTION(fs), last_open_dir); + set_last_open_dir(cf_name); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(fs), last_open_dir); return; } @@ -218,24 +218,7 @@ if any; we can write over cf_name, which is a good thing, given that "get_dirname()" does write over its argument. */ s = get_dirname(cf_name); - if (s != NULL) { - /* Well, there is a directory in there... */ - if (last_open_dir != NULL) { - /* ...and we already have one saved... */ - if (strcmp(last_open_dir, s) != 0) { - /* ...and it's not the same as this one, so free the old one - and assign a copy of the new one to it. */ - g_free(last_open_dir); - last_open_dir = g_strdup(s); - } - } else { - /* ...and we don't already have one saved, so just save this one. */ - last_open_dir = g_strdup(s); - } - } else { - /* There was no directory in there. */ - last_open_dir = NULL; - } + set_last_open_dir(s); g_free(cf_name); } @@ -418,7 +401,7 @@ /* If we've opened a file, start out by showing the files in the directory in which that file resided. */ if (last_open_dir) - gtk_file_selection_complete(GTK_FILE_SELECTION(file_save_as_w), last_open_dir); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_save_as_w), last_open_dir); /* Connect the ok_button to file_save_as_ok_cb function and pass along a pointer to the file selection box widget */ Index: gtk/main.c =================================================================== RCS file: /usr/local/cvsroot/ethereal/gtk/main.c,v retrieving revision 1.189 diff -u -r1.189 gtk/main.c --- gtk/main.c 2001/04/05 05:58:05 1.189 +++ gtk/main.c 2001/04/09 21:27:02 @@ -1287,8 +1287,7 @@ good thing, given that "get_dirname()" does write over its argument. */ s = get_dirname(cf_name); - if (s != NULL) - last_open_dir = s; + set_last_open_dir(s); } else { if (rfcode != NULL) dfilter_free(rfcode); @@ -1690,3 +1689,23 @@ gtk_widget_show(top_level); } + +void +set_last_open_dir(char *dirname) +{ + int len; + + if (last_open_dir) { + g_free(last_open_dir); + } + + if (dirname) { + len = strlen(dirname); + if (dirname[len-1] != '/') { + last_open_dir = g_strconcat(dirname, "/", NULL); + } + } + else { + last_open_dir = NULL; + } +} Index: gtk/main.h =================================================================== RCS file: /usr/local/cvsroot/ethereal/gtk/main.h,v retrieving revision 1.21 diff -u -r1.21 gtk/main.h --- gtk/main.h 2001/03/02 23:10:12 1.21 +++ gtk/main.h 2001/04/09 21:27:02 @@ -65,5 +65,6 @@ char *boldify(const char *); void set_fonts(GdkFont *regular, GdkFont *bold); +void set_last_open_dir(char *dirname); #endif /* __MAIN_H__ */
- Prev by Date: Re: [Ethereal-dev] Ethereal IS-IS function calls ...
- Next by Date: Re: [Ethereal-dev] Small ntp fix
- Previous by thread: Re: [Ethereal-dev] Ethereal IS-IS function calls ...
- Next by thread: RE: [Ethereal-dev] last_open_dir usage incorrect
- Index(es):