aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-12-20 20:52:25 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2015-12-21 07:32:00 +0000
commitdca8f092dd7153d51fcc9f40fed7039f4c8c13b8 (patch)
tree2e56aa9ddc53731e35529ce7b1a9d319cf84d5d3 /epan
parent5f2f6a395a267112396c2965432fa40cf28dee3c (diff)
ui: Fixed column tooltip when having multi-field custom columns.
Change-Id: Iac09b841ff782ea351052ad6b20f5b4ff170e8e8 Reviewed-on: https://code.wireshark.org/review/12752 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'epan')
-rw-r--r--epan/column.c66
1 files changed, 47 insertions, 19 deletions
diff --git a/epan/column.c b/epan/column.c
index 1ec3312501..a8037346d7 100644
--- a/epan/column.c
+++ b/epan/column.c
@@ -784,40 +784,68 @@ set_column_custom_occurrence(const gint col, const gint custom_occurrence)
cfmt->custom_occurrence = custom_occurrence;
}
+static gchar *
+get_custom_field_tooltip (gchar *custom_field, gint occurrence)
+{
+ header_field_info *hfi = proto_registrar_get_byname(custom_field);
+ if (hfi == NULL) {
+ /* Not a valid field */
+ return g_strdup_printf("Unknown Field: %s", custom_field);
+ }
+
+ if (hfi->parent == -1) {
+ /* Protocol */
+ return g_strdup_printf("%s (%s)", hfi->name, hfi->abbrev);
+ }
+
+ if (occurrence == 0) {
+ /* All occurrences */
+ return g_strdup_printf("%s\n%s (%s)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev);
+ }
+
+ /* One given occurence */
+ return g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, occurrence);
+}
+
gchar *
get_column_tooltip(const gint col)
{
GList *clp = g_list_nth(prefs.col_list, col);
fmt_data *cfmt;
- gchar *tooltip_text;
+ gchar **fields;
+ gboolean first = TRUE;
+ GString *column_tooltip;
+ guint i;
if (!clp) /* Invalid column requested */
return NULL;
cfmt = (fmt_data *) clp->data;
- if (cfmt->fmt == COL_CUSTOM) {
- header_field_info *hfi = proto_registrar_get_byname(cfmt->custom_fields);
- /* Check if this is a valid custom_fields */
- if (hfi != NULL) {
- if (hfi->parent != -1) {
- /* Prefix with protocol name */
- if (cfmt->custom_occurrence != 0) {
- tooltip_text = g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, cfmt->custom_occurrence);
- } else {
- tooltip_text = g_strdup_printf("%s\n%s (%s)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev);
- }
- } else {
- tooltip_text = g_strdup_printf("%s (%s)", hfi->name, hfi->abbrev);
+ if (cfmt->fmt != COL_CUSTOM) {
+ /* Use format description */
+ return g_strdup(col_format_desc(cfmt->fmt));
+ }
+
+ fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX, cfmt->custom_fields,
+ G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED);
+ column_tooltip = g_string_new("");
+
+ for (i = 0; i < g_strv_length(fields); i++) {
+ if (fields[i] && *fields[i]) {
+ gchar *field_tooltip = get_custom_field_tooltip(fields[i], cfmt->custom_occurrence);
+ if (!first) {
+ g_string_append(column_tooltip, "\n\nOR\n\n");
}
- } else {
- tooltip_text = g_strdup_printf("Unknown Field: %s", get_column_custom_fields(col));
+ g_string_append(column_tooltip, field_tooltip);
+ g_free (field_tooltip);
+ first = FALSE;
}
- } else {
- tooltip_text = g_strdup(col_format_desc(cfmt->fmt));
}
- return tooltip_text;
+ g_strfreev(fields);
+
+ return g_string_free (column_tooltip, FALSE);
}
void