static void packet_list_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value) { PacketListRecord *record; PacketList *packet_list; g_return_if_fail(PACKETLIST_IS_LIST(tree_model)); packet_list = (PacketList *) tree_model; g_return_if_fail(iter != NULL); g_return_if_fail(iter->stamp == packet_list->stamp); g_return_if_fail(iter->user_data != NULL); /* Note: We use one extra column to store the entire frame_data */ g_return_if_fail(column >= 0 && column < packet_list->n_cols + 1); record = (PacketListRecord*) iter->user_data; #ifdef PACKET_PARANOID_CHECKS g_return_if_fail(PACKET_LIST_RECORD_INDEX_VALID(packet_list->physical_rows, record->physical_pos)); #endif g_return_if_fail(PACKET_LIST_RECORD_INDEX_VALID(packet_list->visible_rows, record->visible_pos)); if (column >= 0 && column < packet_list->n_cols) { int text_column; g_value_init(value, G_TYPE_STRING); if (record->col_text == NULL || !record->colorized) packet_list_dissect_and_cache_record(packet_list, record, !record->colorized); text_column = packet_list->col_to_text[column]; if (text_column == -1) { /* column based on frame_data */ col_fill_in_frame_data(record->fdata, &cfile.cinfo, column, FALSE); g_value_set_string(value, cfile.cinfo.col_data[column]); } else { g_return_if_fail(record->col_text); g_value_set_string(value, record->col_text[text_column]); } } else if (column == packet_list->n_cols) { g_value_init(value, G_TYPE_POINTER); g_value_set_pointer(value, record->fdata); } }
static void packet_list_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value) { PacketListRecord *record; PacketList *packet_list; GType type; g_return_if_fail(PACKETLIST_IS_LIST(tree_model)); g_return_if_fail(iter != NULL); packet_list = PACKET_LIST(tree_model); /* Note: We use one extra column to store the entire PacketListRecord */ g_return_if_fail(column < packet_list->n_columns); record = (PacketListRecord*) iter->user_data; g_return_if_fail(PACKET_LIST_RECORD_INDEX_VALID(packet_list->physical_rows, record->physical_pos)); g_return_if_fail(PACKET_LIST_RECORD_INDEX_VALID(packet_list->visible_rows, record->visible_pos)); type = packet_list->column_types[column]; g_value_init(value, type); /* XXX Probably the switch should be on column or * should we allways return the pointer and read the data as required?? * If we use FOREGROUND_COLOR_COL etc we'll need a couple of "internal" columns */ switch(type){ case G_TYPE_POINTER: g_value_set_pointer(value, record); break; case G_TYPE_STRING: g_return_if_fail(record->fdata->col_text); g_value_set_string(value, record->fdata->col_text[column]); break; default: g_warning (G_STRLOC ": Unsupported type (%s) retrieved.", g_type_name (value->g_type)); break; } }
static PacketListRecord * packet_list_iter_next_visible(PacketList *packet_list, PacketListRecord *record) { PacketListRecord *nextrecord; gint next_visible_pos; g_assert(record->visible_pos >= 0); next_visible_pos = record->visible_pos + 1; /* Is this the last record in the list? */ if(!PACKET_LIST_RECORD_INDEX_VALID(packet_list->visible_rows, next_visible_pos)) return NULL; nextrecord = PACKET_LIST_RECORD_GET(packet_list->visible_rows, next_visible_pos); g_assert(nextrecord->visible_pos == (record->visible_pos + 1)); g_assert(nextrecord->physical_pos >= (record->physical_pos + 1)); return nextrecord; }
static gboolean packet_list_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path) { PacketList *packet_list; PacketListRecord *record; gint *indices, depth; gint n; g_assert(PACKETLIST_IS_LIST(tree_model)); g_assert(path != NULL); indices = gtk_tree_path_get_indices(path); depth = gtk_tree_path_get_depth(path); /* we do not allow children since it's just a list */ g_assert(depth == 1); n = indices[0]; /* the n-th top level row */ packet_list = PACKET_LIST(tree_model); if(PACKET_LIST_RECORD_COUNT(packet_list->visible_rows) == 0) return FALSE; if(!PACKET_LIST_RECORD_INDEX_VALID(packet_list->visible_rows, n)) return FALSE; record = PACKET_LIST_RECORD_GET(packet_list->visible_rows, n); g_assert(record->visible_pos == n); /* We simply store a pointer to our custom record in the iter */ iter->stamp = packet_list->stamp; iter->user_data = record; iter->user_data2 = NULL; iter->user_data3 = NULL; return TRUE; }