2002-11-14 10:32:22 +00:00
|
|
|
/* io_stat.c
|
|
|
|
* io_stat 2002 Ronnie Sahlberg
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2002-11-14 10:32:22 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2002-11-14 10:32:22 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2008-08-05 17:33:14 +00:00
|
|
|
*
|
2002-11-14 10:32:22 +00:00
|
|
|
* 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.
|
2008-08-05 17:33:14 +00:00
|
|
|
*
|
2002-11-14 10:32:22 +00:00
|
|
|
* 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.
|
2008-08-05 17:33:14 +00:00
|
|
|
*
|
2002-11-14 10:32:22 +00:00
|
|
|
* 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
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2009-08-27 04:47:28 +00:00
|
|
|
#include <stdio.h>
|
2002-11-14 10:32:22 +00:00
|
|
|
#include <string.h>
|
2008-02-20 17:53:31 +00:00
|
|
|
#include <math.h>
|
2002-11-16 21:40:32 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
#include <gtk/gtk.h>
|
2004-02-13 00:53:37 +00:00
|
|
|
|
|
|
|
#include <epan/epan_dissect.h>
|
|
|
|
#include <epan/packet_info.h>
|
2005-08-20 20:06:05 +00:00
|
|
|
#include <epan/stat_cmd_args.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2008-04-13 03:32:24 +00:00
|
|
|
#include <epan/strutil.h>
|
|
|
|
|
|
|
|
#include "../stat_menu.h"
|
|
|
|
#include "../alert_box.h"
|
|
|
|
#include "../simple_dialog.h"
|
2002-11-14 10:32:22 +00:00
|
|
|
#include "../color.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
|
|
|
#include "gtk/gtkglobals.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/gui_stat_menu.h"
|
|
|
|
#include "gtk/stock_icons.h"
|
|
|
|
#include "gtk/dlg_utils.h"
|
|
|
|
#include "gtk/filter_dlg.h"
|
|
|
|
#include "gtk/help_dlg.h"
|
|
|
|
#include "gtk/pixmap_save.h"
|
2008-08-05 17:33:14 +00:00
|
|
|
#include "gtk/main.h"
|
2008-10-19 13:40:52 +00:00
|
|
|
#include "gtk/filter_autocomplete.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2002-12-16 21:18:37 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
#define MAX_GRAPHS 5
|
|
|
|
|
2008-02-20 17:53:31 +00:00
|
|
|
#define MAX_YSCALE 28
|
|
|
|
#define LOGARITHMIC_YSCALE 0
|
|
|
|
#define AUTO_MAX_YSCALE 1
|
2010-08-18 22:20:01 +00:00
|
|
|
#define DEFAULT_YSCALE_INDEX 1
|
2008-02-20 17:53:31 +00:00
|
|
|
static guint32 yscale_max[MAX_YSCALE] = {LOGARITHMIC_YSCALE, AUTO_MAX_YSCALE, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000, 20000000, 50000000, 100000000, 200000000, 500000000, 1000000000, 2000000000};
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
#define MAX_PIXELS_PER_TICK 4
|
2010-08-18 22:20:01 +00:00
|
|
|
#define DEFAULT_PIXELS_PER_TICK_INDEX 2
|
2002-11-14 10:32:22 +00:00
|
|
|
static guint32 pixels_per_tick[MAX_PIXELS_PER_TICK] = {1, 2, 5, 10};
|
|
|
|
|
2003-10-14 09:03:03 +00:00
|
|
|
|
|
|
|
#define DEFAULT_PLOT_STYLE 0
|
|
|
|
#define PLOT_STYLE_LINE 0
|
|
|
|
#define PLOT_STYLE_IMPULSE 1
|
2003-10-14 10:34:58 +00:00
|
|
|
#define PLOT_STYLE_FILLED_BAR 2
|
2007-08-26 14:02:59 +00:00
|
|
|
#define PLOT_STYLE_DOT 3
|
|
|
|
#define MAX_PLOT_STYLES 4
|
2005-08-06 14:03:14 +00:00
|
|
|
static const char *plot_style_name[MAX_PLOT_STYLES] = {
|
2003-10-14 09:03:03 +00:00
|
|
|
"Line",
|
|
|
|
"Impulse",
|
2003-10-14 10:34:58 +00:00
|
|
|
"FBar",
|
2007-08-26 14:02:59 +00:00
|
|
|
"Dot",
|
2003-10-14 09:03:03 +00:00
|
|
|
};
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
#define DEFAULT_COUNT_TYPE 0
|
2003-10-11 11:23:52 +00:00
|
|
|
#define COUNT_TYPE_FRAMES 0
|
|
|
|
#define COUNT_TYPE_BYTES 1
|
2007-03-07 23:39:45 +00:00
|
|
|
#define COUNT_TYPE_BITS 2
|
|
|
|
#define COUNT_TYPE_ADVANCED 3
|
2007-12-29 20:57:15 +00:00
|
|
|
#define MAX_COUNT_TYPES 4
|
2007-03-07 23:39:45 +00:00
|
|
|
static const char *count_type_names[MAX_COUNT_TYPES] = {"Packets/Tick", "Bytes/Tick", "Bits/Tick", "Advanced..."};
|
2002-11-16 11:45:58 +00:00
|
|
|
|
|
|
|
/* unit is in ms */
|
2007-09-26 22:50:53 +00:00
|
|
|
#define MAX_TICK_VALUES 7
|
2010-08-18 22:20:01 +00:00
|
|
|
#define DEFAULT_TICK_VALUE_INDEX 3
|
2007-09-26 22:50:53 +00:00
|
|
|
static const guint tick_interval_values[MAX_TICK_VALUES] = { 1, 10, 100, 1000, 10000, 60000, 600000 };
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
#define CALC_TYPE_SUM 0
|
|
|
|
#define CALC_TYPE_COUNT 1
|
|
|
|
#define CALC_TYPE_MAX 2
|
|
|
|
#define CALC_TYPE_MIN 3
|
|
|
|
#define CALC_TYPE_AVG 4
|
2003-10-15 13:10:54 +00:00
|
|
|
#define CALC_TYPE_LOAD 5
|
2007-12-29 20:57:15 +00:00
|
|
|
#define MAX_CALC_TYPES 6
|
2010-08-18 22:20:01 +00:00
|
|
|
#define DEFAULT_CALC_TYPE 0
|
2005-08-06 14:03:14 +00:00
|
|
|
static const char *calc_type_names[MAX_CALC_TYPES] = {"SUM(*)", "COUNT(*)", "MAX(*)", "MIN(*)", "AVG(*)", "LOAD(*)"};
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
typedef struct _io_stat_calc_type_t {
|
|
|
|
struct _io_stat_graph_t *gio;
|
|
|
|
int calc_type;
|
|
|
|
} io_stat_calc_type_t;
|
|
|
|
|
|
|
|
#define NUM_IO_ITEMS 100000
|
|
|
|
typedef struct _io_item_t {
|
|
|
|
guint32 frames; /* always calculated, will hold number of frames*/
|
|
|
|
guint32 bytes; /* always calculated, will hold number of bytes*/
|
2008-01-29 14:27:02 +00:00
|
|
|
guint32 fields;
|
2002-11-29 11:37:33 +00:00
|
|
|
gint32 int_max;
|
|
|
|
gint32 int_min;
|
|
|
|
gint32 int_tot;
|
2008-10-10 15:18:37 +00:00
|
|
|
gfloat float_max;
|
|
|
|
gfloat float_min;
|
|
|
|
gfloat float_tot;
|
|
|
|
gdouble double_max;
|
|
|
|
gdouble double_min;
|
|
|
|
gdouble double_tot;
|
2002-11-29 11:37:33 +00:00
|
|
|
nstime_t time_max;
|
|
|
|
nstime_t time_min;
|
|
|
|
nstime_t time_tot;
|
2003-10-14 09:03:03 +00:00
|
|
|
} io_item_t;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
typedef struct _io_stat_graph_t {
|
|
|
|
struct _io_stat_t *io;
|
2003-10-12 04:20:03 +00:00
|
|
|
io_item_t items[NUM_IO_ITEMS];
|
2003-10-15 08:25:29 +00:00
|
|
|
int plot_style;
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
gboolean display;
|
2002-11-14 10:32:22 +00:00
|
|
|
GtkWidget *display_button;
|
2004-01-13 22:34:10 +00:00
|
|
|
GtkWidget *filter_field;
|
2002-11-29 11:37:33 +00:00
|
|
|
GtkWidget *advanced_buttons;
|
|
|
|
int calc_type;
|
|
|
|
int hf_index;
|
|
|
|
GtkWidget *calc_field;
|
2002-11-14 10:32:22 +00:00
|
|
|
GdkColor color;
|
|
|
|
GdkGC *gc;
|
2003-01-11 11:10:33 +00:00
|
|
|
construct_args_t *args;
|
|
|
|
GtkWidget *filter_bt;
|
2002-11-14 10:32:22 +00:00
|
|
|
} io_stat_graph_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _io_stat_t {
|
2003-10-06 22:10:42 +00:00
|
|
|
gboolean needs_redraw;
|
2010-08-18 22:20:01 +00:00
|
|
|
gint32 interval; /* measurement interval in ms */
|
2008-08-05 17:33:14 +00:00
|
|
|
guint32 last_interval;
|
2003-10-12 04:20:03 +00:00
|
|
|
guint32 max_interval; /* XXX max_interval and num_items are redundant */
|
|
|
|
guint32 num_items;
|
2008-02-16 16:40:36 +00:00
|
|
|
guint32 left_x_border;
|
|
|
|
guint32 right_x_border;
|
2007-12-29 20:57:15 +00:00
|
|
|
gboolean view_as_time;
|
|
|
|
nstime_t start_time;
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
struct _io_stat_graph_t graphs[MAX_GRAPHS];
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *draw_area;
|
|
|
|
GdkPixmap *pixmap;
|
2002-11-17 11:43:40 +00:00
|
|
|
GtkAdjustment *scrollbar_adjustment;
|
|
|
|
GtkWidget *scrollbar;
|
2008-02-16 16:40:36 +00:00
|
|
|
guint first_frame_num[NUM_IO_ITEMS];
|
|
|
|
guint last_frame_num;
|
2002-11-14 10:32:22 +00:00
|
|
|
int pixmap_width;
|
|
|
|
int pixmap_height;
|
|
|
|
int pixels_per_tick;
|
|
|
|
int max_y_units;
|
|
|
|
int count_type;
|
2008-08-05 17:33:14 +00:00
|
|
|
} io_stat_t;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void init_io_stat_window(io_stat_t *io);
|
2010-08-18 22:20:01 +00:00
|
|
|
static void filter_callback(GtkWidget *widget _U_, gpointer user_data);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
static void
|
|
|
|
io_stat_set_title(io_stat_t *io)
|
|
|
|
{
|
|
|
|
char *title;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
if(!io->window){
|
|
|
|
return;
|
|
|
|
}
|
2006-05-22 07:29:40 +00:00
|
|
|
title = g_strdup_printf("Wireshark IO Graphs: %s", cf_get_display_name(&cfile));
|
2003-09-26 02:09:44 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(io->window), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
static void
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_reset(io_stat_t *io)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2003-10-12 04:20:03 +00:00
|
|
|
int i, j;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io->needs_redraw=TRUE;
|
2003-10-12 04:20:03 +00:00
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
|
|
|
for(j=0;j<NUM_IO_ITEMS;j++){
|
|
|
|
io_item_t *ioi;
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
ioi=&io->graphs[i].items[j];
|
2003-10-12 04:20:03 +00:00
|
|
|
|
|
|
|
ioi->frames=0;
|
|
|
|
ioi->bytes=0;
|
2008-01-29 14:27:02 +00:00
|
|
|
ioi->fields=0;
|
2003-10-12 04:20:03 +00:00
|
|
|
ioi->int_max=0;
|
|
|
|
ioi->int_min=0;
|
|
|
|
ioi->int_tot=0;
|
2008-10-10 15:18:37 +00:00
|
|
|
ioi->float_max=0;
|
|
|
|
ioi->float_min=0;
|
|
|
|
ioi->float_tot=0;
|
|
|
|
ioi->double_max=0;
|
|
|
|
ioi->double_min=0;
|
|
|
|
ioi->double_tot=0;
|
2005-10-27 19:42:24 +00:00
|
|
|
nstime_set_zero(&ioi->time_max);
|
|
|
|
nstime_set_zero(&ioi->time_min);
|
|
|
|
nstime_set_zero(&ioi->time_tot);
|
2003-10-12 04:20:03 +00:00
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io->last_interval=0xffffffff;
|
|
|
|
io->max_interval=0;
|
|
|
|
io->num_items=0;
|
2007-12-29 20:57:15 +00:00
|
|
|
io->start_time.secs=0;
|
|
|
|
io->start_time.nsecs=0;
|
2008-02-16 16:40:36 +00:00
|
|
|
for(j=0;j<NUM_IO_ITEMS;j++) {
|
|
|
|
io->first_frame_num[j]=0;
|
|
|
|
}
|
|
|
|
io->last_frame_num=0;
|
2003-08-25 11:06:32 +00:00
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_set_title(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
tap_iostat_reset(void *g)
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
{
|
|
|
|
io_stat_graph_t *gio=g;
|
|
|
|
|
|
|
|
io_stat_reset(gio->io);
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static gboolean
|
|
|
|
tap_iostat_packet(void *g, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
|
|
|
io_stat_graph_t *git=g;
|
2003-10-12 04:20:03 +00:00
|
|
|
io_item_t *it;
|
2002-11-16 11:45:58 +00:00
|
|
|
nstime_t time_delta;
|
2003-10-12 04:20:03 +00:00
|
|
|
int idx;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
/* we sometimes get called when git is disabled.
|
|
|
|
this is a bug since the tap listener should be removed first */
|
|
|
|
if(!git->display){
|
2010-08-18 22:20:01 +00:00
|
|
|
return FALSE;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2003-10-06 22:10:42 +00:00
|
|
|
git->io->needs_redraw=TRUE;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2007-12-29 20:53:10 +00:00
|
|
|
* Find which interval this is supposed to go in and store the
|
2003-10-12 04:20:03 +00:00
|
|
|
* interval index as idx
|
|
|
|
*/
|
2005-08-24 21:31:56 +00:00
|
|
|
time_delta=pinfo->fd->rel_ts;
|
2002-11-16 11:45:58 +00:00
|
|
|
if(time_delta.nsecs<0){
|
|
|
|
time_delta.secs--;
|
|
|
|
time_delta.nsecs+=1000000000;
|
|
|
|
}
|
|
|
|
if(time_delta.secs<0){
|
2003-10-12 04:20:03 +00:00
|
|
|
return FALSE;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2007-03-21 03:26:26 +00:00
|
|
|
idx=(int) ((time_delta.secs*1000+time_delta.nsecs/1000000)/git->io->interval);
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
/* some sanity checks */
|
|
|
|
if((idx<0)||(idx>=NUM_IO_ITEMS)){
|
2007-12-29 20:53:10 +00:00
|
|
|
git->io->num_items = NUM_IO_ITEMS-1;
|
2003-10-12 04:20:03 +00:00
|
|
|
return FALSE;
|
2002-11-16 11:45:58 +00:00
|
|
|
}
|
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
/* update num_items */
|
2004-01-05 18:11:28 +00:00
|
|
|
if((guint32)idx > git->io->num_items){
|
2003-10-12 04:20:03 +00:00
|
|
|
git->io->num_items=idx;
|
2007-08-24 21:23:34 +00:00
|
|
|
git->io->max_interval=(idx+1)*git->io->interval;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 20:57:15 +00:00
|
|
|
/* set start time */
|
|
|
|
if(git->io->start_time.secs == 0 && git->io->start_time.nsecs == 0) {
|
2010-10-27 07:45:31 +00:00
|
|
|
nstime_diff (&git->io->start_time, &pinfo->fd->abs_ts, &pinfo->fd->rel_ts);
|
2007-12-29 20:57:15 +00:00
|
|
|
}
|
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
/* set first and last frame num in current interval */
|
|
|
|
if (git->io->first_frame_num[idx] == 0) {
|
|
|
|
git->io->first_frame_num[idx]=pinfo->fd->num;
|
|
|
|
}
|
|
|
|
git->io->last_frame_num=pinfo->fd->num;
|
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
/*
|
2008-08-05 17:33:14 +00:00
|
|
|
* Find the appropriate io_item_t structure
|
2003-10-12 04:20:03 +00:00
|
|
|
*/
|
|
|
|
it=&git->items[idx];
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
/*
|
|
|
|
* For ADVANCED mode we need to keep track of some more stuff
|
|
|
|
* than just frame and byte counts
|
|
|
|
*/
|
2002-11-29 11:37:33 +00:00
|
|
|
if(git->io->count_type==COUNT_TYPE_ADVANCED){
|
|
|
|
GPtrArray *gp;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
gp=proto_get_finfo_ptr_array(edt->tree, git->hf_index);
|
|
|
|
if(!gp){
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/* update the appropriate counters, make sure that if
|
2008-01-29 14:27:02 +00:00
|
|
|
* fields==0 then this is the first seen value so
|
2008-08-05 17:33:14 +00:00
|
|
|
* set any min/max values accordingly
|
2003-10-12 04:20:03 +00:00
|
|
|
*/
|
2002-11-29 11:37:33 +00:00
|
|
|
for(i=0;i<gp->len;i++){
|
|
|
|
int new_int;
|
2008-10-10 15:18:37 +00:00
|
|
|
float new_float;
|
|
|
|
double new_double;
|
2002-11-29 11:37:33 +00:00
|
|
|
nstime_t *new_time;
|
|
|
|
|
|
|
|
switch(proto_registrar_get_ftype(git->hf_index)){
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
2007-01-18 11:02:26 +00:00
|
|
|
new_int=fvalue_get_uinteger(&((field_info *)gp->pdata[i])->value);
|
|
|
|
|
2008-01-29 14:27:02 +00:00
|
|
|
if((new_int>it->int_max)||(it->fields==0)){
|
2007-01-18 11:02:26 +00:00
|
|
|
it->int_max=new_int;
|
|
|
|
}
|
2008-01-29 14:27:02 +00:00
|
|
|
if((new_int<it->int_min)||(it->fields==0)){
|
2007-01-18 11:02:26 +00:00
|
|
|
it->int_min=new_int;
|
|
|
|
}
|
|
|
|
it->int_tot+=new_int;
|
2008-01-29 14:27:02 +00:00
|
|
|
it->fields++;
|
2007-01-18 11:02:26 +00:00
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
case FT_INT8:
|
|
|
|
case FT_INT16:
|
|
|
|
case FT_INT24:
|
|
|
|
case FT_INT32:
|
2007-01-18 11:02:26 +00:00
|
|
|
new_int=fvalue_get_sinteger(&((field_info *)gp->pdata[i])->value);
|
2008-01-29 14:27:02 +00:00
|
|
|
if((new_int>it->int_max)||(it->fields==0)){
|
2002-11-29 11:37:33 +00:00
|
|
|
it->int_max=new_int;
|
|
|
|
}
|
2008-01-29 14:27:02 +00:00
|
|
|
if((new_int<it->int_min)||(it->fields==0)){
|
2002-11-29 11:37:33 +00:00
|
|
|
it->int_min=new_int;
|
|
|
|
}
|
|
|
|
it->int_tot+=new_int;
|
2008-01-29 14:27:02 +00:00
|
|
|
it->fields++;
|
2002-11-29 11:37:33 +00:00
|
|
|
break;
|
2008-10-10 15:18:37 +00:00
|
|
|
case FT_FLOAT:
|
2008-10-10 16:06:04 +00:00
|
|
|
new_float=(gfloat)fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
|
2008-10-10 15:18:37 +00:00
|
|
|
if((new_float>it->float_max)||(it->fields==0)){
|
|
|
|
it->float_max=new_float;
|
|
|
|
}
|
|
|
|
if((new_float<it->float_min)||(it->fields==0)){
|
|
|
|
it->float_min=new_float;
|
|
|
|
}
|
|
|
|
it->float_tot+=new_float;
|
|
|
|
it->fields++;
|
|
|
|
break;
|
|
|
|
case FT_DOUBLE:
|
|
|
|
new_double=fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
|
|
|
|
if((new_double>it->double_max)||(it->fields==0)){
|
|
|
|
it->double_max=new_double;
|
|
|
|
}
|
|
|
|
if((new_double<it->double_min)||(it->fields==0)){
|
|
|
|
it->double_min=new_double;
|
|
|
|
}
|
|
|
|
it->double_tot+=new_double;
|
|
|
|
it->fields++;
|
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
case FT_RELATIVE_TIME:
|
2003-12-02 21:15:49 +00:00
|
|
|
new_time=fvalue_get(&((field_info *)gp->pdata[0])->value);
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2003-10-15 13:10:54 +00:00
|
|
|
switch(git->calc_type){
|
|
|
|
guint64 t, pt; /* time in us */
|
2010-01-29 23:17:32 +00:00
|
|
|
int j;
|
2003-10-15 13:10:54 +00:00
|
|
|
case CALC_TYPE_LOAD:
|
2008-08-05 17:33:14 +00:00
|
|
|
/* it is a LOAD calculation of a relative time field.
|
2003-10-15 13:10:54 +00:00
|
|
|
* add the time this call spanned to each
|
2008-08-05 17:33:14 +00:00
|
|
|
* interval it spanned according to its contribution
|
2003-10-15 13:10:54 +00:00
|
|
|
* to that interval.
|
|
|
|
*/
|
|
|
|
t=new_time->secs;
|
|
|
|
t=t*1000000+new_time->nsecs/1000;
|
2010-01-29 23:17:32 +00:00
|
|
|
j=idx;
|
2003-10-15 13:10:54 +00:00
|
|
|
/* handle current interval */
|
2005-08-24 21:31:56 +00:00
|
|
|
pt=pinfo->fd->rel_ts.secs*1000000+pinfo->fd->rel_ts.nsecs/1000;
|
2003-10-15 13:10:54 +00:00
|
|
|
pt=pt%(git->io->interval*1000);
|
|
|
|
if(pt>t){
|
|
|
|
pt=t;
|
|
|
|
}
|
|
|
|
while(t){
|
2010-01-29 23:17:32 +00:00
|
|
|
git->items[j].time_tot.nsecs+=(int) (pt*1000);
|
|
|
|
if(git->items[j].time_tot.nsecs>1000000000){
|
|
|
|
git->items[j].time_tot.secs++;
|
|
|
|
git->items[j].time_tot.nsecs-=1000000000;
|
2003-10-15 13:10:54 +00:00
|
|
|
}
|
|
|
|
|
2010-01-29 23:17:32 +00:00
|
|
|
if(j==0){
|
2003-10-15 13:10:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-01-29 23:17:32 +00:00
|
|
|
j--;
|
2003-10-15 13:10:54 +00:00
|
|
|
t-=pt;
|
2004-01-05 18:11:28 +00:00
|
|
|
if(t > (guint32) (git->io->interval*1000)){
|
2003-10-15 13:10:54 +00:00
|
|
|
pt=git->io->interval*1000;
|
|
|
|
} else {
|
|
|
|
pt=t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if( (new_time->secs>it->time_max.secs)
|
|
|
|
||( (new_time->secs==it->time_max.secs)
|
|
|
|
&&(new_time->nsecs>it->time_max.nsecs))
|
2008-01-29 14:27:02 +00:00
|
|
|
||(it->fields==0)){
|
2005-10-27 19:42:24 +00:00
|
|
|
it->time_max=*new_time;
|
2003-10-15 13:10:54 +00:00
|
|
|
}
|
|
|
|
if( (new_time->secs<it->time_min.secs)
|
|
|
|
||( (new_time->secs==it->time_min.secs)
|
|
|
|
&&(new_time->nsecs<it->time_min.nsecs))
|
2008-01-29 14:27:02 +00:00
|
|
|
||(it->fields==0)){
|
2005-10-27 19:42:24 +00:00
|
|
|
it->time_min=*new_time;
|
2003-10-15 13:10:54 +00:00
|
|
|
}
|
2005-10-27 19:42:24 +00:00
|
|
|
nstime_add(&it->time_tot, new_time);
|
2008-01-29 14:27:02 +00:00
|
|
|
it->fields++;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
it->frames++;
|
|
|
|
it->bytes+=pinfo->fd->pkt_len;
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
static guint
|
2008-02-16 19:57:37 +00:00
|
|
|
get_frame_num(io_stat_t *io, guint32 idx, gboolean first)
|
2008-02-16 16:40:36 +00:00
|
|
|
{
|
|
|
|
guint i, frame_num=0;
|
|
|
|
|
2008-02-16 19:57:37 +00:00
|
|
|
if (idx>io->num_items) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
if (first) {
|
|
|
|
frame_num=io->first_frame_num[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame_num==0) {
|
|
|
|
/*
|
2008-08-05 17:33:14 +00:00
|
|
|
* If first frame not found we select the last
|
|
|
|
* frame in the previous interval
|
2008-02-16 16:40:36 +00:00
|
|
|
*
|
|
|
|
* If selecting the last frame we select the frame
|
|
|
|
* before the first frame in the next interval
|
|
|
|
*/
|
|
|
|
for(i=idx+1;i<=io->num_items;i++) {
|
|
|
|
frame_num=io->first_frame_num[i];
|
|
|
|
if (frame_num != 0) {
|
|
|
|
return frame_num-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2008-02-16 16:40:36 +00:00
|
|
|
* If not found we select the last frame
|
|
|
|
*/
|
|
|
|
frame_num=io->last_frame_num;
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame_num;
|
|
|
|
}
|
2002-11-29 11:37:33 +00:00
|
|
|
|
|
|
|
static guint32
|
2003-10-12 04:20:03 +00:00
|
|
|
get_it_value(io_stat_t *io, int graph_id, int idx)
|
2002-11-29 11:37:33 +00:00
|
|
|
{
|
2008-10-10 15:18:37 +00:00
|
|
|
double value=0;
|
2003-10-12 04:20:03 +00:00
|
|
|
int adv_type;
|
|
|
|
io_item_t *it;
|
|
|
|
|
|
|
|
it=&io->graphs[graph_id].items[idx];
|
|
|
|
|
|
|
|
switch(io->count_type){
|
|
|
|
case COUNT_TYPE_FRAMES:
|
|
|
|
return it->frames;
|
|
|
|
case COUNT_TYPE_BYTES:
|
|
|
|
return it->bytes;
|
2007-03-07 23:39:45 +00:00
|
|
|
case COUNT_TYPE_BITS:
|
|
|
|
return (it->bytes * 8);
|
2003-10-12 04:20:03 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
adv_type=proto_registrar_get_ftype(io->graphs[graph_id].hf_index);
|
2003-10-11 11:23:52 +00:00
|
|
|
switch(adv_type){
|
|
|
|
case FT_NONE:
|
2003-10-12 04:20:03 +00:00
|
|
|
switch(io->graphs[graph_id].calc_type){
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
value=it->frames;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-11-29 11:37:33 +00:00
|
|
|
break;
|
2003-10-11 11:23:52 +00:00
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
case FT_INT8:
|
|
|
|
case FT_INT16:
|
|
|
|
case FT_INT24:
|
|
|
|
case FT_INT32:
|
2003-10-12 04:20:03 +00:00
|
|
|
switch(io->graphs[graph_id].calc_type){
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_SUM:
|
|
|
|
value=it->int_tot;
|
2003-10-04 03:10:18 +00:00
|
|
|
break;
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
value=it->frames;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MAX:
|
|
|
|
value=it->int_max;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MIN:
|
|
|
|
value=it->int_min;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_AVG:
|
2008-01-29 14:27:02 +00:00
|
|
|
if(it->fields){
|
|
|
|
value=it->int_tot/it->fields;
|
2003-10-11 11:23:52 +00:00
|
|
|
} else {
|
|
|
|
value=0;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-10-11 11:23:52 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-10 15:18:37 +00:00
|
|
|
case FT_FLOAT:
|
|
|
|
switch(io->graphs[graph_id].calc_type){
|
|
|
|
case CALC_TYPE_SUM:
|
|
|
|
value=it->float_tot;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
value=it->frames;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MAX:
|
|
|
|
value=it->float_max;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MIN:
|
|
|
|
value=it->float_min;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_AVG:
|
|
|
|
if(it->fields){
|
|
|
|
value=it->float_tot/it->fields;
|
|
|
|
} else {
|
|
|
|
value=0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FT_DOUBLE:
|
|
|
|
switch(io->graphs[graph_id].calc_type){
|
|
|
|
case CALC_TYPE_SUM:
|
|
|
|
value=it->double_tot;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
value=it->frames;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MAX:
|
|
|
|
value=it->double_max;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MIN:
|
|
|
|
value=it->double_min;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_AVG:
|
|
|
|
if(it->fields){
|
|
|
|
value=it->double_tot/it->fields;
|
|
|
|
} else {
|
|
|
|
value=0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-10-11 11:23:52 +00:00
|
|
|
case FT_RELATIVE_TIME:
|
2003-10-12 04:20:03 +00:00
|
|
|
switch(io->graphs[graph_id].calc_type){
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
value=it->frames;
|
|
|
|
break;
|
|
|
|
case CALC_TYPE_MAX:
|
2007-03-21 03:26:26 +00:00
|
|
|
value=(guint32) (it->time_max.secs*1000000+it->time_max.nsecs/1000);
|
2003-10-11 11:23:52 +00:00
|
|
|
break;
|
|
|
|
case CALC_TYPE_MIN:
|
2007-03-21 03:26:26 +00:00
|
|
|
value=(guint32) (it->time_min.secs*1000000+it->time_min.nsecs/1000);
|
2003-10-11 11:23:52 +00:00
|
|
|
break;
|
2005-07-15 08:29:26 +00:00
|
|
|
case CALC_TYPE_SUM:
|
2007-03-21 03:26:26 +00:00
|
|
|
value=(guint32) (it->time_tot.secs*1000000+it->time_tot.nsecs/1000);
|
2005-07-15 08:29:26 +00:00
|
|
|
break;
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_AVG:
|
2008-01-29 14:27:02 +00:00
|
|
|
if(it->fields){
|
|
|
|
guint64 t; /* time in us */
|
|
|
|
|
|
|
|
t=it->time_tot.secs;
|
|
|
|
t=t*1000000+it->time_tot.nsecs/1000;
|
|
|
|
value=(guint32) (t/it->fields);
|
2003-10-11 11:23:52 +00:00
|
|
|
} else {
|
|
|
|
value=0;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-10-15 13:10:54 +00:00
|
|
|
case CALC_TYPE_LOAD:
|
2007-03-21 03:26:26 +00:00
|
|
|
value=(guint32) ((it->time_tot.secs*1000000+it->time_tot.nsecs/1000)/io->interval);
|
2003-10-15 13:10:54 +00:00
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
default:
|
2002-12-02 19:44:09 +00:00
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2002-12-02 19:44:09 +00:00
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2008-10-10 16:29:09 +00:00
|
|
|
return (guint32)value; /* FIXME: loss of precision, visible on the graph for small values */
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
|
2003-10-11 23:17:46 +00:00
|
|
|
static void
|
2010-01-29 23:17:32 +00:00
|
|
|
print_time_scale_string(char *buf, int buf_len, guint32 t, guint32 t_max, gboolean log_flag)
|
2003-10-11 23:17:46 +00:00
|
|
|
{
|
2010-01-29 23:17:32 +00:00
|
|
|
if(t_max>=10000000 || (log_flag && t_max>=1000000)){
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(buf, buf_len, "%ds",t/1000000);
|
2007-12-03 22:11:06 +00:00
|
|
|
} else if(t_max>=1000000){
|
2008-02-20 17:53:31 +00:00
|
|
|
g_snprintf(buf, buf_len, "%d.%1ds",t/1000000,(t%1000000)/100000);
|
2010-01-29 23:17:32 +00:00
|
|
|
} else if(t_max>=10000 || (log_flag && t_max>=1000)){
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(buf, buf_len, "%dms",t/1000);
|
2007-12-03 22:11:06 +00:00
|
|
|
} else if(t_max>=1000){
|
2008-02-20 17:53:31 +00:00
|
|
|
g_snprintf(buf, buf_len, "%d.%1dms",t/1000,(t%1000)/100);
|
2003-10-11 23:17:46 +00:00
|
|
|
} else {
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(buf, buf_len, "%dus",t);
|
2003-10-11 23:17:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-20 12:24:14 +00:00
|
|
|
static void
|
|
|
|
print_interval_string(char *buf, int buf_len, guint32 interval, io_stat_t *io,
|
|
|
|
gboolean ext)
|
|
|
|
{
|
|
|
|
if (io->view_as_time) {
|
|
|
|
struct tm *tmp;
|
|
|
|
time_t sec_val = interval/1000 + io->start_time.secs;
|
|
|
|
gint32 nsec_val = interval%1000 + io->start_time.nsecs/1000000;
|
|
|
|
|
|
|
|
if(nsec_val >= 1000) {
|
|
|
|
sec_val++;
|
|
|
|
nsec_val -= 1000;
|
|
|
|
}
|
|
|
|
tmp = localtime (&sec_val);
|
|
|
|
if(io->interval>=1000){
|
|
|
|
g_snprintf(buf, buf_len, "%02d:%02d:%02d", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
|
|
|
|
} else if(io->interval>=100){
|
|
|
|
g_snprintf(buf, buf_len, "%02d:%02d:%02d.%1d", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, nsec_val/100);
|
|
|
|
} else if(io->interval>=10){
|
|
|
|
g_snprintf(buf, buf_len, "%02d:%02d:%02d.%02d", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, nsec_val/10);
|
|
|
|
} else {
|
|
|
|
g_snprintf(buf, buf_len, "%02d:%02d:%02d.%03d", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, nsec_val);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(io->interval>=60000 && ext){
|
|
|
|
g_snprintf(buf, buf_len, "%d%s", interval/60000, ext?"m":"");
|
|
|
|
} else if(io->interval>=1000){
|
|
|
|
g_snprintf(buf, buf_len, "%d%s", interval/1000, ext?"s":"");
|
|
|
|
} else if(io->interval>=100){
|
|
|
|
g_snprintf(buf, buf_len, "%d.%1d%s", interval/1000,(interval/100)%10, ext?"s":"");
|
|
|
|
} else if(io->interval>=10){
|
|
|
|
g_snprintf(buf, buf_len, "%d.%02d%s", interval/1000,(interval/10)%100, ext?"s":"");
|
|
|
|
} else {
|
|
|
|
g_snprintf(buf, buf_len, "%d.%03d%s", interval/1000,interval%1000, ext?"s":"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
static void
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_draw(io_stat_t *io)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2008-02-20 17:53:31 +00:00
|
|
|
int i, tics, ystart, ys;
|
2008-02-17 14:27:52 +00:00
|
|
|
guint32 last_interval, first_interval, interval_delta;
|
2002-11-16 11:45:58 +00:00
|
|
|
gint32 current_interval;
|
2002-11-14 10:32:22 +00:00
|
|
|
guint32 top_y_border;
|
|
|
|
guint32 bottom_y_border;
|
2010-08-18 22:20:01 +00:00
|
|
|
PangoLayout *layout;
|
2007-03-24 00:45:11 +00:00
|
|
|
int label_width, label_height;
|
2002-11-14 10:32:22 +00:00
|
|
|
guint32 draw_width, draw_height;
|
2007-12-29 20:57:15 +00:00
|
|
|
char label_string[45];
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
/* new variables */
|
|
|
|
guint32 num_time_intervals;
|
|
|
|
guint32 max_value; /* max value of seen data */
|
|
|
|
guint32 max_y; /* max value of the Y scale */
|
|
|
|
gboolean draw_y_as_time;
|
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
if(!io->needs_redraw){
|
2002-11-14 10:32:22 +00:00
|
|
|
return;
|
|
|
|
}
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io->needs_redraw=FALSE;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2003-10-11 11:23:52 +00:00
|
|
|
* Find the length of the intervals we have data for
|
|
|
|
* so we know how large arrays we need to malloc()
|
|
|
|
*/
|
2007-09-26 22:50:53 +00:00
|
|
|
num_time_intervals=io->num_items+1;
|
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
/* XXX move this check to _packet() */
|
|
|
|
if(num_time_intervals>NUM_IO_ITEMS){
|
2004-01-31 03:22:42 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "IO-Stat error. There are too many entries, bailing out");
|
2003-10-11 11:23:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-10-12 04:20:03 +00:00
|
|
|
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2003-10-12 04:20:03 +00:00
|
|
|
* find the max value so we can autoscale the y axis
|
2003-10-11 11:23:52 +00:00
|
|
|
*/
|
|
|
|
max_value=0;
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
2003-10-12 04:20:03 +00:00
|
|
|
int idx;
|
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
if(!io->graphs[i].display){
|
|
|
|
continue;
|
|
|
|
}
|
2004-01-05 18:11:28 +00:00
|
|
|
for(idx=0;(guint32) (idx) < num_time_intervals;idx++){
|
2003-10-12 04:20:03 +00:00
|
|
|
guint32 val;
|
|
|
|
|
|
|
|
val=get_it_value(io, i, idx);
|
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
/* keep track of the max value we have encountered */
|
2003-10-12 04:20:03 +00:00
|
|
|
if(val>max_value){
|
|
|
|
max_value=val;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-11 11:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2003-10-11 11:23:52 +00:00
|
|
|
* Clear out old plot
|
|
|
|
*/
|
2010-08-18 22:20:01 +00:00
|
|
|
gdk_draw_rectangle(io->pixmap,
|
|
|
|
io->draw_area->style->white_gc,
|
|
|
|
TRUE,
|
|
|
|
0, 0,
|
|
|
|
io->draw_area->allocation.width,
|
|
|
|
io->draw_area->allocation.height);
|
2003-10-11 11:23:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the y scale we should use
|
|
|
|
*/
|
|
|
|
if(io->max_y_units==AUTO_MAX_YSCALE){
|
2002-11-14 10:32:22 +00:00
|
|
|
max_y=yscale_max[MAX_YSCALE-1];
|
2008-02-20 17:53:31 +00:00
|
|
|
for(i=MAX_YSCALE-1;i>1;i--){
|
2002-11-14 10:32:22 +00:00
|
|
|
if(max_value<yscale_max[i]){
|
|
|
|
max_y=yscale_max[i];
|
|
|
|
}
|
|
|
|
}
|
2008-02-20 17:53:31 +00:00
|
|
|
} else if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
max_y=1000000000;
|
|
|
|
for(i=1000000000;i>1;i/=10){
|
|
|
|
if(max_value<(guint32)i){
|
|
|
|
max_y=i;
|
|
|
|
}
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
} else {
|
2003-10-11 11:23:52 +00:00
|
|
|
/* the user had specified an explicit y scale to use */
|
2002-11-14 10:32:22 +00:00
|
|
|
max_y=io->max_y_units;
|
|
|
|
}
|
|
|
|
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
/*
|
|
|
|
* If we use ADVANCED and all the graphs are plotting
|
|
|
|
* either MIN/MAX/AVG of an FT_RELATIVE_TIME field
|
|
|
|
* then we will do some some special processing for the
|
|
|
|
* labels for the Y axis below:
|
|
|
|
* we will append the time unit " s" " ms" or " us"
|
|
|
|
* and we will present the unit in decimal
|
|
|
|
*/
|
|
|
|
draw_y_as_time=FALSE;
|
|
|
|
if(io->count_type==COUNT_TYPE_ADVANCED){
|
|
|
|
draw_y_as_time=TRUE;
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
|
|
|
int adv_type;
|
|
|
|
|
|
|
|
if(!io->graphs[i].display){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
adv_type=proto_registrar_get_ftype(io->graphs[i].hf_index);
|
|
|
|
switch(adv_type){
|
|
|
|
case FT_RELATIVE_TIME:
|
|
|
|
switch(io->graphs[i].calc_type){
|
2005-07-15 08:29:26 +00:00
|
|
|
case CALC_TYPE_SUM:
|
2003-10-11 11:23:52 +00:00
|
|
|
case CALC_TYPE_MAX:
|
|
|
|
case CALC_TYPE_MIN:
|
|
|
|
case CALC_TYPE_AVG:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
draw_y_as_time=FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
draw_y_as_time=FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
|
|
|
* Calculate size of borders surrounding the plot
|
2003-10-11 11:23:52 +00:00
|
|
|
* The border on the right side needs to be adjusted depending
|
|
|
|
* on the width of the text labels. For simplicity we assume that the
|
|
|
|
* top y scale label will be the widest one
|
|
|
|
*/
|
|
|
|
if(draw_y_as_time){
|
2008-02-20 17:53:31 +00:00
|
|
|
if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
print_time_scale_string(label_string, 15, 100000, 100000, TRUE); /* 100 ms */
|
|
|
|
} else {
|
|
|
|
print_time_scale_string(label_string, 15, max_y, max_y, FALSE);
|
|
|
|
}
|
2003-10-11 11:23:52 +00:00
|
|
|
} else {
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(label_string, 15, "%d", max_y);
|
2003-10-11 11:23:52 +00:00
|
|
|
}
|
2008-04-06 21:45:04 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
layout = gtk_widget_create_pango_layout(io->draw_area, label_string);
|
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2008-04-06 21:45:04 +00:00
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
io->left_x_border=10;
|
|
|
|
io->right_x_border=label_width+20;
|
2002-11-14 10:32:22 +00:00
|
|
|
top_y_border=10;
|
|
|
|
bottom_y_border=label_height+20;
|
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the size of the drawing area for the actual plot
|
|
|
|
*/
|
2008-02-16 16:40:36 +00:00
|
|
|
draw_width=io->pixmap_width-io->right_x_border-io->left_x_border;
|
2002-11-14 10:32:22 +00:00
|
|
|
draw_height=io->pixmap_height-top_y_border-bottom_y_border;
|
|
|
|
|
|
|
|
|
2007-12-29 20:53:10 +00:00
|
|
|
/*
|
|
|
|
* Add a warning if too many entries
|
|
|
|
*/
|
|
|
|
if (num_time_intervals == NUM_IO_ITEMS) {
|
|
|
|
g_snprintf (label_string, 45, "Warning: Graph limited to %d entries", NUM_IO_ITEMS);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
gdk_draw_layout(io->pixmap,
|
2008-08-05 17:33:14 +00:00
|
|
|
io->draw_area->style->black_gc, 5,
|
2007-12-29 20:53:10 +00:00
|
|
|
io->pixmap_height-bottom_y_border-draw_height-label_height/2,
|
|
|
|
layout);
|
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2003-10-11 11:23:52 +00:00
|
|
|
* Draw the y axis and labels
|
|
|
|
* (we always draw the y scale with 11 ticks along the axis)
|
|
|
|
*/
|
2002-11-14 10:32:22 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->draw_area->style->black_gc,
|
2008-08-05 17:33:14 +00:00
|
|
|
io->pixmap_width-io->right_x_border+1,
|
2002-11-14 10:32:22 +00:00
|
|
|
top_y_border,
|
2008-08-05 17:33:14 +00:00
|
|
|
io->pixmap_width-io->right_x_border+1,
|
2002-11-14 10:32:22 +00:00
|
|
|
io->pixmap_height-bottom_y_border);
|
2008-02-20 17:53:31 +00:00
|
|
|
|
|
|
|
if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
tics=(int)log10((double)max_y);
|
|
|
|
ystart=draw_height/10;
|
|
|
|
ys=-1;
|
|
|
|
} else {
|
|
|
|
tics=10;
|
|
|
|
ystart=ys=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=ys;i<=tics;i++){
|
|
|
|
int xwidth, lwidth, ypos;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
xwidth=5;
|
2008-02-20 17:53:31 +00:00
|
|
|
if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
if(i==ys) {
|
|
|
|
/* position for the 0 value */
|
|
|
|
ypos=io->pixmap_height-bottom_y_border;
|
|
|
|
} else if(i==tics) {
|
|
|
|
/* position for the top value, do not draw logarithmic tics above graph */
|
2008-08-05 17:33:14 +00:00
|
|
|
ypos=io->pixmap_height-bottom_y_border-draw_height;
|
2008-02-20 17:53:31 +00:00
|
|
|
} else {
|
|
|
|
int j;
|
|
|
|
/* draw the logarithmic tics */
|
|
|
|
for(j=2;j<10;j++) {
|
|
|
|
ypos=(int)(io->pixmap_height-bottom_y_border-(draw_height-ystart)*(i+log10((double)j))/tics-ystart);
|
|
|
|
/* draw the tick */
|
2008-08-05 17:33:14 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->draw_area->style->black_gc,
|
2008-02-20 17:53:31 +00:00
|
|
|
io->pixmap_width-io->right_x_border+1, ypos,
|
|
|
|
io->pixmap_width-io->right_x_border+1+xwidth, ypos);
|
|
|
|
}
|
2008-08-05 17:33:14 +00:00
|
|
|
ypos=io->pixmap_height-bottom_y_border-(draw_height-ystart)*i/tics-ystart;
|
2008-02-20 17:53:31 +00:00
|
|
|
}
|
|
|
|
/* all "main" logarithmic lines are slightly longer */
|
2002-11-14 10:32:22 +00:00
|
|
|
xwidth=10;
|
2008-02-20 17:53:31 +00:00
|
|
|
} else {
|
|
|
|
if(!(i%5)){
|
|
|
|
/* first, middle and last tick are slightly longer */
|
|
|
|
xwidth=10;
|
|
|
|
}
|
|
|
|
ypos=io->pixmap_height-bottom_y_border-draw_height*i/10;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2003-10-11 11:23:52 +00:00
|
|
|
/* draw the tick */
|
2008-08-05 17:33:14 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->draw_area->style->black_gc,
|
2008-02-20 17:53:31 +00:00
|
|
|
io->pixmap_width-io->right_x_border+1, ypos,
|
|
|
|
io->pixmap_width-io->right_x_border+1+xwidth, ypos);
|
2004-02-25 00:16:28 +00:00
|
|
|
/* draw the labels */
|
2008-02-20 17:53:31 +00:00
|
|
|
if(xwidth==10) {
|
|
|
|
guint32 value;
|
|
|
|
if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
value=(guint32)(max_y/pow(10,tics-i));
|
|
|
|
if(draw_y_as_time){
|
|
|
|
print_time_scale_string(label_string, 15, value, value, TRUE);
|
|
|
|
} else {
|
|
|
|
g_snprintf(label_string, 15, "%d", value);
|
|
|
|
}
|
2004-02-25 00:16:28 +00:00
|
|
|
} else {
|
2008-02-20 17:53:31 +00:00
|
|
|
value=(max_y/10)*i;
|
|
|
|
if(draw_y_as_time){
|
|
|
|
print_time_scale_string(label_string, 15, value, max_y, FALSE);
|
|
|
|
} else {
|
|
|
|
g_snprintf(label_string, 15, "%d", value);
|
|
|
|
}
|
2003-10-26 03:09:03 +00:00
|
|
|
}
|
2008-02-20 17:53:31 +00:00
|
|
|
|
2003-10-27 23:12:53 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
|
|
|
gdk_draw_layout(io->pixmap,
|
2010-08-18 22:20:01 +00:00
|
|
|
io->draw_area->style->black_gc,
|
|
|
|
io->pixmap_width-io->right_x_border+15+label_width-lwidth,
|
|
|
|
ypos-label_height/2,
|
2003-10-27 23:12:53 +00:00
|
|
|
layout);
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
2003-10-11 11:23:52 +00:00
|
|
|
* if we have not specified the last_interval via the gui,
|
|
|
|
* then just pick the current end of the capture so that is scrolls
|
|
|
|
* nicely when doing live captures
|
|
|
|
*/
|
|
|
|
if(io->last_interval==0xffffffff){
|
|
|
|
last_interval=io->max_interval;
|
|
|
|
} else {
|
|
|
|
last_interval=io->last_interval;
|
|
|
|
}
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*XXX*/
|
2002-11-14 10:32:22 +00:00
|
|
|
/* plot the x-scale */
|
2008-02-16 16:40:36 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->draw_area->style->black_gc, io->left_x_border, io->pixmap_height-bottom_y_border+1, io->pixmap_width-io->right_x_border+1, io->pixmap_height-bottom_y_border+1);
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2008-01-03 01:17:47 +00:00
|
|
|
if((last_interval/io->interval)>=draw_width/io->pixels_per_tick){
|
2002-11-16 11:45:58 +00:00
|
|
|
first_interval=(last_interval/io->interval)-draw_width/io->pixels_per_tick+1;
|
|
|
|
first_interval*=io->interval;
|
2002-11-14 10:32:22 +00:00
|
|
|
} else {
|
|
|
|
first_interval=0;
|
|
|
|
}
|
|
|
|
|
2008-02-17 14:27:52 +00:00
|
|
|
interval_delta=(100/io->pixels_per_tick)*io->interval;
|
2007-08-24 21:23:34 +00:00
|
|
|
for(current_interval=last_interval;current_interval>=(gint32)first_interval;current_interval=current_interval-io->interval){
|
2002-11-14 10:32:22 +00:00
|
|
|
int x, xlen;
|
|
|
|
|
2008-02-17 14:27:52 +00:00
|
|
|
/* if pixels_per_tick is 1 or 2, only draw every 10 ticks */
|
|
|
|
/* if pixels_per_tick is 5, only draw every 5 ticks */
|
|
|
|
if(((io->pixels_per_tick<5) && (current_interval%(10*io->interval))) ||
|
|
|
|
((io->pixels_per_tick==5) && (current_interval%(5*io->interval)))){
|
2002-11-14 10:32:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-02-17 14:27:52 +00:00
|
|
|
if(!(current_interval%interval_delta)){
|
2002-11-14 10:32:22 +00:00
|
|
|
xlen=10;
|
2008-02-17 14:27:52 +00:00
|
|
|
} else if(!(current_interval%(interval_delta/2))){
|
|
|
|
xlen=8;
|
|
|
|
} else {
|
|
|
|
xlen=5;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
x=draw_width+io->left_x_border-((last_interval-current_interval)/io->interval)*io->pixels_per_tick;
|
2008-08-05 17:33:14 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->draw_area->style->black_gc,
|
2002-11-14 10:32:22 +00:00
|
|
|
x-1-io->pixels_per_tick/2,
|
2008-08-05 17:33:14 +00:00
|
|
|
io->pixmap_height-bottom_y_border+1,
|
2002-11-14 10:32:22 +00:00
|
|
|
x-1-io->pixels_per_tick/2,
|
|
|
|
io->pixmap_height-bottom_y_border+xlen+1);
|
|
|
|
|
|
|
|
if(xlen==10){
|
2008-01-03 01:17:47 +00:00
|
|
|
int lwidth, x_pos;
|
2008-01-20 12:24:14 +00:00
|
|
|
print_interval_string (label_string, 15, current_interval, io, TRUE);
|
2008-01-03 01:17:47 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
2008-04-06 21:45:04 +00:00
|
|
|
|
2008-01-03 01:17:47 +00:00
|
|
|
if ((x-1-io->pixels_per_tick/2-lwidth/2) < 5) {
|
|
|
|
x_pos=5;
|
|
|
|
} else if ((x-1-io->pixels_per_tick/2+lwidth/2) > (io->pixmap_width-5)) {
|
|
|
|
x_pos=io->pixmap_width-lwidth-5;
|
|
|
|
} else {
|
|
|
|
x_pos=x-1-io->pixels_per_tick/2-lwidth/2;
|
2007-08-24 21:23:34 +00:00
|
|
|
}
|
2008-04-06 21:45:04 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
gdk_draw_layout(io->pixmap,
|
|
|
|
io->draw_area->style->black_gc,
|
|
|
|
x_pos,
|
|
|
|
io->pixmap_height-bottom_y_border+15,
|
|
|
|
layout);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
g_object_unref(G_OBJECT(layout));
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/*
|
|
|
|
* Loop over all graphs and draw them
|
2003-10-11 11:23:52 +00:00
|
|
|
*/
|
2002-11-15 10:55:19 +00:00
|
|
|
for(i=MAX_GRAPHS-1;i>=0;i--){
|
2007-12-03 19:44:27 +00:00
|
|
|
guint64 val;
|
|
|
|
guint32 interval, x_pos, y_pos, prev_x_pos, prev_y_pos;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
if(!io->graphs[i].display){
|
2002-11-14 10:32:22 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-08-24 21:23:34 +00:00
|
|
|
/* initialize prev x/y to the value of the first interval */
|
2008-02-16 16:40:36 +00:00
|
|
|
prev_x_pos=draw_width-1-io->pixels_per_tick*((last_interval-first_interval)/io->interval)+io->left_x_border;
|
2007-08-24 21:23:34 +00:00
|
|
|
val=get_it_value(io, i, first_interval/io->interval);
|
|
|
|
if(val>max_y){
|
|
|
|
prev_y_pos=0;
|
2008-02-20 17:53:31 +00:00
|
|
|
} else if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
if (val==0) {
|
|
|
|
prev_y_pos=(guint32)(draw_height-1+top_y_border);
|
|
|
|
} else {
|
2010-08-18 22:20:01 +00:00
|
|
|
prev_y_pos=(guint32)((draw_height-ystart)-1-((log10((double)((gint64)val)))*(draw_height-ystart))/(log10((double)max_y))+top_y_border);
|
2008-02-20 17:53:31 +00:00
|
|
|
}
|
2007-08-24 21:23:34 +00:00
|
|
|
} else {
|
2007-12-03 20:43:30 +00:00
|
|
|
prev_y_pos=(guint32)(draw_height-1-(val*draw_height)/max_y+top_y_border);
|
2007-08-24 21:23:34 +00:00
|
|
|
}
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2007-08-24 21:23:34 +00:00
|
|
|
for(interval=first_interval;interval<last_interval;interval+=io->interval){
|
2008-02-16 16:40:36 +00:00
|
|
|
x_pos=draw_width-1-io->pixels_per_tick*((last_interval-interval)/io->interval)+io->left_x_border;
|
2003-10-12 04:20:03 +00:00
|
|
|
|
|
|
|
val=get_it_value(io, i, interval/io->interval);
|
2002-11-14 10:32:22 +00:00
|
|
|
if(val>max_y){
|
2003-10-11 11:23:52 +00:00
|
|
|
y_pos=0;
|
2008-02-20 17:53:31 +00:00
|
|
|
} else if(io->max_y_units==LOGARITHMIC_YSCALE){
|
|
|
|
if (val==0) {
|
|
|
|
y_pos=(guint32)(draw_height-1+top_y_border);
|
|
|
|
} else {
|
2010-08-18 22:20:01 +00:00
|
|
|
y_pos=(guint32)((draw_height-ystart)-1-((log10((double)((gint64)val)))*(draw_height-ystart))/(log10((double)max_y))+top_y_border);
|
2008-02-20 17:53:31 +00:00
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
} else {
|
2007-12-03 20:43:30 +00:00
|
|
|
y_pos=(guint32)(draw_height-1-(val*draw_height)/max_y+top_y_border);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 09:03:03 +00:00
|
|
|
switch(io->graphs[i].plot_style){
|
|
|
|
case PLOT_STYLE_LINE:
|
2006-02-01 08:59:59 +00:00
|
|
|
/* dont need to draw anything if the segment
|
|
|
|
* is entirely above the top of the graph
|
|
|
|
*/
|
|
|
|
if( (prev_y_pos!=0) || (y_pos!=0) ){
|
|
|
|
gdk_draw_line(io->pixmap, io->graphs[i].gc,
|
|
|
|
prev_x_pos, prev_y_pos,
|
|
|
|
x_pos, y_pos);
|
|
|
|
}
|
2003-10-14 09:03:03 +00:00
|
|
|
break;
|
|
|
|
case PLOT_STYLE_IMPULSE:
|
|
|
|
if(val){
|
2008-08-05 17:33:14 +00:00
|
|
|
gdk_draw_line(io->pixmap, io->graphs[i].gc,
|
2003-10-14 09:03:03 +00:00
|
|
|
x_pos, draw_height-1+top_y_border,
|
|
|
|
x_pos, y_pos);
|
|
|
|
}
|
|
|
|
break;
|
2003-10-14 10:34:58 +00:00
|
|
|
case PLOT_STYLE_FILLED_BAR:
|
|
|
|
if(val){
|
|
|
|
gdk_draw_rectangle(io->pixmap,
|
2010-08-18 22:20:01 +00:00
|
|
|
io->graphs[i].gc, TRUE,
|
2003-10-14 10:34:58 +00:00
|
|
|
x_pos-io->pixels_per_tick/2,
|
2007-12-04 00:36:39 +00:00
|
|
|
y_pos,
|
2003-10-14 10:34:58 +00:00
|
|
|
io->pixels_per_tick,
|
2007-12-04 00:36:39 +00:00
|
|
|
draw_height-1+top_y_border-y_pos);
|
2007-08-26 14:02:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PLOT_STYLE_DOT:
|
|
|
|
if(val){
|
|
|
|
gdk_draw_rectangle(io->pixmap,
|
2010-08-18 22:20:01 +00:00
|
|
|
io->graphs[i].gc, TRUE,
|
2007-08-26 14:02:59 +00:00
|
|
|
x_pos-io->pixels_per_tick/2,
|
2007-12-04 00:36:39 +00:00
|
|
|
y_pos-io->pixels_per_tick/2,
|
2007-08-26 14:02:59 +00:00
|
|
|
io->pixels_per_tick,
|
|
|
|
io->pixels_per_tick);
|
2003-10-14 10:34:58 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-10-14 09:03:03 +00:00
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
prev_y_pos=y_pos;
|
|
|
|
prev_x_pos=x_pos;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-11 11:23:52 +00:00
|
|
|
|
|
|
|
|
2002-11-15 10:55:19 +00:00
|
|
|
gdk_draw_pixmap(io->draw_area->window,
|
2002-11-14 10:32:22 +00:00
|
|
|
io->draw_area->style->fg_gc[GTK_WIDGET_STATE(io->draw_area)],
|
|
|
|
io->pixmap,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
io->pixmap_width, io->pixmap_height);
|
2002-11-15 10:55:19 +00:00
|
|
|
|
2002-11-17 11:43:40 +00:00
|
|
|
|
|
|
|
/* update the scrollbar */
|
2008-11-16 14:41:35 +00:00
|
|
|
if (io->max_interval == 0) {
|
|
|
|
io->scrollbar_adjustment->upper=(gfloat) io->interval;
|
|
|
|
io->scrollbar_adjustment->step_increment=(gfloat) (io->interval/10);
|
|
|
|
io->scrollbar_adjustment->page_increment=(gfloat) io->interval;
|
|
|
|
} else {
|
|
|
|
io->scrollbar_adjustment->upper=(gfloat) io->max_interval;
|
|
|
|
io->scrollbar_adjustment->step_increment=(gfloat) ((last_interval-first_interval)/10);
|
|
|
|
io->scrollbar_adjustment->page_increment=(gfloat) (last_interval-first_interval);
|
|
|
|
}
|
2007-08-24 21:38:10 +00:00
|
|
|
io->scrollbar_adjustment->page_size=io->scrollbar_adjustment->page_increment;
|
2007-08-25 08:20:59 +00:00
|
|
|
io->scrollbar_adjustment->value=(gfloat)first_interval;
|
2002-11-17 11:43:40 +00:00
|
|
|
gtk_adjustment_changed(io->scrollbar_adjustment);
|
|
|
|
gtk_adjustment_value_changed(io->scrollbar_adjustment);
|
2003-10-11 11:23:52 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
static void
|
|
|
|
io_stat_redraw(io_stat_t *io)
|
|
|
|
{
|
|
|
|
io->needs_redraw=TRUE;
|
|
|
|
io_stat_draw(io);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
tap_iostat_draw(void *g)
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
{
|
|
|
|
io_stat_graph_t *git=g;
|
|
|
|
|
|
|
|
io_stat_draw(git->io);
|
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
/* ok we get called with both the filter and the field.
|
2004-03-08 07:47:14 +00:00
|
|
|
make sure the field is part of the filter.
|
|
|
|
(make sure and make sure just append it)
|
|
|
|
the field MUST be part of the filter or else we wont
|
|
|
|
be able to pick up the field values after the edt tree has been
|
2008-08-05 17:33:14 +00:00
|
|
|
pruned
|
2004-03-08 07:47:14 +00:00
|
|
|
*/
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
static GString *
|
"gtk_entry_get_text()" returns a "const char *" - assign the result to
one.
"get_basename()" doesn't modify its argument, and its callers don't
modify the substring pointed to by the result, so make it take a "const
char *" as an argument and return a "const char *".
"find_last_pathname_separator()" doesn't modify its argument, so make it
a "const char *" - but some of its callers pass a non-"const" "char *"
and modify the result, so don't make its return value a "const char *".
And, as none of its callers are outside "filesystem.c", make it static.
In "about_folders_page_new()", have separate variables for pathnames
returned as "const char *" (which are cached by the routine that returns
them, so you can't modify them - and can't free them, so get rid of the
commented-out "g_free()" calls for them) and pathnames returned as "char
*" (which are allocated anew for each call, and can be modified, but
have to be freed).
Clean up white space.
svn path=/trunk/; revision=12881
2004-12-31 00:26:36 +00:00
|
|
|
enable_graph(io_stat_graph_t *gio, const char *filter, const char *field)
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
{
|
2007-12-12 09:31:02 +00:00
|
|
|
char real_filter[262];
|
2004-03-08 07:47:14 +00:00
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
gio->display=TRUE;
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2004-03-08 07:47:14 +00:00
|
|
|
real_filter[0]=0;
|
|
|
|
if(filter){
|
|
|
|
/* skip all whitespaces */
|
|
|
|
while(*filter){
|
|
|
|
if(*filter==' '){
|
|
|
|
filter++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(*filter=='\t'){
|
|
|
|
filter++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(*filter){
|
2007-12-12 09:31:02 +00:00
|
|
|
g_snprintf(real_filter, 257, "(%s)", filter);
|
|
|
|
real_filter[257]=0;
|
2004-03-08 07:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(field){
|
|
|
|
/* skip all whitespaces */
|
|
|
|
while(*field){
|
|
|
|
if(*field==' '){
|
|
|
|
field++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(*field=='\t'){
|
|
|
|
field++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(*field){
|
|
|
|
if(real_filter[0]!=0){
|
2008-02-29 13:33:37 +00:00
|
|
|
g_strlcat(real_filter, " && ", 262);
|
2004-03-08 07:47:14 +00:00
|
|
|
}
|
2008-02-29 13:33:37 +00:00
|
|
|
g_strlcat(real_filter, field, 262);
|
2004-03-08 07:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return register_tap_listener("frame", gio, real_filter[0]?real_filter:NULL,
|
2010-08-18 22:20:01 +00:00
|
|
|
TL_REQUIRES_PROTO_TREE,
|
|
|
|
tap_iostat_reset, tap_iostat_packet, tap_iostat_draw);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disable_graph(io_stat_graph_t *gio)
|
|
|
|
{
|
|
|
|
if (gio->display) {
|
|
|
|
gio->display=FALSE;
|
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(gio);
|
|
|
|
unprotect_thread_critical_region();
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gio->display_button),
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
iostat_init(const char *optarg _U_, void* userdata _U_)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
|
|
|
io_stat_t *io;
|
|
|
|
int i=0;
|
|
|
|
static color_t col[MAX_GRAPHS] = {
|
|
|
|
{0, 0x0000, 0x0000, 0x0000},
|
|
|
|
{0, 0xffff, 0x0000, 0x0000},
|
|
|
|
{0, 0x0000, 0xffff, 0x0000},
|
|
|
|
{0, 0x0000, 0x0000, 0xffff},
|
|
|
|
{0, 0xffff, 0x5000, 0xffff}
|
|
|
|
};
|
2003-04-23 08:20:06 +00:00
|
|
|
GString *error_string;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
io=g_malloc(sizeof(io_stat_t));
|
2003-10-06 22:10:42 +00:00
|
|
|
io->needs_redraw=TRUE;
|
2010-08-18 22:20:01 +00:00
|
|
|
io->interval=tick_interval_values[DEFAULT_TICK_VALUE_INDEX];
|
2002-11-14 10:32:22 +00:00
|
|
|
io->window=NULL;
|
|
|
|
io->draw_area=NULL;
|
|
|
|
io->pixmap=NULL;
|
2002-11-17 11:43:40 +00:00
|
|
|
io->scrollbar=NULL;
|
|
|
|
io->scrollbar_adjustment=NULL;
|
2002-11-14 10:32:22 +00:00
|
|
|
io->pixmap_width=500;
|
|
|
|
io->pixmap_height=200;
|
2010-08-18 22:20:01 +00:00
|
|
|
io->pixels_per_tick=pixels_per_tick[DEFAULT_PIXELS_PER_TICK_INDEX];
|
2002-11-14 10:32:22 +00:00
|
|
|
io->max_y_units=AUTO_MAX_YSCALE;
|
|
|
|
io->count_type=0;
|
2002-11-17 11:43:40 +00:00
|
|
|
io->last_interval=0xffffffff;
|
|
|
|
io->max_interval=0;
|
2003-10-12 04:20:03 +00:00
|
|
|
io->num_items=0;
|
2008-02-16 16:40:36 +00:00
|
|
|
io->left_x_border=0;
|
|
|
|
io->right_x_border=500;
|
2008-01-02 20:09:20 +00:00
|
|
|
io->view_as_time=FALSE;
|
2007-12-29 20:57:15 +00:00
|
|
|
io->start_time.secs=0;
|
|
|
|
io->start_time.nsecs=0;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
|
|
|
io->graphs[i].gc=NULL;
|
|
|
|
io->graphs[i].color.pixel=col[i].pixel;
|
|
|
|
io->graphs[i].color.red=col[i].red;
|
|
|
|
io->graphs[i].color.green=col[i].green;
|
|
|
|
io->graphs[i].color.blue=col[i].blue;
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io->graphs[i].display=0;
|
2002-11-14 10:32:22 +00:00
|
|
|
io->graphs[i].display_button=NULL;
|
2004-01-13 22:34:10 +00:00
|
|
|
io->graphs[i].filter_field=NULL;
|
2002-11-29 11:37:33 +00:00
|
|
|
io->graphs[i].advanced_buttons=NULL;
|
2002-11-14 10:32:22 +00:00
|
|
|
io->graphs[i].io=io;
|
2003-01-11 11:10:33 +00:00
|
|
|
|
|
|
|
io->graphs[i].args=g_malloc(sizeof(construct_args_t));
|
|
|
|
io->graphs[i].args->title = NULL;
|
|
|
|
io->graphs[i].args->wants_apply_button=TRUE;
|
|
|
|
io->graphs[i].args->activate_on_ok=TRUE;
|
2005-12-31 17:09:27 +00:00
|
|
|
io->graphs[i].args->modal_and_transient=FALSE;
|
2003-01-11 11:10:33 +00:00
|
|
|
|
|
|
|
io->graphs[i].filter_bt=NULL;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_reset(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2004-03-08 07:47:14 +00:00
|
|
|
error_string=enable_graph(&io->graphs[0], NULL, NULL);
|
2010-08-18 22:20:01 +00:00
|
|
|
g_assert((error_string == NULL) && "Can't attach io_stat tap !");
|
|
|
|
#if 0
|
2003-04-23 08:20:06 +00:00
|
|
|
if(error_string){
|
2010-08-18 22:20:01 +00:00
|
|
|
|
2006-05-28 17:19:08 +00:00
|
|
|
fprintf(stderr, "wireshark: Can't attach io_stat tap: %s\n",
|
2003-04-23 08:20:06 +00:00
|
|
|
error_string->str);
|
|
|
|
g_string_free(error_string, TRUE);
|
2002-11-14 10:32:22 +00:00
|
|
|
io->graphs[0].display=0;
|
|
|
|
io->graphs[0].display_button=NULL;
|
2004-01-13 22:34:10 +00:00
|
|
|
io->graphs[0].filter_field=NULL;
|
2002-11-29 11:37:33 +00:00
|
|
|
io->graphs[0].advanced_buttons=NULL;
|
2002-11-14 10:32:22 +00:00
|
|
|
exit(10);
|
2008-08-05 17:33:14 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
#endif
|
2002-11-14 10:32:22 +00:00
|
|
|
/* build the GUI */
|
|
|
|
init_io_stat_window(io);
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2008-10-13 17:28:36 +00:00
|
|
|
gdk_window_raise(io->window->window);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static void
|
|
|
|
draw_area_destroy_cb(GtkWidget *widget _U_, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2002-11-14 10:32:22 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
2003-10-12 04:20:03 +00:00
|
|
|
if(io->graphs[i].display){
|
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(&io->graphs[i]);
|
|
|
|
unprotect_thread_critical_region();
|
2003-01-11 11:10:33 +00:00
|
|
|
|
2005-08-17 21:52:16 +00:00
|
|
|
g_free( (gpointer) (io->graphs[i].args->title) );
|
2003-10-12 04:20:03 +00:00
|
|
|
io->graphs[i].args->title=NULL;
|
2003-01-11 11:10:33 +00:00
|
|
|
|
2003-10-12 04:20:03 +00:00
|
|
|
g_free(io->graphs[i].args);
|
|
|
|
io->graphs[i].args=NULL;
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
g_free(io);
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static gboolean
|
|
|
|
pixmap_clicked_event(GtkWidget *widget _U_, GdkEventButton *event, gpointer user_data)
|
2008-02-16 16:40:36 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2008-02-16 16:40:36 +00:00
|
|
|
guint32 draw_width, interval, last_interval;
|
|
|
|
guint frame_num;
|
|
|
|
|
|
|
|
draw_width=io->pixmap_width-io->right_x_border-io->left_x_border;
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2008-02-16 16:40:36 +00:00
|
|
|
if ((event->x <= (draw_width+io->left_x_border+1-(draw_width/io->pixels_per_tick)*io->pixels_per_tick)) ||
|
|
|
|
(event->x >= (draw_width+io->left_x_border-io->pixels_per_tick/2))) {
|
|
|
|
/* Outside draw area */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((event->button==1 || event->button==3) && io->pixmap!=NULL) {
|
|
|
|
/*
|
|
|
|
* Button 1 selects the first package in the interval.
|
|
|
|
* Button 3 selects the last package in the interval.
|
|
|
|
*/
|
|
|
|
if (io->last_interval==0xffffffff) {
|
|
|
|
last_interval=io->max_interval;
|
|
|
|
} else {
|
|
|
|
last_interval=io->last_interval;
|
|
|
|
}
|
|
|
|
|
2008-02-16 17:19:09 +00:00
|
|
|
interval=(guint32)((last_interval/io->interval)-(draw_width+io->left_x_border-event->x-io->pixels_per_tick/2-1)/io->pixels_per_tick);
|
2008-02-16 16:40:36 +00:00
|
|
|
frame_num=get_frame_num (io, interval, event->button==1?TRUE:FALSE);
|
|
|
|
if (frame_num != 0) {
|
|
|
|
cf_goto_frame(&cfile, frame_num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
/* create a new backing pixmap of the appropriate size */
|
2010-08-18 22:20:01 +00:00
|
|
|
static gboolean
|
|
|
|
draw_area_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2002-11-14 10:32:22 +00:00
|
|
|
int i;
|
2007-06-23 05:58:01 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2007-06-22 22:22:10 +00:00
|
|
|
GtkWidget *save_bt;
|
|
|
|
#endif
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
if(io->pixmap){
|
2002-11-15 10:55:19 +00:00
|
|
|
gdk_pixmap_unref(io->pixmap);
|
2002-11-14 10:32:22 +00:00
|
|
|
io->pixmap=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
io->pixmap=gdk_pixmap_new(widget->window,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height,
|
|
|
|
-1);
|
|
|
|
io->pixmap_width=widget->allocation.width;
|
|
|
|
io->pixmap_height=widget->allocation.height;
|
|
|
|
|
2007-06-23 05:58:01 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2008-04-11 16:26:32 +00:00
|
|
|
save_bt = g_object_get_data(G_OBJECT(io->window), "save_bt");
|
|
|
|
g_object_set_data(G_OBJECT(save_bt), "pixmap", io->pixmap);
|
2007-06-22 22:22:10 +00:00
|
|
|
gtk_widget_set_sensitive(save_bt, TRUE);
|
|
|
|
#endif
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
gdk_draw_rectangle(io->pixmap,
|
|
|
|
widget->style->white_gc,
|
|
|
|
TRUE,
|
|
|
|
0, 0,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height);
|
|
|
|
|
|
|
|
/* set up the colors and the GC structs for this pixmap */
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
|
|
|
io->graphs[i].gc=gdk_gc_new(io->pixmap);
|
|
|
|
gdk_gc_set_rgb_fg_color(io->graphs[i].gc, &io->graphs[i].color);
|
|
|
|
}
|
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static void
|
|
|
|
scrollbar_changed(GtkWidget *widget _U_, gpointer user_data)
|
2002-11-17 11:43:40 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2002-11-17 11:43:40 +00:00
|
|
|
guint32 mi;
|
|
|
|
|
2003-12-23 00:16:46 +00:00
|
|
|
mi=(guint32) (io->scrollbar_adjustment->value+io->scrollbar_adjustment->page_size);
|
2002-11-17 11:43:40 +00:00
|
|
|
if(io->last_interval==mi){
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-17 11:43:40 +00:00
|
|
|
}
|
|
|
|
if( (io->last_interval==0xffffffff)
|
|
|
|
&& (mi==io->max_interval) ){
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-17 11:43:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
io->last_interval=(mi/io->interval)*io->interval;
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(io);
|
2002-11-17 11:43:40 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-17 11:43:40 +00:00
|
|
|
}
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
/* redraw the screen from the backing pixmap */
|
2010-08-18 22:20:01 +00:00
|
|
|
static gboolean
|
|
|
|
draw_area_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-15 10:55:19 +00:00
|
|
|
gdk_draw_pixmap(widget->window,
|
2002-11-14 10:32:22 +00:00
|
|
|
widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
|
|
|
|
io->pixmap,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.width, event->area.height);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void
|
2002-11-14 10:32:22 +00:00
|
|
|
create_draw_area(io_stat_t *io, GtkWidget *box)
|
|
|
|
{
|
|
|
|
io->draw_area=gtk_drawing_area_new();
|
2010-08-18 22:20:01 +00:00
|
|
|
g_signal_connect(io->draw_area, "destroy", G_CALLBACK(draw_area_destroy_cb), io);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2008-04-11 20:31:05 +00:00
|
|
|
gtk_widget_set_size_request(io->draw_area, io->pixmap_width, io->pixmap_height);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
/* signals needed to handle backing pixmap */
|
2010-08-18 22:20:01 +00:00
|
|
|
g_signal_connect(io->draw_area, "expose-event", G_CALLBACK(draw_area_expose_event), io);
|
|
|
|
g_signal_connect(io->draw_area, "configure-event", G_CALLBACK(draw_area_configure_event), io);
|
2008-02-16 16:40:36 +00:00
|
|
|
gtk_widget_add_events (io->draw_area, GDK_BUTTON_PRESS_MASK);
|
2010-08-18 22:20:01 +00:00
|
|
|
g_signal_connect(io->draw_area, "button-press-event", G_CALLBACK(pixmap_clicked_event), io);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
gtk_widget_show(io->draw_area);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), io->draw_area, TRUE, TRUE, 0);
|
2002-11-17 11:43:40 +00:00
|
|
|
|
|
|
|
/* create the associated scrollbar */
|
|
|
|
io->scrollbar_adjustment=(GtkAdjustment *)gtk_adjustment_new(0,0,0,0,0,0);
|
|
|
|
io->scrollbar=gtk_hscrollbar_new(io->scrollbar_adjustment);
|
|
|
|
gtk_widget_show(io->scrollbar);
|
2003-03-05 15:54:31 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(box), io->scrollbar, FALSE, FALSE, 0);
|
2010-08-18 22:20:01 +00:00
|
|
|
g_signal_connect(io->scrollbar_adjustment, "value-changed", G_CALLBACK(scrollbar_changed), io);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static void
|
|
|
|
tick_interval_select(GtkWidget *item, gpointer user_data)
|
2002-11-16 11:45:58 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2009-10-16 10:32:06 +00:00
|
|
|
int i;
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
i = gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
2003-10-14 09:15:51 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
io->interval=tick_interval_values[i];
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2008-10-13 17:28:36 +00:00
|
|
|
gdk_window_raise(io->window->window);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(io);
|
2002-11-16 11:45:58 +00:00
|
|
|
}
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
pixels_per_tick_select(GtkWidget *item, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2009-10-16 10:32:06 +00:00
|
|
|
int i;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
i = gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
|
|
|
io->pixels_per_tick=pixels_per_tick[i];
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 09:03:03 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
plot_style_select(GtkWidget *item, gpointer user_data)
|
2003-10-14 09:03:03 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_graph_t *ppt = user_data;
|
2003-10-14 09:03:03 +00:00
|
|
|
int val;
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
val=gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
2003-10-14 09:03:03 +00:00
|
|
|
|
|
|
|
ppt->plot_style=val;
|
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(ppt->io);
|
2003-10-14 09:03:03 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_pixels_per_tick_menu_items(io_stat_t *io)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
|
|
|
char str[5];
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
int i;
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
for(i=0;i<MAX_PIXELS_PER_TICK;i++){
|
2005-01-01 23:54:32 +00:00
|
|
|
g_snprintf(str, 5, "%u", pixels_per_tick[i]);
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_PIXELS_PER_TICK_INDEX);
|
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(pixels_per_tick_select), io);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
return combo_box;
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static void
|
|
|
|
yscale_select(GtkWidget *item, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
|
|
|
int i;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
i = gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
2003-10-14 09:55:40 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
io->max_y_units = yscale_max[i];
|
|
|
|
io_stat_redraw(io);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_tick_interval_menu_items(io_stat_t *io)
|
2002-11-16 11:45:58 +00:00
|
|
|
{
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2009-10-27 13:59:05 +00:00
|
|
|
char str[15];
|
|
|
|
int i;
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
2002-11-16 11:45:58 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
for(i=0;i<MAX_TICK_VALUES;i++){
|
2010-08-18 22:20:01 +00:00
|
|
|
if(tick_interval_values[i]>=60000){
|
|
|
|
g_snprintf(str, sizeof(str), "%u min", tick_interval_values[i]/60000);
|
|
|
|
} else if(tick_interval_values[i]>=1000){
|
|
|
|
g_snprintf(str, sizeof(str), "%u sec", tick_interval_values[i]/1000);
|
|
|
|
} else if(tick_interval_values[i]>=100){
|
|
|
|
g_snprintf(str, sizeof(str), "0.%1u sec", (tick_interval_values[i]/100)%10);
|
|
|
|
} else if(tick_interval_values[i]>=10){
|
|
|
|
g_snprintf(str, sizeof(str), "0.%02u sec", (tick_interval_values[i]/10)%10);
|
|
|
|
} else {
|
|
|
|
g_snprintf(str, sizeof(str), "0.%03u sec", (tick_interval_values[i])%10);
|
|
|
|
}
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
|
2002-11-16 11:45:58 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_TICK_VALUE_INDEX);
|
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(tick_interval_select), io);
|
2009-10-16 10:32:06 +00:00
|
|
|
|
|
|
|
return combo_box;
|
2002-11-16 11:45:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_yscale_max_menu_items(io_stat_t *io)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
|
|
|
char str[15];
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
int i;
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
for(i=0;i<MAX_YSCALE;i++){
|
2008-02-20 17:53:31 +00:00
|
|
|
if(yscale_max[i]==LOGARITHMIC_YSCALE){
|
2008-02-29 13:33:37 +00:00
|
|
|
g_strlcpy(str, "Logarithmic", 15);
|
2008-02-20 17:53:31 +00:00
|
|
|
} else if(yscale_max[i]==AUTO_MAX_YSCALE){
|
2008-02-29 13:33:37 +00:00
|
|
|
g_strlcpy(str, "Auto", 15);
|
2002-11-14 10:32:22 +00:00
|
|
|
} else {
|
2005-01-01 23:54:32 +00:00
|
|
|
g_snprintf(str, 15, "%u", yscale_max[i]);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), str);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_YSCALE_INDEX);
|
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(yscale_select), io);
|
2009-10-16 10:32:06 +00:00
|
|
|
return combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
count_type_select(GtkWidget *item, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2007-12-12 09:31:02 +00:00
|
|
|
static gboolean advanced_visible=FALSE;
|
2009-10-16 10:32:06 +00:00
|
|
|
int i;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
io->count_type = gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
2003-10-14 10:01:00 +00:00
|
|
|
|
|
|
|
if(io->count_type==COUNT_TYPE_ADVANCED){
|
2002-11-29 11:37:33 +00:00
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(&io->graphs[i]);
|
2003-10-14 10:01:00 +00:00
|
|
|
gtk_widget_show(io->graphs[i].advanced_buttons);
|
2010-08-18 22:20:01 +00:00
|
|
|
/* redraw the entire window so the unhidden widgets show up, hopefully */
|
|
|
|
gtk_widget_queue_draw_area(io->window,
|
2009-10-04 15:49:52 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
io->window->allocation.width,
|
|
|
|
io->window->allocation.height);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2007-12-12 09:31:02 +00:00
|
|
|
advanced_visible=TRUE;
|
|
|
|
io_stat_redraw(io);
|
|
|
|
} else if (advanced_visible) {
|
2002-11-29 11:37:33 +00:00
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
2003-10-14 10:01:00 +00:00
|
|
|
gtk_widget_hide(io->graphs[i].advanced_buttons);
|
2007-12-12 09:31:02 +00:00
|
|
|
filter_callback(item, &io->graphs[i]);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2007-12-12 09:31:02 +00:00
|
|
|
advanced_visible=FALSE;
|
|
|
|
} else {
|
|
|
|
io_stat_redraw(io);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_frames_or_bytes_menu_items(io_stat_t *io)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
int i;
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
for(i=0;i<MAX_COUNT_TYPES;i++){
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), count_type_names[i]);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_COUNT_TYPE);
|
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(count_type_select), io);
|
2009-10-16 10:32:06 +00:00
|
|
|
return combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void
|
2009-10-16 10:32:06 +00:00
|
|
|
create_ctrl_menu(io_stat_t *io, GtkWidget *box, const char *name, GtkWidget * (*func)(io_stat_t *io))
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
hbox=gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(box), hbox);
|
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), hbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
|
|
|
label=gtk_label_new(name);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = (*func)(io);
|
|
|
|
gtk_box_pack_end(GTK_BOX(hbox), combo_box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(combo_box);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 20:57:15 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
view_as_time_toggle_dest(GtkWidget *widget _U_, gpointer user_data)
|
2007-12-29 20:57:15 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2007-12-29 20:57:15 +00:00
|
|
|
|
|
|
|
io->view_as_time = io->view_as_time ? FALSE : TRUE;
|
|
|
|
|
|
|
|
io_stat_redraw(io);
|
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void
|
2002-11-14 10:32:22 +00:00
|
|
|
create_ctrl_area(io_stat_t *io, GtkWidget *box)
|
|
|
|
{
|
2007-09-26 22:50:53 +00:00
|
|
|
GtkWidget *frame_vbox;
|
|
|
|
GtkWidget *frame;
|
2002-11-14 10:32:22 +00:00
|
|
|
GtkWidget *vbox;
|
2007-12-29 20:57:15 +00:00
|
|
|
GtkWidget *view_cb;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2004-02-24 23:25:28 +00:00
|
|
|
frame_vbox=gtk_vbox_new(FALSE, 0);
|
2008-02-17 18:37:56 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(box), frame_vbox, FALSE, FALSE, 0);
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_widget_show(frame_vbox);
|
|
|
|
|
2007-09-26 22:50:53 +00:00
|
|
|
frame = gtk_frame_new("X Axis");
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(frame_vbox), frame);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
2002-11-14 10:32:22 +00:00
|
|
|
vbox=gtk_vbox_new(FALSE, 0);
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
|
2002-11-14 10:32:22 +00:00
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), vbox, FALSE, FALSE, 0, GTK_PACK_END);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
2004-02-25 00:16:28 +00:00
|
|
|
create_ctrl_menu(io, vbox, "Tick interval:", create_tick_interval_menu_items);
|
|
|
|
create_ctrl_menu(io, vbox, "Pixels per tick:", create_pixels_per_tick_menu_items);
|
2004-02-24 23:25:28 +00:00
|
|
|
|
2008-04-11 19:04:34 +00:00
|
|
|
view_cb = gtk_check_button_new_with_mnemonic("_View as time of day");
|
2007-12-29 20:57:15 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(vbox), view_cb);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(view_cb), io->view_as_time);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(view_cb, "toggled", G_CALLBACK(view_as_time_toggle_dest), io);
|
2007-12-29 20:57:15 +00:00
|
|
|
gtk_widget_show(view_cb);
|
|
|
|
|
2007-09-26 22:50:53 +00:00
|
|
|
frame = gtk_frame_new("Y Axis");
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(frame_vbox), frame);
|
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), vbox, FALSE, FALSE, 0, GTK_PACK_END);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
2007-09-26 22:50:53 +00:00
|
|
|
create_ctrl_menu(io, vbox, "Unit:", create_frames_or_bytes_menu_items);
|
2004-02-24 23:25:28 +00:00
|
|
|
create_ctrl_menu(io, vbox, "Scale:", create_yscale_max_menu_items);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
static void
|
|
|
|
filter_callback(GtkWidget *widget _U_, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_graph_t *gio = user_data;
|
"gtk_entry_get_text()" returns a "const char *" - assign the result to
one.
"get_basename()" doesn't modify its argument, and its callers don't
modify the substring pointed to by the result, so make it take a "const
char *" as an argument and return a "const char *".
"find_last_pathname_separator()" doesn't modify its argument, so make it
a "const char *" - but some of its callers pass a non-"const" "char *"
and modify the result, so don't make its return value a "const char *".
And, as none of its callers are outside "filesystem.c", make it static.
In "about_folders_page_new()", have separate variables for pathnames
returned as "const char *" (which are cached by the routine that returns
them, so you can't modify them - and can't free them, so get rid of the
commented-out "g_free()" calls for them) and pathnames returned as "char
*" (which are allocated anew for each call, and can be modified, but
have to be freed).
Clean up white space.
svn path=/trunk/; revision=12881
2004-12-31 00:26:36 +00:00
|
|
|
const char *filter;
|
2007-12-12 09:31:02 +00:00
|
|
|
const char *field=NULL;
|
2002-11-29 11:37:33 +00:00
|
|
|
header_field_info *hfi;
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
dfilter_t *dfilter;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2004-07-27 06:29:22 +00:00
|
|
|
/* this graph is not active, just update display and redraw */
|
|
|
|
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gio->display_button))){
|
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2004-07-27 06:29:22 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
/* first check if the field string is valid */
|
|
|
|
if(gio->io->count_type==COUNT_TYPE_ADVANCED){
|
2007-12-12 09:31:02 +00:00
|
|
|
field=gtk_entry_get_text(GTK_ENTRY(gio->calc_field));
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
/* warn and bail out if there was no field specified */
|
|
|
|
if(field==NULL || field[0]==0){
|
2004-12-29 01:08:20 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You didn't specify a field name.");
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
/* warn and bail out if the field could not be found */
|
|
|
|
hfi=proto_registrar_get_byname(field);
|
|
|
|
if(hfi==NULL){
|
2005-10-27 19:42:24 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "There is no field named '%s'.", field);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
gio->hf_index=hfi->id;
|
|
|
|
/* check that the type is compatible */
|
|
|
|
switch(hfi->type){
|
|
|
|
case FT_UINT8:
|
|
|
|
case FT_UINT16:
|
|
|
|
case FT_UINT24:
|
|
|
|
case FT_UINT32:
|
|
|
|
case FT_INT8:
|
|
|
|
case FT_INT16:
|
|
|
|
case FT_INT24:
|
|
|
|
case FT_INT32:
|
2008-10-10 15:18:37 +00:00
|
|
|
case FT_FLOAT:
|
|
|
|
case FT_DOUBLE:
|
2003-10-15 13:10:54 +00:00
|
|
|
/* these values support all calculations except LOAD */
|
|
|
|
switch(gio->calc_type){
|
|
|
|
case CALC_TYPE_LOAD:
|
2004-04-17 01:01:22 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2003-10-15 13:10:54 +00:00
|
|
|
"LOAD(*) is only supported for relative-time fields.");
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2003-10-15 13:10:54 +00:00
|
|
|
}
|
2002-11-29 11:37:33 +00:00
|
|
|
/* these types support all calculations */
|
|
|
|
break;
|
|
|
|
case FT_RELATIVE_TIME:
|
2003-10-06 22:10:42 +00:00
|
|
|
/* this type only supports COUNT, MAX, MIN, AVG */
|
2002-11-29 11:37:33 +00:00
|
|
|
switch(gio->calc_type){
|
2005-07-15 08:29:26 +00:00
|
|
|
case CALC_TYPE_SUM:
|
2002-11-29 11:37:33 +00:00
|
|
|
case CALC_TYPE_COUNT:
|
|
|
|
case CALC_TYPE_MAX:
|
|
|
|
case CALC_TYPE_MIN:
|
|
|
|
case CALC_TYPE_AVG:
|
2003-10-15 13:10:54 +00:00
|
|
|
case CALC_TYPE_LOAD:
|
2002-11-29 11:37:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-04-17 01:01:22 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2003-10-06 22:10:42 +00:00
|
|
|
"%s is a relative-time field, so %s calculations are not supported on it.",
|
|
|
|
field,
|
|
|
|
calc_type_names[gio->calc_type]);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2003-10-06 22:10:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FT_UINT64:
|
|
|
|
case FT_INT64:
|
|
|
|
/*
|
|
|
|
* XXX - support this if gint64/guint64 are
|
|
|
|
* available?
|
|
|
|
*/
|
|
|
|
if(gio->calc_type!=CALC_TYPE_COUNT){
|
2004-04-17 01:01:22 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2003-10-06 22:10:42 +00:00
|
|
|
"%s is a 64-bit integer, so %s calculations are not supported on it.",
|
|
|
|
field,
|
|
|
|
calc_type_names[gio->calc_type]);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if(gio->calc_type!=CALC_TYPE_COUNT){
|
2004-04-17 01:01:22 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2008-10-10 15:18:37 +00:00
|
|
|
"%s doesn't have integral or float values, so %s calculations are not supported on it.",
|
2003-10-06 22:10:42 +00:00
|
|
|
field,
|
|
|
|
calc_type_names[gio->calc_type]);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2003-10-06 22:10:42 +00:00
|
|
|
break;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-14 10:32:22 +00:00
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
/* first check if the filter string is valid. */
|
"gtk_entry_get_text()" returns a "const char *" - assign the result to
one.
"get_basename()" doesn't modify its argument, and its callers don't
modify the substring pointed to by the result, so make it take a "const
char *" as an argument and return a "const char *".
"find_last_pathname_separator()" doesn't modify its argument, so make it
a "const char *" - but some of its callers pass a non-"const" "char *"
and modify the result, so don't make its return value a "const char *".
And, as none of its callers are outside "filesystem.c", make it static.
In "about_folders_page_new()", have separate variables for pathnames
returned as "const char *" (which are cached by the routine that returns
them, so you can't modify them - and can't free them, so get rid of the
commented-out "g_free()" calls for them) and pathnames returned as "char
*" (which are allocated anew for each call, and can be modified, but
have to be freed).
Clean up white space.
svn path=/trunk/; revision=12881
2004-12-31 00:26:36 +00:00
|
|
|
filter=gtk_entry_get_text(GTK_ENTRY(gio->filter_field));
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
if(!dfilter_compile(filter, &dfilter)) {
|
2004-02-11 00:55:28 +00:00
|
|
|
bad_dfilter_alert_box(filter);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
2004-01-13 21:10:38 +00:00
|
|
|
if (dfilter != NULL)
|
|
|
|
dfilter_free(dfilter);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
/* ok, we have a valid filter and the graph is active.
|
|
|
|
first just try to delete any previous settings and then apply
|
|
|
|
the new ones.
|
|
|
|
*/
|
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(gio);
|
|
|
|
unprotect_thread_critical_region();
|
2008-08-05 17:33:14 +00:00
|
|
|
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_reset(gio->io);
|
2004-03-08 07:47:14 +00:00
|
|
|
enable_graph(gio, filter, field);
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2008-10-13 17:28:36 +00:00
|
|
|
gdk_window_raise(gio->io->window->window);
|
Add a routine "io_stat_reset()" to reset an io_stat_t; have
"gtk_iostat_reset()" call it, and have calls to
"gtk_iostat_reset(&io->graphs[0])" just call "io_stat_reset(io)".
Add a routine "io_stat_draw()" to draw an io_stat_t; have
"gtk_iostat_draw()" call it, and have calls to
"gtk_iostat_draw(&io->graphs[0])" just call "io_stat_draw(io)".
Add a routine "io_stat_redraw()" to set the "needs_redraw" flag on an
io_stat_t and call "io_stat_draw()" on it, in order to force a redraw.
Use that in place of set flag/io_stat_draw pairs.
Add a routine "enable_graph()" to set an io_stat_graph_t's display flag
to TRUE and register a tap listener for it, and add a routine
"disable_graph()" to, if an io_stat_graph_t's display flag is set, clear
it, remove its tap listener, and turn its display button off. Use
"disable_graph()" to disable graphs, rather than just turning the
display flag off, so that we ensure that the invariant "tap listener
present iff graph enabled" is preserved - the code to destroy an io-stat
window only removes tap listeners for enabled graphs, so it depends on
that invariant being preserved.
Check the validity of a display filter by compiling it, not by going
through the whole sequence of registering a tap listener.
svn path=/trunk/; revision=9656
2004-01-13 21:04:52 +00:00
|
|
|
io_stat_redraw(gio->io);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
calc_type_select(GtkWidget *item, gpointer user_data)
|
2002-11-29 11:37:33 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_graph_t *gio = user_data;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
gio->calc_type=gtk_combo_box_get_active (GTK_COMBO_BOX(item));
|
2002-11-29 11:37:33 +00:00
|
|
|
|
|
|
|
/* disable the graph */
|
2009-10-16 10:32:06 +00:00
|
|
|
disable_graph(gio);
|
|
|
|
io_stat_redraw(gio->io);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
static GtkWidget *
|
|
|
|
create_calc_types_menu_items(io_stat_graph_t *gio)
|
2002-11-29 11:37:33 +00:00
|
|
|
{
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-29 11:37:33 +00:00
|
|
|
int i;
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
for(i=0;i<MAX_CALC_TYPES;i++){
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), calc_type_names[i]);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_CALC_TYPE);
|
2009-10-16 10:32:06 +00:00
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(calc_type_select), gio);
|
|
|
|
return combo_box;
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-10-16 10:32:06 +00:00
|
|
|
create_advanced_menu(io_stat_graph_t *gio, GtkWidget *box, const char *name, GtkWidget *(*func)(io_stat_graph_t *io))
|
2002-11-29 11:37:33 +00:00
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2002-11-29 11:37:33 +00:00
|
|
|
|
|
|
|
hbox=gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(box), hbox);
|
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), hbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
|
|
|
label=gtk_label_new(name);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = (*func)(gio);
|
|
|
|
gtk_box_pack_end(GTK_BOX(hbox), combo_box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(combo_box);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_advanced_field(io_stat_graph_t *gio, GtkWidget *box)
|
|
|
|
{
|
|
|
|
|
2008-06-29 15:51:43 +00:00
|
|
|
gio->calc_field=gtk_entry_new();
|
|
|
|
gtk_entry_set_max_length(GTK_ENTRY(gio->calc_field),50);
|
2008-02-17 18:37:56 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(box), gio->calc_field, TRUE, TRUE, 0);
|
2002-11-29 11:37:33 +00:00
|
|
|
gtk_widget_show(gio->calc_field);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(gio->calc_field, "activate", G_CALLBACK(filter_callback), gio);
|
2008-10-10 17:10:15 +00:00
|
|
|
g_object_set_data (G_OBJECT(gio->calc_field), E_FILT_FIELD_NAME_ONLY_KEY, "");
|
|
|
|
g_signal_connect(gio->calc_field, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
2008-10-19 13:40:52 +00:00
|
|
|
g_object_set_data(G_OBJECT(box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
|
|
|
g_signal_connect(gio->calc_field, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
|
|
|
g_signal_connect(gio->io->window, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
2008-10-11 14:32:46 +00:00
|
|
|
colorize_filter_te_as_empty(gio->calc_field);
|
2002-11-29 11:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_advanced_box(io_stat_graph_t *gio, GtkWidget *box)
|
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
|
|
|
|
hbox=gtk_hbox_new(FALSE, 0);
|
|
|
|
gio->advanced_buttons=hbox;
|
|
|
|
gtk_container_add(GTK_CONTAINER(box), hbox);
|
2008-02-17 18:37:56 +00:00
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), hbox, TRUE, TRUE, 0, GTK_PACK_START);
|
2002-11-29 11:37:33 +00:00
|
|
|
gtk_widget_hide(hbox);
|
|
|
|
|
2003-10-06 22:10:42 +00:00
|
|
|
gio->calc_type=CALC_TYPE_SUM;
|
2002-11-29 11:37:33 +00:00
|
|
|
create_advanced_menu(gio, hbox, "Calc:", create_calc_types_menu_items);
|
|
|
|
create_advanced_field(gio, hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
filter_button_clicked(GtkWidget *w, gpointer user_data)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_graph_t *gio = user_data;
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2003-01-15 05:58:50 +00:00
|
|
|
display_filter_construct_cb(w, gio->args);
|
2003-01-11 11:10:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-12-16 21:18:37 +00:00
|
|
|
|
2003-01-11 11:10:33 +00:00
|
|
|
static void
|
|
|
|
create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
|
|
|
|
{
|
2009-10-16 10:32:06 +00:00
|
|
|
GtkWidget *combo_box;
|
2003-01-11 11:10:33 +00:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
2010-08-18 22:20:01 +00:00
|
|
|
char str[256];
|
2003-10-14 09:03:03 +00:00
|
|
|
int i;
|
2002-12-16 21:18:37 +00:00
|
|
|
|
2004-02-24 23:25:28 +00:00
|
|
|
hbox=gtk_hbox_new(FALSE, 3);
|
2002-11-14 10:32:22 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(box), hbox);
|
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), hbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(str, 256, "Graph %d", num);
|
2007-12-29 20:53:10 +00:00
|
|
|
gio->display_button=gtk_toggle_button_new_with_label(str);
|
2002-11-14 10:32:22 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gio->display_button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(gio->display_button);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gio->display_button), gio->display);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(gio->display_button, "toggled", G_CALLBACK(filter_callback), gio);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2004-02-24 23:25:28 +00:00
|
|
|
label=gtk_label_new("Color");
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
2002-11-15 10:55:19 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gio->color);
|
|
|
|
gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &gio->color);
|
|
|
|
gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &gio->color);
|
|
|
|
gtk_widget_modify_fg(label, GTK_STATE_SELECTED, &gio->color);
|
|
|
|
gtk_widget_modify_fg(label, GTK_STATE_INSENSITIVE, &gio->color);
|
2010-08-23 15:58:48 +00:00
|
|
|
/* g_signal_connect(gio->display_button, "toggled", G_CALLBACK(filter_callback), gio);*/
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
|
2002-12-16 21:18:37 +00:00
|
|
|
/* filter prefs dialog */
|
2008-04-11 18:58:19 +00:00
|
|
|
gio->filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
|
2003-01-11 11:10:33 +00:00
|
|
|
|
2006-05-22 07:29:40 +00:00
|
|
|
g_snprintf(str, 256, "Wireshark: Display Filter IO-Stat (Filter:%d)", num);
|
2009-03-13 22:06:48 +00:00
|
|
|
g_free( (gpointer) (gio->args->title) );
|
2008-08-05 17:33:14 +00:00
|
|
|
gio->args->title=g_strdup(str);
|
2003-01-11 11:10:33 +00:00
|
|
|
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(gio->filter_bt, "clicked", G_CALLBACK(filter_button_clicked), gio);
|
|
|
|
g_signal_connect(gio->filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
|
2003-01-11 11:10:33 +00:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gio->filter_bt, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(gio->filter_bt);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2008-06-29 15:51:43 +00:00
|
|
|
gio->filter_field=gtk_entry_new();
|
2010-08-18 22:20:01 +00:00
|
|
|
gtk_entry_set_max_length(GTK_ENTRY(gio->filter_field),256);
|
2002-12-16 21:18:37 +00:00
|
|
|
/* filter prefs dialog */
|
2008-04-11 16:26:32 +00:00
|
|
|
g_object_set_data(G_OBJECT(gio->filter_bt), E_FILT_TE_PTR_KEY, gio->filter_field);
|
2002-12-16 21:18:37 +00:00
|
|
|
/* filter prefs dialog */
|
|
|
|
|
2008-02-17 18:37:56 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), gio->filter_field, TRUE, TRUE, 0);
|
2004-01-13 22:34:10 +00:00
|
|
|
gtk_widget_show(gio->filter_field);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(gio->filter_field, "activate", G_CALLBACK(filter_callback), gio);
|
|
|
|
g_signal_connect(gio->filter_field, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
2008-10-19 13:40:52 +00:00
|
|
|
g_object_set_data(G_OBJECT(box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
|
|
|
g_signal_connect(gio->filter_field, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
|
|
|
g_signal_connect(gio->io->window, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
2008-10-11 14:32:46 +00:00
|
|
|
colorize_filter_te_as_empty(gio->filter_field);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
create_advanced_box(gio, hbox);
|
|
|
|
|
2003-10-14 09:03:03 +00:00
|
|
|
/*
|
|
|
|
* create PlotStyle menu
|
|
|
|
*/
|
2004-03-13 15:15:26 +00:00
|
|
|
g_snprintf(str, 256, " Style:");
|
2003-10-14 09:03:03 +00:00
|
|
|
label=gtk_label_new(str);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
combo_box = gtk_combo_box_new_text ();
|
2003-10-14 09:03:03 +00:00
|
|
|
for(i=0;i<MAX_PLOT_STYLES;i++){
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), plot_style_name[i]);
|
2003-10-14 09:03:03 +00:00
|
|
|
}
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), DEFAULT_PLOT_STYLE);
|
|
|
|
g_signal_connect(combo_box, "changed", G_CALLBACK(plot_style_select), &gio->io->graphs[num-1]);
|
2003-10-14 09:03:03 +00:00
|
|
|
|
2009-10-16 10:32:06 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(hbox), combo_box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(combo_box);
|
2003-10-14 09:03:03 +00:00
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
static void
|
2002-11-14 10:32:22 +00:00
|
|
|
create_filter_area(io_stat_t *io, GtkWidget *box)
|
|
|
|
{
|
2004-02-24 23:25:28 +00:00
|
|
|
GtkWidget *frame;
|
2002-11-14 10:32:22 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
int i;
|
|
|
|
|
2007-12-29 23:20:14 +00:00
|
|
|
frame=gtk_frame_new("Graphs");
|
2008-02-17 18:37:56 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
|
2004-02-24 23:25:28 +00:00
|
|
|
gtk_widget_show(frame);
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 1);
|
|
|
|
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
|
2002-11-14 10:32:22 +00:00
|
|
|
gtk_box_set_child_packing(GTK_BOX(box), vbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++){
|
2003-01-11 11:10:33 +00:00
|
|
|
create_filter_box(&io->graphs[i], vbox, i+1);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2002-11-29 11:37:33 +00:00
|
|
|
return;
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2008-01-20 12:24:14 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
copy_as_csv_cb(GtkWindow *copy_bt _U_, gpointer user_data)
|
2008-01-20 12:24:14 +00:00
|
|
|
{
|
|
|
|
guint32 i, interval, val;
|
|
|
|
char string[15];
|
2008-08-05 17:33:14 +00:00
|
|
|
GtkClipboard *cb;
|
2008-01-20 12:24:14 +00:00
|
|
|
GString *CSV_str=g_string_new("");
|
2010-08-18 22:20:01 +00:00
|
|
|
io_stat_t *io = user_data;
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2008-01-20 12:24:14 +00:00
|
|
|
g_string_append(CSV_str, "Interval start");
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++) {
|
|
|
|
if (io->graphs[i].display) {
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_append_printf(CSV_str, ",Graph %d", i+1);
|
2008-01-20 12:24:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_string_append(CSV_str,"\n");
|
|
|
|
|
|
|
|
for(interval=0; interval<io->max_interval; interval+=io->interval) {
|
|
|
|
print_interval_string (string, 15, interval, io, FALSE);
|
|
|
|
g_string_append(CSV_str, string);
|
|
|
|
for(i=0;i<MAX_GRAPHS;i++) {
|
|
|
|
if (io->graphs[i].display) {
|
|
|
|
val=get_it_value(io, i, interval/io->interval);
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_append_printf(CSV_str, ",%d", val);
|
2008-01-20 12:24:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_string_append(CSV_str,"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now that we have the CSV data, copy it into the default clipboard */
|
|
|
|
cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */
|
|
|
|
gtk_clipboard_set_text(cb, CSV_str->str, -1); /* Copy the CSV data into the clipboard */
|
|
|
|
g_string_free(CSV_str, TRUE); /* Free the memory */
|
2008-08-05 17:33:14 +00:00
|
|
|
}
|
2008-01-20 12:24:14 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
static void
|
2002-11-14 10:32:22 +00:00
|
|
|
init_io_stat_window(io_stat_t *io)
|
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
2005-01-20 23:17:23 +00:00
|
|
|
GtkWidget *bbox;
|
2007-06-22 22:22:10 +00:00
|
|
|
GtkWidget *close_bt, *help_bt;
|
2008-01-20 12:24:14 +00:00
|
|
|
GtkTooltips *tooltips = gtk_tooltips_new();
|
|
|
|
GtkWidget *copy_bt;
|
2007-06-23 05:58:01 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2007-06-22 22:22:10 +00:00
|
|
|
GtkWidget *save_bt;
|
|
|
|
#endif
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2009-06-21 20:42:07 +00:00
|
|
|
/* create the main window, transient_for top_level */
|
2010-08-18 22:20:01 +00:00
|
|
|
io->window = dlg_window_new("I/O Graphs");
|
2009-06-21 20:42:07 +00:00
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(io->window), TRUE);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(io->window), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
create_draw_area(io, vbox);
|
|
|
|
|
2004-02-24 23:25:28 +00:00
|
|
|
hbox=gtk_hbox_new(FALSE, 3);
|
2003-03-05 20:12:04 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
|
2002-11-14 10:32:22 +00:00
|
|
|
gtk_box_set_child_packing(GTK_BOX(vbox), hbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
|
|
|
create_filter_area(io, hbox);
|
|
|
|
create_ctrl_area(io, hbox);
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
io_stat_set_title(io);
|
2004-02-24 17:53:40 +00:00
|
|
|
|
2007-06-23 05:58:01 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2008-06-21 13:36:31 +00:00
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_SAVE,
|
|
|
|
GTK_STOCK_COPY, GTK_STOCK_HELP, NULL);
|
2008-04-06 21:45:04 +00:00
|
|
|
#else
|
2008-08-05 17:33:14 +00:00
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_COPY,
|
2008-06-21 13:36:31 +00:00
|
|
|
GTK_STOCK_HELP, NULL);
|
2007-06-22 22:22:10 +00:00
|
|
|
#endif
|
2005-01-20 23:17:23 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
2007-12-29 23:20:14 +00:00
|
|
|
gtk_widget_show(bbox);
|
2005-01-20 23:17:23 +00:00
|
|
|
|
2008-04-11 16:26:32 +00:00
|
|
|
close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2007-12-29 23:20:14 +00:00
|
|
|
window_set_cancel_button(io->window, close_bt, window_cancel_button_cb);
|
2008-01-20 12:24:14 +00:00
|
|
|
gtk_tooltips_set_tip(tooltips, close_bt, "Close this dialog", NULL);
|
2005-01-20 23:17:23 +00:00
|
|
|
|
2007-06-23 05:58:01 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2008-04-11 16:26:32 +00:00
|
|
|
save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
|
2007-12-29 23:20:14 +00:00
|
|
|
gtk_widget_set_sensitive(save_bt, FALSE);
|
2008-01-20 12:24:14 +00:00
|
|
|
gtk_tooltips_set_tip(tooltips, save_bt, "Save the displayed graph to a file", NULL);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(save_bt, "clicked", G_CALLBACK(pixmap_save_cb), NULL);
|
2008-04-11 16:26:32 +00:00
|
|
|
g_object_set_data(G_OBJECT(io->window), "save_bt", save_bt);
|
2007-06-22 22:22:10 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-11 16:26:32 +00:00
|
|
|
copy_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_COPY);
|
2008-08-05 17:33:14 +00:00
|
|
|
gtk_tooltips_set_tip(tooltips, copy_bt,
|
2008-12-20 01:39:16 +00:00
|
|
|
"Copy values from selected graphs to the clipboard in CSV (Comma Separated Values) format", NULL);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(copy_bt, "clicked", G_CALLBACK(copy_as_csv_cb), io);
|
2008-01-20 12:24:14 +00:00
|
|
|
|
2008-06-21 13:36:31 +00:00
|
|
|
help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_STATS_IO_GRAPH_DIALOG);
|
|
|
|
gtk_tooltips_set_tip (tooltips, help_bt, "Show topic specific help", NULL);
|
2004-02-24 17:53:40 +00:00
|
|
|
|
2010-08-18 22:20:01 +00:00
|
|
|
g_signal_connect(io->window, "delete-event", G_CALLBACK(window_delete_event_cb), NULL);
|
2004-02-24 17:53:40 +00:00
|
|
|
|
2007-12-29 23:20:14 +00:00
|
|
|
gtk_widget_show(io->window);
|
|
|
|
window_present(io->window);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
static void
|
2010-08-18 22:20:01 +00:00
|
|
|
gui_iostat_cb(GtkWidget *w _U_, gpointer d _U_)
|
2002-11-14 10:32:22 +00:00
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
iostat_init(NULL,NULL);
|
2002-11-14 10:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_gtk_iostat(void)
|
|
|
|
{
|
2010-08-18 22:20:01 +00:00
|
|
|
register_stat_cmd_arg("io,stat", iostat_init,NULL);
|
2002-11-14 10:32:22 +00:00
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
register_stat_menu_item_stock("_IO Graphs",
|
2010-08-18 22:20:01 +00:00
|
|
|
REGISTER_STAT_GROUP_GENERIC, WIRESHARK_STOCK_GRAPHS,
|
|
|
|
gui_iostat_cb, NULL, NULL, NULL);
|
2003-04-23 05:37:23 +00:00
|
|
|
}
|