diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index e52ed0d3a0..09b16492dd 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -671,6 +671,7 @@ libwireshark.so.0 libwireshark0 #MINVER# get_column_format_matches@Base 1.9.1 get_column_resolved@Base 1.9.1 get_column_title@Base 1.9.1 + get_column_tooltip@Base 2.0.1 get_column_visible@Base 1.9.1 get_column_width_string@Base 1.9.1 get_conversation_address@Base 1.99.0 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 diff --git a/ui/gtk/packet_list.c b/ui/gtk/packet_list.c index 7a604ed954..a46562367b 100644 --- a/ui/gtk/packet_list.c +++ b/ui/gtk/packet_list.c @@ -656,7 +656,6 @@ create_view_and_model(void) gint i, col_width; gdouble value; gchar *tooltip_text; - header_field_info *hfi; gint col_min_width; gchar *escaped_title; col_item_t* col_item; @@ -705,26 +704,7 @@ create_view_and_model(void) show_cell_data_func, GINT_TO_POINTER(i), NULL); - if (col_item->col_fmt == COL_CUSTOM) { - hfi = proto_registrar_get_byname(col_item->col_custom_field); - /* Check if this is a valid custom_field */ - if (hfi != NULL) { - if (hfi->parent != -1) { - /* Prefix with protocol name */ - if (col_item->col_custom_occurrence != 0) { - tooltip_text = g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, col_item->col_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(i)); - } - } else { - tooltip_text = g_strdup(col_format_desc(col_item->col_fmt)); - } + escaped_title = ws_strdup_escape_char(col_item->col_title, '_'); gtk_tree_view_column_set_title(col, escaped_title); g_free (escaped_title); @@ -769,6 +749,7 @@ create_view_and_model(void) gtk_tree_view_append_column(GTK_TREE_VIEW(packetlist->view), col); + tooltip_text = get_column_tooltip(i); gtk_widget_set_tooltip_text(gtk_tree_view_column_get_button(col), tooltip_text); g_free(tooltip_text); g_signal_connect(gtk_tree_view_column_get_button(col), "button_press_event", diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index 0ee0b662c7..55fdf29494 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -528,20 +528,30 @@ QVariant PacketListModel::data(const QModelIndex &d_index, int role) const } QVariant PacketListModel::headerData(int section, Qt::Orientation orientation, - int role) const + int role) const { - if (!cap_file_) return QVariant(); + QVariant data; + + if (!cap_file_) return data; if (orientation == Qt::Horizontal && section < prefs.num_cols) { switch (role) { case Qt::DisplayRole: - return get_column_title(section); + data = get_column_title(section); + break; + case Qt::ToolTipRole: + { + gchar *tooltip = get_column_tooltip(section); + data = tooltip; + g_free (tooltip); + break; + } default: break; } } - return QVariant(); + return data; } void PacketListModel::flushVisibleRows() diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h index 6562cebeee..7d67eb3a3d 100644 --- a/ui/qt/packet_list_model.h +++ b/ui/qt/packet_list_model.h @@ -58,7 +58,7 @@ public: int columnCount(const QModelIndex & = QModelIndex()) const; QVariant data(const QModelIndex &d_index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + int role = Qt::DisplayRole | Qt::ToolTipRole) const; gint appendPacket(frame_data *fdata); frame_data *getRowFdata(int row);