52f8fe90bb7e7e7eabf31ff223ca25fcbf20feee
[obnox/wireshark/wip.git] / gtk / packet_list_store.h
1 /* packet_list_store.h
2  *
3  * $Id$
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22  * USA.
23  */
24
25 /* Uncomment to track some statistics (const strings, etc.) */
26 /* #define NEW_PACKET_LIST_STATISTICS */
27
28 #ifndef __NEW_PACKET_LIST_H__
29 #define __NEW_PACKET_LIST_H__
30
31 #ifdef NEW_PACKET_LIST
32
33 #include <glib.h>
34
35 #include "epan/column_info.h"
36 #include "epan/frame_data.h"
37
38 #define PACKETLIST_TYPE_LIST (packet_list_get_type())
39 #define PACKET_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PACKETLIST_TYPE_LIST, PacketList))
40 #define PACKETLIST_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CART((klass), PACKETLIST_TYPE_LIST))
41 #define PACKETLIST_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PACKETLIST_TYPE_LIST))
42 #define PACKETLIST_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass), PACKETLIST_TYPE_LIST)
43 #define PACKETLIST_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PACKETLIST_TYPE_LIST, PacketListClass))
44
45 typedef struct _PacketListRecord PacketListRecord;
46 typedef struct _PacketList PacketList;
47 typedef struct _PacketListClass PacketListClass;
48
49 #define PACKET_LIST_RECORD_GET(rows, pos) ((PacketListRecord*) g_ptr_array_index((rows), (pos)))
50 #define PACKET_LIST_RECORD_SET(rows, pos, item) g_ptr_array_index((rows), (pos)) = (item)
51 #define PACKET_LIST_RECORD_APPEND(rows, item) g_ptr_array_add((rows), (item))
52 #define PACKET_LIST_RECORD_COUNT(rows) ((rows) ? (rows)->len : 0)
53 #define PACKET_LIST_RECORD_INDEX_VALID(rows, idx) ((rows) ? (((guint) (idx)) < (rows)->len) : FALSE)
54
55 /* PacketListRecord: represents a row */
56 struct _PacketListRecord
57 {
58         /* Has this record been columnized? */
59         gboolean columnized;
60         /* Has this record been colorized? */
61         gboolean colorized;
62         frame_data *fdata;
63
64         /* admin stuff used by the custom list model */
65         /* position within the physical array */
66         guint physical_pos;
67         /* position within the visible array */
68         gint visible_pos;
69 };
70
71 /* PacketListRecord: Everything for our model implementation. */
72 struct _PacketList
73 {
74         GObject parent; /* MUST be first */
75
76         GPtrArray *visible_rows;
77         /* Array of pointers to the PacketListRecord structure for each row. */
78         GPtrArray *physical_rows;
79
80         /* Has the entire file been columnized? */
81         gboolean columnized;
82
83         gint n_columns;
84         /* Note: We need one extra column to store the entire PacketListRecord */
85         GType column_types[NUM_COL_FMTS+1];
86         GtkWidget *view; /* XXX - Does this really belong here?? */
87
88         gint sort_id;
89         GtkSortType sort_order;
90
91         GStringChunk *string_pool;
92
93         /* Random integer to check whether an iter belongs to our model. */
94         gint stamp;
95
96 #ifdef NEW_PACKET_LIST_STATISTICS
97         /* Statistics */
98         guint const_strings;
99 #endif
100 };
101
102 /* PacketListClass: more boilerplate GObject stuff */
103 struct _PacketListClass
104 {
105         GObjectClass parent_class;
106 };
107
108 GType packet_list_list_get_type(void);
109 PacketList *new_packet_list_new(void);
110 void new_packet_list_store_clear(PacketList *packet_list);
111 guint packet_list_recreate_visible_rows(PacketList *packet_list);
112 gboolean packet_list_visible_record(PacketList *packet_list, GtkTreeIter *iter);
113 gint packet_list_append_record(PacketList *packet_list, frame_data *fdata);
114 void packet_list_change_record(PacketList *packet_list, guint row, gint col, column_info *cinfo);
115 void packet_list_dissect_and_cache_iter(PacketList *packet_list, GtkTreeIter *iter, gboolean dissect_columns, gboolean dissect_color);
116 void packet_list_reset_colorized(PacketList *packet_list);
117 const char* packet_list_get_widest_column_string(PacketList *packet_list, gint col);
118
119 #endif /* NEW_PACKET_LIST */
120
121 #endif /* __NEW_PACKET_LIST_H__ */