diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2020-07-14 19:04:00 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2020-07-15 03:57:01 +0000 |
commit | 3ff0a55d5c77702e946195efb5ea5253f6482032 (patch) | |
tree | 9e619892f4ea76f43706699448c62857670eb582 /ui/preference_utils.c | |
parent | 6037b401069186dbc47e9b87da633537f6d981f2 (diff) |
Qt: Check if "Apply as Column" column already exists
Use the existing (possible hidden) column when doing "Apply as Column"
on a field which is already used as a custom column. This will help
prevent having multiple equal custom columns, where all will be hidden
at startup and profile change when only one of them are configured as
hidden.
Multiple equal columns can always be manually configured using
"Preferences -> Appearance -> Columns" if this is intended.
Change-Id: Ib03893facfa3f194f3b3303645fb3f9313ec9e91
Reviewed-on: https://code.wireshark.org/review/37861
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/preference_utils.c')
-rw-r--r-- | ui/preference_utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c index 404c13c997..ef6ca14778 100644 --- a/ui/preference_utils.c +++ b/ui/preference_utils.c @@ -200,6 +200,28 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields return colnr; } +gint +column_prefs_has_custom(const gchar *custom_field) +{ + GList *clp; + fmt_data *cfmt; + gint colnr = -1; + + for (gint i = 0; i < prefs.num_cols; i++) { + clp = g_list_nth(prefs.col_list, i); + if (clp == NULL) /* Sanity check, invalid column requested */ + continue; + + cfmt = (fmt_data *) clp->data; + if (cfmt->fmt == COL_CUSTOM && strcmp(custom_field, cfmt->custom_fields) == 0) { + colnr = i; + break; + } + } + + return colnr; +} + void column_prefs_remove_link(GList *col_link) { |