aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-06-12 07:04:35 +0000
committerGuy Harris <guy@alum.mit.edu>1999-06-12 07:04:35 +0000
commit018a989bbe3ae6d979997030b86d3b86bad87f9f (patch)
tree66be0956f81eed20d8b54cf568b23d6c37d02789
parenta4005dff5e8d21a7fe8cfb036d3459e16884d2fe (diff)
Don't pop up the "Can't open preferences file" dialog until *after*
we've shown the top-level window, because we want it to pop up on *top* of the top-level window, rather than being hidden behind it. Put a "strerror()"-based reason *why* the open failed in that dialog. svn path=/trunk/; revision=308
-rw-r--r--ethereal.c22
-rw-r--r--prefs.c11
-rw-r--r--prefs.h4
3 files changed, 27 insertions, 10 deletions
diff --git a/ethereal.c b/ethereal.c
index 38e48a3b65..db13a53acf 100644
--- a/ethereal.c
+++ b/ethereal.c
@@ -1,6 +1,6 @@
/* ethereal.c
*
- * $Id: ethereal.c,v 1.36 1999/06/11 16:44:50 gram Exp $
+ * $Id: ethereal.c,v 1.37 1999/06/12 07:04:34 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -51,6 +51,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -546,6 +547,8 @@ main(int argc, char *argv[])
{
int opt, i;
extern char *optarg;
+ char *pf_path;
+ int pf_open_errno = 0;
GtkWidget *window, *main_vbox, *menubar, *u_pane, *l_pane,
*bv_table, *bv_hscroll, *bv_vscroll, *stat_hbox,
*tv_scrollw, *filter_bt, *filter_te;
@@ -571,7 +574,13 @@ main(int argc, char *argv[])
gtk_init (&argc, &argv);
- prefs = read_prefs();
+ prefs = read_prefs(&pf_path);
+ if (pf_path != NULL) {
+ /* The preferences file exists, but couldn't be opened; "pf_path" is
+ its pathname. Remember "errno", as that says why the attempt
+ failed. */
+ pf_open_errno = errno;
+ }
/* Initialize the capture file struct */
cf.plist = NULL;
@@ -888,6 +897,15 @@ main(int argc, char *argv[])
gtk_widget_show(window);
+ /* If we failed to open the preferences file, pop up an alert box;
+ we defer it until now, so that the alert box is more likely to
+ come up on top of the main window. */
+ if (pf_path != NULL) {
+ simple_dialog(ESD_TYPE_WARN, NULL,
+ "Can't open preferences file\n\"%s\": %s.", pf_path,
+ strerror(pf_open_errno));
+ }
+
gtk_main();
exit(0);
diff --git a/prefs.c b/prefs.c
index 4afa481779..45736e4dd2 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.16 1999/03/01 18:57:01 gram Exp $
+ * $Id: prefs.c,v 1.17 1999/06/12 07:04:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -274,7 +274,7 @@ print.file: /a/very/long/path/
#define MAX_VAL_LEN 1024
#define DEF_NUM_COLS 6
e_prefs *
-read_prefs() {
+read_prefs(char **pf_path_return) {
enum { START, IN_VAR, PRE_VAL, IN_VAL, IN_SKIP };
FILE *pf;
gchar cur_var[MAX_VAR_LEN], cur_val[MAX_VAL_LEN];
@@ -311,11 +311,10 @@ read_prefs() {
sprintf(pf_path, "%s/%s/%s", getenv("HOME"), PF_DIR, PF_NAME);
}
+ *pf_path_return = NULL;
if ((pf = fopen(pf_path, "r")) == NULL) {
- if (errno != ENOENT) {
- simple_dialog(ESD_TYPE_WARN, NULL,
- "Can't open preferences file\n\"%s\".", pf_path);
- }
+ if (errno != ENOENT)
+ *pf_path_return = pf_path;
return &prefs;
}
diff --git a/prefs.h b/prefs.h
index 2cd9343f4a..3e6348f999 100644
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
- * $Id: prefs.h,v 1.5 1998/11/17 04:29:11 gerald Exp $
+ * $Id: prefs.h,v 1.6 1999/06/12 07:04:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -49,6 +49,6 @@ typedef struct _e_prefs {
#define E_FILT_TE_PTR_KEY "filter_te_ptr"
void prefs_cb(GtkWidget *, gpointer);
-e_prefs* read_prefs();
+e_prefs* read_prefs(char **);
#endif /* prefs.h */