moved window geometry values from prefs to recent,
added new pref / recent setting: "maximized main window", which will save, if the main window is maximized or not, this will take effect on GTK version 2 only, but is saved nonetheless svn path=/trunk/; revision=9949
This commit is contained in:
parent
5ed2dfc130
commit
d11080a09f
|
@ -1,7 +1,7 @@
|
|||
/* file_dlg.c
|
||||
* Dialog boxes for handling files
|
||||
*
|
||||
* $Id: file_dlg.c,v 1.90 2004/01/31 18:32:36 ulfl Exp $
|
||||
* $Id: file_dlg.c,v 1.91 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -44,6 +44,7 @@
|
|||
#include "main.h"
|
||||
#include "compat_macros.h"
|
||||
#include "prefs.h"
|
||||
#include "recent.h"
|
||||
#include "color.h"
|
||||
#include "../ui_util.h"
|
||||
#include "gtk/color_filters.h"
|
||||
|
@ -249,9 +250,9 @@ file_open_cmd(GtkWidget *w)
|
|||
last_open_dir);
|
||||
}
|
||||
else {
|
||||
if (prefs.gui_fileopen_remembered_dir != NULL) {
|
||||
if (recent.gui_fileopen_remembered_dir != NULL) {
|
||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_open_w),
|
||||
prefs.gui_fileopen_remembered_dir);
|
||||
recent.gui_fileopen_remembered_dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* gui_prefs.c
|
||||
* Dialog box for GUI preferences
|
||||
*
|
||||
* $Id: gui_prefs.c,v 1.62 2004/01/31 03:22:40 guy Exp $
|
||||
* $Id: gui_prefs.c,v 1.63 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -65,6 +65,7 @@ static gint recent_files_count_changed_cb(GtkWidget *recent_files_entry _U_,
|
|||
#define HEX_DUMP_HIGHLIGHT_STYLE_KEY "hex_dump_highlight_style"
|
||||
#define GEOMETRY_POSITION_KEY "geometry_position"
|
||||
#define GEOMETRY_SIZE_KEY "geometry_size"
|
||||
#define GEOMETRY_MAXIMIZED_KEY "geometry_maximized"
|
||||
|
||||
#define GUI_FILEOPEN_KEY "fileopen_behavior"
|
||||
#define GUI_RECENT_FILES_COUNT_KEY "recent_files_count"
|
||||
|
@ -156,7 +157,7 @@ gui_prefs_show(void)
|
|||
GtkWidget *ptree_browse_om, *highlight_style_om;
|
||||
GtkWidget *fileopen_rb, *fileopen_dir_te, *toolbar_style_om;
|
||||
GtkWidget *recent_files_count_max_te;
|
||||
GtkWidget *save_position_cb, *save_size_cb;
|
||||
GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb;
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
GtkWidget *expander_style_om, *line_style_om;
|
||||
#else
|
||||
|
@ -245,6 +246,10 @@ gui_prefs_show(void)
|
|||
"Save window size:", NULL, prefs.gui_geometry_save_size);
|
||||
OBJECT_SET_DATA(main_vb, GEOMETRY_SIZE_KEY, save_size_cb);
|
||||
|
||||
save_maximized_cb = create_preference_check_button(main_tb, pos++,
|
||||
"Save maximized state:", NULL, prefs.gui_geometry_save_maximized);
|
||||
OBJECT_SET_DATA(main_vb, GEOMETRY_MAXIMIZED_KEY, save_maximized_cb);
|
||||
|
||||
/* Allow user to select where they want the File Open dialog to open to
|
||||
* by default */
|
||||
fileopen_rb = create_preference_radio_buttons(main_tb, pos++,
|
||||
|
@ -428,6 +433,8 @@ gui_prefs_fetch(GtkWidget *w)
|
|||
GEOMETRY_POSITION_KEY));
|
||||
prefs.gui_geometry_save_size =
|
||||
gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_SIZE_KEY));
|
||||
prefs.gui_geometry_save_maximized =
|
||||
gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_MAXIMIZED_KEY));
|
||||
prefs.gui_fileopen_style = fetch_preference_radio_buttons_val(
|
||||
OBJECT_GET_DATA(w, GUI_FILEOPEN_KEY), gui_fileopen_vals);
|
||||
|
||||
|
|
233
gtk/main.c
233
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.385 2004/02/01 10:01:19 ulfl Exp $
|
||||
* $Id: main.c,v 1.386 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -147,8 +147,6 @@ static GString *comp_info_str, *runtime_info_str;
|
|||
gchar *ethereal_path = NULL;
|
||||
gchar *last_open_dir = NULL;
|
||||
static gboolean updated_last_open_dir = FALSE;
|
||||
static gint root_x = G_MAXINT, root_y = G_MAXINT, top_width, top_height;
|
||||
static gboolean updated_geometry = FALSE;
|
||||
|
||||
/* init with an invalid value, so that "recent" can detect this and */
|
||||
/* distinguish it from a command line value */
|
||||
|
@ -173,6 +171,7 @@ static gboolean list_link_layer_types;
|
|||
|
||||
static void create_main_window(gint, gint, gint, e_prefs*);
|
||||
static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_);
|
||||
static void main_save_window_geometry(GtkWidget *widget);
|
||||
#ifdef WIN32
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
static void try_to_get_windows_font_gtk2 (void);
|
||||
|
@ -1103,6 +1102,9 @@ main_do_quit(void)
|
|||
gchar *rec_path;
|
||||
|
||||
|
||||
/* get the current geometry, before writing it to disk */
|
||||
main_save_window_geometry(top_level);
|
||||
|
||||
/* write user's recent file to disk
|
||||
* It is no problem to write this file, even if we do not quit */
|
||||
write_recent(&rec_path);
|
||||
|
@ -1193,10 +1195,40 @@ main_window_delete_event_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
main_window_configure_event_cb(GtkWidget *widget, GdkEvent *event _U_, gpointer data _U_)
|
||||
static void
|
||||
main_load_window_geometry(GtkWidget *widget)
|
||||
{
|
||||
/* as we now have the geometry from the recent file, set it */
|
||||
if (prefs.gui_geometry_save_position) {
|
||||
gtk_widget_set_uposition(GTK_WIDGET(top_level),
|
||||
recent.gui_geometry_main_x,
|
||||
recent.gui_geometry_main_y);
|
||||
}
|
||||
if (prefs.gui_geometry_save_size) {
|
||||
WIDGET_SET_SIZE(top_level,
|
||||
recent.gui_geometry_main_width,
|
||||
recent.gui_geometry_main_height);
|
||||
} else {
|
||||
WIDGET_SET_SIZE(top_level, DEF_WIDTH, -1);
|
||||
}
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
if(prefs.gui_geometry_save_maximized) {
|
||||
if (recent.gui_geometry_main_maximized) {
|
||||
gdk_window_maximize(widget->window);
|
||||
} else {
|
||||
gdk_window_unmaximize(widget->window);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
main_save_window_geometry(GtkWidget *widget)
|
||||
{
|
||||
gint desk_x, desk_y;
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
GdkWindowState state;
|
||||
#endif
|
||||
|
||||
/* Try to grab our geometry.
|
||||
|
||||
|
@ -1212,24 +1244,36 @@ main_window_configure_event_cb(GtkWidget *widget, GdkEvent *event _U_, gpointer
|
|||
|
||||
http://mail.gnome.org/archives/gtk-devel-list/2001-March/msg00289.html
|
||||
http://www.gtk.org/faq/#AEN606
|
||||
*/
|
||||
|
||||
XXX - should we get this from the event itself? */
|
||||
if (prefs.gui_geometry_save_position) {
|
||||
gdk_window_get_root_origin(widget->window,
|
||||
&recent.gui_geometry_main_x,
|
||||
&recent.gui_geometry_main_y);
|
||||
if (gdk_window_get_deskrelative_origin(widget->window,
|
||||
&desk_x, &desk_y)) {
|
||||
if (desk_x <= recent.gui_geometry_main_x &&
|
||||
desk_y <= recent.gui_geometry_main_y)
|
||||
{
|
||||
recent.gui_geometry_main_x = desk_x;
|
||||
recent.gui_geometry_main_y = desk_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gdk_window_get_root_origin(widget->window, &root_x, &root_y);
|
||||
if (gdk_window_get_deskrelative_origin(widget->window,
|
||||
&desk_x, &desk_y)) {
|
||||
if (desk_x <= root_x && desk_y <= root_y) {
|
||||
root_x = desk_x;
|
||||
root_y = desk_y;
|
||||
}
|
||||
}
|
||||
if (prefs.gui_geometry_save_size) {
|
||||
/* XXX - Is this the "approved" method? */
|
||||
gdk_window_get_size(widget->window,
|
||||
&recent.gui_geometry_main_width,
|
||||
&recent.gui_geometry_main_height);
|
||||
}
|
||||
|
||||
/* XXX - Is this the "approved" method? */
|
||||
gdk_window_get_size(widget->window, &top_width, &top_height);
|
||||
|
||||
updated_geometry = TRUE;
|
||||
|
||||
return FALSE;
|
||||
#if GTK_MAJOR_VERSION >= 2
|
||||
if(prefs.gui_geometry_save_maximized) {
|
||||
state = gdk_window_get_state(widget->window);
|
||||
recent.gui_geometry_main_maximized = (state == GDK_WINDOW_STATE_MAXIMIZED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void file_quit_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
|
||||
|
@ -1770,7 +1814,6 @@ main(int argc, char *argv[])
|
|||
#if GTK_MAJOR_VERSION < 2
|
||||
char *bold_font_name;
|
||||
#endif
|
||||
gboolean prefs_write_needed = FALSE;
|
||||
ethereal_tap_list *tli = NULL;
|
||||
gchar *tap_opt = NULL;
|
||||
|
||||
|
@ -2568,14 +2611,53 @@ main(int argc, char *argv[])
|
|||
we were told to. */
|
||||
create_main_window(pl_size, tv_size, bv_size, prefs);
|
||||
|
||||
dnd_init(top_level);
|
||||
|
||||
/* Read the recent file, as we have the gui now ready for it. */
|
||||
read_recent(&rf_path, &rf_open_errno);
|
||||
|
||||
/* rearrange all the widgets */
|
||||
main_widgets_rearrange();
|
||||
|
||||
/* Fill in column titles. This must be done after the top level window
|
||||
is displayed.
|
||||
|
||||
XXX - is that still true, with fixed-width columns? */
|
||||
packet_list_set_column_titles();
|
||||
|
||||
menu_recent_read_finished();
|
||||
|
||||
switch (font_apply()) {
|
||||
case FA_SUCCESS:
|
||||
break;
|
||||
case FA_FONT_NOT_RESIZEABLE:
|
||||
/* "font_apply()" popped up an alert box. */
|
||||
/* turn off zooming - font can't be resized */
|
||||
case FA_FONT_NOT_AVAILABLE:
|
||||
/* XXX - did we successfully load the un-zoomed version earlier?
|
||||
If so, this *probably* means the font is available, but not at
|
||||
this particular zoom level, but perhaps some other failure
|
||||
occurred; I'm not sure you can determine which is the case,
|
||||
however. */
|
||||
/* turn off zooming - zoom level is unavailable */
|
||||
default:
|
||||
/* in any other case than FA_SUCCESS, turn off zooming */
|
||||
recent.gui_zoom_level = 0;
|
||||
/* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
|
||||
}
|
||||
|
||||
dnd_init(top_level);
|
||||
|
||||
colors_init();
|
||||
colfilter_init();
|
||||
|
||||
/*** we have finished all init things, show the main window ***/
|
||||
gtk_widget_show(top_level);
|
||||
|
||||
/* the window can be maximized only, if it's visible, so do it after show! */
|
||||
main_load_window_geometry(top_level);
|
||||
|
||||
/* process all pending GUI events before continue */
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
/* If we were given the name of a capture file, read it in now;
|
||||
we defer it until now, so that, if we can't open it, and pop
|
||||
up an alert box, the alert box is more likely to come up on
|
||||
|
@ -2779,87 +2861,6 @@ main(int argc, char *argv[])
|
|||
|
||||
gtk_main();
|
||||
|
||||
/* If the last opened directory, or our geometry, has changed, save
|
||||
whatever we're supposed to save. */
|
||||
if (updated_last_open_dir || updated_geometry) {
|
||||
/* Re-read our saved preferences. */
|
||||
prefs = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
|
||||
&pf_open_errno, &pf_read_errno, &pf_path);
|
||||
if (pf_path == NULL) {
|
||||
/* We succeeded in reading the preferences. */
|
||||
|
||||
if (updated_last_open_dir) {
|
||||
/* The pathname of the last directory in which we've opened
|
||||
a file has changed. If it changed from what's in the
|
||||
preferences file, and we're supposed to save it, update
|
||||
the preference value and note that we will have to write
|
||||
the preferences out. */
|
||||
if (prefs->gui_fileopen_style == FO_STYLE_LAST_OPENED) {
|
||||
/* Yes, we're supposed to save it.
|
||||
Has a file been opened since Ethereal was started? */
|
||||
if (last_open_dir != NULL) {
|
||||
/* Yes. Is the most recently navigated-to directory
|
||||
different from the saved directory? */
|
||||
if (prefs->gui_fileopen_remembered_dir == NULL ||
|
||||
strcmp(prefs->gui_fileopen_remembered_dir, last_open_dir) != 0) {
|
||||
/* Yes. */
|
||||
prefs->gui_fileopen_remembered_dir = last_open_dir;
|
||||
prefs_write_needed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updated_geometry) {
|
||||
/* We got a geometry update, in the form of a configure_notify
|
||||
event, so the geometry has changed. If it changed from
|
||||
what's in the preferences file, and we're supposed to save
|
||||
the current values of the changed geometry item (position or
|
||||
size), update the preference value and note that we will have
|
||||
to write the preferences out.
|
||||
|
||||
XXX - should GUI stuff such as this be in a separate file? */
|
||||
if (prefs->gui_geometry_save_position) {
|
||||
if (prefs->gui_geometry_main_x != root_x) {
|
||||
prefs->gui_geometry_main_x = root_x;
|
||||
prefs_write_needed = TRUE;
|
||||
}
|
||||
if (prefs->gui_geometry_main_y != root_y) {
|
||||
prefs->gui_geometry_main_y = root_y;
|
||||
prefs_write_needed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs->gui_geometry_save_size) {
|
||||
if (prefs->gui_geometry_main_width != top_width) {
|
||||
prefs->gui_geometry_main_width = top_width;
|
||||
prefs_write_needed = TRUE;
|
||||
}
|
||||
if (prefs->gui_geometry_main_height != top_height) {
|
||||
prefs->gui_geometry_main_height = top_height;
|
||||
prefs_write_needed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the preferences if we need to do so.
|
||||
|
||||
XXX - this doesn't save the preferences if you don't have a
|
||||
preferences file. Forcibly writing a preferences file would
|
||||
save the current settings even if you haven't changed them,
|
||||
meaning that if the defaults change it won't affect you.
|
||||
Perhaps we need to keep track of what the *user* has changed,
|
||||
and only write out *those* preferences. */
|
||||
if (prefs_write_needed) {
|
||||
write_prefs(&pf_path);
|
||||
}
|
||||
} else {
|
||||
/* We failed to read the preferences - silently ignore the
|
||||
error. */
|
||||
g_free(pf_path);
|
||||
}
|
||||
}
|
||||
|
||||
epan_cleanup();
|
||||
g_free(rc_file);
|
||||
|
||||
|
@ -3561,20 +3562,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
|||
NULL);
|
||||
SIGNAL_CONNECT(top_level, "realize", window_icon_realize_cb, NULL);
|
||||
gtk_window_set_title(GTK_WINDOW(top_level), "The Ethereal Network Analyzer");
|
||||
if (prefs->gui_geometry_save_position) {
|
||||
gtk_widget_set_uposition(GTK_WIDGET(top_level),
|
||||
prefs->gui_geometry_main_x,
|
||||
prefs->gui_geometry_main_y);
|
||||
}
|
||||
if (prefs->gui_geometry_save_size) {
|
||||
WIDGET_SET_SIZE(top_level, prefs->gui_geometry_main_width,
|
||||
prefs->gui_geometry_main_height);
|
||||
} else {
|
||||
WIDGET_SET_SIZE(top_level, DEF_WIDTH, -1);
|
||||
}
|
||||
gtk_window_set_policy(GTK_WINDOW(top_level), TRUE, TRUE, FALSE);
|
||||
SIGNAL_CONNECT(top_level, "configure_event", main_window_configure_event_cb,
|
||||
NULL);
|
||||
|
||||
/* Container for menu bar, toolbar(s), paned windows and progress/info box */
|
||||
main_vbox = gtk_vbox_new(FALSE, 1);
|
||||
|
@ -3748,17 +3736,6 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
|||
stat_hbox = gtk_hbox_new(FALSE, 1);
|
||||
gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0);
|
||||
gtk_widget_show(stat_hbox);
|
||||
|
||||
/* rearrange all the widgets */
|
||||
main_widgets_rearrange();
|
||||
|
||||
gtk_widget_show(top_level);
|
||||
|
||||
/* Fill in column titles. This must be done after the top level window
|
||||
is displayed.
|
||||
|
||||
XXX - is that still true, with fixed-width columns? */
|
||||
packet_list_set_column_titles();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* menu.h
|
||||
* Menu definitions
|
||||
*
|
||||
* $Id: menu.h,v 1.15 2004/01/29 23:11:38 ulfl Exp $
|
||||
* $Id: menu.h,v 1.16 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
/* Write all recent capture filenames to the user's recent file */
|
||||
void menu_recent_file_write_all(FILE *rf);
|
||||
void menu_open_recent_file_cmd(GtkWidget *w);
|
||||
extern void menu_recent_read_finished(void);
|
||||
|
||||
GtkWidget *main_menu_new(GtkAccelGroup **);
|
||||
void set_menu_object_data (gchar *path, gchar *key, gpointer data);
|
||||
|
|
91
gtk/recent.c
91
gtk/recent.c
|
@ -2,7 +2,7 @@
|
|||
* Recent "preference" handling routines
|
||||
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
|
||||
*
|
||||
* $Id: recent.c,v 1.7 2004/01/25 18:51:25 ulfl Exp $
|
||||
* $Id: recent.c,v 1.8 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -39,11 +39,27 @@
|
|||
#include "prefs.h"
|
||||
#include "prefs-int.h"
|
||||
|
||||
|
||||
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
|
||||
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
|
||||
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
|
||||
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
|
||||
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
|
||||
#define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show"
|
||||
#define RECENT_GUI_TIME_FORMAT "gui.time_format"
|
||||
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry_main_width"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_HEIGHT "gui.geometry_main_height"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED "gui.geometry_main_maximized"
|
||||
#define RECENT_GUI_FILEOPEN_REMEMBERED_DIR "gui.fileopen_remembered_dir"
|
||||
|
||||
|
||||
#define RECENT_FILE_NAME "recent"
|
||||
|
||||
/* #include "../menu.h" */
|
||||
extern void add_menu_recent_capture_file(gchar *file);
|
||||
extern void menu_recent_read_finished(void);
|
||||
|
||||
recent_settings_t recent;
|
||||
|
||||
|
@ -146,6 +162,26 @@ write_recent(char **rf_path_return)
|
|||
fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n",
|
||||
recent.gui_zoom_level);
|
||||
|
||||
fprintf(rf, "\n# Main window geometry.\n");
|
||||
fprintf(rf, "# Decimal integers.\n");
|
||||
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d\n", recent.gui_geometry_main_x);
|
||||
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d\n", recent.gui_geometry_main_y);
|
||||
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
|
||||
recent.gui_geometry_main_width);
|
||||
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
|
||||
recent.gui_geometry_main_height);
|
||||
|
||||
fprintf(rf, "\n# Main window maximized (GTK2 only).\n");
|
||||
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s\n",
|
||||
recent.gui_geometry_main_maximized == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
if (recent.gui_fileopen_remembered_dir != NULL) {
|
||||
fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n");
|
||||
fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n",
|
||||
recent.gui_fileopen_remembered_dir);
|
||||
}
|
||||
|
||||
fclose(rf);
|
||||
|
||||
/* XXX - catch I/O errors (e.g. "ran out of disk space") and return
|
||||
|
@ -212,6 +248,28 @@ read_set_recent_pair(gchar *key, gchar *value)
|
|||
find_index_from_string_array(value, ts_type_text, TS_RELATIVE);
|
||||
} else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) {
|
||||
recent.gui_zoom_level = strtol(value, NULL, 0);
|
||||
|
||||
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
recent.gui_geometry_main_maximized = TRUE;
|
||||
}
|
||||
else {
|
||||
recent.gui_geometry_main_maximized = FALSE;
|
||||
}
|
||||
|
||||
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_X) == 0) {
|
||||
recent.gui_geometry_main_x = strtol(value, NULL, 10);
|
||||
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_Y) == 0) {
|
||||
recent.gui_geometry_main_y = strtol(value, NULL, 10);
|
||||
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
|
||||
recent.gui_geometry_main_width = strtol(value, NULL, 10);
|
||||
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
|
||||
recent.gui_geometry_main_height = strtol(value, NULL, 10);
|
||||
|
||||
} else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
|
||||
if (recent.gui_fileopen_remembered_dir != NULL)
|
||||
g_free(recent.gui_fileopen_remembered_dir);
|
||||
recent.gui_fileopen_remembered_dir = g_strdup(value);
|
||||
}
|
||||
|
||||
return PREFS_SET_OK;
|
||||
|
@ -236,6 +294,13 @@ read_recent(char **rf_path_return, int *rf_errno_return)
|
|||
recent.gui_time_format = TS_RELATIVE;
|
||||
recent.gui_zoom_level = 0;
|
||||
|
||||
recent.gui_geometry_main_x = 20;
|
||||
recent.gui_geometry_main_y = 20;
|
||||
recent.gui_geometry_main_width = DEF_WIDTH;
|
||||
recent.gui_geometry_main_height = -1;
|
||||
recent.gui_fileopen_remembered_dir= NULL;
|
||||
recent.gui_geometry_main_maximized= FALSE;
|
||||
|
||||
/* Construct the pathname of the user's recent file. */
|
||||
rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
|
||||
|
||||
|
@ -258,28 +323,6 @@ read_recent(char **rf_path_return, int *rf_errno_return)
|
|||
*rf_path_return = rf_path;
|
||||
}
|
||||
}
|
||||
|
||||
menu_recent_read_finished();
|
||||
|
||||
switch (font_apply()) {
|
||||
|
||||
case FA_SUCCESS:
|
||||
break;
|
||||
|
||||
case FA_FONT_NOT_RESIZEABLE:
|
||||
/* "font_apply()" popped up an alert box. */
|
||||
recent.gui_zoom_level = 0; /* turn off zooming - font can't be resized */
|
||||
break;
|
||||
|
||||
case FA_FONT_NOT_AVAILABLE:
|
||||
/* XXX - did we successfully load the un-zoomed version earlier?
|
||||
If so, this *probably* means the font is available, but not at
|
||||
this particular zoom level, but perhaps some other failure
|
||||
occurred; I'm not sure you can determine which is the case,
|
||||
however. */
|
||||
recent.gui_zoom_level = 0; /* turn off zooming - zoom level is unavailable */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
18
gtk/recent.h
18
gtk/recent.h
|
@ -2,7 +2,7 @@
|
|||
* Definitions for recent "preference" handling routines
|
||||
* Copyright 2004, Ulf Lamping <ulf.lamping@web.de>
|
||||
*
|
||||
* $Id: recent.h,v 1.3 2004/01/20 18:47:25 ulfl Exp $
|
||||
* $Id: recent.h,v 1.4 2004/02/01 20:28:11 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -31,14 +31,6 @@
|
|||
|
||||
#define RECENT_KEY_CAPTURE_FILE "recent.capture_file"
|
||||
#define RECENT_KEY_DISPLAY_FILTER "recent.display_filter"
|
||||
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
|
||||
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
|
||||
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
|
||||
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
|
||||
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
|
||||
#define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show"
|
||||
#define RECENT_GUI_TIME_FORMAT "gui.time_format"
|
||||
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
|
||||
|
||||
typedef struct recent_settings_tag {
|
||||
gboolean main_toolbar_show;
|
||||
|
@ -51,6 +43,14 @@ typedef struct recent_settings_tag {
|
|||
gboolean statusbar_show;
|
||||
gint gui_time_format;
|
||||
gint gui_zoom_level;
|
||||
|
||||
gint gui_geometry_main_x;
|
||||
gint gui_geometry_main_y;
|
||||
gint gui_geometry_main_width;
|
||||
gint gui_geometry_main_height;
|
||||
gchar *gui_fileopen_remembered_dir;
|
||||
|
||||
gboolean gui_geometry_main_maximized; /* this is valid in GTK2 only */
|
||||
} recent_settings_t;
|
||||
|
||||
extern recent_settings_t recent;
|
||||
|
|
63
prefs.c
63
prefs.c
|
@ -1,7 +1,7 @@
|
|||
/* prefs.c
|
||||
* Routines for handling preferences
|
||||
*
|
||||
* $Id: prefs.c,v 1.123 2004/01/27 04:11:48 guy Exp $
|
||||
* $Id: prefs.c,v 1.124 2004/02/01 20:28:10 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -985,14 +985,10 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
|
|||
prefs.gui_marked_bg.blue = 0;
|
||||
prefs.gui_geometry_save_position = 0;
|
||||
prefs.gui_geometry_save_size = 1;
|
||||
prefs.gui_geometry_main_x = 20;
|
||||
prefs.gui_geometry_main_y = 20;
|
||||
prefs.gui_geometry_main_width = DEF_WIDTH;
|
||||
prefs.gui_geometry_main_height = -1;
|
||||
prefs.gui_geometry_save_maximized= 1;
|
||||
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
|
||||
prefs.gui_recent_files_count_max = 10;
|
||||
prefs.gui_fileopen_dir = g_strdup("");
|
||||
prefs.gui_fileopen_remembered_dir = NULL;
|
||||
|
||||
/* set the default values for the capture dialog box */
|
||||
prefs.capture_device = NULL;
|
||||
|
@ -1288,6 +1284,7 @@ prefs_set_pref(char *prefarg)
|
|||
#define PRS_GUI_FILEOPEN_REMEMBERED_DIR "gui.fileopen.remembered_dir"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_POSITION "gui.geometry.save.position"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_SIZE "gui.geometry.save.size"
|
||||
#define PRS_GUI_GEOMETRY_SAVE_MAXIMIZED "gui.geometry.save.maximized"
|
||||
#define PRS_GUI_GEOMETRY_MAIN_X "gui.geometry.main.x"
|
||||
#define PRS_GUI_GEOMETRY_MAIN_Y "gui.geometry.main.y"
|
||||
#define PRS_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry.main.width"
|
||||
|
@ -1568,14 +1565,17 @@ set_pref(gchar *pref_name, gchar *value)
|
|||
else {
|
||||
prefs.gui_geometry_save_size = FALSE;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_X) == 0) {
|
||||
prefs.gui_geometry_main_x = strtol(value, NULL, 10);
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_Y) == 0) {
|
||||
prefs.gui_geometry_main_y = strtol(value, NULL, 10);
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
|
||||
prefs.gui_geometry_main_width = strtol(value, NULL, 10);
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
|
||||
prefs.gui_geometry_main_height = strtol(value, NULL, 10);
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_MAXIMIZED) == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
prefs.gui_geometry_save_maximized = TRUE;
|
||||
}
|
||||
else {
|
||||
prefs.gui_geometry_save_maximized = FALSE;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_X) == 0) { /* deprecated */
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_Y) == 0) { /* deprecated */
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_WIDTH) == 0) { /* deprecated */
|
||||
} else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_HEIGHT) == 0) { /* deprecated */
|
||||
} else if (strcmp(pref_name, PRS_GUI_FILEOPEN_STYLE) == 0) {
|
||||
prefs.gui_fileopen_style =
|
||||
find_index_from_string_array(value, gui_fileopen_style_text,
|
||||
|
@ -1590,10 +1590,7 @@ set_pref(gchar *pref_name, gchar *value)
|
|||
if (prefs.gui_fileopen_dir != NULL)
|
||||
g_free(prefs.gui_fileopen_dir);
|
||||
prefs.gui_fileopen_dir = g_strdup(value);
|
||||
} else if (strcmp(pref_name, PRS_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
|
||||
if (prefs.gui_fileopen_remembered_dir != NULL)
|
||||
g_free(prefs.gui_fileopen_remembered_dir);
|
||||
prefs.gui_fileopen_remembered_dir = g_strdup(value);
|
||||
} else if (strcmp(pref_name, PRS_GUI_FILEOPEN_REMEMBERED_DIR) == 0) { /* deprecated */
|
||||
|
||||
/* handle the capture options */
|
||||
} else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
|
||||
|
@ -2160,6 +2157,11 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, PRS_GUI_GEOMETRY_SAVE_SIZE ": %s\n",
|
||||
prefs.gui_geometry_save_size == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Save window maximized state at exit (GKT2 only)?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_GEOMETRY_SAVE_MAXIMIZED ": %s\n",
|
||||
prefs.gui_geometry_save_maximized == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Where to start the File Open dialog box.\n");
|
||||
fprintf(pf, "# One of: LAST_OPENED, SPECIFIED\n");
|
||||
fprintf(pf, PRS_GUI_FILEOPEN_STYLE ": %s\n",
|
||||
|
@ -2174,21 +2176,6 @@ write_prefs(char **pf_path_return)
|
|||
prefs.gui_fileopen_dir);
|
||||
}
|
||||
|
||||
if (prefs.gui_fileopen_remembered_dir != NULL) {
|
||||
fprintf(pf, "\n# Last directory navigated to in File Open dialog.\n");
|
||||
fprintf(pf, PRS_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n",
|
||||
prefs.gui_fileopen_remembered_dir);
|
||||
}
|
||||
|
||||
fprintf(pf, "\n# Main window geometry.\n");
|
||||
fprintf(pf, "# Decimal integers.\n");
|
||||
fprintf(pf, PRS_GUI_GEOMETRY_MAIN_X ": %d\n", prefs.gui_geometry_main_x);
|
||||
fprintf(pf, PRS_GUI_GEOMETRY_MAIN_Y ": %d\n", prefs.gui_geometry_main_y);
|
||||
fprintf(pf, PRS_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
|
||||
prefs.gui_geometry_main_width);
|
||||
fprintf(pf, PRS_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
|
||||
prefs.gui_geometry_main_height);
|
||||
|
||||
fprintf(pf, "\n####### Name Resolution ########\n");
|
||||
|
||||
fprintf(pf, "\n# Resolve addresses to names?\n");
|
||||
|
@ -2280,7 +2267,6 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest->gui_hex_dump_highlight_style = src->gui_hex_dump_highlight_style;
|
||||
dest->gui_toolbar_main_style = src->gui_toolbar_main_style;
|
||||
dest->gui_fileopen_dir = g_strdup(src->gui_fileopen_dir);
|
||||
dest->gui_fileopen_remembered_dir = g_strdup(src->gui_fileopen_remembered_dir);
|
||||
dest->gui_fileopen_style = src->gui_fileopen_style;
|
||||
dest->gui_font_name1 = g_strdup(src->gui_font_name1);
|
||||
dest->gui_font_name2 = g_strdup(src->gui_font_name2);
|
||||
|
@ -2288,10 +2274,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest->gui_marked_bg = src->gui_marked_bg;
|
||||
dest->gui_geometry_save_position = src->gui_geometry_save_position;
|
||||
dest->gui_geometry_save_size = src->gui_geometry_save_size;
|
||||
dest->gui_geometry_main_x = src->gui_geometry_main_x;
|
||||
dest->gui_geometry_main_y = src->gui_geometry_main_y;
|
||||
dest->gui_geometry_main_width = src->gui_geometry_main_width;
|
||||
dest->gui_geometry_main_height = src->gui_geometry_main_height;
|
||||
dest->gui_geometry_save_maximized = src->gui_geometry_save_maximized;
|
||||
/* values for the capture dialog box */
|
||||
dest->capture_device = g_strdup(src->capture_device);
|
||||
dest->capture_devices_descr = g_strdup(src->capture_devices_descr);
|
||||
|
@ -2329,10 +2312,6 @@ free_prefs(e_prefs *pr)
|
|||
g_free(pr->gui_fileopen_dir);
|
||||
pr->gui_fileopen_dir = NULL;
|
||||
}
|
||||
if (pr->gui_fileopen_remembered_dir != NULL) {
|
||||
g_free(pr->gui_fileopen_remembered_dir);
|
||||
pr->gui_fileopen_remembered_dir = NULL;
|
||||
}
|
||||
if (pr->capture_device != NULL) {
|
||||
g_free(pr->capture_device);
|
||||
pr->capture_device = NULL;
|
||||
|
|
8
prefs.h
8
prefs.h
|
@ -1,7 +1,7 @@
|
|||
/* prefs.h
|
||||
* Definitions for preference handling routines
|
||||
*
|
||||
* $Id: prefs.h,v 1.55 2004/01/20 18:47:22 ulfl Exp $
|
||||
* $Id: prefs.h,v 1.56 2004/02/01 20:28:10 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -88,14 +88,10 @@ typedef struct _e_prefs {
|
|||
color_t gui_marked_bg;
|
||||
gboolean gui_geometry_save_position;
|
||||
gboolean gui_geometry_save_size;
|
||||
gint gui_geometry_main_x;
|
||||
gint gui_geometry_main_y;
|
||||
gint gui_geometry_main_width;
|
||||
gint gui_geometry_main_height;
|
||||
gboolean gui_geometry_save_maximized;
|
||||
guint gui_fileopen_style;
|
||||
guint gui_recent_files_count_max;
|
||||
gchar *gui_fileopen_dir;
|
||||
gchar *gui_fileopen_remembered_dir;
|
||||
guint32 name_resolve;
|
||||
gint name_resolve_concurrency;
|
||||
gchar *capture_device;
|
||||
|
|
Loading…
Reference in New Issue