aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/io_stat.c
diff options
context:
space:
mode:
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2003-10-14 09:03:03 +0000
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2003-10-14 09:03:03 +0000
commit18e43c0f4c1e8b2d20f3265049b47edcbf656716 (patch)
tree951a9d18da1521c9bece585b1acdfda2000230c6 /gtk/io_stat.c
parentb3171bbe960e7f5c17fa6068121a6da73cef0e4f (diff)
update to iostat
add different styles to draw the plot git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8689 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk/io_stat.c')
-rw-r--r--gtk/io_stat.c87
1 files changed, 72 insertions, 15 deletions
diff --git a/gtk/io_stat.c b/gtk/io_stat.c
index 59ebf9ed3d..a4230a056f 100644
--- a/gtk/io_stat.c
+++ b/gtk/io_stat.c
@@ -1,7 +1,7 @@
/* io_stat.c
* io_stat 2002 Ronnie Sahlberg
*
- * $Id: io_stat.c,v 1.36 2003/10/12 04:20:03 sahlberg Exp $
+ * $Id: io_stat.c,v 1.37 2003/10/14 09:03:03 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -66,6 +66,17 @@ static guint32 yscale_max[MAX_YSCALE] = {AUTO_MAX_YSCALE, 10, 20, 50, 100, 200,
#define DEFAULT_PIXELS_PER_TICK 2
static guint32 pixels_per_tick[MAX_PIXELS_PER_TICK] = {1, 2, 5, 10};
+
+#define DEFAULT_PLOT_STYLE 0
+#define PLOT_STYLE_LINE 0
+#define PLOT_STYLE_IMPULSE 1
+#define MAX_PLOT_STYLES 2
+static char *plot_style_name[MAX_PLOT_STYLES] = {
+ "Line",
+ "Impulse",
+};
+
+
#define COUNT_TYPE_FRAMES 0
#define COUNT_TYPE_BYTES 1
#define COUNT_TYPE_ADVANCED 2
@@ -101,11 +112,12 @@ typedef struct _io_item_t {
nstime_t time_max;
nstime_t time_min;
nstime_t time_tot;
-} io_item_t; /* XXX to be removed */
+} io_item_t;
typedef struct _io_stat_graph_t {
struct _io_stat_t *io;
io_item_t items[NUM_IO_ITEMS];
+ int plot_style;;
int display;
GtkWidget *display_button;
GtkWidget *color_button;
@@ -141,7 +153,6 @@ typedef struct _io_stat_tick_interval_t {
int interval;
} io_stat_tick_interval_t;
-
typedef struct _io_stat_t {
gboolean needs_redraw;
gint32 interval; /* measurement interval in ms */
@@ -831,11 +842,20 @@ gtk_iostat_draw(void *g)
continue;
}
- gdk_draw_line(io->pixmap, io->graphs[i].gc,
- prev_x_pos,
- prev_y_pos,
- x_pos,
- y_pos);
+ switch(io->graphs[i].plot_style){
+ case PLOT_STYLE_LINE:
+ gdk_draw_line(io->pixmap, io->graphs[i].gc,
+ prev_x_pos, prev_y_pos,
+ x_pos, y_pos);
+ break;
+ case PLOT_STYLE_IMPULSE:
+ if(val){
+ gdk_draw_line(io->pixmap, io->graphs[i].gc,
+ x_pos, draw_height-1+top_y_border,
+ x_pos, y_pos);
+ }
+ break;
+ }
prev_y_pos=y_pos;
prev_x_pos=x_pos;
@@ -1129,6 +1149,21 @@ pixels_per_tick_select(GtkWidget *item _U_, gpointer key)
gtk_iostat_draw(&ppt->io->graphs[0]);
}
+static void
+plot_style_select(GtkWidget *item, gpointer key)
+{
+ int val;
+ io_stat_graph_t *ppt;
+
+ ppt=(io_stat_graph_t *)key;
+ val=(int)gtk_object_get_data(GTK_OBJECT(item), "plot_style");
+
+ ppt->plot_style=val;
+
+ ppt->io->needs_redraw=TRUE;
+ gtk_iostat_draw(ppt);
+}
+
static void
create_pixels_per_tick_menu_items(io_stat_t *io, GtkWidget *menu)
{
@@ -1572,9 +1607,13 @@ filter_button_clicked(GtkWidget *w, gpointer uio)
static void
create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
{
+ GtkWidget *option_menu;
+ GtkWidget *menu;
+ GtkWidget *menu_item;
GtkWidget *hbox;
GtkWidget *label;
char str[256];
+ int i;
hbox=gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box), hbox);
@@ -1595,10 +1634,6 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
- label=gtk_label_new(" Color:");
- gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
gio->color_button=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(hbox), gio->color_button, FALSE, FALSE, 0);
gtk_widget_show(gio->color_button);
@@ -1627,9 +1662,6 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
/* gtk_signal_connect(GTK_OBJECT(gio->display_button), "toggled", GTK_SIGNAL_FUNC(filter_callback), gio);*/
- /* filter prefs dialog --- comment out static label */
- /* label=gtk_label_new(" Filter:"); */
-
/* filter prefs dialog */
label=gtk_label_new(" ");
gtk_widget_show(label);
@@ -1660,6 +1692,31 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
create_advanced_box(gio, hbox);
+
+ /*
+ * create PlotStyle menu
+ */
+ sprintf(str, " Style:");
+ label=gtk_label_new(str);
+ gtk_widget_show(label);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ option_menu=gtk_option_menu_new();
+ menu=gtk_menu_new();
+ for(i=0;i<MAX_PLOT_STYLES;i++){
+ menu_item=gtk_menu_item_new_with_label(plot_style_name[i]);
+ gtk_object_set_data(GTK_OBJECT(menu_item), "plot_style", (gpointer)i);
+ SIGNAL_CONNECT(menu_item, "activate", plot_style_select, &gio->io->graphs[num-1]);
+ gtk_widget_show(menu_item);
+ gtk_menu_append(GTK_MENU(menu), menu_item);
+ }
+ gtk_menu_set_active(GTK_MENU(menu), DEFAULT_PLOT_STYLE);
+
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
+ gtk_box_pack_end(GTK_BOX(hbox), option_menu, FALSE, FALSE, 0);
+ gtk_widget_show(option_menu);
+
+
return;
}