2005-08-21 19:24:11 +00:00
|
|
|
/* gui_stat_util.c
|
2003-04-25 20:54:18 +00:00
|
|
|
* gui functions used by stats
|
|
|
|
* Copyright 2003 Lars Roland
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2003-04-25 20:54:18 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-04-25 20:54:18 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
2008-04-13 01:54:20 +00:00
|
|
|
#include <string.h>
|
2003-04-25 20:54:18 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2003-04-25 20:54:18 +00:00
|
|
|
#include "../simple_dialog.h"
|
|
|
|
#include "../file.h"
|
|
|
|
#include "../globals.h"
|
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "gtk/gui_stat_util.h"
|
|
|
|
|
|
|
|
|
2003-04-25 20:54:18 +00:00
|
|
|
/* insert a string into a GTK_TABLE at column x and row y*/
|
2004-06-01 21:56:04 +00:00
|
|
|
#if 0
|
|
|
|
/* Statistic table */
|
|
|
|
typedef struct _gtk_table {
|
|
|
|
GtkWidget *widget; /**< the table widget */
|
|
|
|
int height; /**< the height */
|
|
|
|
int width; /**< the width */
|
|
|
|
}gtk_table;
|
2003-04-25 20:54:18 +00:00
|
|
|
|
|
|
|
void
|
2005-06-27 08:13:41 +00:00
|
|
|
add_table_entry(gtk_table *tab, const char *str, int x, int y)
|
2003-04-25 20:54:18 +00:00
|
|
|
{
|
|
|
|
GtkWidget *tmp;
|
|
|
|
|
|
|
|
if(y>=tab->height){
|
|
|
|
tab->height=y+1;
|
|
|
|
gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
|
|
|
|
}
|
|
|
|
if(x>=tab->width){
|
|
|
|
tab->width=x+1;
|
|
|
|
gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp=gtk_label_new(str);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(tab->widget), tmp, x, x+1, y, y+1);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_widget_show(tmp);
|
|
|
|
}
|
2004-06-01 21:56:04 +00:00
|
|
|
#endif
|
2003-04-25 20:54:18 +00:00
|
|
|
|
2003-04-27 21:50:59 +00:00
|
|
|
/* init a main windowfor stats, set title and display used filter in window */
|
|
|
|
|
|
|
|
void
|
2005-08-05 20:59:08 +00:00
|
|
|
init_main_stat_window(GtkWidget *window, GtkWidget *mainbox, const char *title, const char *filter)
|
2003-04-27 21:50:59 +00:00
|
|
|
{
|
|
|
|
GtkWidget *main_label;
|
|
|
|
GtkWidget *filter_label;
|
2007-11-28 03:04:09 +00:00
|
|
|
char *filter_string;
|
2003-04-27 21:50:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window), title);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), mainbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(mainbox), 10);
|
|
|
|
gtk_widget_show(mainbox);
|
|
|
|
|
|
|
|
main_label=gtk_label_new(title);
|
|
|
|
gtk_box_pack_start(GTK_BOX(mainbox), main_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(main_label);
|
|
|
|
|
2007-11-28 03:04:09 +00:00
|
|
|
filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
|
2003-04-27 21:50:59 +00:00
|
|
|
filter_label=gtk_label_new(filter_string);
|
2007-11-28 03:04:09 +00:00
|
|
|
g_free(filter_string);
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
|
2003-04-27 21:50:59 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(mainbox), filter_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(filter_label);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a table, using a scrollable gtkclist */
|
|
|
|
|
|
|
|
GtkCList *
|
2005-08-05 20:59:08 +00:00
|
|
|
create_stat_table(GtkWidget *scrolled_window, GtkWidget *vbox, int columns, const char *titles[])
|
2003-04-27 21:50:59 +00:00
|
|
|
{
|
|
|
|
GtkCList *table;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* create table */
|
2005-08-10 19:49:45 +00:00
|
|
|
table = GTK_CLIST(gtk_clist_new_with_titles(columns, (gchar **) titles));
|
2003-04-27 21:50:59 +00:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* configure clist */
|
|
|
|
gtk_clist_column_titles_passive(table);
|
|
|
|
gtk_clist_column_titles_show(table);
|
|
|
|
for (i = 0; i < columns; i++)
|
|
|
|
gtk_clist_set_column_auto_resize(table, i, TRUE);
|
2003-08-21 17:48:04 +00:00
|
|
|
gtk_clist_set_selection_mode(table, GTK_SELECTION_SINGLE);
|
2003-04-27 21:50:59 +00:00
|
|
|
|
|
|
|
/* Put clist into a scrolled window */
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolled_window),
|
|
|
|
GTK_WIDGET(table));
|
|
|
|
gtk_widget_show(GTK_WIDGET(table));
|
|
|
|
gtk_widget_show(scrolled_window);
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
2003-08-21 17:48:04 +00:00
|
|
|
|