Convert GUI layout preferences to use preference effects.

Another simple example of how to use preference effects to limit
the times a capture file is redissected unnecessarily.

Also clean up some of the grammar of preference effect descriptions.

Change-Id: I2db92e8e3ee913d3b37162916bd0ef7ac8ecd794
Reviewed-on: https://code.wireshark.org/review/25175
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2018-01-06 19:03:36 -05:00 committed by Anders Broman
parent 4e87f6c01a
commit 3f2f16411f
3 changed files with 20 additions and 23 deletions

View File

@ -148,14 +148,15 @@ gui_type_t prefs_get_gui_type(pref_t *pref);
WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
/* Bitmask of flags for how a preference could affect changes in Wireshark */
/* Bitmask of flags for the effect of a preference in Wireshark */
#define PREF_EFFECT_DISSECTION (1u << 0)
#define PREF_EFFECT_CAPTURE (1u << 1)
#define PREF_EFFECT_GUI (1u << 2)
#define PREF_EFFECT_FONT (1u << 3)
#define PREF_EFFECT_GUI_LAYOUT (1u << 4)
#define PREF_EFFECT_CUSTOM (1u << 31)
/** Fetch flags that show preference effect
/** Fetch flags that show the effect of the preference
*
* @param pref A preference.
*
@ -165,11 +166,11 @@ WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
WS_DLL_PUBLIC
unsigned int prefs_get_effect_flags(pref_t *pref);
/** Set flags for preference effect
/** Set flags for the effect of the preference
* The intention is to distinguish preferences that affect
* dissection from those that don't. A bitmask was added to
* provide great flexibility in the types of things that a
* preference could affect.
* provide greater flexibility in the types of effects
* preferences can have.
*
* @param pref A preference.
* @param flags Bitmask of flags to apply to preference. Note that flags

View File

@ -2984,7 +2984,7 @@ prefs_register_modules(void)
module_t *printing, *capture_module, *console_module,
*gui_layout_module, *gui_font_module;
module_t *extcap_module;
unsigned int layout_gui_flags;
struct pref_custom_cbs custom_cbs;
if (protocols_module != NULL) {
@ -3306,27 +3306,35 @@ prefs_register_modules(void)
/* User Interface : Layout */
gui_layout_module = prefs_register_subtree(gui_module, "Layout", "Layout", gui_layout_callback);
/* Adjust the preference effects of layout GUI for better handling of preferences at Wireshark (GUI) level */
layout_gui_flags = prefs_get_module_effect_flags(gui_layout_module);
layout_gui_flags |= PREF_EFFECT_GUI_LAYOUT;
layout_gui_flags &= (~PREF_EFFECT_DISSECTION);
prefs_register_uint_preference(gui_layout_module, "layout_type",
"Layout type",
"Layout type (1-6)",
10,
(guint*)(void*)(&prefs.gui_layout_type));
prefs_set_effect_flags_by_name(gui_layout_module, "layout_type", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_1",
"Layout content of the pane 1",
"Layout content of the pane 1",
(gint*)(void*)(&prefs.gui_layout_content_1), gui_layout_content, FALSE);
prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_1", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_2",
"Layout content of the pane 2",
"Layout content of the pane 2",
(gint*)(void*)(&prefs.gui_layout_content_2), gui_layout_content, FALSE);
prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_2", layout_gui_flags);
prefs_register_enum_preference(gui_layout_module, "layout_content_3",
"Layout content of the pane 3",
"Layout content of the pane 3",
(gint*)(void*)(&prefs.gui_layout_content_3), gui_layout_content, FALSE);
prefs_set_effect_flags_by_name(gui_layout_module, "layout_content_3", layout_gui_flags);
prefs_register_bool_preference(gui_layout_module, "packet_list_separator.enabled",
"Enable Packet List Separator",

View File

@ -201,25 +201,13 @@ void PreferencesDialog::on_advancedSearchLineEdit_textEdited(const QString &sear
void PreferencesDialog::on_buttonBox_accepted()
{
gchar* err = NULL;
unsigned int must_redissect = 0;
QVector<unsigned> old_layout = QVector<unsigned>() << prefs.gui_layout_type
<< prefs.gui_layout_content_1
<< prefs.gui_layout_content_2
<< prefs.gui_layout_content_3;
unsigned int redissect_flags = 0;
// XXX - We should validate preferences as the user changes them, not here.
// XXX - We're also too enthusiastic about setting must_redissect.
// if (!prefs_main_fetch_all(parent_w, &must_redissect))
// return; /* Errors in some preference setting - already reported */
prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer)&must_redissect);
prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer)&redissect_flags);
QVector<unsigned> new_layout = QVector<unsigned>() << prefs.gui_layout_type
<< prefs.gui_layout_content_1
<< prefs.gui_layout_content_2
<< prefs.gui_layout_content_3;
if (new_layout[0] != old_layout[0]) {
if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) {
// Layout type changed, reset sizes
recent.gui_geometry_main_upper_pane = 0;
recent.gui_geometry_main_lower_pane = 0;
@ -269,13 +257,13 @@ void PreferencesDialog::on_buttonBox_accepted()
wsApp->setMonospaceFont(prefs.gui_qt_font_name);
if (must_redissect & PREF_EFFECT_DISSECTION) {
if (redissect_flags & PREF_EFFECT_DISSECTION) {
/* Redissect all the packets, and re-evaluate the display filter. */
wsApp->queueAppSignal(WiresharkApplication::PacketDissectionChanged);
}
wsApp->queueAppSignal(WiresharkApplication::PreferencesChanged);
if (new_layout != old_layout) {
if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) {
wsApp->queueAppSignal(WiresharkApplication::RecentPreferencesRead);
}
}