2 * gui functions used by stats
3 * Copyright 2003 Lars Roland
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
38 #include "gtk_stat_util.h"
39 #include "compat_macros.h"
40 #include "../simple_dialog.h"
42 #include "../globals.h"
44 /* insert a string into a GTK_TABLE at column x and row y*/
47 typedef struct _gtk_table {
48 GtkWidget *widget; /**< the table widget */
49 int height; /**< the height */
50 int width; /**< the width */
54 add_table_entry(gtk_table *tab, const char *str, int x, int y)
60 gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
64 gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
67 tmp=gtk_label_new(str);
68 gtk_table_attach_defaults(GTK_TABLE(tab->widget), tmp, x, x+1, y, y+1);
69 gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
74 /* init a main windowfor stats, set title and display used filter in window */
77 init_main_stat_window(GtkWidget *window, GtkWidget *mainbox, char *title, char *filter)
79 GtkWidget *main_label;
80 GtkWidget *filter_label;
81 char filter_string[256];
84 gtk_window_set_title(GTK_WINDOW(window), title);
86 gtk_container_add(GTK_CONTAINER(window), mainbox);
87 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 10);
88 gtk_widget_show(mainbox);
90 main_label=gtk_label_new(title);
91 gtk_box_pack_start(GTK_BOX(mainbox), main_label, FALSE, FALSE, 0);
92 gtk_widget_show(main_label);
94 g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
95 filter_label=gtk_label_new(filter_string);
96 gtk_box_pack_start(GTK_BOX(mainbox), filter_label, FALSE, FALSE, 0);
97 gtk_widget_show(filter_label);
101 /* create a table, using a scrollable gtkclist */
104 create_stat_table(GtkWidget *scrolled_window, GtkWidget *vbox, int columns, char *titles[])
110 table = GTK_CLIST(gtk_clist_new_with_titles(columns, titles));
112 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
114 /* configure clist */
115 gtk_clist_column_titles_passive(table);
116 gtk_clist_column_titles_show(table);
117 for (i = 0; i < columns; i++)
118 gtk_clist_set_column_auto_resize(table, i, TRUE);
119 gtk_clist_set_selection_mode(table, GTK_SELECTION_SINGLE);
121 /* Put clist into a scrolled window */
122 gtk_container_add(GTK_CONTAINER(scrolled_window),
124 gtk_widget_show(GTK_WIDGET(table));
125 gtk_widget_show(scrolled_window);