summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-11-22 21:25:15 +0100
committerAnders Broman <a.broman58@gmail.com>2015-11-23 05:41:09 +0000
commitc5fb402222be88e95e26793ffca9aa1c15c70732 (patch)
treeb81267fba9d3f2d625042cb23d1d9c432badc20f /epan
parentfad15654b1900a9af59d9dabf705060c6f9f058d (diff)
downloadwireshark-c5fb402222be88e95e26793ffca9aa1c15c70732.tar.gz
Qt: Set tooltip for packet list header
Added get_column_tooltip() to use common code in GTK and Qt. Change-Id: I2f6ce95e2e129752bbb958a28aec6f42aa81be3d Reviewed-on: https://code.wireshark.org/review/12047 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/column.c36
-rw-r--r--epan/column.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/epan/column.c b/epan/column.c
index 5555d3e0c8..ca482c8127 100644
--- a/epan/column.c
+++ b/epan/column.c
@@ -784,6 +784,42 @@ set_column_custom_occurrence(const gint col, const gint custom_occurrence)
cfmt->custom_occurrence = custom_occurrence;
}
+gchar *
+get_column_tooltip(const gint col)
+{
+ GList *clp = g_list_nth(prefs.col_list, col);
+ fmt_data *cfmt;
+ gchar *tooltip_text;
+
+ 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_field);
+ /* Check if this is a valid custom_field */
+ 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);
+ }
+ } else {
+ tooltip_text = g_strdup_printf("Unknown Field: %s", get_column_custom_field(col));
+ }
+ } else {
+ tooltip_text = g_strdup(col_format_desc(cfmt->fmt));
+ }
+
+ return tooltip_text;
+}
+
void
build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences)
{
diff --git a/epan/column.h b/epan/column.h
index 3061c36e82..af19b07ca2 100644
--- a/epan/column.h
+++ b/epan/column.h
@@ -75,6 +75,8 @@ WS_DLL_PUBLIC
const gchar *get_column_width_string(const gint, const gint);
WS_DLL_PUBLIC
gint get_column_char_width(const gint format);
+WS_DLL_PUBLIC
+gchar *get_column_tooltip(const gint col);
WS_DLL_PUBLIC
void