Introduce "Show Resolved" as an option in custom columns. This will determine
if we show the value or the string representing the value. This setting is not stored in the preferences file yet, and the option is not available in the columns preferences window. svn path=/trunk/; revision=33317
This commit is contained in:
parent
64ebe8caae
commit
beb4314276
|
@ -683,6 +683,34 @@ set_column_visible(const gint col, gboolean visible)
|
|||
cfmt->visible = visible;
|
||||
}
|
||||
|
||||
gboolean
|
||||
get_column_resolved(const gint col)
|
||||
{
|
||||
GList *clp = g_list_nth(prefs.col_list, col);
|
||||
fmt_data *cfmt;
|
||||
|
||||
if (!clp) /* Invalid column requested */
|
||||
return TRUE;
|
||||
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
|
||||
return(cfmt->resolved);
|
||||
}
|
||||
|
||||
void
|
||||
set_column_resolved(const gint col, gboolean resolved)
|
||||
{
|
||||
GList *clp = g_list_nth(prefs.col_list, col);
|
||||
fmt_data *cfmt;
|
||||
|
||||
if (!clp) /* Invalid column requested */
|
||||
return;
|
||||
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
|
||||
cfmt->resolved = resolved;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
get_column_custom_field(const gint col)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct _fmt_data {
|
|||
gchar *fmt;
|
||||
gchar *custom_field;
|
||||
gboolean visible;
|
||||
gboolean resolved;
|
||||
} fmt_data;
|
||||
|
||||
const gchar *col_format_to_string(const gint);
|
||||
|
@ -44,6 +45,8 @@ gint get_column_format_from_str(const gchar *);
|
|||
gchar *get_column_title(const gint);
|
||||
gboolean get_column_visible(const gint);
|
||||
void set_column_visible(const gint, gboolean);
|
||||
gboolean get_column_resolved(const gint);
|
||||
void set_column_resolved(const gint, gboolean);
|
||||
const gchar *get_column_custom_field(const gint);
|
||||
const gchar *get_column_width_string(const gint, const gint);
|
||||
const char *get_column_longest_string(const gint);
|
||||
|
|
|
@ -1085,6 +1085,7 @@ init_prefs(void) {
|
|||
cfmt->title = g_strdup(col_fmt[i * 2]);
|
||||
cfmt->fmt = g_strdup(col_fmt[(i * 2) + 1]);
|
||||
cfmt->visible = TRUE;
|
||||
cfmt->resolved = TRUE;
|
||||
cfmt->custom_field = NULL;
|
||||
prefs.col_list = g_list_append(prefs.col_list, cfmt);
|
||||
}
|
||||
|
@ -1989,6 +1990,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
|
|||
cfmt->custom_field = NULL;
|
||||
}
|
||||
cfmt->visible = prefs_is_column_hidden (cols_hidden_list, prefs_fmt) ? FALSE : TRUE;
|
||||
cfmt->resolved = TRUE;
|
||||
g_free (prefs_fmt);
|
||||
col_l_elt = col_l_elt->next;
|
||||
prefs.col_list = g_list_append(prefs.col_list, cfmt);
|
||||
|
@ -3255,6 +3257,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest_cfmt->custom_field = NULL;
|
||||
}
|
||||
dest_cfmt->visible = src_cfmt->visible;
|
||||
dest_cfmt->resolved = src_cfmt->resolved;
|
||||
dest->col_list = g_list_append(dest->col_list, dest_cfmt);
|
||||
}
|
||||
dest->num_cols = src->num_cols;
|
||||
|
|
16
gtk/menus.c
16
gtk/menus.c
|
@ -797,6 +797,10 @@ static GtkItemFactoryEntry packet_list_heading_items[] =
|
|||
|
||||
{"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
|
||||
|
||||
{"/Show Resolved", NULL, GTK_MENU_FUNC(new_packet_list_column_menu_cb), COLUMN_SELECTED_TOGGLE_RESOLVED, "<CheckItem>", NULL,},
|
||||
|
||||
{"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
|
||||
|
||||
{"/Align Left", NULL, GTK_MENU_FUNC(new_packet_list_column_menu_cb), COLUMN_SELECTED_ALIGN_LEFT, "<StockItem>", GTK_STOCK_JUSTIFY_LEFT,},
|
||||
{"/Align Center", NULL, GTK_MENU_FUNC(new_packet_list_column_menu_cb), COLUMN_SELECTED_ALIGN_CENTER, "<StockItem>", GTK_STOCK_JUSTIFY_CENTER,},
|
||||
{"/Align Right", NULL, GTK_MENU_FUNC(new_packet_list_column_menu_cb), COLUMN_SELECTED_ALIGN_RIGHT, "<StockItem>", GTK_STOCK_JUSTIFY_RIGHT,},
|
||||
|
@ -3392,6 +3396,18 @@ rebuild_visible_columns_menu (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
menus_set_column_resolved (gboolean resolved, gboolean can_resolve)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
|
||||
menu = gtk_item_factory_get_widget(packet_list_heading_factory, "/Show Resolved");
|
||||
g_object_set_data(G_OBJECT(menu), "skip-update", (void *)1);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), resolved && can_resolve);
|
||||
set_menu_sensitivity(packet_list_heading_factory, "/Show Resolved", can_resolve);
|
||||
g_object_set_data(G_OBJECT(menu), "skip-update", NULL);
|
||||
}
|
||||
|
||||
void
|
||||
menus_set_column_align_default (gboolean right_justify)
|
||||
{
|
||||
|
|
|
@ -117,6 +117,9 @@ extern GtkWidget *popup_menu_object;
|
|||
column justification. */
|
||||
void menus_set_column_align_default (gboolean right_justify);
|
||||
|
||||
/* Update the packet list heading menu to indicate if column can be resolved. */
|
||||
void menus_set_column_resolved (gboolean resolved, gboolean can_resolve);
|
||||
|
||||
/* Enable or disable menu items based on whether a tree row is selected
|
||||
and and on whether a "Match Selected" can be done. */
|
||||
void set_menus_for_selected_tree_row(capture_file *cf);
|
||||
|
|
|
@ -160,7 +160,7 @@ right_justify_column (gint col)
|
|||
case COL_CUSTOM:
|
||||
hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[col]);
|
||||
/* Check if this is a valid field and we have no strings lookup table */
|
||||
if ((hfi != NULL) && (hfi->strings == NULL)) {
|
||||
if ((hfi != NULL) && ((hfi->strings == NULL) || !get_column_resolved(col))) {
|
||||
/* Check for bool, framenum and decimal/octal integer types */
|
||||
if ((hfi->type == FT_BOOLEAN) || (hfi->type == FT_FRAMENUM) ||
|
||||
(((hfi->display == BASE_DEC) || (hfi->display == BASE_OCT)) &&
|
||||
|
@ -177,6 +177,32 @@ right_justify_column (gint col)
|
|||
return right_justify;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
resolve_column (gint col)
|
||||
{
|
||||
header_field_info *hfi;
|
||||
gboolean resolve = FALSE;
|
||||
|
||||
switch (cfile.cinfo.col_fmt[col]) {
|
||||
|
||||
case COL_CUSTOM:
|
||||
hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[col]);
|
||||
/* Check if this is a valid field and we have no strings lookup table */
|
||||
if ((hfi != NULL) && (hfi->strings != NULL) &&
|
||||
/* Check for bool, framenum and decimal/octal integer types */
|
||||
((hfi->type == FT_BOOLEAN) || (hfi->type == FT_FRAMENUM) ||
|
||||
IS_FT_INT(hfi->type) || IS_FT_UINT(hfi->type))) {
|
||||
resolve = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return resolve;
|
||||
}
|
||||
|
||||
static void
|
||||
col_title_change_ok (GtkWidget *w, gpointer parent_w)
|
||||
{
|
||||
|
@ -408,7 +434,18 @@ new_packet_list_remove_column (gint col_id, GtkTreeViewColumn *col _U_)
|
|||
}
|
||||
|
||||
void
|
||||
new_packet_list_column_menu_cb (GtkWidget *w _U_, gpointer user_data _U_, COLUMN_SELECTED_E action)
|
||||
new_packet_list_toggle_resolved (GtkWidget *w, gint col_id)
|
||||
{
|
||||
/* We have to check for skip-update because we get an emit in menus_set_column_resolved() */
|
||||
if (g_object_get_data(G_OBJECT(w), "skip-update") == NULL) {
|
||||
set_column_resolved (col_id, get_column_resolved (col_id) ? FALSE : TRUE);
|
||||
|
||||
new_packet_list_recreate();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
new_packet_list_column_menu_cb (GtkWidget *w, gpointer user_data _U_, COLUMN_SELECTED_E action)
|
||||
{
|
||||
GtkTreeViewColumn *col = (GtkTreeViewColumn *)
|
||||
g_object_get_data(G_OBJECT(packetlist->view), E_MPACKET_LIST_COLUMN_KEY);
|
||||
|
@ -425,6 +462,9 @@ new_packet_list_column_menu_cb (GtkWidget *w _U_, gpointer user_data _U_, COLUMN
|
|||
gtk_tree_view_column_set_sort_indicator(col, FALSE);
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(packetlist), 0, GTK_SORT_ASCENDING);
|
||||
break;
|
||||
case COLUMN_SELECTED_TOGGLE_RESOLVED:
|
||||
new_packet_list_toggle_resolved (w, col_id);
|
||||
break;
|
||||
case COLUMN_SELECTED_ALIGN_LEFT:
|
||||
new_packet_list_xalign_column (col_id, col, COLUMN_XALIGN_LEFT);
|
||||
break;
|
||||
|
@ -464,6 +504,7 @@ new_packet_list_column_button_pressed_cb (GtkWidget *widget, GdkEvent *event, gp
|
|||
gboolean right_justify = right_justify_column (col_id);
|
||||
|
||||
menus_set_column_align_default (right_justify);
|
||||
menus_set_column_resolved (get_column_resolved (col_id), resolve_column (col_id));
|
||||
g_object_set_data(G_OBJECT(packetlist->view), E_MPACKET_LIST_COLUMN_KEY, col);
|
||||
popup_menu_handler (widget, event, menu);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef enum {
|
|||
COLUMN_SELECTED_SORT_ASCENDING,
|
||||
COLUMN_SELECTED_SORT_DESCENDING,
|
||||
COLUMN_SELECTED_SORT_NONE,
|
||||
COLUMN_SELECTED_TOGGLE_RESOLVED,
|
||||
COLUMN_SELECTED_ALIGN_LEFT,
|
||||
COLUMN_SELECTED_ALIGN_CENTER,
|
||||
COLUMN_SELECTED_ALIGN_RIGHT,
|
||||
|
|
|
@ -738,8 +738,12 @@ packet_list_change_record(PacketList *packet_list, guint row, gint col, column_i
|
|||
|
||||
if(!packet_list->string_pool)
|
||||
packet_list->string_pool = g_string_chunk_new(32);
|
||||
|
||||
str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)cinfo->col_data[col]);
|
||||
if (!get_column_resolved (col) && cinfo->col_expr.col_expr_val[col]) {
|
||||
/* Use the unresolved value in col_expr_val */
|
||||
str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)cinfo->col_expr.col_expr_val[col]);
|
||||
} else {
|
||||
str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)cinfo->col_data[col]);
|
||||
}
|
||||
record->fdata->col_text[col] = str;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -340,6 +340,7 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field)
|
|||
cfmt->title = g_strdup(title);
|
||||
cfmt->fmt = g_strdup(col_format_to_string(fmt));
|
||||
cfmt->custom_field = g_strdup(custom_field);
|
||||
cfmt->resolved = TRUE;
|
||||
|
||||
if (custom_field) {
|
||||
cfmt->visible = TRUE;
|
||||
|
|
Loading…
Reference in New Issue