2 * gui functions used by stats
3 * Copyright 2003 Lars Roland
5 * $Id: gtk_stat_util.c,v 1.3 2003/08/21 17:48:04 guy Exp $
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 add_table_entry(gtk_table *tab, char *str, int x, int y)
53 gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
57 gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
60 tmp=gtk_label_new(str);
61 gtk_table_attach_defaults(GTK_TABLE(tab->widget), tmp, x, x+1, y, y+1);
62 gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
66 /* init a main windowfor stats, set title and display used filter in window */
69 init_main_stat_window(GtkWidget *window, GtkWidget *mainbox, char *title, char *filter)
71 GtkWidget *main_label;
72 GtkWidget *filter_label;
73 char filter_string[256];
76 gtk_window_set_title(GTK_WINDOW(window), title);
78 gtk_container_add(GTK_CONTAINER(window), mainbox);
79 gtk_container_set_border_width(GTK_CONTAINER(mainbox), 10);
80 gtk_widget_show(mainbox);
82 main_label=gtk_label_new(title);
83 gtk_box_pack_start(GTK_BOX(mainbox), main_label, FALSE, FALSE, 0);
84 gtk_widget_show(main_label);
86 snprintf(filter_string,255,"Filter:%s",filter?filter:"");
87 filter_label=gtk_label_new(filter_string);
88 gtk_box_pack_start(GTK_BOX(mainbox), filter_label, FALSE, FALSE, 0);
89 gtk_widget_show(filter_label);
93 /* create a table, using a scrollable gtkclist */
96 create_stat_table(GtkWidget *scrolled_window, GtkWidget *vbox, int columns, char *titles[])
102 table = GTK_CLIST(gtk_clist_new_with_titles(columns, titles));
104 /* configure scrolling window*/
105 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
106 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
107 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
109 /* configure clist */
110 gtk_clist_column_titles_passive(table);
111 gtk_clist_column_titles_show(table);
112 for (i = 0; i < columns; i++)
113 gtk_clist_set_column_auto_resize(table, i, TRUE);
114 gtk_clist_set_selection_mode(table, GTK_SELECTION_SINGLE);
116 /* Put clist into a scrolled window */
117 gtk_container_add(GTK_CONTAINER(scrolled_window),
119 gtk_widget_show(GTK_WIDGET(table));
120 gtk_widget_show(scrolled_window);