forked from osmocom/wireshark
From Giorgio Tino: Add a "static text" protocol preference type. This
can be used to add descriptive text inline with other preference items. The "preference" contents are not written to disk. Fixup whitespace. svn path=/trunk/; revision=20037
This commit is contained in:
parent
f6bdcf2251
commit
40ca271813
|
@ -55,6 +55,7 @@ typedef enum {
|
|||
PREF_ENUM,
|
||||
PREF_STRING,
|
||||
PREF_RANGE,
|
||||
PREF_STATIC_TEXT,
|
||||
PREF_OBSOLETE
|
||||
} pref_type_t;
|
||||
|
||||
|
|
48
epan/prefs.c
48
epan/prefs.c
|
@ -626,6 +626,17 @@ prefs_register_range_preference(module_t *module, const char *name,
|
|||
preference->saved_val.range = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a static text 'preference'. It can be used to add explanatory
|
||||
* text inline with other preferences in the GUI.
|
||||
* Note: Static preferences are not saved to the preferences file.
|
||||
*/
|
||||
void prefs_register_static_text_preference(module_t *module, const char *name,
|
||||
const char *title, const char *description)
|
||||
{
|
||||
register_preference(module, name, title, description, PREF_STATIC_TEXT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a preference that used to be supported but no longer is.
|
||||
*/
|
||||
|
@ -972,7 +983,7 @@ init_prefs(void) {
|
|||
* verified on XP: "Lucida Console"
|
||||
* unknown for other windows versions.
|
||||
*
|
||||
* Problem: if we have no preferences file, and the default font name is unknown,
|
||||
* Problem: if we have no preferences file, and the default font name is unknown,
|
||||
* we cannot save Preferences as an error dialog pops up "You have not selected a font".
|
||||
*/
|
||||
prefs.gui_font_name1 = g_strdup("-*-Lucida Console-medium-r-*-*-*-100-*-*-*-*-*-*");
|
||||
|
@ -1191,7 +1202,7 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
|
|||
return &prefs;
|
||||
}
|
||||
|
||||
/* read the preferences file (or similiar) and call the callback
|
||||
/* read the preferences file (or similiar) and call the callback
|
||||
* function to set each key/value pair found */
|
||||
int
|
||||
read_prefs_file(const char *pf_path, FILE *pf, pref_set_pair_cb pref_set_pair_fct, void *private_data)
|
||||
|
@ -1771,7 +1782,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
|
|||
find_index_from_string_array(value, gui_layout_content_text, 0);
|
||||
} else if (strcmp(pref_name, PRS_CONSOLE_LOG_LEVEL) == 0) {
|
||||
prefs.console_log_level = strtoul(value, NULL, 10);
|
||||
|
||||
|
||||
/* handle the capture options */
|
||||
} else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
|
||||
if (prefs.capture_device != NULL)
|
||||
|
@ -2114,6 +2125,11 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
|
|||
break;
|
||||
}
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
return PREFS_SET_OBSOLETE; /* no such preference any more */
|
||||
}
|
||||
|
@ -2224,6 +2240,12 @@ write_pref(gpointer data, gpointer user_data)
|
|||
break;
|
||||
}
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
{
|
||||
/* Nothing to do */
|
||||
break;
|
||||
}
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
|
@ -2279,7 +2301,7 @@ write_prefs(char **pf_path_return)
|
|||
"# Wireshark. Making manual changes should be safe, however.\n", pf);
|
||||
|
||||
fprintf (pf, "\n######## User Interface ########\n");
|
||||
|
||||
|
||||
fprintf(pf, "\n# Vertical scrollbars should be on right side?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_SCROLLBAR_ON_RIGHT ": %s\n",
|
||||
|
@ -2334,12 +2356,12 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
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, "# 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# Open a console window (WIN32 only)?\n");
|
||||
fprintf(pf, "# One of: NEVER, AUTOMATIC, ALWAYS\n");
|
||||
fprintf(pf, PRS_GUI_CONSOLE_OPEN ": %s\n",
|
||||
|
@ -2365,21 +2387,21 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, "# A decimal number (in seconds).\n");
|
||||
fprintf(pf, PRS_GUI_FILEOPEN_PREVIEW ": %d\n",
|
||||
prefs.gui_fileopen_preview);
|
||||
|
||||
|
||||
fprintf(pf, "\n# Ask to save unsaved capture files?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_ASK_UNSAVED ": %s\n",
|
||||
prefs.gui_ask_unsaved == TRUE ? "TRUE" : "FALSE");
|
||||
prefs.gui_ask_unsaved == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Wrap to beginning/end of file during search?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_FIND_WRAP ": %s\n",
|
||||
prefs.gui_find_wrap == TRUE ? "TRUE" : "FALSE");
|
||||
prefs.gui_find_wrap == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Settings dialogs use a save button?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
fprintf(pf, PRS_GUI_USE_PREF_SAVE ": %s\n",
|
||||
prefs.gui_use_pref_save == TRUE ? "TRUE" : "FALSE");
|
||||
prefs.gui_use_pref_save == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# The path to the webbrowser.\n");
|
||||
fprintf(pf, "# Ex: mozilla %%s\n");
|
||||
|
@ -2405,7 +2427,7 @@ write_prefs(char **pf_path_return)
|
|||
gui_layout_content_text[prefs.gui_layout_content_3]);
|
||||
|
||||
fprintf (pf, "\n######## User Interface: Columns ########\n");
|
||||
|
||||
|
||||
clp = prefs.col_list;
|
||||
col_l = NULL;
|
||||
while (clp) {
|
||||
|
@ -2476,7 +2498,7 @@ write_prefs(char **pf_path_return)
|
|||
prefs.console_log_level);
|
||||
|
||||
fprintf(pf, "\n####### Capture ########\n");
|
||||
|
||||
|
||||
if (prefs.capture_device != NULL) {
|
||||
fprintf(pf, "\n# Default capture device\n");
|
||||
fprintf(pf, PRS_CAP_DEVICE ": %s\n", prefs.capture_device);
|
||||
|
@ -2531,7 +2553,7 @@ write_prefs(char **pf_path_return)
|
|||
"%s: %s\n", PRS_PRINT_CMD, prefs.pr_cmd);
|
||||
|
||||
fprintf(pf, "\n####### Name Resolution ########\n");
|
||||
|
||||
|
||||
fprintf(pf, "\n# Resolve addresses to names?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive), or a list of address types to resolve.\n");
|
||||
fprintf(pf, PRS_NAME_RESOLVE ": %s\n",
|
||||
|
|
|
@ -307,6 +307,12 @@ extern void prefs_register_range_preference(module_t *module, const char *name,
|
|||
const char *title, const char *description, range_t **var,
|
||||
guint32 max_value);
|
||||
|
||||
/*
|
||||
* Register a static text 'preference'. It can be used to add some info/explanation.
|
||||
*/
|
||||
extern void prefs_register_static_text_preference(module_t *module, const char *name,
|
||||
const char *title, const char *description);
|
||||
|
||||
/*
|
||||
* Register a preference that used to be supported but no longer is.
|
||||
*/
|
||||
|
|
|
@ -144,7 +144,13 @@ pref_show(pref_t *pref, gpointer user_data)
|
|||
title = pref->title;
|
||||
label_string = g_malloc(strlen(title) + 2);
|
||||
strcpy(label_string, title);
|
||||
strcat(label_string, ":");
|
||||
|
||||
/*
|
||||
* Sometimes we don't want to append a ':' after a static text string...
|
||||
* If it is needed, we will specify it in the string itself.
|
||||
*/
|
||||
if(pref->type != PREF_STATIC_TEXT)
|
||||
strcat(label_string, ":");
|
||||
|
||||
/* Save the current value of the preference, so that we can revert it if
|
||||
the user does "Apply" and then "Cancel", and create the control for
|
||||
|
@ -224,6 +230,13 @@ pref_show(pref_t *pref, gpointer user_data)
|
|||
break;
|
||||
}
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
{
|
||||
pref->control = create_preference_static_text(main_tb, pref->ordinal,
|
||||
label_string, pref->description);
|
||||
break;
|
||||
}
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
|
@ -905,6 +918,28 @@ create_preference_entry(GtkWidget *main_tb, int table_position,
|
|||
return entry;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_preference_static_text(GtkWidget *main_tb, int table_position,
|
||||
const gchar *label_text, const gchar *tooltip_text)
|
||||
{
|
||||
GtkTooltips *tooltips;
|
||||
GtkWidget *label;
|
||||
|
||||
tooltips = OBJECT_GET_DATA(main_tb, E_TOOLTIPS_KEY);
|
||||
|
||||
if(label_text != NULL)
|
||||
label = gtk_label_new(label_text);
|
||||
else
|
||||
label = gtk_label_new("");
|
||||
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 2,
|
||||
table_position, table_position + 1);
|
||||
if (tooltip_text != NULL && tooltips != NULL)
|
||||
gtk_tooltips_set_tip(tooltips, label, tooltip_text, NULL);
|
||||
gtk_widget_show(label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
static guint
|
||||
pref_check(pref_t *pref, gpointer user_data)
|
||||
{
|
||||
|
@ -950,6 +985,10 @@ pref_check(pref_t *pref, gpointer user_data)
|
|||
}
|
||||
g_free(newrange);
|
||||
}
|
||||
break;
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
/* Value can't be bad. */
|
||||
break;
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
|
@ -1050,6 +1089,9 @@ pref_fetch(pref_t *pref, gpointer user_data)
|
|||
break;
|
||||
}
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
break;
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
|
@ -1165,6 +1207,9 @@ pref_clean(pref_t *pref, gpointer user_data _U_)
|
|||
}
|
||||
break;
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
break;
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
|
@ -1346,10 +1391,10 @@ prefs_main_write(void)
|
|||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
/*
|
||||
* Load the Wireshark decryption keys (just set) and save
|
||||
* the changes to the adapters' registry
|
||||
*/
|
||||
/*
|
||||
* Load the Wireshark decryption keys (just set) and save
|
||||
* the changes to the adapters' registry
|
||||
*/
|
||||
airpcap_load_decryption_keys(airpcap_if_list);
|
||||
#endif
|
||||
}
|
||||
|
@ -1495,6 +1540,9 @@ pref_revert(pref_t *pref, gpointer user_data)
|
|||
}
|
||||
break;
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
break;
|
||||
|
||||
case PREF_OBSOLETE:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
|
|
|
@ -147,4 +147,16 @@ extern gint fetch_preference_option_menu_val(GtkWidget *optmenu, const enum_val_
|
|||
extern GtkWidget *create_preference_entry(GtkWidget *main_tb, int table_row,
|
||||
const gchar *label_text, const gchar *tooltip_text, char *value);
|
||||
|
||||
/** Create a static text for a preferences page.
|
||||
*
|
||||
* @param main_tb the table to put this entry into
|
||||
* @param table_row row in the table
|
||||
* @param label_text the label text
|
||||
* @param tooltip_text the tooltip for this text (not neded at all...)
|
||||
* @return the new static text label
|
||||
*/
|
||||
GtkWidget *
|
||||
create_preference_static_text(GtkWidget *main_tb, int table_position,
|
||||
const gchar *label_text, const gchar *tooltip_text);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue