aboutsummaryrefslogtreecommitdiffstats
path: root/epan/prefs.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2008-04-12 19:37:05 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2008-04-12 19:37:05 +0000
commit41e9bde0371c5802136fc3081097e5104c75d024 (patch)
tree8fe3fe8012da7eda78ef6d348d0f68a7a638926d /epan/prefs.c
parent2b19b4e07ed2667a6226865a8197715e6ad45c76 (diff)
Added an option to save column widths in the recent file.
Not 100% implemented for usage with configuration profiles with different column layout yet, as this requires some of the recent values to be saved in each profile. svn path=/trunk/; revision=24949
Diffstat (limited to 'epan/prefs.c')
-rw-r--r--epan/prefs.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index ab1ae76cdc..1b4c20188e 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -58,9 +58,7 @@ static module_t *prefs_register_module_or_subtree(module_t *parent,
void (*apply_cb)(void));
static struct preference *find_preference(module_t *, const char *);
static prefs_set_pref_e set_pref(gchar*, gchar*, void *);
-static GList *get_string_list(gchar *);
static gchar *put_string_list(GList *);
-static void clear_string_list(GList *);
static void free_col_info(e_prefs *);
#define PF_NAME "preferences"
@@ -806,8 +804,8 @@ prefs_register_modules(void)
/* Parse through a list of comma-separated, possibly quoted strings.
Return a list of the string data. */
-static GList *
-get_string_list(gchar *str)
+GList *
+prefs_get_string_list(gchar *str)
{
enum { PRE_STRING, IN_QUOT, NOT_IN_QUOT };
@@ -830,7 +828,7 @@ get_string_list(gchar *str)
/* We were in the middle of a quoted string or backslash escape,
and ran out of characters; that's an error. */
g_free(slstr);
- clear_string_list(sl);
+ prefs_clear_string_list(sl);
return NULL;
}
slstr[j] = '\0';
@@ -956,8 +954,8 @@ put_string_list(GList *sl)
return(pref_str);
}
-static void
-clear_string_list(GList *sl)
+void
+prefs_clear_string_list(GList *sl)
{
GList *l = sl;
@@ -1157,9 +1155,10 @@ init_prefs(void) {
prefs.gui_marked_bg.blue = 0;
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
- prefs.gui_geometry_save_position = 0;
- prefs.gui_geometry_save_size = 1;
- prefs.gui_geometry_save_maximized= 1;
+ prefs.gui_geometry_save_position = FALSE;
+ prefs.gui_geometry_save_size = TRUE;
+ prefs.gui_geometry_save_maximized= TRUE;
+ prefs.gui_geometry_save_column_width = FALSE;
prefs.gui_console_open = console_open_never;
prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED;
prefs.gui_recent_files_count_max = 10;
@@ -1631,6 +1630,7 @@ prefs_is_capture_device_hidden(const char *name)
#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_SAVE_COLUMN_WIDTH "gui.geometry.save.column_width"
#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"
@@ -1777,12 +1777,12 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
if (prefs.pr_cmd) g_free(prefs.pr_cmd);
prefs.pr_cmd = g_strdup(value);
} else if (strcmp(pref_name, PRS_COL_FMT) == 0) {
- col_l = get_string_list(value);
+ col_l = prefs_get_string_list(value);
if (col_l == NULL)
return PREFS_SET_SYNTAX_ERR;
if ((g_list_length(col_l) % 2) != 0) {
/* A title didn't have a matching format. */
- clear_string_list(col_l);
+ prefs_clear_string_list(col_l);
return PREFS_SET_SYNTAX_ERR;
}
/* Check to make sure all column formats are valid. */
@@ -1791,7 +1791,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
/* Make sure the title isn't empty. */
if (strcmp(col_l_elt->data, "") == 0) {
/* It is. */
- clear_string_list(col_l);
+ prefs_clear_string_list(col_l);
return PREFS_SET_SYNTAX_ERR;
}
@@ -1802,7 +1802,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
if (strncmp(col_l_elt->data, cust_format, cust_format_len) != 0) {
if (get_column_format_from_str(col_l_elt->data) == -1) {
/* It's not a valid column format. */
- clear_string_list(col_l);
+ prefs_clear_string_list(col_l);
return PREFS_SET_SYNTAX_ERR;
}
}
@@ -1831,7 +1831,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
col_l_elt = col_l_elt->next;
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
- clear_string_list(col_l);
+ prefs_clear_string_list(col_l);
} else if (strcmp(pref_name, PRS_STREAM_CL_FG) == 0) {
cval = strtoul(value, NULL, 16);
prefs.st_client_fg.pixel = 0;
@@ -1954,6 +1954,13 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
else {
prefs.gui_geometry_save_maximized = FALSE;
}
+ } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_SAVE_COLUMN_WIDTH) == 0) {
+ if (g_ascii_strcasecmp(value, "true") == 0) {
+ prefs.gui_geometry_save_column_width = TRUE;
+ }
+ else {
+ prefs.gui_geometry_save_column_width = 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 */
@@ -2613,11 +2620,16 @@ 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 (GTK2 only)?\n");
+ fprintf(pf, "\n# Save window maximized state at exit?\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# Save packet list column widths?\n");
+ fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(pf, PRS_GUI_GEOMETRY_SAVE_COLUMN_WIDTH ": %s\n",
+ prefs.gui_geometry_save_column_width == TRUE ? "TRUE" : "FALSE");
+
fprintf(pf, "\n# Open a console window (WIN32 only)?\n");
fprintf(pf, "# One of: NEVER, AUTOMATIC, ALWAYS\n");
fprintf(pf, PRS_GUI_CONSOLE_OPEN ": %s\n",
@@ -2909,6 +2921,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->gui_geometry_save_position = src->gui_geometry_save_position;
dest->gui_geometry_save_size = src->gui_geometry_save_size;
dest->gui_geometry_save_maximized = src->gui_geometry_save_maximized;
+ dest->gui_geometry_save_column_width = src->gui_geometry_save_column_width;
dest->gui_webbrowser = g_strdup(src->gui_webbrowser);
dest->gui_window_title = g_strdup(src->gui_window_title);
dest->console_log_level = src->console_log_level;