Internalize struct preference
Move "struct preference" into prefs.c, essentially creating a "private" structure to handle preferences. The 2 motivating factors were: 1. Better memory management so that clients/users of API don't have to worry about it. 2. Hide the ugliness of the union stuff and make it transparent to the API. A few bugs related to preference <-> Decode As integration were fixed while in the neighborhood. Change-Id: I509b9a236235d066b139c98222b701475e0ed365 Reviewed-on: https://code.wireshark.org/review/19578 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
76cf1d0b0a
commit
21a3b8cc71
31
debian/libwireshark0.symbols
vendored
31
debian/libwireshark0.symbols
vendored
@ -924,6 +924,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||
port_with_resolution_to_str_buf@Base 2.0.0
|
||||
postseq_cleanup_all_protocols@Base 1.9.1
|
||||
prefs@Base 1.9.1
|
||||
prefs_add_decode_as_value@Base 2.3.0
|
||||
prefs_apply@Base 1.9.1
|
||||
prefs_apply_all@Base 1.9.1
|
||||
prefs_capture_device_monitor_mode@Base 1.9.1
|
||||
@ -931,10 +932,29 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||
prefs_clear_string_list@Base 1.9.1
|
||||
prefs_find_module@Base 1.9.1
|
||||
prefs_find_preference@Base 1.9.1
|
||||
prefs_get_bool_value@Base 2.3.0
|
||||
prefs_get_color_value@Base 2.3.0
|
||||
prefs_get_control@Base 2.3.0
|
||||
prefs_get_description@Base 2.3.0
|
||||
prefs_get_enum_value@Base 2.3.0
|
||||
prefs_get_enum_radiobuttons@Base 2.3.0
|
||||
prefs_get_enumvals@Base 2.3.0
|
||||
prefs_get_gui_type@Base 2.3.0
|
||||
prefs_get_max_value@Base 2.3.0
|
||||
prefs_get_name@Base 2.3.0
|
||||
prefs_get_ordinal@Base 2.3.0
|
||||
prefs_get_range_value@Base 2.3.0
|
||||
prefs_get_range_value_real@Base 2.3.0
|
||||
prefs_get_string_list@Base 1.9.1
|
||||
prefs_get_string_value@Base 2.3.0
|
||||
prefs_get_title@Base 2.3.0
|
||||
prefs_get_title_by_name@Base 1.9.1
|
||||
prefs_get_type@Base 2.3.0
|
||||
prefs_get_uat_value@Base 2.3.0
|
||||
prefs_get_uint_base@Base 2.3.0
|
||||
prefs_get_uint_value@Base 2.3.0
|
||||
prefs_get_uint_value_real@Base 2.3.0
|
||||
prefs_invert_bool_value@Base 2.3.0
|
||||
prefs_is_capture_device_hidden@Base 1.9.1
|
||||
prefs_is_registered_protocol@Base 1.9.1
|
||||
prefs_module_has_submodules@Base 1.9.1
|
||||
@ -961,9 +981,17 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||
prefs_register_uat_preference_qt@Base 1.12.0~rc1
|
||||
prefs_register_uint_preference@Base 1.9.1
|
||||
prefs_reset@Base 1.9.1
|
||||
prefs_remove_decode_as_value@Base 2.3.0
|
||||
prefs_set_bool_value@Base 2.3.0
|
||||
prefs_set_color_value@Base 2.3.0
|
||||
prefs_set_control@Base 2.3.0
|
||||
prefs_set_enum_value@Base 2.3.0
|
||||
prefs_set_pref@Base 1.9.1
|
||||
prefs_set_range_value@Base 2.1.0
|
||||
prefs_set_string_like_value@Base 2.1.0
|
||||
prefs_set_range_value_work@Base 2.3.0
|
||||
prefs_set_stashed_range_value@Base 2.3.0
|
||||
prefs_set_string_value@Base 2.3.0
|
||||
prefs_set_uint_value@Base 2.3.0
|
||||
print_bookmark@Base 1.12.0~rc1
|
||||
print_finale@Base 1.12.0~rc1
|
||||
print_hex_data@Base 1.12.0~rc1
|
||||
@ -1236,6 +1264,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||
req_resp_hdrs_do_reassembly@Base 1.9.1
|
||||
reset_conversation_table_data@Base 1.99.0
|
||||
reset_hostlist_table_data@Base 1.99.0
|
||||
reset_pref@Base 2.3.0
|
||||
reset_rtd_table@Base 1.99.8
|
||||
reset_srt_table@Base 1.99.8
|
||||
reset_stat_table@Base 1.99.8
|
||||
|
@ -152,13 +152,14 @@ static GSList *dissector_reset_list = NULL;
|
||||
*/
|
||||
static prefs_set_pref_e
|
||||
read_set_decode_as_entries(gchar *key, const gchar *value,
|
||||
void *user_data _U_,
|
||||
void *user_data,
|
||||
gboolean return_range_errors _U_)
|
||||
{
|
||||
gchar *values[4] = {NULL, NULL, NULL, NULL};
|
||||
gchar delimiter[4] = {',', ',', ',','\0'};
|
||||
gchar *pch;
|
||||
guint i, j;
|
||||
GHashTable* processed_entries = (GHashTable*)user_data;
|
||||
dissector_table_t sub_dissectors;
|
||||
prefs_set_pref_e retval = PREFS_SET_OK;
|
||||
gboolean is_valid = FALSE;
|
||||
@ -182,6 +183,7 @@ read_set_decode_as_entries(gchar *key, const gchar *value,
|
||||
ftenum_t selector_type;
|
||||
pref_t* pref_value;
|
||||
module_t *module;
|
||||
const char* proto_name;
|
||||
|
||||
selector_type = dissector_table_get_type(sub_dissectors);
|
||||
|
||||
@ -207,26 +209,21 @@ read_set_decode_as_entries(gchar *key, const gchar *value,
|
||||
}
|
||||
|
||||
/* Now apply the value data back to dissector table preference */
|
||||
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
|
||||
proto_name = proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle));
|
||||
module = prefs_find_module(proto_name);
|
||||
pref_value = prefs_find_preference(module, values[0]);
|
||||
if (pref_value != NULL) {
|
||||
switch(pref_value->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
/* This doesn't support multiple values for a dissector in Decode As because the
|
||||
preference only supports a single value. This leads to a "last port for
|
||||
dissector in Decode As wins" */
|
||||
*pref_value->varp.uint = (guint)long_value;
|
||||
module->prefs_changed = TRUE;
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_add_value(pref_value, (guint)long_value);
|
||||
module->prefs_changed = TRUE;
|
||||
break;
|
||||
default:
|
||||
/* XXX - Worth asserting over? */
|
||||
break;
|
||||
gboolean replace = FALSE;
|
||||
if (g_hash_table_lookup(processed_entries, proto_name) == NULL) {
|
||||
/* First decode as entry for this protocol, ranges may be replaced */
|
||||
replace = TRUE;
|
||||
|
||||
/* Remember we've processed this protocol */
|
||||
g_hash_table_insert(processed_entries, (gpointer)proto_name, (gpointer)proto_name);
|
||||
}
|
||||
|
||||
prefs_add_decode_as_value(pref_value, (guint)long_value, replace);
|
||||
module->prefs_changed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -260,7 +257,10 @@ load_decode_as_entries(void)
|
||||
|
||||
daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE);
|
||||
if ((daf = ws_fopen(daf_path, "r")) != NULL) {
|
||||
read_prefs_file(daf_path, daf, read_set_decode_as_entries, NULL);
|
||||
/* Store saved entries for better range processing */
|
||||
GHashTable* processed_entries = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
read_prefs_file(daf_path, daf, read_set_decode_as_entries, processed_entries);
|
||||
g_hash_table_destroy(processed_entries);
|
||||
fclose(daf);
|
||||
}
|
||||
g_free(daf_path);
|
||||
|
@ -325,7 +325,7 @@ megacostat_filtercheck(const char *opt_arg _U_, const char **filter _U_, char**
|
||||
return;
|
||||
}
|
||||
|
||||
if (!*megaco_ctx_track->varp.boolp || !*h248_ctx_track->varp.boolp) {
|
||||
if (!prefs_get_bool_value(megaco_ctx_track, pref_current) || !prefs_get_bool_value(h248_ctx_track, pref_current)) {
|
||||
*err = g_strdup_printf("Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n"
|
||||
"has to be set to true to enable measurement of service response times.\n");
|
||||
}
|
||||
|
121
epan/prefs-int.h
121
epan/prefs-int.h
@ -116,57 +116,6 @@ typedef enum {
|
||||
GUI_QT
|
||||
} gui_type_t;
|
||||
|
||||
/** Struct to hold preference data */
|
||||
struct preference {
|
||||
const char *name; /**< name of preference */
|
||||
const char *title; /**< title to use in GUI */
|
||||
const char *description; /**< human-readable description of preference */
|
||||
int ordinal; /**< ordinal number of this preference */
|
||||
int type; /**< type of that preference */
|
||||
gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
|
||||
union { /* The Qt preference code assumes that these will all be pointers (and unique) */
|
||||
guint *uint;
|
||||
gboolean *boolp;
|
||||
gint *enump;
|
||||
char **string;
|
||||
range_t **range;
|
||||
struct epan_uat* uat;
|
||||
color_t *colorp;
|
||||
GList** list;
|
||||
} varp; /**< pointer to variable storing the value */
|
||||
union {
|
||||
guint uint;
|
||||
gboolean boolval;
|
||||
gint enumval;
|
||||
char *string;
|
||||
range_t *range;
|
||||
color_t color;
|
||||
GList* list;
|
||||
} stashed_val; /**< original value, when editing from the GUI */
|
||||
union {
|
||||
guint uint;
|
||||
gboolean boolval;
|
||||
gint enumval;
|
||||
char *string;
|
||||
range_t *range;
|
||||
color_t color;
|
||||
GList* list;
|
||||
} default_val; /**< the default value of the preference */
|
||||
union {
|
||||
guint base; /**< input/output base, for PREF_UINT */
|
||||
guint32 max_value; /**< maximum value of a range */
|
||||
struct {
|
||||
const enum_val_t *enumvals; /**< list of name & values */
|
||||
gboolean radio_buttons; /**< TRUE if it should be shown as
|
||||
radio buttons rather than as an
|
||||
option menu or combo box in
|
||||
the preferences tab */
|
||||
} enum_info; /**< for PREF_ENUM */
|
||||
} info; /**< display/text file information */
|
||||
struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
|
||||
void *control; /**< handle for GUI control for this preference. GTK+ only? */
|
||||
};
|
||||
|
||||
/* read_prefs_file: read in a generic config file and do a callback to */
|
||||
/* pref_set_pair_fct() for every key/value pair found */
|
||||
/**
|
||||
@ -178,28 +127,36 @@ struct preference {
|
||||
*/
|
||||
typedef prefs_set_pref_e (*pref_set_pair_cb) (gchar *key, const gchar *value, void *private_data, gboolean return_range_errors);
|
||||
|
||||
/** Set the value of a string-like preference. */
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed);
|
||||
const char* prefs_get_description(pref_t *pref);
|
||||
|
||||
/** Set the value of a range preference. Return FALSE on error, TRUE otherwise. */
|
||||
WS_DLL_PUBLIC
|
||||
gboolean
|
||||
prefs_set_range_value(pref_t *pref, const gchar *value, gboolean *changed);
|
||||
const char* prefs_get_title(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
const char* prefs_get_name(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
int prefs_get_type(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
gui_type_t prefs_get_gui_type(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC guint32 prefs_get_max_value(pref_t *pref);
|
||||
|
||||
// GTK only
|
||||
WS_DLL_PUBLIC void* prefs_get_control(pref_t *pref);
|
||||
WS_DLL_PUBLIC void prefs_set_control(pref_t *pref, void* control);
|
||||
WS_DLL_PUBLIC int prefs_get_ordinal(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
gboolean prefs_set_range_value_work(pref_t *pref, const gchar *value,
|
||||
gboolean return_range_errors, gboolean *changed);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
gboolean
|
||||
prefs_set_stashed_range_value(pref_t *pref, const gchar *value);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
gboolean
|
||||
prefs_set_stashed_range(pref_t *pref, range_t *value);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
range_t *
|
||||
prefs_get_stashed_range(pref_t *pref);
|
||||
|
||||
/** Add a range value of a range preference. */
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
@ -210,10 +167,36 @@ WS_DLL_PUBLIC
|
||||
void
|
||||
prefs_range_remove_value(pref_t *pref, guint32 val);
|
||||
|
||||
/** Set the value of an enum preference. */
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
prefs_set_enum_value(pref_t *pref, const gchar *value, gboolean *changed);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source);
|
||||
WS_DLL_PUBLIC gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source);
|
||||
WS_DLL_PUBLIC void prefs_invert_bool_value(pref_t *pref, pref_source_t source);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source);
|
||||
WS_DLL_PUBLIC guint prefs_get_uint_base(pref_t *pref);
|
||||
WS_DLL_PUBLIC guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source);
|
||||
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source);
|
||||
WS_DLL_PUBLIC gint prefs_get_enum_value(pref_t *pref, pref_source_t source);
|
||||
WS_DLL_PUBLIC const enum_val_t* prefs_get_enumvals(pref_t *pref);
|
||||
WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
|
||||
WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
|
||||
WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);
|
||||
|
||||
WS_DLL_PUBLIC struct epan_uat* prefs_get_uat_value(pref_t *pref);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source);
|
||||
WS_DLL_PUBLIC range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source);
|
||||
|
||||
WS_DLL_PUBLIC gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace);
|
||||
WS_DLL_PUBLIC gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default);
|
||||
|
||||
WS_DLL_PUBLIC void reset_pref(pref_t *pref);
|
||||
|
||||
/** read the preferences file (or similar) and call the callback
|
||||
* function to set each key/value pair found
|
||||
|
557
epan/prefs.c
557
epan/prefs.c
@ -204,6 +204,102 @@ static const enum_val_t gui_packet_list_elide_mode[] = {
|
||||
{NULL, NULL, -1}
|
||||
};
|
||||
|
||||
/** Struct to hold preference data */
|
||||
struct preference {
|
||||
const char *name; /**< name of preference */
|
||||
const char *title; /**< title to use in GUI */
|
||||
const char *description; /**< human-readable description of preference */
|
||||
int ordinal; /**< ordinal number of this preference */
|
||||
int type; /**< type of that preference */
|
||||
gui_type_t gui; /**< type of the GUI (QT, GTK or both) the preference is registered for */
|
||||
union { /* The Qt preference code assumes that these will all be pointers (and unique) */
|
||||
guint *uint;
|
||||
gboolean *boolp;
|
||||
gint *enump;
|
||||
char **string;
|
||||
range_t **range;
|
||||
struct epan_uat* uat;
|
||||
color_t *colorp;
|
||||
GList** list;
|
||||
} varp; /**< pointer to variable storing the value */
|
||||
union {
|
||||
guint uint;
|
||||
gboolean boolval;
|
||||
gint enumval;
|
||||
char *string;
|
||||
range_t *range;
|
||||
color_t color;
|
||||
GList* list;
|
||||
} stashed_val; /**< original value, when editing from the GUI */
|
||||
union {
|
||||
guint uint;
|
||||
gboolean boolval;
|
||||
gint enumval;
|
||||
char *string;
|
||||
range_t *range;
|
||||
color_t color;
|
||||
GList* list;
|
||||
} default_val; /**< the default value of the preference */
|
||||
union {
|
||||
guint base; /**< input/output base, for PREF_UINT */
|
||||
guint32 max_value; /**< maximum value of a range */
|
||||
struct {
|
||||
const enum_val_t *enumvals; /**< list of name & values */
|
||||
gboolean radio_buttons; /**< TRUE if it should be shown as
|
||||
radio buttons rather than as an
|
||||
option menu or combo box in
|
||||
the preferences tab */
|
||||
} enum_info; /**< for PREF_ENUM */
|
||||
} info; /**< display/text file information */
|
||||
struct pref_custom_cbs custom_cbs; /**< for PREF_CUSTOM */
|
||||
void *control; /**< handle for GUI control for this preference. GTK+ only? */
|
||||
};
|
||||
|
||||
const char* prefs_get_description(pref_t *pref)
|
||||
{
|
||||
return pref->description;
|
||||
}
|
||||
|
||||
const char* prefs_get_title(pref_t *pref)
|
||||
{
|
||||
return pref->title;
|
||||
}
|
||||
|
||||
int prefs_get_type(pref_t *pref)
|
||||
{
|
||||
return pref->type;
|
||||
}
|
||||
|
||||
gui_type_t prefs_get_gui_type(pref_t *pref)
|
||||
{
|
||||
return pref->gui;
|
||||
}
|
||||
|
||||
const char* prefs_get_name(pref_t *pref)
|
||||
{
|
||||
return pref->name;
|
||||
}
|
||||
|
||||
guint32 prefs_get_max_value(pref_t *pref)
|
||||
{
|
||||
return pref->info.max_value;
|
||||
}
|
||||
|
||||
void* prefs_get_control(pref_t *pref)
|
||||
{
|
||||
return pref->control;
|
||||
}
|
||||
|
||||
void prefs_set_control(pref_t *pref, void* control)
|
||||
{
|
||||
pref->control = control;
|
||||
}
|
||||
|
||||
int prefs_get_ordinal(pref_t *pref)
|
||||
{
|
||||
return pref->ordinal;
|
||||
}
|
||||
|
||||
/*
|
||||
* List of all modules with preference settings.
|
||||
*/
|
||||
@ -1036,6 +1132,78 @@ prefs_register_bool_preference(module_t *module, const char *name,
|
||||
preference->default_val.boolval = *var;
|
||||
}
|
||||
|
||||
gboolean prefs_set_bool_value(pref_t *pref, gboolean value, pref_source_t source)
|
||||
{
|
||||
gboolean changed = FALSE;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if (pref->default_val.boolval != value) {
|
||||
pref->default_val.boolval = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if (pref->stashed_val.boolval != value) {
|
||||
pref->stashed_val.boolval = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if (*pref->varp.boolp != value) {
|
||||
*pref->varp.boolp = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void prefs_invert_bool_value(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
pref->default_val.boolval = !pref->default_val.boolval;
|
||||
break;
|
||||
case pref_stashed:
|
||||
pref->stashed_val.boolval = !pref->stashed_val.boolval;
|
||||
break;
|
||||
case pref_current:
|
||||
*pref->varp.boolp = !(*pref->varp.boolp);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean prefs_get_bool_value(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return pref->default_val.boolval;
|
||||
break;
|
||||
case pref_stashed:
|
||||
return pref->stashed_val.boolval;
|
||||
break;
|
||||
case pref_current:
|
||||
return *pref->varp.boolp;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a preference with an enumerated value.
|
||||
*/
|
||||
@ -1055,6 +1223,69 @@ prefs_register_enum_preference(module_t *module, const char *name,
|
||||
preference->info.enum_info.radio_buttons = radio_buttons;
|
||||
}
|
||||
|
||||
gboolean prefs_set_enum_value(pref_t *pref, gint value, pref_source_t source)
|
||||
{
|
||||
gboolean changed = FALSE;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if (pref->default_val.enumval != value) {
|
||||
pref->default_val.enumval = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if (pref->stashed_val.enumval != value) {
|
||||
pref->stashed_val.enumval = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if (*pref->varp.enump != value) {
|
||||
*pref->varp.enump = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
gint prefs_get_enum_value(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return pref->default_val.enumval;
|
||||
break;
|
||||
case pref_stashed:
|
||||
return pref->stashed_val.enumval;
|
||||
break;
|
||||
case pref_current:
|
||||
return *pref->varp.enump;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const enum_val_t* prefs_get_enumvals(pref_t *pref)
|
||||
{
|
||||
return pref->info.enum_info.enumvals;
|
||||
}
|
||||
|
||||
gboolean prefs_get_enum_radiobuttons(pref_t *pref)
|
||||
{
|
||||
return pref->info.enum_info.radio_buttons;
|
||||
}
|
||||
|
||||
static void
|
||||
register_string_like_preference(module_t *module, const char *name,
|
||||
const char *title, const char *description,
|
||||
@ -1097,18 +1328,70 @@ register_string_like_preference(module_t *module, const char *name,
|
||||
/*
|
||||
* For use by UI code that sets preferences.
|
||||
*/
|
||||
void
|
||||
prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
|
||||
gboolean
|
||||
prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source)
|
||||
{
|
||||
if (*pref->varp.string) {
|
||||
if (strcmp(*pref->varp.string, value) != 0) {
|
||||
*changed = TRUE;
|
||||
g_free(*pref->varp.string);
|
||||
gboolean changed = FALSE;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if (*pref->default_val.string) {
|
||||
if (strcmp(pref->default_val.string, value) != 0) {
|
||||
changed = TRUE;
|
||||
g_free(pref->default_val.string);
|
||||
pref->default_val.string = g_strdup(value);
|
||||
}
|
||||
} else if (value) {
|
||||
pref->default_val.string = g_strdup(value);
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if (pref->stashed_val.string) {
|
||||
if (strcmp(pref->stashed_val.string, value) != 0) {
|
||||
changed = TRUE;
|
||||
g_free(pref->stashed_val.string);
|
||||
pref->stashed_val.string = g_strdup(value);
|
||||
}
|
||||
} else if (value) {
|
||||
pref->stashed_val.string = g_strdup(value);
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if (*pref->varp.string) {
|
||||
if (strcmp(*pref->varp.string, value) != 0) {
|
||||
changed = TRUE;
|
||||
g_free(*pref->varp.string);
|
||||
*pref->varp.string = g_strdup(value);
|
||||
}
|
||||
} else if (value) {
|
||||
*pref->varp.string = g_strdup(value);
|
||||
}
|
||||
} else if (value) {
|
||||
*pref->varp.string = g_strdup(value);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
char* prefs_get_string_value(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return pref->default_val.string;
|
||||
case pref_stashed:
|
||||
return pref->stashed_val.string;
|
||||
case pref_current:
|
||||
return *pref->varp.string;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1201,7 +1484,7 @@ prefs_register_range_preference(module_t *module, const char *name,
|
||||
description, var, max_value, PREF_RANGE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
prefs_set_range_value_work(pref_t *pref, const gchar *value,
|
||||
gboolean return_range_errors, gboolean *changed)
|
||||
{
|
||||
@ -1225,12 +1508,6 @@ prefs_set_range_value_work(pref_t *pref, const gchar *value,
|
||||
/*
|
||||
* For use by UI code that sets preferences.
|
||||
*/
|
||||
gboolean
|
||||
prefs_set_range_value(pref_t *pref, const gchar *value, gboolean *changed)
|
||||
{
|
||||
return prefs_set_range_value_work(pref, value, TRUE, changed);
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
|
||||
{
|
||||
@ -1251,22 +1528,64 @@ prefs_set_stashed_range_value(pref_t *pref, const gchar *value)
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_set_stashed_range(pref_t *pref, range_t *value)
|
||||
gboolean prefs_set_range_value(pref_t *pref, range_t *value, pref_source_t source)
|
||||
{
|
||||
if (!ranges_are_equal(pref->stashed_val.range, value)) {
|
||||
wmem_free(wmem_epan_scope(), pref->stashed_val.range);
|
||||
pref->stashed_val.range = range_copy(wmem_epan_scope(), value);
|
||||
return TRUE;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if (!ranges_are_equal(pref->default_val.range, value)) {
|
||||
wmem_free(wmem_epan_scope(), pref->default_val.range);
|
||||
pref->default_val.range = range_copy(wmem_epan_scope(), value);
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if (!ranges_are_equal(pref->stashed_val.range, value)) {
|
||||
wmem_free(wmem_epan_scope(), pref->stashed_val.range);
|
||||
pref->stashed_val.range = range_copy(wmem_epan_scope(), value);
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if (!ranges_are_equal(*pref->varp.range, value)) {
|
||||
wmem_free(wmem_epan_scope(), *pref->varp.range);
|
||||
*pref->varp.range = range_copy(wmem_epan_scope(), value);
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return changed;
|
||||
}
|
||||
|
||||
range_t *
|
||||
prefs_get_stashed_range(pref_t *pref)
|
||||
range_t* prefs_get_range_value_real(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
return pref->stashed_val.range;
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return pref->default_val.range;
|
||||
case pref_stashed:
|
||||
return pref->stashed_val.range;
|
||||
break;
|
||||
case pref_current:
|
||||
return *pref->varp.range;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
range_t* prefs_get_range_value(const char *module_name, const char* pref_name)
|
||||
{
|
||||
return prefs_get_range_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1326,6 +1645,11 @@ prefs_register_uat_preference_qt(module_t *module, const char *name,
|
||||
preference->gui = GUI_QT;
|
||||
}
|
||||
|
||||
struct epan_uat* prefs_get_uat_value(pref_t *pref)
|
||||
{
|
||||
return pref->varp.uat;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a color preference.
|
||||
*/
|
||||
@ -1340,6 +1664,64 @@ prefs_register_color_preference(module_t *module, const char *name,
|
||||
preference->default_val.color = *color;
|
||||
}
|
||||
|
||||
gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source)
|
||||
{
|
||||
gboolean changed = FALSE;
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if ((pref->default_val.color.red != value.red) &&
|
||||
(pref->default_val.color.green != value.green) &&
|
||||
(pref->default_val.color.blue != value.blue)) {
|
||||
changed = TRUE;
|
||||
pref->default_val.color = value;
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if ((pref->stashed_val.color.red != value.red) &&
|
||||
(pref->stashed_val.color.green != value.green) &&
|
||||
(pref->stashed_val.color.blue != value.blue)) {
|
||||
changed = TRUE;
|
||||
pref->stashed_val.color = value;
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if ((pref->varp.colorp->red != value.red) &&
|
||||
(pref->varp.colorp->green != value.green) &&
|
||||
(pref->varp.colorp->blue != value.blue)) {
|
||||
changed = TRUE;
|
||||
*pref->varp.colorp = value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
color_t* prefs_get_color_value(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return &pref->default_val.color;
|
||||
case pref_stashed:
|
||||
return &pref->stashed_val.color;
|
||||
break;
|
||||
case pref_current:
|
||||
return pref->varp.colorp;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a "custom" preference with a list.
|
||||
* XXX - This should be temporary until we can find a better way
|
||||
@ -1405,6 +1787,58 @@ void prefs_register_decode_as_preference(module_t *module, const char *name,
|
||||
preference->info.base = 10;
|
||||
}
|
||||
|
||||
gboolean prefs_add_decode_as_value(pref_t *pref, guint value, gboolean replace)
|
||||
{
|
||||
switch(pref->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
/* This doesn't support multiple values for a dissector in Decode As because the
|
||||
preference only supports a single value. This leads to a "last port for
|
||||
dissector in Decode As wins" */
|
||||
*pref->varp.uint = value;
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
if (replace)
|
||||
{
|
||||
/* If range has single value, replace it */
|
||||
if (((*pref->varp.range)->nranges == 1) &&
|
||||
((*pref->varp.range)->ranges[0].low == (*pref->varp.range)->ranges[0].high)) {
|
||||
wmem_free(wmem_epan_scope(), *pref->varp.range);
|
||||
*pref->varp.range = range_empty(wmem_epan_scope());
|
||||
}
|
||||
}
|
||||
|
||||
prefs_range_add_value(pref, value);
|
||||
break;
|
||||
default:
|
||||
/* XXX - Worth asserting over? */
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean prefs_remove_decode_as_value(pref_t *pref, guint value, gboolean set_default)
|
||||
{
|
||||
switch(pref->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
if (set_default) {
|
||||
*pref->varp.uint = pref->default_val.uint;
|
||||
} else {
|
||||
*pref->varp.uint = 0;
|
||||
}
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_remove_value(pref, value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a preference that used to be supported but no longer is.
|
||||
*/
|
||||
@ -1920,7 +2354,7 @@ column_hidden_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
|
||||
fmt_data *cfmt;
|
||||
pref_t *format_pref;
|
||||
|
||||
prefs_set_string_like_value(pref, value, changed);
|
||||
(*changed) |= prefs_set_string_value(pref, value, pref_current);
|
||||
|
||||
/*
|
||||
* Set the "visible" flag for the existing columns; we need to
|
||||
@ -2433,8 +2867,7 @@ capture_column_to_str_cb(pref_t* pref, gboolean default_val)
|
||||
static prefs_set_pref_e
|
||||
colorized_frame_set_cb(pref_t* pref, const gchar* value, gboolean* changed)
|
||||
{
|
||||
prefs_set_string_like_value(pref, value, changed);
|
||||
|
||||
(*changed) |= prefs_set_string_value(pref, value, pref_current);
|
||||
return PREFS_SET_OK;
|
||||
}
|
||||
|
||||
@ -3604,7 +4037,7 @@ pre_init_prefs(void)
|
||||
/*
|
||||
* Reset a single dissector preference.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
reset_pref(pref_t *pref)
|
||||
{
|
||||
int type;
|
||||
@ -4153,20 +4586,66 @@ prefs_set_pref(char *prefarg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
guint prefs_get_uint_value(const char *module_name, const char* pref_name)
|
||||
guint prefs_get_uint_value_real(pref_t *pref, pref_source_t source)
|
||||
{
|
||||
pref_t *pref = prefs_find_preference(prefs_find_module(module_name), pref_name);
|
||||
g_assert(pref != NULL);
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
return pref->default_val.uint;
|
||||
break;
|
||||
case pref_stashed:
|
||||
return pref->stashed_val.uint;
|
||||
break;
|
||||
case pref_current:
|
||||
return *pref->varp.uint;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return *pref->varp.uint;
|
||||
return 0;
|
||||
}
|
||||
|
||||
range_t* prefs_get_range_value(const char *module_name, const char* pref_name)
|
||||
guint prefs_get_uint_value(const char *module_name, const char* pref_name)
|
||||
{
|
||||
pref_t *pref = prefs_find_preference(prefs_find_module(module_name), pref_name);
|
||||
g_assert(pref != NULL);
|
||||
return prefs_get_uint_value_real(prefs_find_preference(prefs_find_module(module_name), pref_name), pref_current);
|
||||
}
|
||||
|
||||
return *pref->varp.range;
|
||||
gboolean prefs_set_uint_value(pref_t *pref, guint value, pref_source_t source)
|
||||
{
|
||||
gboolean changed = FALSE;
|
||||
switch (source)
|
||||
{
|
||||
case pref_default:
|
||||
if (pref->default_val.uint != value) {
|
||||
pref->default_val.uint = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_stashed:
|
||||
if (pref->stashed_val.uint != value) {
|
||||
pref->stashed_val.uint = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
case pref_current:
|
||||
if (*pref->varp.uint != value) {
|
||||
*pref->varp.uint = value;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
guint prefs_get_uint_base(pref_t *pref)
|
||||
{
|
||||
return pref->info.base;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4693,7 +5172,7 @@ deprecated_port_pref(gchar *pref_name, const gchar *value)
|
||||
pref = prefs_find_preference(module, port_range_prefs[i].table_name);
|
||||
if (pref != NULL)
|
||||
{
|
||||
if (!prefs_set_range_value(pref, value, &module->prefs_changed))
|
||||
if (!prefs_set_range_value_work(pref, value, TRUE, &module->prefs_changed))
|
||||
{
|
||||
return FALSE; /* number was bad */
|
||||
}
|
||||
@ -5253,7 +5732,7 @@ set_pref(gchar *pref_name, const gchar *value, void *private_data _U_,
|
||||
case PREF_STRING:
|
||||
case PREF_FILENAME:
|
||||
case PREF_DIRNAME:
|
||||
prefs_set_string_like_value(pref, value, &containing_module->prefs_changed);
|
||||
containing_module->prefs_changed |= prefs_set_string_value(pref, value, pref_current);
|
||||
break;
|
||||
|
||||
case PREF_RANGE:
|
||||
|
@ -100,7 +100,7 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||
pref_t *display_pref = prefs_find_preference(frame_module, "disable_packet_size_limited_in_summary");
|
||||
if (display_pref)
|
||||
{
|
||||
if (*display_pref->varp.boolp)
|
||||
if (prefs_get_bool_value(display_pref, pref_current))
|
||||
display_info = FALSE;
|
||||
}
|
||||
}
|
||||
|
1
extcap.c
1
extcap.c
@ -48,7 +48,6 @@
|
||||
#include <log.h>
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/prefs-int.h>
|
||||
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
|
@ -304,9 +304,9 @@ get_wep_key(pref_t *pref, gpointer ud)
|
||||
/* Retrieve user data info */
|
||||
user_data = (keys_cb_data_t*)ud;
|
||||
|
||||
if (g_ascii_strcasecmp(pref->name, "wep_key_table") == 0 && pref->type == PREF_UAT)
|
||||
if (g_ascii_strcasecmp(prefs_get_name(pref), "wep_key_table") == 0 && prefs_get_type(pref) == PREF_UAT)
|
||||
{
|
||||
uat = pref->varp.uat;
|
||||
uat = prefs_get_uat_value(pref);
|
||||
/* This is just a sanity check. UAT should be loaded */
|
||||
if (!uat->loaded)
|
||||
{
|
||||
@ -368,9 +368,9 @@ set_wep_key(pref_t *pref, gpointer ud _U_)
|
||||
/* Retrieve user data info */
|
||||
user_data = (keys_cb_data_t*)ud;
|
||||
|
||||
if (g_ascii_strcasecmp(pref->name, "wep_key_table") == 0 && pref->type == PREF_UAT)
|
||||
if (g_ascii_strcasecmp(prefs_get_name(pref), "wep_key_table") == 0 && prefs_get_type(pref) == PREF_UAT)
|
||||
{
|
||||
uat = pref->varp.uat;
|
||||
uat = prefs_get_uat_value(pref);
|
||||
if (!uat->loaded)
|
||||
{
|
||||
/* UAT will only be loaded if previous keys exist, so it may need
|
||||
@ -1099,18 +1099,13 @@ static guint
|
||||
test_if_on(pref_t *pref, gpointer ud)
|
||||
{
|
||||
gboolean *is_on;
|
||||
gboolean number;
|
||||
|
||||
/* Retrieve user data info */
|
||||
is_on = (gboolean*)ud;
|
||||
|
||||
|
||||
if (g_ascii_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL)
|
||||
if (g_ascii_strncasecmp(prefs_get_name(pref), "enable_decryption", 17) == 0 && prefs_get_gui_type(pref) == PREF_BOOL)
|
||||
{
|
||||
number = *pref->varp.boolp;
|
||||
|
||||
if (number) *is_on = TRUE;
|
||||
else *is_on = FALSE;
|
||||
*is_on = prefs_get_bool_value(pref, pref_current);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1446,14 +1441,9 @@ set_on_off(pref_t *pref, gpointer ud)
|
||||
/* Retrieve user data info */
|
||||
is_on = (gboolean*)ud;
|
||||
|
||||
if (g_ascii_strncasecmp(pref->name, "enable_decryption", 17) == 0 && pref->type == PREF_BOOL)
|
||||
if (g_ascii_strncasecmp(prefs_get_name(pref), "enable_decryption", 17) == 0 && prefs_get_type(pref) == PREF_BOOL)
|
||||
{
|
||||
|
||||
if (*is_on)
|
||||
*pref->varp.boolp = TRUE;
|
||||
else
|
||||
*pref->varp.boolp = FALSE;
|
||||
|
||||
prefs_set_bool_value(pref, *is_on, pref_current);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -645,7 +645,7 @@ decode_simple (GtkWidget *notebook_pg)
|
||||
GtkTreeIter iter;
|
||||
decode_as_t *entry;
|
||||
gchar *table_name, *abbrev;
|
||||
dissector_handle_t handle;
|
||||
dissector_handle_t handle, temp_handle;
|
||||
guint value_loop, *selector_type;
|
||||
gpointer ptr, value_ptr;
|
||||
gint requested_index = 0;
|
||||
@ -683,15 +683,14 @@ decode_simple (GtkWidget *notebook_pg)
|
||||
for (value_loop = 0; value_loop < entry->values[requested_index].num_values; value_loop++)
|
||||
{
|
||||
pref_t* pref_value;
|
||||
dissector_handle_t temp_handle;
|
||||
module_t *module;
|
||||
|
||||
guint8 saved_curr_layer_num = cfile.edt->pi.curr_layer_num;
|
||||
cfile.edt->pi.curr_layer_num = (guint8)GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(notebook_pg), E_PAGE_CURR_LAYER_NUM));
|
||||
value_ptr = entry->values[requested_index].build_values[value_loop](&cfile.edt->pi);
|
||||
/* Find the handle currently associated with the value */
|
||||
temp_handle = dissector_get_uint_handle(sub_dissectors, GPOINTER_TO_UINT(value_ptr));
|
||||
if (abbrev != NULL && strcmp(abbrev, "(default)") == 0) {
|
||||
/* Find the handle currently associated with the value */
|
||||
temp_handle = dissector_get_uint_handle(sub_dissectors, GPOINTER_TO_UINT(value_ptr));
|
||||
|
||||
add_reset_list = entry->reset_value(table_name, value_ptr);
|
||||
|
||||
@ -702,17 +701,7 @@ decode_simple (GtkWidget *notebook_pg)
|
||||
pref_value = prefs_find_preference(module, table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
switch(pref_value->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
*pref_value->varp.uint = pref_value->default_val.uint;
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_remove_value(pref_value, GPOINTER_TO_UINT(value_ptr));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prefs_remove_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -721,25 +710,25 @@ decode_simple (GtkWidget *notebook_pg)
|
||||
|
||||
/* For now, only numeric dissector tables can use preferences */
|
||||
if (IS_FT_UINT(dissector_table_get_type(sub_dissectors))) {
|
||||
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
|
||||
pref_value = prefs_find_preference(module, table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
switch(pref_value->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
/* This doesn't support multiple values for a dissector in Decode As because the
|
||||
preference only supports a single value. This leads to a "last port for
|
||||
dissector in Decode As wins" */
|
||||
*pref_value->varp.uint = GPOINTER_TO_UINT(value_ptr);
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_add_value(pref_value, GPOINTER_TO_UINT(value_ptr));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (requested_action != E_DECODE_NO) {
|
||||
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
|
||||
pref_value = prefs_find_preference(module, table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
prefs_add_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), FALSE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (temp_handle != NULL) {
|
||||
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(temp_handle)));
|
||||
pref_value = prefs_find_preference(module, table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
prefs_remove_decode_as_value(pref_value, GPOINTER_TO_UINT(value_ptr), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
cfile.edt->pi.curr_layer_num = saved_curr_layer_num;
|
||||
|
@ -4822,11 +4822,11 @@ set_menus_for_selected_packet(capture_file *cf)
|
||||
static void
|
||||
menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
|
||||
{
|
||||
gboolean *value = (gboolean *)data;
|
||||
pref_t *pref = (pref_t*)data;
|
||||
module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
|
||||
|
||||
module->prefs_changed = TRUE;
|
||||
*value = !(*value);
|
||||
prefs_invert_bool_value(pref, pref_current);
|
||||
|
||||
prefs_apply (module);
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
@ -4839,16 +4839,15 @@ menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
|
||||
static void
|
||||
menu_prefs_change_enum (GtkWidget *w, gpointer data)
|
||||
{
|
||||
gint *value = (gint *)data;
|
||||
pref_t *pref = (pref_t*)data;
|
||||
module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
|
||||
gint new_value = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(w), "enumval"));
|
||||
|
||||
if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
|
||||
return;
|
||||
|
||||
if (*value != new_value) {
|
||||
if (prefs_set_enum_value(pref, new_value, pref_current)) {
|
||||
module->prefs_changed = TRUE;
|
||||
*value = new_value;
|
||||
|
||||
prefs_apply (module);
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
@ -4876,25 +4875,22 @@ menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
|
||||
gchar *p;
|
||||
guint uval;
|
||||
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_UINT:
|
||||
uval = (guint)strtoul(new_value, &p, pref->info.base);
|
||||
uval = (guint)strtoul(new_value, &p, prefs_get_uint_base(pref));
|
||||
if (p == new_value || *p != '\0') {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The value \"%s\" isn't a valid number.",
|
||||
new_value);
|
||||
return;
|
||||
}
|
||||
if (*pref->varp.uint != uval) {
|
||||
module->prefs_changed = TRUE;
|
||||
*pref->varp.uint = uval;
|
||||
}
|
||||
module->prefs_changed |= prefs_set_uint_value(pref, uval, pref_current);
|
||||
break;
|
||||
case PREF_STRING:
|
||||
prefs_set_string_like_value(pref, new_value, &module->prefs_changed);
|
||||
module->prefs_changed |= prefs_set_string_value(pref, new_value, pref_current);
|
||||
break;
|
||||
case PREF_RANGE:
|
||||
if (!prefs_set_range_value(pref, new_value, &module->prefs_changed)) {
|
||||
if (!prefs_set_range_value_work(pref, new_value, TRUE, &module->prefs_changed)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The value \"%s\" isn't a valid range.",
|
||||
new_value);
|
||||
@ -4931,41 +4927,12 @@ menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
|
||||
{
|
||||
pref_t *pref = (pref_t *)data;
|
||||
module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
|
||||
gchar *value = NULL, *tmp_value, *label_str;
|
||||
gchar *value = NULL, *label_str;
|
||||
|
||||
GtkWidget *win, *main_grid, *main_vb, *bbox, *cancel_bt, *ok_bt;
|
||||
GtkWidget *entry, *label;
|
||||
|
||||
switch (pref->type) {
|
||||
case PREF_UINT:
|
||||
switch (pref->info.base) {
|
||||
case 8:
|
||||
value = g_strdup_printf("%o", *pref->varp.uint);
|
||||
break;
|
||||
case 10:
|
||||
value = g_strdup_printf("%u", *pref->varp.uint);
|
||||
break;
|
||||
case 16:
|
||||
value = g_strdup_printf("%x", *pref->varp.uint);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PREF_STRING:
|
||||
value = g_strdup(*pref->varp.string);
|
||||
break;
|
||||
case PREF_RANGE:
|
||||
/* Convert wmem to g_alloc memory */
|
||||
tmp_value = range_convert_range(NULL, *pref->varp.range);
|
||||
value = g_strdup(tmp_value);
|
||||
wmem_free(NULL, tmp_value);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
value = prefs_pref_to_str(pref, pref_current);
|
||||
|
||||
win = dlg_window_new(module->description);
|
||||
|
||||
@ -4980,19 +4947,19 @@ menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 10);
|
||||
|
||||
label_str = g_strdup_printf("%s:", pref->title);
|
||||
label_str = g_strdup_printf("%s:", prefs_get_title(pref));
|
||||
label = gtk_label_new(label_str);
|
||||
g_free(label_str);
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), label, 0, 1, 1, 1);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
|
||||
if (pref->description)
|
||||
gtk_widget_set_tooltip_text(label, pref->description);
|
||||
if (prefs_get_description(pref))
|
||||
gtk_widget_set_tooltip_text(label, prefs_get_description(pref));
|
||||
|
||||
entry = gtk_entry_new();
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), entry, 1, 1, 1, 1);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), value);
|
||||
if (pref->description)
|
||||
gtk_widget_set_tooltip_text(entry, pref->description);
|
||||
if (prefs_get_description(pref))
|
||||
gtk_widget_set_tooltip_text(entry, prefs_get_description(pref));
|
||||
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
|
||||
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
@ -5024,17 +4991,17 @@ add_protocol_prefs_generic_menu(pref_t *pref, gpointer data, GtkUIManager *ui_me
|
||||
const enum_val_t *enum_valp;
|
||||
gchar *label = NULL, *tmp_str;
|
||||
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_UINT:
|
||||
switch (pref->info.base) {
|
||||
switch (prefs_get_uint_base(pref)) {
|
||||
case 8:
|
||||
label = g_strdup_printf ("%s: %o", pref->title, *pref->varp.uint);
|
||||
label = g_strdup_printf ("%s: %o", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
|
||||
break;
|
||||
case 10:
|
||||
label = g_strdup_printf ("%s: %u", pref->title, *pref->varp.uint);
|
||||
label = g_strdup_printf ("%s: %u", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
|
||||
break;
|
||||
case 16:
|
||||
label = g_strdup_printf ("%s: %x", pref->title, *pref->varp.uint);
|
||||
label = g_strdup_printf ("%s: %x", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
@ -5046,40 +5013,40 @@ add_protocol_prefs_generic_menu(pref_t *pref, gpointer data, GtkUIManager *ui_me
|
||||
g_free (label);
|
||||
break;
|
||||
case PREF_BOOL:
|
||||
menu_item = gtk_check_menu_item_new_with_label(pref->title);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), *pref->varp.boolp);
|
||||
menu_item = gtk_check_menu_item_new_with_label(prefs_get_title(pref));
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), prefs_get_bool_value(pref, pref_current));
|
||||
g_object_set_data (G_OBJECT(menu_item), "module", module);
|
||||
g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref->varp.boolp);
|
||||
g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref);
|
||||
break;
|
||||
case PREF_ENUM:
|
||||
menu_item = gtk_menu_item_new_with_label(pref->title);
|
||||
menu_item = gtk_menu_item_new_with_label(prefs_get_title(pref));
|
||||
sub_menu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), sub_menu);
|
||||
enum_valp = pref->info.enum_info.enumvals;
|
||||
enum_valp = prefs_get_enumvals(pref);
|
||||
while (enum_valp->name != NULL) {
|
||||
menu_sub_item = gtk_radio_menu_item_new_with_label(group, enum_valp->description);
|
||||
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_sub_item));
|
||||
if (enum_valp->value == *pref->varp.enump) {
|
||||
if (enum_valp->value == prefs_get_enum_value(pref, pref_current)) {
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_sub_item), TRUE);
|
||||
}
|
||||
g_object_set_data (G_OBJECT(menu_sub_item), "module", module);
|
||||
g_object_set_data (G_OBJECT(menu_sub_item), "enumval", GINT_TO_POINTER(enum_valp->value));
|
||||
g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref->varp.enump);
|
||||
g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_sub_item);
|
||||
gtk_widget_show (menu_sub_item);
|
||||
enum_valp++;
|
||||
}
|
||||
break;
|
||||
case PREF_STRING:
|
||||
label = g_strdup_printf ("%s: %s", pref->title, *pref->varp.string);
|
||||
label = g_strdup_printf ("%s: %s", prefs_get_title(pref), prefs_get_string_value(pref, pref_current));
|
||||
menu_item = gtk_menu_item_new_with_label(label);
|
||||
g_object_set_data (G_OBJECT(menu_item), "module", module);
|
||||
g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
|
||||
g_free (label);
|
||||
break;
|
||||
case PREF_RANGE:
|
||||
tmp_str = range_convert_range (NULL, *pref->varp.range);
|
||||
label = g_strdup_printf ("%s: %s", pref->title, tmp_str);
|
||||
tmp_str = range_convert_range (NULL, prefs_get_range_value_real(pref, pref_current));
|
||||
label = g_strdup_printf ("%s: %s", prefs_get_title(pref), tmp_str);
|
||||
wmem_free(NULL, tmp_str);
|
||||
menu_item = gtk_menu_item_new_with_label(label);
|
||||
g_object_set_data (G_OBJECT(menu_item), "module", module);
|
||||
@ -5087,9 +5054,9 @@ add_protocol_prefs_generic_menu(pref_t *pref, gpointer data, GtkUIManager *ui_me
|
||||
g_free (label);
|
||||
break;
|
||||
case PREF_UAT:
|
||||
label = g_strdup_printf ("%s...", pref->title);
|
||||
label = g_strdup_printf ("%s...", prefs_get_title(pref));
|
||||
menu_item = gtk_menu_item_new_with_label(label);
|
||||
g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), pref->varp.uat);
|
||||
g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), prefs_get_uat_value(pref));
|
||||
g_free (label);
|
||||
break;
|
||||
|
||||
|
@ -127,20 +127,20 @@ pref_show(pref_t *pref, gpointer user_data)
|
||||
const char *type_name = prefs_pref_type_name(pref);
|
||||
char *label_string;
|
||||
size_t label_len;
|
||||
char uint_str[10+1];
|
||||
char *uint_str;
|
||||
char *tooltip_txt;
|
||||
|
||||
/* Give this preference a label which is its title, followed by a colon,
|
||||
and left-align it. */
|
||||
title = pref->title;
|
||||
title = prefs_get_title(pref);
|
||||
label_len = strlen(title) + 2;
|
||||
label_string = (char *)g_malloc(label_len);
|
||||
g_strlcpy(label_string, title, label_len);
|
||||
|
||||
tooltip_txt = pref->description? g_strdup_printf("%s\n\nName: %s.%s\nType: %s",
|
||||
pref->description,
|
||||
tooltip_txt = prefs_get_description(pref) ? g_strdup_printf("%s\n\nName: %s.%s\nType: %s",
|
||||
prefs_get_description(pref),
|
||||
module->name,
|
||||
pref->name,
|
||||
prefs_get_name(pref),
|
||||
type_name ? type_name : "Unknown"
|
||||
): NULL;
|
||||
|
||||
@ -148,7 +148,7 @@ pref_show(pref_t *pref, gpointer user_data)
|
||||
* 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)
|
||||
if (prefs_get_type(pref) != PREF_STATIC_TEXT)
|
||||
g_strlcat(label_string, ":", label_len);
|
||||
|
||||
pref_stash(pref, NULL);
|
||||
@ -156,7 +156,7 @@ pref_show(pref_t *pref, gpointer user_data)
|
||||
/* 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
|
||||
editing the preference. */
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
|
||||
case PREF_UINT:
|
||||
case PREF_DECODE_AS_UINT:
|
||||
@ -164,65 +164,53 @@ pref_show(pref_t *pref, gpointer user_data)
|
||||
Even more annoyingly, even if there were, GLib doesn't define
|
||||
G_MAXUINT - but I think ANSI C may define UINT_MAX, so we could
|
||||
use that. */
|
||||
switch (pref->info.base) {
|
||||
|
||||
case 10:
|
||||
g_snprintf(uint_str, sizeof(uint_str), "%u", pref->stashed_val.uint);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
g_snprintf(uint_str, sizeof(uint_str), "%o", pref->stashed_val.uint);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
g_snprintf(uint_str, sizeof(uint_str), "%x", pref->stashed_val.uint);
|
||||
break;
|
||||
}
|
||||
pref->control = create_preference_entry(main_grid, pref->ordinal,
|
||||
uint_str = prefs_pref_to_str(pref, pref_stashed);
|
||||
prefs_set_control(pref, create_preference_entry(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
uint_str);
|
||||
uint_str));
|
||||
g_free(uint_str);
|
||||
break;
|
||||
|
||||
case PREF_BOOL:
|
||||
pref->control = create_preference_check_button(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_check_button(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
pref->stashed_val.boolval);
|
||||
prefs_get_bool_value(pref, pref_stashed)));
|
||||
break;
|
||||
|
||||
case PREF_ENUM:
|
||||
if (pref->info.enum_info.radio_buttons) {
|
||||
if (prefs_get_enum_radiobuttons(pref)) {
|
||||
/* Show it as radio buttons. */
|
||||
pref->control = create_preference_radio_buttons(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_radio_buttons(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
pref->info.enum_info.enumvals,
|
||||
pref->stashed_val.enumval);
|
||||
prefs_get_enumvals(pref),
|
||||
prefs_get_enum_value(pref, pref_stashed)));
|
||||
} else {
|
||||
/* Show it as an option menu. */
|
||||
pref->control = create_preference_option_menu(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_option_menu(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
pref->info.enum_info.enumvals,
|
||||
pref->stashed_val.enumval);
|
||||
prefs_get_enumvals(pref),
|
||||
prefs_get_enum_value(pref, pref_stashed)));
|
||||
}
|
||||
break;
|
||||
|
||||
case PREF_STRING:
|
||||
pref->control = create_preference_entry(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_entry(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
pref->stashed_val.string);
|
||||
prefs_get_string_value(pref, pref_stashed)));
|
||||
break;
|
||||
|
||||
case PREF_FILENAME:
|
||||
pref->control = create_preference_path_entry(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_path_entry(main_grid, prefs_get_ordinal(pref),
|
||||
label_string,
|
||||
tooltip_txt,
|
||||
pref->stashed_val.string, FALSE);
|
||||
prefs_get_string_value(pref, pref_stashed), FALSE));
|
||||
break;
|
||||
|
||||
case PREF_DIRNAME:
|
||||
pref->control = create_preference_path_entry(main_grid, pref->ordinal,
|
||||
prefs_set_control(pref, create_preference_path_entry(main_grid, prefs_get_ordinal(pref),
|
||||
label_string,
|
||||
tooltip_txt,
|
||||
pref->stashed_val.string, TRUE);
|
||||
prefs_get_string_value(pref, pref_stashed), TRUE));
|
||||
break;
|
||||
|
||||
case PREF_RANGE:
|
||||
@ -230,27 +218,27 @@ pref_show(pref_t *pref, gpointer user_data)
|
||||
{
|
||||
char *range_str_p;
|
||||
|
||||
range_str_p = range_convert_range(NULL, *pref->varp.range);
|
||||
pref->control = create_preference_entry(main_grid, pref->ordinal,
|
||||
range_str_p = range_convert_range(NULL, prefs_get_range_value_real(pref, pref_current));
|
||||
prefs_set_control(pref, create_preference_entry(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
range_str_p);
|
||||
range_str_p));
|
||||
wmem_free(NULL, range_str_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case PREF_STATIC_TEXT:
|
||||
{
|
||||
pref->control = create_preference_static_text(main_grid, pref->ordinal,
|
||||
label_string, tooltip_txt);
|
||||
prefs_set_control(pref, create_preference_static_text(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt));
|
||||
break;
|
||||
}
|
||||
|
||||
case PREF_UAT:
|
||||
{
|
||||
if (pref->gui == GUI_ALL || pref->gui == GUI_GTK)
|
||||
pref->control = create_preference_uat(main_grid, pref->ordinal,
|
||||
if (prefs_get_gui_type(pref) == GUI_ALL || prefs_get_gui_type(pref) == GUI_GTK)
|
||||
prefs_set_control(pref, create_preference_uat(main_grid, prefs_get_ordinal(pref),
|
||||
label_string, tooltip_txt,
|
||||
pref->varp.uat);
|
||||
prefs_get_uat_value(pref)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -951,11 +939,11 @@ pref_check(pref_t *pref, gpointer user_data)
|
||||
pref_t **badpref = (pref_t **)user_data;
|
||||
|
||||
/* Fetch the value of the preference, and check whether it's valid. */
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
|
||||
case PREF_UINT:
|
||||
case PREF_DECODE_AS_UINT:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
errno = 0;
|
||||
|
||||
/* XXX: The following ugly hack prevents a gcc warning
|
||||
@ -971,7 +959,7 @@ pref_check(pref_t *pref, gpointer user_data)
|
||||
and thus avoiding the need to check whether it's a valid number, would also be a good idea."
|
||||
]
|
||||
*/
|
||||
if (strtoul(str_val, &p, pref->info.base)){}
|
||||
if (strtoul(str_val, &p, prefs_get_uint_base(pref))){}
|
||||
if (p == str_val || *p != '\0' || errno != 0) {
|
||||
*badpref = pref;
|
||||
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
||||
@ -994,12 +982,12 @@ pref_check(pref_t *pref, gpointer user_data)
|
||||
|
||||
case PREF_RANGE:
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
|
||||
if (strlen(str_val) != 0) {
|
||||
range_t *newrange;
|
||||
|
||||
if (range_convert_str(NULL, &newrange, str_val, pref->info.max_value) != CVT_NO_ERROR) {
|
||||
if (range_convert_str(NULL, &newrange, str_val, prefs_get_max_value(pref)) != CVT_NO_ERROR) {
|
||||
*badpref = pref;
|
||||
wmem_free(NULL, newrange);
|
||||
return PREFS_SET_SYNTAX_ERR; /* range was bad */
|
||||
@ -1042,143 +1030,83 @@ pref_fetch(pref_t *pref, gpointer user_data)
|
||||
{
|
||||
const char *str_val;
|
||||
char *p;
|
||||
guint uval;
|
||||
guint uval, uval_stashed;
|
||||
gboolean bval;
|
||||
gint enumval;
|
||||
dissector_table_t sub_dissectors;
|
||||
dissector_handle_t handle;
|
||||
module_t *module = (module_t *)user_data;
|
||||
pref_unstash_data_t unstash_data;
|
||||
|
||||
/* Fetch the value of the preference, and set the appropriate variable
|
||||
to it. */
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
|
||||
case PREF_DECODE_AS_UINT:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
uval = (guint)strtoul(str_val, &p, pref->info.base);
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
uval = (guint)strtoul(str_val, &p, prefs_get_uint_base(pref));
|
||||
#if 0
|
||||
if (p == value || *p != '\0')
|
||||
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
||||
#endif
|
||||
if (*pref->varp.uint != uval) {
|
||||
module->prefs_changed = TRUE;
|
||||
if (*pref->varp.uint != pref->default_val.uint) {
|
||||
dissector_reset_uint(pref->name, *pref->varp.uint);
|
||||
}
|
||||
*pref->varp.uint = uval;
|
||||
/* Save stashed value to use pref_unstash and restore it later */
|
||||
uval_stashed = prefs_get_uint_value_real(pref, pref_stashed);
|
||||
prefs_set_uint_value(pref, uval, pref_stashed);
|
||||
|
||||
sub_dissectors = find_dissector_table(pref->name);
|
||||
if (sub_dissectors != NULL) {
|
||||
handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)module->title);
|
||||
if (handle != NULL) {
|
||||
dissector_change_uint(pref->name, *pref->varp.uint, handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
unstash_data.module = module;
|
||||
unstash_data.handle_decode_as = TRUE;
|
||||
pref_unstash(pref, (gpointer)&unstash_data);
|
||||
|
||||
/* Restore stashed value */
|
||||
prefs_set_uint_value(pref, uval_stashed, pref_stashed);
|
||||
break;
|
||||
|
||||
case PREF_UINT:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
uval = (guint)strtoul(str_val, &p, pref->info.base);
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
uval = (guint)strtoul(str_val, &p, prefs_get_uint_base(pref));
|
||||
#if 0
|
||||
if (p == value || *p != '\0')
|
||||
return PREFS_SET_SYNTAX_ERR; /* number was bad */
|
||||
#endif
|
||||
if (*pref->varp.uint != uval) {
|
||||
module->prefs_changed = TRUE;
|
||||
*pref->varp.uint = uval;
|
||||
}
|
||||
module->prefs_changed |= prefs_set_uint_value(pref, uval, pref_current);
|
||||
break;
|
||||
|
||||
case PREF_BOOL:
|
||||
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref->control));
|
||||
if (*pref->varp.boolp != bval) {
|
||||
module->prefs_changed = TRUE;
|
||||
*pref->varp.boolp = bval;
|
||||
}
|
||||
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_get_control(pref)));
|
||||
module->prefs_changed |= prefs_set_bool_value(pref, bval, pref_current);
|
||||
break;
|
||||
|
||||
case PREF_ENUM:
|
||||
if (pref->info.enum_info.radio_buttons) {
|
||||
enumval = fetch_preference_radio_buttons_val((GtkWidget *)pref->control,
|
||||
pref->info.enum_info.enumvals);
|
||||
if (prefs_get_enum_radiobuttons(pref)) {
|
||||
enumval = fetch_preference_radio_buttons_val((GtkWidget *)prefs_get_control(pref),
|
||||
prefs_get_enumvals(pref));
|
||||
} else {
|
||||
enumval = fetch_preference_option_menu_val((GtkWidget *)pref->control,
|
||||
pref->info.enum_info.enumvals);
|
||||
enumval = fetch_preference_option_menu_val((GtkWidget *)prefs_get_control(pref),
|
||||
prefs_get_enumvals(pref));
|
||||
}
|
||||
|
||||
if (*pref->varp.enump != enumval) {
|
||||
module->prefs_changed = TRUE;
|
||||
*pref->varp.enump = enumval;
|
||||
}
|
||||
module->prefs_changed |= prefs_set_enum_value(pref, enumval, pref_current);
|
||||
break;
|
||||
|
||||
case PREF_STRING:
|
||||
case PREF_FILENAME:
|
||||
case PREF_DIRNAME:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
prefs_set_string_like_value(pref, str_val, &module->prefs_changed);
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
module->prefs_changed |= prefs_set_string_value(pref, str_val, pref_current);
|
||||
break;
|
||||
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
{
|
||||
range_t *newrange;
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
|
||||
if (range_convert_str_work(wmem_epan_scope(), &newrange, str_val, pref->info.max_value, TRUE) != CVT_NO_ERROR) {
|
||||
#if 0
|
||||
return PREFS_SET_SYNTAX_ERR; /* range was bad */
|
||||
#else
|
||||
return 0; /* XXX - should fail */
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!ranges_are_equal(*pref->varp.range, newrange)) {
|
||||
guint32 i, j;
|
||||
|
||||
wmem_free(wmem_epan_scope(), *pref->varp.range);
|
||||
*pref->varp.range = newrange;
|
||||
module->prefs_changed = TRUE;
|
||||
|
||||
/* Name of preference is the dissector table */
|
||||
sub_dissectors = find_dissector_table(pref->name);
|
||||
if (sub_dissectors != NULL) {
|
||||
handle = dissector_table_get_dissector_handle(sub_dissectors, (gchar*)module->title);
|
||||
if (handle != NULL) {
|
||||
/* Delete all of the old values from the dissector table */
|
||||
for (i = 0; i < (*pref->varp.range)->nranges; i++) {
|
||||
for (j = (*pref->varp.range)->ranges[i].low; j < (*pref->varp.range)->ranges[i].high; j++) {
|
||||
dissector_delete_uint(pref->name, j, handle);
|
||||
decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
|
||||
}
|
||||
|
||||
dissector_delete_uint(pref->name, (*pref->varp.range)->ranges[i].high, handle);
|
||||
decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER((*pref->varp.range)->ranges[i].high), NULL, NULL);
|
||||
}
|
||||
|
||||
/* Add new values to the dissector table */
|
||||
for (i = 0; i < newrange->nranges; i++) {
|
||||
for (j = newrange->ranges[i].low; j < newrange->ranges[i].high; j++) {
|
||||
dissector_change_uint(pref->name, j, handle);
|
||||
decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(j), NULL, NULL);
|
||||
}
|
||||
|
||||
dissector_change_uint(pref->name, newrange->ranges[i].high, handle);
|
||||
decode_build_reset_list(pref->name, dissector_table_get_type(sub_dissectors), GUINT_TO_POINTER(newrange->ranges[i].high), NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
wmem_free(wmem_epan_scope(), newrange);
|
||||
}
|
||||
module->prefs_changed |= prefs_set_stashed_range_value(pref, str_val);
|
||||
|
||||
unstash_data.module = module;
|
||||
unstash_data.handle_decode_as = TRUE;
|
||||
pref_unstash(pref, (gpointer)&unstash_data);
|
||||
break;
|
||||
}
|
||||
case PREF_RANGE:
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
|
||||
if (!prefs_set_range_value(pref, str_val, &module->prefs_changed))
|
||||
str_val = gtk_entry_get_text(GTK_ENTRY(prefs_get_control(pref)));
|
||||
if (!prefs_set_range_value_work(pref, str_val, TRUE, &module->prefs_changed))
|
||||
#if 0
|
||||
return PREFS_SET_SYNTAX_ERR; /* range was bad */
|
||||
#else
|
||||
@ -1321,18 +1249,20 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
|
||||
switch (prefs_modules_foreach(module_prefs_check, (gpointer)&badpref)) {
|
||||
|
||||
case PREFS_SET_SYNTAX_ERR:
|
||||
switch (badpref->type) {
|
||||
switch (prefs_get_type(badpref)) {
|
||||
|
||||
case PREF_UINT:
|
||||
case PREF_DECODE_AS_UINT:
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The value for \"%s\" isn't a valid number.",
|
||||
badpref->title);
|
||||
prefs_get_title(badpref));
|
||||
return FALSE;
|
||||
|
||||
case PREF_RANGE:
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The value for \"%s\" isn't a valid range.",
|
||||
badpref->title);
|
||||
prefs_get_title(badpref));
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
|
@ -101,17 +101,9 @@ prefs_store_ext_helper(const char * module_name, const char *pref_name, const ch
|
||||
if (!pref)
|
||||
return FALSE;
|
||||
|
||||
if ( pref->type == PREF_STRING )
|
||||
if (prefs_get_type(pref) == PREF_STRING )
|
||||
{
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = (gchar *) g_strdup(pref_value);
|
||||
/* unstash - taken from preferences_util */
|
||||
if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0)
|
||||
{
|
||||
pref_changed = TRUE;
|
||||
g_free(*pref->varp.string);
|
||||
*pref->varp.string = g_strdup(pref->stashed_val.string);
|
||||
}
|
||||
pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
|
||||
}
|
||||
|
||||
return pref_changed;
|
||||
|
@ -74,8 +74,8 @@ void CapturePreferencesFrame::updateWidgets()
|
||||
interface_t device;
|
||||
QString default_device_string;
|
||||
|
||||
if (pref_device_->stashed_val.string) {
|
||||
default_device_string = pref_device_->stashed_val.string;
|
||||
if (prefs_get_string_value(pref_device_, pref_stashed)) {
|
||||
default_device_string = prefs_get_string_value(pref_device_, pref_stashed);
|
||||
}
|
||||
ui->defaultInterfaceComboBox->clear();
|
||||
if (global_capture_opts.all_ifaces->len == 0) {
|
||||
@ -111,37 +111,36 @@ void CapturePreferencesFrame::updateWidgets()
|
||||
ui->defaultInterfaceComboBox->clearEditText();
|
||||
}
|
||||
|
||||
ui->capturePromModeCheckBox->setChecked(pref_prom_mode_->stashed_val.boolval);
|
||||
ui->capturePcapNgCheckBox->setChecked(pref_pcap_ng_->stashed_val.boolval);
|
||||
ui->captureRealTimeCheckBox->setChecked(pref_real_time_->stashed_val.boolval);
|
||||
ui->captureAutoScrollCheckBox->setChecked(pref_auto_scroll_->stashed_val.boolval);
|
||||
ui->capturePromModeCheckBox->setChecked(prefs_get_bool_value(pref_prom_mode_, pref_stashed));
|
||||
ui->capturePcapNgCheckBox->setChecked(prefs_get_bool_value(pref_pcap_ng_, pref_stashed));
|
||||
ui->captureRealTimeCheckBox->setChecked(prefs_get_bool_value(pref_real_time_, pref_stashed));
|
||||
ui->captureAutoScrollCheckBox->setChecked(prefs_get_bool_value(pref_auto_scroll_, pref_stashed));
|
||||
#endif // HAVE_LIBPCAP
|
||||
}
|
||||
|
||||
void CapturePreferencesFrame::on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface)
|
||||
{
|
||||
g_free((void *)pref_device_->stashed_val.string);
|
||||
pref_device_->stashed_val.string = g_strdup(new_iface.toUtf8().constData());
|
||||
prefs_set_string_value(pref_device_, new_iface.toUtf8().constData(), pref_stashed);
|
||||
}
|
||||
|
||||
void CapturePreferencesFrame::on_capturePromModeCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_prom_mode_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_prom_mode_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void CapturePreferencesFrame::on_capturePcapNgCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_pcap_ng_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_pcap_ng_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void CapturePreferencesFrame::on_captureRealTimeCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_real_time_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_real_time_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void CapturePreferencesFrame::on_captureAutoScrollCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_auto_scroll_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_auto_scroll_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -567,6 +567,10 @@ void DecodeAsDialog::gatherChangedEntries(const gchar *table_name,
|
||||
|
||||
void DecodeAsDialog::applyChanges()
|
||||
{
|
||||
dissector_table_t sub_dissectors;
|
||||
module_t *module;
|
||||
pref_t* pref_value;
|
||||
dissector_handle_t handle;
|
||||
// Reset all dissector tables, then apply all rules from GUI.
|
||||
|
||||
// We can't call g_hash_table_removed from g_hash_table_foreach, which
|
||||
@ -578,6 +582,18 @@ void DecodeAsDialog::applyChanges()
|
||||
// instead.
|
||||
dissector_all_tables_foreach_changed(gatherChangedEntries, this);
|
||||
foreach (UintPair uint_entry, changed_uint_entries_) {
|
||||
/* Set "Decode As preferences" to default values */
|
||||
sub_dissectors = find_dissector_table(uint_entry.first);
|
||||
handle = dissector_get_uint_handle(sub_dissectors, uint_entry.second);
|
||||
if (handle != NULL) {
|
||||
module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
|
||||
pref_value = prefs_find_preference(module, uint_entry.first);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
reset_pref(pref_value);
|
||||
}
|
||||
}
|
||||
|
||||
dissector_reset_uint(uint_entry.first, uint_entry.second);
|
||||
}
|
||||
changed_uint_entries_.clear();
|
||||
@ -605,9 +621,6 @@ void DecodeAsDialog::applyChanges()
|
||||
if (!g_strcmp0(decode_as_entry->table_name, ui_name_to_name_[item->text(table_col_)])) {
|
||||
gpointer selector_value;
|
||||
QByteArray byteArray;
|
||||
module_t *module;
|
||||
pref_t* pref_value;
|
||||
dissector_table_t sub_dissectors;
|
||||
|
||||
switch (selector_type) {
|
||||
case FT_UINT8:
|
||||
@ -638,17 +651,7 @@ void DecodeAsDialog::applyChanges()
|
||||
pref_value = prefs_find_preference(module, decode_as_entry->table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
switch(pref_value->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
*pref_value->varp.uint = pref_value->default_val.uint;
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_remove_value(pref_value, GPOINTER_TO_UINT(selector_value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prefs_remove_decode_as_value(pref_value, GPOINTER_TO_UINT(selector_value), TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -663,20 +666,7 @@ void DecodeAsDialog::applyChanges()
|
||||
pref_value = prefs_find_preference(module, decode_as_entry->table_name);
|
||||
if (pref_value != NULL) {
|
||||
module->prefs_changed = TRUE;
|
||||
switch(pref_value->type)
|
||||
{
|
||||
case PREF_DECODE_AS_UINT:
|
||||
/* This doesn't support multiple values for a dissector in Decode As because the
|
||||
preference only supports a single value. This leads to a "last port for
|
||||
dissector in Decode As wins" */
|
||||
*pref_value->varp.uint = GPOINTER_TO_UINT(selector_value);
|
||||
break;
|
||||
case PREF_DECODE_AS_RANGE:
|
||||
prefs_range_add_value(pref_value, GPOINTER_TO_UINT(selector_value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prefs_add_decode_as_value(pref_value, GPOINTER_TO_UINT(selector_value), FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -699,7 +699,7 @@ QString ExtcapArgument::prefKey(const QString & device_name)
|
||||
|
||||
pref = extcap_pref_for_argument(device_name.toStdString().c_str(), _argument);
|
||||
if ( pref != NULL )
|
||||
return QString(pref->name);
|
||||
return QString(prefs_get_name(pref));
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ FontColorPreferencesFrame::FontColorPreferencesFrame(QWidget *parent) :
|
||||
pref_invalid_bg_ = prefFromPrefPtr(&prefs.gui_text_invalid);
|
||||
pref_deprecated_bg_ = prefFromPrefPtr(&prefs.gui_text_deprecated);
|
||||
|
||||
cur_font_.fromString(pref_qt_gui_font_name_->stashed_val.string);
|
||||
cur_font_.fromString(prefs_get_string_value(pref_qt_gui_font_name_, pref_stashed));
|
||||
|
||||
}
|
||||
|
||||
@ -102,83 +102,86 @@ void FontColorPreferencesFrame::updateWidgets()
|
||||
"}";
|
||||
|
||||
ui->markedFGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_marked_fg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_fg_, pref_stashed)).name())
|
||||
.arg(margin));
|
||||
ui->markedBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_marked_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->markedSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_marked_fg_->stashed_val.color).name(),
|
||||
ColorUtils::fromColorT(&pref_marked_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_fg_, pref_stashed)).name(),
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_marked_bg_, pref_stashed)).name()));
|
||||
ui->markedSampleLineEdit->setFont(cur_font_);
|
||||
|
||||
ui->ignoredFGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_ignored_fg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name())
|
||||
.arg(margin));
|
||||
ui->ignoredBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_ignored_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->ignoredSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_ignored_fg_->stashed_val.color).name(),
|
||||
ColorUtils::fromColorT(&pref_ignored_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_fg_, pref_stashed)).name(),
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_ignored_bg_, pref_stashed)).name()));
|
||||
ui->ignoredSampleLineEdit->setFont(cur_font_);
|
||||
|
||||
ui->clientFGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_client_fg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_client_fg_, pref_stashed)).name())
|
||||
.arg(margin));
|
||||
ui->clientBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_client_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_client_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->clientSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_client_fg_->stashed_val.color).name(),
|
||||
ColorUtils::fromColorT(&pref_client_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_client_fg_, pref_stashed)).name(),
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_client_bg_, pref_stashed)).name()));
|
||||
ui->clientSampleLineEdit->setFont(cur_font_);
|
||||
|
||||
ui->serverFGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_server_fg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_server_fg_, pref_stashed)).name())
|
||||
.arg(margin));
|
||||
ui->serverBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_server_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_server_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->serverSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_server_fg_->stashed_val.color).name(),
|
||||
ColorUtils::fromColorT(&pref_server_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_server_fg_, pref_stashed)).name(),
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_server_bg_, pref_stashed)).name()));
|
||||
ui->serverSampleLineEdit->setFont(cur_font_);
|
||||
|
||||
ui->validFilterBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_valid_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->validFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
"palette(text)",
|
||||
ColorUtils::fromColorT(&pref_valid_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_valid_bg_, pref_stashed)).name()));
|
||||
ui->invalidFilterBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_invalid_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->invalidFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
"palette(text)",
|
||||
ColorUtils::fromColorT(&pref_invalid_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_invalid_bg_, pref_stashed)).name()));
|
||||
ui->deprecatedFilterBGPushButton->setStyleSheet(color_button_ss.arg(
|
||||
ColorUtils::fromColorT(&pref_deprecated_bg_->stashed_val.color).name())
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name())
|
||||
.arg(0));
|
||||
ui->deprecatedFilterSampleLineEdit->setStyleSheet(sample_text_ss.arg(
|
||||
"palette(text)",
|
||||
ColorUtils::fromColorT(&pref_deprecated_bg_->stashed_val.color).name()));
|
||||
ColorUtils::fromColorT(prefs_get_color_value(pref_deprecated_bg_, pref_stashed)).name()));
|
||||
}
|
||||
|
||||
void FontColorPreferencesFrame::changeColor(pref_t *pref)
|
||||
{
|
||||
QColorDialog color_dlg;
|
||||
color_t* color = prefs_get_color_value(pref, pref_stashed);
|
||||
|
||||
color_dlg.setCurrentColor(QColor(
|
||||
pref->stashed_val.color.red >> 8,
|
||||
pref->stashed_val.color.green >> 8,
|
||||
pref->stashed_val.color.blue >> 8
|
||||
color->red >> 8,
|
||||
color->green >> 8,
|
||||
color->blue >> 8
|
||||
));
|
||||
if (color_dlg.exec() == QDialog::Accepted) {
|
||||
QColor cc = color_dlg.currentColor();
|
||||
pref->stashed_val.color.red = cc.red() << 8 | cc.red();
|
||||
pref->stashed_val.color.green = cc.green() << 8 | cc.green();
|
||||
pref->stashed_val.color.blue = cc.blue() << 8 | cc.blue();
|
||||
color_t new_color;
|
||||
new_color.red = cc.red() << 8 | cc.red();
|
||||
new_color.green = cc.green() << 8 | cc.green();
|
||||
new_color.blue = cc.blue() << 8 | cc.blue();
|
||||
prefs_set_color_value(pref, new_color, pref_stashed);
|
||||
updateWidgets();
|
||||
}
|
||||
}
|
||||
@ -188,8 +191,7 @@ void FontColorPreferencesFrame::on_fontPushButton_clicked()
|
||||
bool ok;
|
||||
QFont new_font = QFontDialog::getFont(&ok, cur_font_, this, wsApp->windowTitleString(tr("Font")));
|
||||
if (ok) {
|
||||
g_free(pref_qt_gui_font_name_->stashed_val.string);
|
||||
pref_qt_gui_font_name_->stashed_val.string = qstring_strdup(new_font.toString());
|
||||
prefs_set_string_value(pref_qt_gui_font_name_, new_font.toString().toStdString().c_str(), pref_stashed);
|
||||
cur_font_ = new_font;
|
||||
updateWidgets();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ LayoutPreferencesFrame::LayoutPreferencesFrame(QWidget *parent) :
|
||||
ui->layout6ToolButton->setStyleSheet(image_pad_ss);
|
||||
|
||||
pref_packet_list_separator_ = prefFromPrefPtr(&prefs.gui_qt_packet_list_separator);
|
||||
ui->packetListSeparatorCheckBox->setChecked(pref_packet_list_separator_->stashed_val.boolval);
|
||||
ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_stashed));
|
||||
}
|
||||
|
||||
LayoutPreferencesFrame::~LayoutPreferencesFrame()
|
||||
@ -64,7 +64,7 @@ void LayoutPreferencesFrame::showEvent(QShowEvent *)
|
||||
|
||||
void LayoutPreferencesFrame::updateWidgets()
|
||||
{
|
||||
switch (pref_layout_type_->stashed_val.uint) {
|
||||
switch (prefs_get_uint_value_real(pref_layout_type_, pref_stashed)) {
|
||||
case layout_type_5:
|
||||
ui->layout5ToolButton->setChecked(true);
|
||||
break;
|
||||
@ -85,7 +85,7 @@ void LayoutPreferencesFrame::updateWidgets()
|
||||
break;
|
||||
}
|
||||
|
||||
switch (pref_layout_content_1_->stashed_val.enumval) {
|
||||
switch (prefs_get_enum_value(pref_layout_content_1_, pref_stashed)) {
|
||||
case layout_pane_content_plist:
|
||||
ui->pane1PacketListRadioButton->setChecked(true);
|
||||
break;
|
||||
@ -100,7 +100,7 @@ void LayoutPreferencesFrame::updateWidgets()
|
||||
break;
|
||||
}
|
||||
|
||||
switch (pref_layout_content_2_->stashed_val.enumval) {
|
||||
switch (prefs_get_enum_value(pref_layout_content_2_, pref_stashed)) {
|
||||
case layout_pane_content_plist:
|
||||
ui->pane2PacketListRadioButton->setChecked(true);
|
||||
break;
|
||||
@ -115,7 +115,7 @@ void LayoutPreferencesFrame::updateWidgets()
|
||||
break;
|
||||
}
|
||||
|
||||
switch (pref_layout_content_3_->stashed_val.enumval) {
|
||||
switch (prefs_get_enum_value(pref_layout_content_3_, pref_stashed)) {
|
||||
case layout_pane_content_plist:
|
||||
ui->pane3PacketListRadioButton->setChecked(true);
|
||||
break;
|
||||
@ -134,43 +134,43 @@ void LayoutPreferencesFrame::updateWidgets()
|
||||
void LayoutPreferencesFrame::on_layout5ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_5;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_5, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_layout2ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_2;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_2, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_layout1ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_1;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_1, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_layout4ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_4;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_4, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_layout3ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_3;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_3, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_layout6ToolButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_type_->stashed_val.uint = layout_type_6;
|
||||
prefs_set_uint_value(pref_layout_type_, layout_type_6, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_pane1PacketListRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_1_->stashed_val.enumval = layout_pane_content_plist;
|
||||
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_plist, pref_stashed);
|
||||
if (ui->pane2PacketListRadioButton->isChecked())
|
||||
ui->pane2NoneRadioButton->click();
|
||||
if (ui->pane3PacketListRadioButton->isChecked())
|
||||
@ -180,7 +180,7 @@ void LayoutPreferencesFrame::on_pane1PacketListRadioButton_toggled(bool checked)
|
||||
void LayoutPreferencesFrame::on_pane1PacketDetailsRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_1_->stashed_val.enumval = layout_pane_content_pdetails;
|
||||
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_pdetails, pref_stashed);
|
||||
if (ui->pane2PacketDetailsRadioButton->isChecked())
|
||||
ui->pane2NoneRadioButton->click();
|
||||
if (ui->pane3PacketDetailsRadioButton->isChecked())
|
||||
@ -190,7 +190,7 @@ void LayoutPreferencesFrame::on_pane1PacketDetailsRadioButton_toggled(bool check
|
||||
void LayoutPreferencesFrame::on_pane1PacketBytesRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_1_->stashed_val.enumval = layout_pane_content_pbytes;
|
||||
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_pbytes, pref_stashed);
|
||||
if (ui->pane2PacketBytesRadioButton->isChecked())
|
||||
ui->pane2NoneRadioButton->click();
|
||||
if (ui->pane3PacketBytesRadioButton->isChecked())
|
||||
@ -200,13 +200,13 @@ void LayoutPreferencesFrame::on_pane1PacketBytesRadioButton_toggled(bool checked
|
||||
void LayoutPreferencesFrame::on_pane1NoneRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_1_->stashed_val.enumval = layout_pane_content_none;
|
||||
prefs_set_enum_value(pref_layout_content_1_, layout_pane_content_none, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_pane2PacketListRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_2_->stashed_val.enumval = layout_pane_content_plist;
|
||||
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_plist, pref_stashed);
|
||||
if (ui->pane1PacketListRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane3PacketListRadioButton->isChecked())
|
||||
@ -216,7 +216,7 @@ void LayoutPreferencesFrame::on_pane2PacketListRadioButton_toggled(bool checked)
|
||||
void LayoutPreferencesFrame::on_pane2PacketDetailsRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_2_->stashed_val.enumval = layout_pane_content_pdetails;
|
||||
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_pdetails, pref_stashed);
|
||||
if (ui->pane1PacketDetailsRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane3PacketDetailsRadioButton->isChecked())
|
||||
@ -226,7 +226,7 @@ void LayoutPreferencesFrame::on_pane2PacketDetailsRadioButton_toggled(bool check
|
||||
void LayoutPreferencesFrame::on_pane2PacketBytesRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_2_->stashed_val.enumval = layout_pane_content_pbytes;
|
||||
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_pbytes, pref_stashed);
|
||||
if (ui->pane1PacketBytesRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane3PacketBytesRadioButton->isChecked())
|
||||
@ -236,13 +236,13 @@ void LayoutPreferencesFrame::on_pane2PacketBytesRadioButton_toggled(bool checked
|
||||
void LayoutPreferencesFrame::on_pane2NoneRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_2_->stashed_val.enumval = layout_pane_content_none;
|
||||
prefs_set_enum_value(pref_layout_content_2_, layout_pane_content_none, pref_stashed);
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_pane3PacketListRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_3_->stashed_val.enumval = layout_pane_content_plist;
|
||||
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_plist, pref_stashed);
|
||||
if (ui->pane1PacketListRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane2PacketListRadioButton->isChecked())
|
||||
@ -252,7 +252,7 @@ void LayoutPreferencesFrame::on_pane3PacketListRadioButton_toggled(bool checked)
|
||||
void LayoutPreferencesFrame::on_pane3PacketDetailsRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_3_->stashed_val.enumval = layout_pane_content_pdetails;
|
||||
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_pdetails, pref_stashed);
|
||||
if (ui->pane1PacketDetailsRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane2PacketDetailsRadioButton->isChecked())
|
||||
@ -262,7 +262,7 @@ void LayoutPreferencesFrame::on_pane3PacketDetailsRadioButton_toggled(bool check
|
||||
void LayoutPreferencesFrame::on_pane3PacketBytesRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_3_->stashed_val.enumval = layout_pane_content_pbytes;
|
||||
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_pbytes, pref_stashed);
|
||||
if (ui->pane1PacketBytesRadioButton->isChecked())
|
||||
ui->pane1NoneRadioButton->click();
|
||||
if (ui->pane2PacketBytesRadioButton->isChecked())
|
||||
@ -272,26 +272,26 @@ void LayoutPreferencesFrame::on_pane3PacketBytesRadioButton_toggled(bool checked
|
||||
void LayoutPreferencesFrame::on_pane3NoneRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (!checked) return;
|
||||
pref_layout_content_3_->stashed_val.enumval = layout_pane_content_none;
|
||||
prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_none, pref_stashed);
|
||||
}
|
||||
|
||||
|
||||
void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *)
|
||||
{
|
||||
pref_layout_type_->stashed_val.uint = pref_layout_type_->default_val.uint;
|
||||
pref_layout_content_1_->stashed_val.enumval = pref_layout_content_1_->default_val.enumval;
|
||||
reset_stashed_pref(pref_layout_type_);
|
||||
reset_stashed_pref(pref_layout_content_1_);
|
||||
updateWidgets();
|
||||
pref_layout_content_2_->stashed_val.enumval = pref_layout_content_2_->default_val.enumval;
|
||||
reset_stashed_pref(pref_layout_content_2_);
|
||||
updateWidgets();
|
||||
pref_layout_content_3_->stashed_val.enumval = pref_layout_content_3_->default_val.enumval;
|
||||
reset_stashed_pref(pref_layout_content_3_);
|
||||
updateWidgets();
|
||||
|
||||
ui->packetListSeparatorCheckBox->setChecked(pref_packet_list_separator_->default_val.boolval);
|
||||
ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_default));
|
||||
}
|
||||
|
||||
void LayoutPreferencesFrame::on_packetListSeparatorCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_packet_list_separator_->stashed_val.boolval = (gboolean) checked;
|
||||
prefs_set_bool_value(pref_packet_list_separator_, (gboolean) checked, pref_stashed);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,28 +121,28 @@ void MainWindowPreferencesFrame::showEvent(QShowEvent *)
|
||||
void MainWindowPreferencesFrame::updateWidgets()
|
||||
{
|
||||
// Yes, this means we're potentially clobbering two prefs in favor of one.
|
||||
if (pref_geometry_save_position_->stashed_val.boolval || pref_geometry_save_size_->stashed_val.boolval || pref_geometry_save_maximized_->stashed_val.boolval) {
|
||||
if (prefs_get_bool_value(pref_geometry_save_position_, pref_stashed) || prefs_get_bool_value(pref_geometry_save_size_, pref_stashed) || prefs_get_bool_value(pref_geometry_save_maximized_, pref_stashed)) {
|
||||
ui->geometryCheckBox->setChecked(true);
|
||||
} else {
|
||||
ui->geometryCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
if (pref_fileopen_style_->stashed_val.enumval == FO_STYLE_LAST_OPENED) {
|
||||
if (prefs_get_enum_value(pref_fileopen_style_, pref_stashed) == FO_STYLE_LAST_OPENED) {
|
||||
ui->foStyleLastOpenedRadioButton->setChecked(true);
|
||||
} else {
|
||||
ui->foStyleSpecifiedRadioButton->setChecked(true);
|
||||
}
|
||||
|
||||
ui->foStyleSpecifiedLineEdit->setText(pref_fileopen_dir_->stashed_val.string);
|
||||
ui->foStyleSpecifiedLineEdit->setText(prefs_get_string_value(pref_fileopen_dir_, pref_stashed));
|
||||
|
||||
ui->maxFilterLineEdit->setText(QString::number(pref_recent_df_entries_max_->stashed_val.uint));
|
||||
ui->maxRecentLineEdit->setText(QString::number(pref_recent_files_count_max_->stashed_val.uint));
|
||||
ui->maxFilterLineEdit->setText(QString::number(prefs_get_uint_value_real(pref_recent_df_entries_max_, pref_stashed)));
|
||||
ui->maxRecentLineEdit->setText(QString::number(prefs_get_uint_value_real(pref_recent_files_count_max_, pref_stashed)));
|
||||
|
||||
ui->confirmUnsavedCheckBox->setChecked(pref_ask_unsaved_->stashed_val.boolval);
|
||||
ui->autoScrollCheckBox->setChecked(pref_auto_scroll_on_expand_->stashed_val.boolval);
|
||||
ui->autoScrollPercentageLineEdit->setText(QString::number(pref_auto_scroll_on_expand_->stashed_val.uint));
|
||||
ui->confirmUnsavedCheckBox->setChecked(prefs_get_bool_value(pref_ask_unsaved_, pref_stashed));
|
||||
ui->autoScrollCheckBox->setChecked(prefs_get_bool_value(pref_auto_scroll_on_expand_, pref_stashed));
|
||||
ui->autoScrollPercentageLineEdit->setText(QString::number(prefs_get_uint_value_real(pref_auto_scroll_on_expand_, pref_stashed)));
|
||||
|
||||
ui->mainToolbarComboBox->setCurrentIndex(pref_toolbar_main_style_->stashed_val.enumval);
|
||||
ui->mainToolbarComboBox->setCurrentIndex(prefs_get_enum_value(pref_toolbar_main_style_, pref_stashed));
|
||||
|
||||
for (int i = 0; i < ui->languageComboBox->count(); i += 1) {
|
||||
if (QString(language) == ui->languageComboBox->itemData(i).toString()) {
|
||||
@ -154,30 +154,29 @@ void MainWindowPreferencesFrame::updateWidgets()
|
||||
|
||||
void MainWindowPreferencesFrame::on_geometryCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_geometry_save_position_->stashed_val.boolval = checked;
|
||||
pref_geometry_save_size_->stashed_val.boolval = checked;
|
||||
pref_geometry_save_maximized_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_geometry_save_position_, checked, pref_stashed);
|
||||
prefs_set_bool_value(pref_geometry_save_size_, checked, pref_stashed);
|
||||
prefs_set_bool_value(pref_geometry_save_maximized_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_foStyleLastOpenedRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
pref_fileopen_style_->stashed_val.enumval = FO_STYLE_LAST_OPENED;
|
||||
prefs_set_enum_value(pref_fileopen_style_, FO_STYLE_LAST_OPENED, pref_stashed);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_foStyleSpecifiedRadioButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
pref_fileopen_style_->stashed_val.enumval = FO_STYLE_SPECIFIED;
|
||||
prefs_set_enum_value(pref_fileopen_style_, FO_STYLE_SPECIFIED, pref_stashed);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_foStyleSpecifiedLineEdit_textEdited(const QString &new_dir)
|
||||
{
|
||||
g_free(pref_fileopen_dir_->stashed_val.string);
|
||||
pref_fileopen_dir_->stashed_val.string = qstring_strdup(new_dir);
|
||||
pref_fileopen_style_->stashed_val.enumval = FO_STYLE_SPECIFIED;
|
||||
prefs_set_string_value(pref_fileopen_dir_, new_dir.toStdString().c_str(), pref_stashed);
|
||||
prefs_set_enum_value(pref_fileopen_style_, FO_STYLE_SPECIFIED, pref_stashed);
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
@ -188,42 +187,41 @@ void MainWindowPreferencesFrame::on_foStyleSpecifiedPushButton_clicked()
|
||||
if (specified_dir.isEmpty()) return;
|
||||
|
||||
ui->foStyleSpecifiedLineEdit->setText(specified_dir);
|
||||
g_free(pref_fileopen_dir_->stashed_val.string);
|
||||
pref_fileopen_dir_->stashed_val.string = qstring_strdup(specified_dir);
|
||||
pref_fileopen_style_->stashed_val.enumval = FO_STYLE_SPECIFIED;
|
||||
prefs_set_string_value(pref_fileopen_dir_, specified_dir.toStdString().c_str(), pref_stashed);
|
||||
prefs_set_enum_value(pref_fileopen_style_, FO_STYLE_SPECIFIED, pref_stashed);
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_maxFilterLineEdit_textEdited(const QString &new_max)
|
||||
{
|
||||
pref_recent_df_entries_max_->stashed_val.uint = new_max.toUInt();
|
||||
prefs_set_uint_value(pref_recent_df_entries_max_, new_max.toUInt(), pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_maxRecentLineEdit_textEdited(const QString &new_max)
|
||||
{
|
||||
pref_recent_files_count_max_->stashed_val.uint = new_max.toUInt();
|
||||
prefs_set_uint_value(pref_recent_files_count_max_, new_max.toUInt(), pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_confirmUnsavedCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_ask_unsaved_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_ask_unsaved_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_autoScrollCheckBox_toggled(bool checked)
|
||||
{
|
||||
pref_auto_scroll_on_expand_->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref_auto_scroll_on_expand_, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_autoScrollPercentageLineEdit_textEdited(const QString &new_pct)
|
||||
{
|
||||
pref_auto_scroll_percentage_->stashed_val.uint = new_pct.toUInt();
|
||||
pref_auto_scroll_on_expand_->stashed_val.boolval = TRUE;
|
||||
prefs_set_uint_value(pref_auto_scroll_percentage_, new_pct.toUInt(), pref_stashed);
|
||||
prefs_set_bool_value(pref_auto_scroll_on_expand_, TRUE, pref_stashed);
|
||||
ui->autoScrollCheckBox->setChecked(true);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_mainToolbarComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
pref_toolbar_main_style_->stashed_val.enumval = index;
|
||||
prefs_set_enum_value(pref_toolbar_main_style_, index, pref_stashed);
|
||||
}
|
||||
|
||||
void MainWindowPreferencesFrame::on_languageComboBox_currentIndexChanged(int index)
|
||||
|
@ -68,16 +68,16 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
if (!pref || !vb) return 0;
|
||||
|
||||
// Convert the pref description from plain text to rich text.
|
||||
QString description = html_escape(pref->description);
|
||||
QString description = html_escape(prefs_get_description(pref));
|
||||
description.replace('\n', "<br>");
|
||||
QString tooltip = QString("<span>%1</span>").arg(description);
|
||||
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_UINT:
|
||||
case PREF_DECODE_AS_UINT:
|
||||
{
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
hb->addWidget(label);
|
||||
QLineEdit *uint_le = new QLineEdit();
|
||||
@ -91,7 +91,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
}
|
||||
case PREF_BOOL:
|
||||
{
|
||||
QCheckBox *bool_cb = new QCheckBox(title_to_shortcut(pref->title));
|
||||
QCheckBox *bool_cb = new QCheckBox(title_to_shortcut(prefs_get_title(pref)));
|
||||
bool_cb->setToolTip(tooltip);
|
||||
bool_cb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
||||
vb->addWidget(bool_cb);
|
||||
@ -100,14 +100,14 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
case PREF_ENUM:
|
||||
{
|
||||
const enum_val_t *ev;
|
||||
if (!pref->info.enum_info.enumvals) return 0;
|
||||
if (prefs_get_enumvals(pref) == NULL) return 0;
|
||||
|
||||
if (pref->info.enum_info.radio_buttons) {
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
if (prefs_get_enum_radiobuttons(pref)) {
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
vb->addWidget(label);
|
||||
QButtonGroup *enum_bg = new QButtonGroup(vb);
|
||||
for (ev = pref->info.enum_info.enumvals; ev && ev->description; ev++) {
|
||||
for (ev = prefs_get_enumvals(pref); ev && ev->description; ev++) {
|
||||
QRadioButton *enum_rb = new QRadioButton(title_to_shortcut(ev->description));
|
||||
enum_rb->setToolTip(tooltip);
|
||||
QStyleOption style_opt;
|
||||
@ -126,10 +126,10 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
QComboBox *enum_cb = new QComboBox();
|
||||
enum_cb->setToolTip(tooltip);
|
||||
enum_cb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
||||
for (ev = pref->info.enum_info.enumvals; ev && ev->description; ev++) {
|
||||
for (ev = prefs_get_enumvals(pref); ev && ev->description; ev++) {
|
||||
enum_cb->addItem(ev->description, QVariant(ev->value));
|
||||
}
|
||||
hb->addWidget(new QLabel(pref->title));
|
||||
hb->addWidget(new QLabel(prefs_get_title(pref)));
|
||||
hb->addWidget(enum_cb);
|
||||
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
vb->addLayout(hb);
|
||||
@ -139,7 +139,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
case PREF_STRING:
|
||||
{
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
hb->addWidget(label);
|
||||
QLineEdit *string_le = new QLineEdit();
|
||||
@ -155,7 +155,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
case PREF_RANGE:
|
||||
{
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
hb->addWidget(label);
|
||||
SyntaxLineEdit *range_se = new SyntaxLineEdit();
|
||||
@ -169,7 +169,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
}
|
||||
case PREF_STATIC_TEXT:
|
||||
{
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
label->setWordWrap(true);
|
||||
vb->addWidget(label);
|
||||
@ -178,7 +178,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
case PREF_UAT:
|
||||
{
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
hb->addWidget(label);
|
||||
QPushButton *uat_pb = new QPushButton(QObject::tr("Edit" UTF8_HORIZONTAL_ELLIPSIS));
|
||||
@ -192,7 +192,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
|
||||
case PREF_FILENAME:
|
||||
case PREF_DIRNAME:
|
||||
{
|
||||
QLabel *label = new QLabel(pref->title);
|
||||
QLabel *label = new QLabel(prefs_get_title(pref));
|
||||
label->setToolTip(tooltip);
|
||||
vb->addWidget(label);
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
@ -252,7 +252,7 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(le->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_DECODE_AS_UINT:
|
||||
connect(le, SIGNAL(textEdited(QString)), this, SLOT(uintLineEditTextEdited(QString)));
|
||||
break;
|
||||
@ -277,7 +277,7 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(cb->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_BOOL) {
|
||||
if (prefs_get_type(pref) == PREF_BOOL) {
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(boolCheckBoxToggled(bool)));
|
||||
}
|
||||
}
|
||||
@ -286,7 +286,7 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(rb->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_ENUM && pref->info.enum_info.radio_buttons) {
|
||||
if (prefs_get_type(pref) == PREF_ENUM && prefs_get_enum_radiobuttons(pref)) {
|
||||
connect(rb, SIGNAL(toggled(bool)), this, SLOT(enumRadioButtonToggled(bool)));
|
||||
}
|
||||
}
|
||||
@ -295,7 +295,7 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(combo->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_ENUM && !pref->info.enum_info.radio_buttons) {
|
||||
if (prefs_get_type(pref) == PREF_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
||||
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(enumComboBoxCurrentIndexChanged(int)));
|
||||
}
|
||||
}
|
||||
@ -304,12 +304,16 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(pb->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_UAT) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_UAT:
|
||||
connect(pb, SIGNAL(pressed()), this, SLOT(uatPushButtonPressed()));
|
||||
} else if (pref->type == PREF_FILENAME) {
|
||||
break;
|
||||
case PREF_FILENAME:
|
||||
connect(pb, SIGNAL(pressed()), this, SLOT(filenamePushButtonPressed()));
|
||||
} else if (pref->type == PREF_DIRNAME) {
|
||||
break;
|
||||
case PREF_DIRNAME:
|
||||
connect(pb, SIGNAL(pressed()), this, SLOT(dirnamePushButtonPressed()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,8 +354,8 @@ void ModulePreferencesScrollArea::updateWidgets()
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(cb->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_BOOL) {
|
||||
cb->setChecked(pref->stashed_val.boolval);
|
||||
if (prefs_get_type(pref) == PREF_BOOL) {
|
||||
cb->setChecked(prefs_get_bool_value(pref, pref_stashed));
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,8 +366,8 @@ void ModulePreferencesScrollArea::updateWidgets()
|
||||
QButtonGroup *enum_bg = enum_rb->group();
|
||||
if (!enum_bg) continue;
|
||||
|
||||
if (pref->type == PREF_ENUM && pref->info.enum_info.radio_buttons) {
|
||||
if (pref->stashed_val.enumval == enum_bg->id(enum_rb)) {
|
||||
if (prefs_get_type(pref) == PREF_ENUM && prefs_get_enum_radiobuttons(pref)) {
|
||||
if (prefs_get_enum_value(pref, pref_stashed) == enum_bg->id(enum_rb)) {
|
||||
enum_rb->setChecked(true);
|
||||
}
|
||||
}
|
||||
@ -373,9 +377,9 @@ void ModulePreferencesScrollArea::updateWidgets()
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
|
||||
if (!pref) continue;
|
||||
|
||||
if (pref->type == PREF_ENUM && !pref->info.enum_info.radio_buttons) {
|
||||
if (prefs_get_type(pref) == PREF_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
||||
for (int i = 0; i < enum_cb->count(); i++) {
|
||||
if (pref->stashed_val.enumval == enum_cb->itemData(i).toInt()) {
|
||||
if (prefs_get_enum_value(pref, pref_stashed) == enum_cb->itemData(i).toInt()) {
|
||||
enum_cb->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
@ -394,7 +398,7 @@ void ModulePreferencesScrollArea::uintLineEditTextEdited(const QString &new_str)
|
||||
bool ok;
|
||||
uint new_uint = new_str.toUInt(&ok, 0);
|
||||
if (ok) {
|
||||
pref->stashed_val.uint = new_uint;
|
||||
prefs_set_uint_value(pref, new_uint, pref_stashed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +410,7 @@ void ModulePreferencesScrollArea::boolCheckBoxToggled(bool checked)
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(bool_cb->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
pref->stashed_val.boolval = checked;
|
||||
prefs_set_bool_value(pref, checked, pref_stashed);
|
||||
}
|
||||
|
||||
void ModulePreferencesScrollArea::enumRadioButtonToggled(bool checked)
|
||||
@ -422,7 +426,7 @@ void ModulePreferencesScrollArea::enumRadioButtonToggled(bool checked)
|
||||
if (!pref) return;
|
||||
|
||||
if (enum_bg->checkedId() >= 0) {
|
||||
pref->stashed_val.enumval = enum_bg->checkedId();
|
||||
prefs_set_enum_value(pref, enum_bg->checkedId(), pref_stashed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,7 +438,7 @@ void ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged(int index)
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
pref->stashed_val.enumval = enum_cb->itemData(index).toInt();
|
||||
prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_stashed);
|
||||
}
|
||||
|
||||
void ModulePreferencesScrollArea::stringLineEditTextEdited(const QString &new_str)
|
||||
@ -445,8 +449,7 @@ void ModulePreferencesScrollArea::stringLineEditTextEdited(const QString &new_st
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(string_le->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = qstring_strdup(new_str);
|
||||
prefs_set_string_value(pref, new_str.toStdString().c_str(), pref_stashed);
|
||||
}
|
||||
|
||||
void ModulePreferencesScrollArea::rangeSyntaxLineEditTextEdited(const QString &new_str)
|
||||
@ -476,7 +479,7 @@ void ModulePreferencesScrollArea::uatPushButtonPressed()
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(uat_pb->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
UatDialog uat_dlg(this, pref->varp.uat);
|
||||
UatDialog uat_dlg(this, prefs_get_uat_value(pref));
|
||||
uat_dlg.exec();
|
||||
}
|
||||
|
||||
@ -488,13 +491,12 @@ void ModulePreferencesScrollArea::filenamePushButtonPressed()
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(filename_pb->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
QString filename = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(pref->title),
|
||||
pref->stashed_val.string, QString(), NULL,
|
||||
QString filename = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(prefs_get_title(pref)),
|
||||
prefs_get_string_value(pref, pref_stashed), QString(), NULL,
|
||||
QFileDialog::DontConfirmOverwrite);
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = qstring_strdup(QDir::toNativeSeparators(filename));
|
||||
prefs_set_string_value(pref, QDir::toNativeSeparators(filename).toStdString().c_str(), pref_stashed);
|
||||
updateWidgets();
|
||||
}
|
||||
}
|
||||
@ -507,12 +509,11 @@ void ModulePreferencesScrollArea::dirnamePushButtonPressed()
|
||||
pref_t *pref = VariantPointer<pref_t>::asPtr(dirname_pb->property(pref_prop_));
|
||||
if (!pref) return;
|
||||
|
||||
QString dirname = QFileDialog::getExistingDirectory(this, wsApp->windowTitleString(pref->title),
|
||||
pref->stashed_val.string);
|
||||
QString dirname = QFileDialog::getExistingDirectory(this, wsApp->windowTitleString(prefs_get_title(pref)),
|
||||
prefs_get_string_value(pref, pref_stashed));
|
||||
|
||||
if (!dirname.isEmpty()) {
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = qstring_strdup(QDir::toNativeSeparators(dirname));
|
||||
prefs_set_string_value(pref, QDir::toNativeSeparators(dirname).toStdString().c_str(), pref_stashed);
|
||||
updateWidgets();
|
||||
}
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module
|
||||
ui->modulePreferencesToolButton->setText(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(module_->title));
|
||||
|
||||
pref_stash(pref_, NULL);
|
||||
ui->preferenceTitleLabel->setText(QString("%1:").arg(pref->title));
|
||||
ui->preferenceTitleLabel->setText(QString("%1:").arg(prefs_get_title(pref)));
|
||||
|
||||
// Convert the pref description from plain text to rich text.
|
||||
QString description = html_escape(pref->description);
|
||||
QString description = html_escape(prefs_get_description(pref));
|
||||
description.replace('\n', "<br>");
|
||||
QString tooltip = QString("<span>%1</span>").arg(description);
|
||||
ui->preferenceTitleLabel->setToolTip(tooltip);
|
||||
@ -94,22 +94,22 @@ void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module
|
||||
|
||||
bool show = false;
|
||||
|
||||
switch (pref_->type) {
|
||||
switch (prefs_get_type(pref_)) {
|
||||
case PREF_UINT:
|
||||
new_uint_ = pref->stashed_val.uint;
|
||||
new_uint_ = prefs_get_uint_value_real(pref_, pref_stashed);
|
||||
connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(uintLineEditTextEdited(QString)));
|
||||
show = true;
|
||||
break;
|
||||
case PREF_STRING:
|
||||
new_str_ = pref->stashed_val.string;
|
||||
new_str_ = prefs_get_string_value(pref_, pref_stashed);
|
||||
connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(stringLineEditTextEdited(QString)));
|
||||
show = true;
|
||||
break;
|
||||
case PREF_RANGE:
|
||||
wmem_free(NULL, new_range_);
|
||||
new_range_ = range_copy(NULL, prefs_get_stashed_range(pref));
|
||||
new_range_ = range_copy(NULL, prefs_get_range_value_real(pref_, pref_stashed));
|
||||
connect(ui->preferenceLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(rangeLineEditTextEdited(QString)));
|
||||
show = true;
|
||||
@ -127,7 +127,7 @@ void PreferenceEditorFrame::editPreference(preference *pref, pref_module *module
|
||||
void PreferenceEditorFrame::uintLineEditTextEdited(const QString &new_str)
|
||||
{
|
||||
if (new_str.isEmpty()) {
|
||||
new_uint_ = pref_->stashed_val.uint;
|
||||
new_uint_ = prefs_get_uint_value_real(pref_, pref_stashed);
|
||||
ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
return;
|
||||
@ -139,7 +139,7 @@ void PreferenceEditorFrame::uintLineEditTextEdited(const QString &new_str)
|
||||
new_uint_ = new_uint;
|
||||
ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Valid);
|
||||
} else {
|
||||
new_uint_ = pref_->stashed_val.uint;
|
||||
new_uint_ = prefs_get_uint_value_real(pref_, pref_stashed);
|
||||
ui->preferenceLineEdit->setSyntaxState(SyntaxLineEdit::Invalid);
|
||||
}
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
|
||||
@ -154,7 +154,7 @@ void PreferenceEditorFrame::rangeLineEditTextEdited(const QString &new_str)
|
||||
{
|
||||
range_t *new_range = NULL;
|
||||
|
||||
convert_ret_t ret = range_convert_str(NULL, &new_range, new_str.toUtf8().constData(), pref_->info.max_value);
|
||||
convert_ret_t ret = range_convert_str(NULL, &new_range, new_str.toUtf8().constData(), prefs_get_max_value(pref_));
|
||||
wmem_free(NULL, new_range_);
|
||||
new_range_ = new_range;
|
||||
|
||||
@ -188,22 +188,15 @@ void PreferenceEditorFrame::on_preferenceLineEdit_returnPressed()
|
||||
void PreferenceEditorFrame::on_buttonBox_accepted()
|
||||
{
|
||||
bool apply = false;
|
||||
switch(pref_->type) {
|
||||
switch(prefs_get_type(pref_)) {
|
||||
case PREF_UINT:
|
||||
if (pref_->stashed_val.uint != new_uint_) {
|
||||
pref_->stashed_val.uint = new_uint_;
|
||||
apply = true;
|
||||
}
|
||||
apply = prefs_set_uint_value(pref_, new_uint_, pref_stashed);
|
||||
break;
|
||||
case PREF_STRING:
|
||||
if (new_str_.compare(pref_->stashed_val.string) != 0) {
|
||||
g_free(pref_->stashed_val.string);
|
||||
pref_->stashed_val.string = qstring_strdup(new_str_);
|
||||
apply = true;
|
||||
}
|
||||
apply = prefs_set_string_value(pref_, new_str_.toStdString().c_str(), pref_stashed);
|
||||
break;
|
||||
case PREF_RANGE:
|
||||
apply = prefs_set_stashed_range(pref_, new_range_);
|
||||
apply = prefs_set_range_value(pref_, new_range_, pref_stashed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -112,11 +112,11 @@ public:
|
||||
case adv_name_col_:
|
||||
{
|
||||
QString full_name = QString(module_->name ? module_->name : module_->parent->name);
|
||||
full_name += QString(".%1").arg(pref_->name);
|
||||
full_name += QString(".%1").arg(prefs_get_name(pref_));
|
||||
return full_name;
|
||||
}
|
||||
case adv_status_col_:
|
||||
if ((pref_->type == PREF_UAT && (pref_->gui == GUI_ALL || pref_->gui == GUI_QT))|| pref_->type == PREF_CUSTOM) {
|
||||
if ((prefs_get_type(pref_) == PREF_UAT && (prefs_get_gui_type(pref_) == GUI_ALL || prefs_get_gui_type(pref_) == GUI_QT))|| prefs_get_type(pref_) == PREF_CUSTOM) {
|
||||
return QObject::tr("Unknown");
|
||||
} else if (is_default) {
|
||||
return QObject::tr("Default");
|
||||
@ -137,7 +137,7 @@ public:
|
||||
case Qt::ToolTipRole:
|
||||
switch (column) {
|
||||
case adv_name_col_:
|
||||
return QString("<span>%1</span>").arg(pref_->description);
|
||||
return QString("<span>%1</span>").arg(prefs_get_description(pref_));
|
||||
case adv_status_col_:
|
||||
return QObject::tr("Has this preference been changed?");
|
||||
case adv_type_col_:
|
||||
@ -243,7 +243,7 @@ fill_advanced_prefs(module_t *module, gpointer root_ptr)
|
||||
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
|
||||
pref_t *pref = (pref_t *) pref_l->data;
|
||||
|
||||
if (pref->type == PREF_OBSOLETE || pref->type == PREF_STATIC_TEXT) continue;
|
||||
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT) continue;
|
||||
|
||||
const char *type_name = prefs_pref_type_name(pref);
|
||||
if (!type_name) continue;
|
||||
@ -254,8 +254,8 @@ fill_advanced_prefs(module_t *module, gpointer root_ptr)
|
||||
tl_children << item;
|
||||
|
||||
// .uat is a void * so it wins the "useful key value" prize.
|
||||
if (pref->varp.uat) {
|
||||
prefInsertPrefPtr(pref->varp.uat, pref);
|
||||
if (prefs_get_uat_value(pref)) {
|
||||
prefInsertPrefPtr( prefs_get_uat_value(pref), pref);
|
||||
}
|
||||
}
|
||||
tl_item->addChildren(tl_children);
|
||||
@ -342,7 +342,7 @@ module_prefs_unstash(module_t *module, gpointer data)
|
||||
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
|
||||
pref_t *pref = (pref_t *) pref_l->data;
|
||||
|
||||
if (pref->type == PREF_OBSOLETE || pref->type == PREF_STATIC_TEXT) continue;
|
||||
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT) continue;
|
||||
|
||||
unstashed_data.module = module;
|
||||
pref_unstash(pref, &unstashed_data);
|
||||
@ -366,7 +366,7 @@ module_prefs_clean_stash(module_t *module, gpointer)
|
||||
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
|
||||
pref_t *pref = (pref_t *) pref_l->data;
|
||||
|
||||
if (pref->type == PREF_OBSOLETE || pref->type == PREF_STATIC_TEXT) continue;
|
||||
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT) continue;
|
||||
|
||||
pref_clean_stash(pref, NULL);
|
||||
}
|
||||
@ -644,36 +644,30 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
|
||||
} else {
|
||||
QWidget *editor = NULL;
|
||||
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_DECODE_AS_UINT:
|
||||
{
|
||||
cur_line_edit_ = new QLineEdit();
|
||||
// cur_line_edit_->setInputMask("0000000009;");
|
||||
saved_string_pref_ = QString::number(pref->stashed_val.uint, pref->info.base);
|
||||
connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(uintPrefEditingFinished()));
|
||||
editor = cur_line_edit_;
|
||||
break;
|
||||
}
|
||||
case PREF_UINT:
|
||||
{
|
||||
char* tmpstr = prefs_pref_to_str(pref, pref_stashed);
|
||||
cur_line_edit_ = new QLineEdit();
|
||||
// cur_line_edit_->setInputMask("0000000009;");
|
||||
saved_string_pref_ = QString::number(pref->stashed_val.uint, pref->info.base);
|
||||
saved_string_pref_ = tmpstr;
|
||||
g_free(tmpstr);
|
||||
connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(uintPrefEditingFinished()));
|
||||
editor = cur_line_edit_;
|
||||
break;
|
||||
}
|
||||
case PREF_BOOL:
|
||||
pref->stashed_val.boolval = !pref->stashed_val.boolval;
|
||||
prefs_invert_bool_value(pref, pref_stashed);
|
||||
adv_ti->updatePref();
|
||||
break;
|
||||
case PREF_ENUM:
|
||||
{
|
||||
cur_combo_box_ = new QComboBox();
|
||||
const enum_val_t *ev;
|
||||
for (ev = pref->info.enum_info.enumvals; ev && ev->description; ev++) {
|
||||
for (ev = prefs_get_enumvals(pref); ev && ev->description; ev++) {
|
||||
cur_combo_box_->addItem(ev->description, QVariant(ev->value));
|
||||
if (pref->stashed_val.enumval == ev->value)
|
||||
if (prefs_get_enum_value(pref, pref_stashed) == ev->value)
|
||||
cur_combo_box_->setCurrentIndex(cur_combo_box_->count() - 1);
|
||||
}
|
||||
saved_combo_idx_ = cur_combo_box_->currentIndex();
|
||||
@ -684,7 +678,7 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
|
||||
case PREF_STRING:
|
||||
{
|
||||
cur_line_edit_ = new QLineEdit();
|
||||
saved_string_pref_ = pref->stashed_val.string;
|
||||
saved_string_pref_ = prefs_get_string_value(pref, pref_stashed);
|
||||
connect(cur_line_edit_, SIGNAL(editingFinished()), this, SLOT(stringPrefEditingFinished()));
|
||||
editor = cur_line_edit_;
|
||||
break;
|
||||
@ -694,16 +688,15 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
|
||||
{
|
||||
QString filename;
|
||||
|
||||
if (pref->type == PREF_FILENAME) {
|
||||
filename = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(pref->title),
|
||||
pref->stashed_val.string);
|
||||
if (prefs_get_type(pref) == PREF_FILENAME) {
|
||||
filename = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(prefs_get_title(pref)),
|
||||
prefs_get_string_value(pref, pref_stashed));
|
||||
} else {
|
||||
filename = QFileDialog::getExistingDirectory(this, wsApp->windowTitleString(pref->title),
|
||||
pref->stashed_val.string);
|
||||
filename = QFileDialog::getExistingDirectory(this, wsApp->windowTitleString(prefs_get_title(pref)),
|
||||
prefs_get_string_value(pref, pref_stashed));
|
||||
}
|
||||
if (!filename.isEmpty()) {
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = qstring_strdup(QDir::toNativeSeparators(filename));
|
||||
prefs_set_string_value(pref, QDir::toNativeSeparators(filename).toStdString().c_str(), pref_stashed);
|
||||
adv_ti->updatePref();
|
||||
}
|
||||
break;
|
||||
@ -723,25 +716,27 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
|
||||
case PREF_COLOR:
|
||||
{
|
||||
QColorDialog color_dlg;
|
||||
color_t color = *prefs_get_color_value(pref, pref_stashed);
|
||||
|
||||
color_dlg.setCurrentColor(QColor(
|
||||
pref->stashed_val.color.red >> 8,
|
||||
pref->stashed_val.color.green >> 8,
|
||||
pref->stashed_val.color.blue >> 8
|
||||
color.red >> 8,
|
||||
color.green >> 8,
|
||||
color.blue >> 8
|
||||
));
|
||||
if (color_dlg.exec() == QDialog::Accepted) {
|
||||
QColor cc = color_dlg.currentColor();
|
||||
pref->stashed_val.color.red = cc.red() << 8 | cc.red();
|
||||
pref->stashed_val.color.green = cc.green() << 8 | cc.green();
|
||||
pref->stashed_val.color.blue = cc.blue() << 8 | cc.blue();
|
||||
color.red = cc.red() << 8 | cc.red();
|
||||
color.green = cc.green() << 8 | cc.green();
|
||||
color.blue = cc.blue() << 8 | cc.blue();
|
||||
prefs_set_color_value(pref, color, pref_stashed);
|
||||
adv_ti->updatePref();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PREF_UAT:
|
||||
{
|
||||
if (pref->gui == GUI_ALL || pref->gui == GUI_QT) {
|
||||
UatDialog uat_dlg(this, pref->varp.uat);
|
||||
if (prefs_get_gui_type(pref) == GUI_ALL || prefs_get_gui_type(pref) == GUI_QT) {
|
||||
UatDialog uat_dlg(this, prefs_get_uat_value(pref));
|
||||
uat_dlg.exec();
|
||||
}
|
||||
break;
|
||||
@ -749,7 +744,7 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cur_pref_type_ = pref->type;
|
||||
cur_pref_type_ = prefs_get_type(pref);
|
||||
if (cur_line_edit_) {
|
||||
cur_line_edit_->setText(saved_string_pref_);
|
||||
cur_line_edit_->selectAll();
|
||||
@ -799,9 +794,9 @@ void PreferencesDialog::uintPrefEditingFinished()
|
||||
if (!pref) return;
|
||||
|
||||
bool ok;
|
||||
guint new_val = cur_line_edit_->text().toUInt(&ok, pref->info.base);
|
||||
guint new_val = cur_line_edit_->text().toUInt(&ok, prefs_get_uint_base(pref));
|
||||
|
||||
if (ok) pref->stashed_val.uint = new_val;
|
||||
if (ok) prefs_set_uint_value(pref, new_val, pref_stashed);
|
||||
pd_ui_->advancedTree->removeItemWidget(adv_ti, 3);
|
||||
adv_ti->updatePref();
|
||||
}
|
||||
@ -814,7 +809,7 @@ void PreferencesDialog::enumPrefCurrentIndexChanged(int index)
|
||||
pref_t *pref = adv_ti->pref();
|
||||
if (!pref) return;
|
||||
|
||||
pref->stashed_val.enumval = cur_combo_box_->itemData(index).toInt();
|
||||
prefs_set_uint_value(pref, cur_combo_box_->itemData(index).toInt(), pref_stashed);
|
||||
adv_ti->updatePref();
|
||||
}
|
||||
|
||||
@ -826,8 +821,7 @@ void PreferencesDialog::stringPrefEditingFinished()
|
||||
pref_t *pref = adv_ti->pref();
|
||||
if (!pref) return;
|
||||
|
||||
g_free((void *)pref->stashed_val.string);
|
||||
pref->stashed_val.string = qstring_strdup(cur_line_edit_->text());
|
||||
prefs_set_string_value(pref, cur_line_edit_->text().toStdString().c_str(), pref_stashed);
|
||||
pd_ui_->advancedTree->removeItemWidget(adv_ti, 3);
|
||||
adv_ti->updatePref();
|
||||
}
|
||||
@ -845,7 +839,7 @@ void PreferencesDialog::rangePrefTextChanged(const QString &text)
|
||||
syntax_edit->setSyntaxState(SyntaxLineEdit::Empty);
|
||||
} else {
|
||||
range_t *newrange;
|
||||
convert_ret_t ret = range_convert_str(NULL, &newrange, text.toUtf8().constData(), pref->info.max_value);
|
||||
convert_ret_t ret = range_convert_str(NULL, &newrange, text.toUtf8().constData(), prefs_get_max_value(pref));
|
||||
|
||||
if (ret == CVT_NO_ERROR) {
|
||||
syntax_edit->setSyntaxState(SyntaxLineEdit::Valid);
|
||||
|
@ -49,13 +49,13 @@ public:
|
||||
QAction(NULL),
|
||||
pref_(pref)
|
||||
{
|
||||
setText(pref_->title);
|
||||
setText(prefs_get_title(pref_));
|
||||
setCheckable(true);
|
||||
setChecked(*pref->varp.boolp);
|
||||
setChecked(prefs_get_bool_value(pref_, pref_current));
|
||||
}
|
||||
|
||||
void setBoolValue() {
|
||||
*pref_->varp.boolp = isChecked();
|
||||
prefs_set_bool_value(pref_, isChecked(), pref_current);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -76,11 +76,7 @@ public:
|
||||
}
|
||||
|
||||
bool setEnumValue() {
|
||||
if (*pref_->varp.enump != enumval_) {
|
||||
*pref_->varp.enump = enumval_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return prefs_set_enum_value(pref_, enumval_, pref_current);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -95,11 +91,11 @@ public:
|
||||
QAction(NULL),
|
||||
pref_(pref)
|
||||
{
|
||||
setText(QString("%1" UTF8_HORIZONTAL_ELLIPSIS).arg(pref_->title));
|
||||
setText(QString("%1" UTF8_HORIZONTAL_ELLIPSIS).arg(prefs_get_title(pref_)));
|
||||
}
|
||||
|
||||
void showUatDialog() {
|
||||
UatDialog uat_dlg(parentWidget(), pref_->varp.uat);
|
||||
UatDialog uat_dlg(parentWidget(), prefs_get_uat_value(pref_));
|
||||
uat_dlg.exec();
|
||||
// Emitting PacketDissectionChanged directly from a QDialog can cause
|
||||
// problems on OS X.
|
||||
@ -118,7 +114,7 @@ public:
|
||||
QAction(NULL),
|
||||
pref_(pref)
|
||||
{
|
||||
QString title = pref_->title;
|
||||
QString title = prefs_get_title(pref_);
|
||||
|
||||
title.append(QString(": %1" UTF8_HORIZONTAL_ELLIPSIS).arg(gchar_free_to_qstring(prefs_pref_to_str(pref_, pref_current))));
|
||||
|
||||
@ -203,7 +199,7 @@ void ProtocolPreferencesMenu::setModule(const char *module_name)
|
||||
|
||||
void ProtocolPreferencesMenu::addMenuItem(preference *pref)
|
||||
{
|
||||
switch (pref->type) {
|
||||
switch (prefs_get_type(pref)) {
|
||||
case PREF_BOOL:
|
||||
{
|
||||
BoolPreferenceAction *bpa = new BoolPreferenceAction(pref);
|
||||
@ -214,10 +210,10 @@ void ProtocolPreferencesMenu::addMenuItem(preference *pref)
|
||||
case PREF_ENUM:
|
||||
{
|
||||
QActionGroup *ag = new QActionGroup(this);
|
||||
QMenu *enum_menu = addMenu(pref->title);
|
||||
for (const enum_val_t *enum_valp = pref->info.enum_info.enumvals; enum_valp->name; enum_valp++) {
|
||||
QMenu *enum_menu = addMenu(prefs_get_title(pref));
|
||||
for (const enum_val_t *enum_valp = prefs_get_enumvals(pref); enum_valp->name; enum_valp++) {
|
||||
EnumPreferenceAction *epa = new EnumPreferenceAction(pref, enum_valp->description, enum_valp->value, ag);
|
||||
if (*pref->varp.enump == enum_valp->value) {
|
||||
if (prefs_get_enum_value(pref, pref_current) == enum_valp->value) {
|
||||
epa->setChecked(true);
|
||||
}
|
||||
enum_menu->addAction(epa);
|
||||
@ -248,7 +244,7 @@ void ProtocolPreferencesMenu::addMenuItem(preference *pref)
|
||||
default:
|
||||
// A type we currently don't handle (e.g. PREF_FILENAME). Just open
|
||||
// the prefs dialog.
|
||||
QString title = QString("%1" UTF8_HORIZONTAL_ELLIPSIS).arg(pref->title);
|
||||
QString title = QString("%1" UTF8_HORIZONTAL_ELLIPSIS).arg(prefs_get_title(pref));
|
||||
QAction *mpa = addAction(title);
|
||||
connect(mpa, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered()));
|
||||
break;
|
||||
|
@ -98,7 +98,7 @@ void SCTPChunkStatisticsDialog::fillTable(bool all)
|
||||
FILE* fp = NULL;
|
||||
|
||||
pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types");
|
||||
uat_t *uat = pref->varp.uat;
|
||||
uat_t *uat = prefs_get_uat_value(pref);
|
||||
gchar* fname = uat_get_actual_filename(uat,TRUE);
|
||||
bool init = false;
|
||||
|
||||
@ -212,7 +212,7 @@ void SCTPChunkStatisticsDialog::on_pushButton_clicked()
|
||||
|
||||
pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types");
|
||||
|
||||
uat_t *uat = pref->varp.uat;
|
||||
uat_t *uat = prefs_get_uat_value(pref);
|
||||
|
||||
gchar* fname = uat_get_actual_filename(uat,TRUE);
|
||||
|
||||
@ -284,16 +284,16 @@ void SCTPChunkStatisticsDialog::on_actionChunkTypePreferences_triggered()
|
||||
gchar* err = NULL;
|
||||
|
||||
pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types");
|
||||
uat_t *uat = pref->varp.uat;
|
||||
uat_t *uat = prefs_get_uat_value(pref);
|
||||
uat_clear(uat);
|
||||
|
||||
if (!uat_load(pref->varp.uat, &err)) {
|
||||
if (!uat_load(uat, &err)) {
|
||||
/* XXX - report this through the GUI */
|
||||
printf("Error loading table '%s': %s",pref->varp.uat->name,err);
|
||||
printf("Error loading table '%s': %s", uat->name,err);
|
||||
g_free(err);
|
||||
}
|
||||
|
||||
UatDialog *uatdialog = new UatDialog(this, pref->varp.uat);
|
||||
UatDialog *uatdialog = new UatDialog(this, uat);
|
||||
uatdialog->exec();
|
||||
// Emitting PacketDissectionChanged directly from a QDialog can cause
|
||||
// problems on OS X.
|
||||
|
Loading…
x
Reference in New Issue
Block a user