2013-03-04 16:36:40 +00:00
|
|
|
/* graph_analysis.c
|
2006-05-22 07:29:40 +00:00
|
|
|
* Graphic Analysis addition for Wireshark
|
2005-02-01 12:12:35 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright 2004, Verso Technologies Inc.
|
|
|
|
* By Alejandro Vaquero <alejandrovaquero@yahoo.com>
|
|
|
|
*
|
|
|
|
* based on rtp_analysis.c and io_stat
|
|
|
|
*
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-02-01 12:12:35 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-02-01 12:12:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2009-08-27 03:54:57 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2005-02-21 03:06:41 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2008-04-13 01:54:20 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
2011-06-20 00:48:05 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
# include <gdk/gdkkeysyms-compat.h>
|
|
|
|
#endif
|
2008-04-13 01:54:20 +00:00
|
|
|
|
|
|
|
#include <epan/epan_dissect.h>
|
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/dissectors/packet-rtp.h>
|
|
|
|
#include <epan/addr_resolv.h>
|
2011-09-15 05:59:09 +00:00
|
|
|
#include <epan/filesystem.h>
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2012-02-17 12:46:50 +00:00
|
|
|
#include "ui/util.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/alert_box.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
#include "ui/last_open_dir.h"
|
|
|
|
#include "ui/recent.h"
|
|
|
|
#include "ui/simple_dialog.h"
|
|
|
|
|
2008-05-22 15:46:27 +00:00
|
|
|
#include <wsutil/file_util.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gtkglobals.h"
|
|
|
|
#include "ui/gtk/file_dlg.h"
|
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/main.h"
|
|
|
|
#include "ui/gtk/graph_analysis.h"
|
2011-07-21 17:44:02 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/old-gtk-compat.h"
|
2011-07-21 17:44:02 +00:00
|
|
|
|
2012-01-15 22:40:03 +00:00
|
|
|
#include "../../image/voip_bg.xpm"
|
2005-07-18 08:29:03 +00:00
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
|
2005-06-06 14:01:04 +00:00
|
|
|
#define MAX_LABEL 50
|
|
|
|
#define MAX_COMMENT 100
|
|
|
|
#define ITEM_HEIGHT 20
|
|
|
|
#define NODE_WIDTH 100
|
|
|
|
#define TOP_Y_BORDER 40
|
2008-10-29 07:28:44 +00:00
|
|
|
#define BOTTOM_Y_BORDER 2
|
2005-06-06 14:01:04 +00:00
|
|
|
#define COMMENT_WIDTH 400
|
2012-01-15 22:09:43 +00:00
|
|
|
#define TIME_WIDTH 150
|
2005-06-06 14:01:04 +00:00
|
|
|
|
|
|
|
#define NODE_CHARS_WIDTH 20
|
2010-07-30 00:17:49 +00:00
|
|
|
#define CONV_TIME_HEADER "Conv.| Time "
|
2005-07-17 23:12:12 +00:00
|
|
|
#define TIME_HEADER "|Time "
|
2010-07-30 00:17:49 +00:00
|
|
|
#define CONV_TIME_EMPTY_HEADER " | "
|
|
|
|
#define TIME_EMPTY_HEADER "| "
|
2005-07-17 23:12:12 +00:00
|
|
|
#define CONV_TIME_HEADER_LENGTH 16
|
|
|
|
#define TIME_HEADER_LENGTH 10
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Reset the user_data structure */
|
2010-07-30 00:17:49 +00:00
|
|
|
static void graph_analysis_reset(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
user_data->num_nodes = 0;
|
|
|
|
user_data->num_items = 0;
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<MAX_NUM_NODES; i++) {
|
2005-02-24 21:31:20 +00:00
|
|
|
user_data->nodes[i].type = AT_NONE;
|
|
|
|
user_data->nodes[i].len = 0;
|
|
|
|
g_free((void *)user_data->nodes[i].data);
|
2005-03-01 16:19:46 +00:00
|
|
|
user_data->nodes[i].data = NULL;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.first_node = 0;
|
|
|
|
user_data->dlg.first_item = 0;
|
|
|
|
user_data->dlg.left_x_border = 0;
|
|
|
|
user_data->dlg.selected_item = 0xFFFFFFFF; /*not item selected */
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-08-11 16:42:21 +00:00
|
|
|
/* Init the user_data structure */
|
2010-07-30 00:17:49 +00:00
|
|
|
static void graph_analysis_init_dlg(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2005-03-01 16:19:46 +00:00
|
|
|
int i;
|
2013-03-04 16:36:40 +00:00
|
|
|
|
2005-03-01 16:19:46 +00:00
|
|
|
user_data->num_nodes = 0;
|
|
|
|
user_data->num_items = 0;
|
2005-10-03 05:55:26 +00:00
|
|
|
user_data->on_destroy_user_data = NULL;
|
|
|
|
user_data->data = NULL;
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<MAX_NUM_NODES; i++) {
|
2005-03-01 16:19:46 +00:00
|
|
|
user_data->nodes[i].type = AT_NONE;
|
|
|
|
user_data->nodes[i].len = 0;
|
|
|
|
user_data->nodes[i].data = NULL;
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.first_node = 0;
|
|
|
|
user_data->dlg.first_item = 0;
|
|
|
|
user_data->dlg.left_x_border = 0;
|
|
|
|
user_data->dlg.selected_item = 0xFFFFFFFF; /*not item selected */
|
2005-09-21 03:28:22 +00:00
|
|
|
/* init dialog_graph */
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.needs_redraw = TRUE;
|
|
|
|
user_data->dlg.draw_area_time = NULL;
|
|
|
|
user_data->dlg.draw_area = NULL;
|
|
|
|
user_data->dlg.draw_area_comments = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_main = NULL;
|
|
|
|
user_data->dlg.surface_time = NULL;
|
|
|
|
user_data->dlg.surface_comments = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_main = NULL;
|
|
|
|
user_data->dlg.pixmap_time = NULL;
|
|
|
|
user_data->dlg.pixmap_comments = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.v_scrollbar = NULL;
|
|
|
|
user_data->dlg.v_scrollbar_adjustment = NULL;
|
|
|
|
user_data->dlg.hpane = NULL;
|
|
|
|
user_data->dlg.surface_width = 350;
|
|
|
|
user_data->dlg.surface_height = 400;
|
|
|
|
user_data->dlg.first_node = 0;
|
|
|
|
user_data->dlg.first_item = 0;
|
|
|
|
user_data->dlg.left_x_border = 0;
|
|
|
|
user_data->dlg.selected_item = 0xFFFFFFFF; /*not item selected */
|
|
|
|
user_data->dlg.window = NULL;
|
|
|
|
user_data->dlg.parent_w = NULL;
|
2005-09-13 04:53:36 +00:00
|
|
|
user_data->dlg.inverse = FALSE;
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.title = NULL;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* CALLBACKS */
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2005-10-03 05:55:26 +00:00
|
|
|
/* close the dialog window */
|
2008-10-20 20:24:01 +00:00
|
|
|
static void on_destroy(GtkWidget *win _U_, graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2005-02-24 21:31:20 +00:00
|
|
|
int i;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<MAX_NUM_NODES; i++) {
|
2005-02-24 21:31:20 +00:00
|
|
|
user_data->nodes[i].type = AT_NONE;
|
|
|
|
user_data->nodes[i].len = 0;
|
|
|
|
g_free((void *)user_data->nodes[i].data);
|
2005-03-01 16:19:46 +00:00
|
|
|
user_data->nodes[i].data = NULL;
|
2005-02-24 21:31:20 +00:00
|
|
|
}
|
2005-03-01 16:19:46 +00:00
|
|
|
user_data->dlg.window = NULL;
|
2005-10-03 05:55:26 +00:00
|
|
|
g_free(user_data->dlg.title);
|
|
|
|
user_data->dlg.title = NULL;
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->on_destroy_user_data) {
|
2008-10-20 20:24:01 +00:00
|
|
|
user_data->on_destroy_user_data(user_data->data);
|
2005-10-03 05:55:26 +00:00
|
|
|
}
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RIGHT_ARROW 1
|
|
|
|
#define LEFT_ARROW 0
|
|
|
|
#define WIDTH_ARROW 8
|
|
|
|
#define HEIGHT_ARROW 6
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-01-06 16:36:22 +00:00
|
|
|
static void draw_arrow(cairo_surface_t *surface, GdkRGBA *color, gint x, gint y, gboolean arrow_type)
|
2011-08-12 12:32:18 +00:00
|
|
|
{
|
|
|
|
cairo_t *cr;
|
|
|
|
|
|
|
|
cr = cairo_create (surface);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, color);
|
2011-08-12 12:32:18 +00:00
|
|
|
if (arrow_type == LEFT_ARROW)
|
|
|
|
{
|
|
|
|
cairo_move_to (cr, x + WIDTH_ARROW, y);
|
|
|
|
cairo_line_to (cr, x + WIDTH_ARROW, y + HEIGHT_ARROW);
|
|
|
|
cairo_line_to (cr, x, y + HEIGHT_ARROW / 2.);
|
|
|
|
}
|
|
|
|
else if (arrow_type == RIGHT_ARROW)
|
|
|
|
{
|
|
|
|
cairo_move_to (cr, x, y);
|
|
|
|
cairo_line_to (cr, x + WIDTH_ARROW, y + HEIGHT_ARROW / 2.);
|
|
|
|
cairo_line_to (cr, x, y + HEIGHT_ARROW);
|
|
|
|
}
|
|
|
|
cairo_close_path (cr);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
|
|
|
#else
|
2013-01-06 16:36:22 +00:00
|
|
|
static void draw_arrow(GdkDrawable *pixmap, GdkRGBA *color, gint x, gint y, gboolean arrow_type)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2011-08-09 12:17:06 +00:00
|
|
|
cairo_t *cr;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(pixmap)) {
|
2011-08-09 12:17:06 +00:00
|
|
|
cr = gdk_cairo_create (pixmap);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, color);
|
2011-08-09 12:17:06 +00:00
|
|
|
if (arrow_type == LEFT_ARROW)
|
|
|
|
{
|
|
|
|
cairo_move_to (cr, x + WIDTH_ARROW, y);
|
|
|
|
cairo_line_to (cr, x + WIDTH_ARROW, y + HEIGHT_ARROW);
|
|
|
|
cairo_line_to (cr, x, y + HEIGHT_ARROW / 2.);
|
|
|
|
}
|
|
|
|
else if (arrow_type == RIGHT_ARROW)
|
|
|
|
{
|
|
|
|
cairo_move_to (cr, x, y);
|
|
|
|
cairo_line_to (cr, x + WIDTH_ARROW, y + HEIGHT_ARROW / 2.);
|
|
|
|
cairo_line_to (cr, x, y + HEIGHT_ARROW);
|
|
|
|
}
|
|
|
|
cairo_close_path (cr);
|
|
|
|
cairo_fill (cr);
|
2013-03-04 16:36:40 +00:00
|
|
|
|
2011-08-09 12:17:06 +00:00
|
|
|
cairo_destroy (cr);
|
2005-07-17 23:12:12 +00:00
|
|
|
}
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-04-07 09:14:35 +00:00
|
|
|
/****************************************************************************/
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Adds trailing characters to complete the requested length. */
|
2005-04-07 09:14:35 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
static void enlarge_string(GString *gstr, guint32 length, char pad) {
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2009-04-16 00:45:26 +00:00
|
|
|
gsize i;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i = gstr->len; i < length; i++) {
|
2005-09-21 03:28:22 +00:00
|
|
|
g_string_append_c(gstr, pad);
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* overwrites the characters in a string, between positions p1 and p2, with */
|
|
|
|
/* the characters of text_to_insert */
|
2008-10-20 20:24:01 +00:00
|
|
|
/* NB: it does not check that p1 and p2 fit into string */
|
2005-04-07 09:14:35 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
static void overwrite (GString *gstr, char *text_to_insert, guint32 p1, guint32 p2) {
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2009-04-16 00:45:26 +00:00
|
|
|
gsize len;
|
2007-04-22 15:43:01 +00:00
|
|
|
gsize pos;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
|
|
|
if (p1 == p2)
|
|
|
|
return;
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (p1 > p2) {
|
2005-09-21 03:28:22 +00:00
|
|
|
pos = p2;
|
|
|
|
len = p1 - p2;
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
else{
|
2005-09-21 03:28:22 +00:00
|
|
|
pos = p1;
|
|
|
|
len = p2 - p1;
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (len > strlen(text_to_insert)) {
|
2005-09-21 03:28:22 +00:00
|
|
|
len = strlen(text_to_insert);
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
2009-04-16 00:45:26 +00:00
|
|
|
if (pos > gstr->len)
|
2005-09-21 03:28:22 +00:00
|
|
|
pos = gstr->len;
|
|
|
|
|
2007-04-22 15:43:01 +00:00
|
|
|
/* ouch this is ugly but gtk1 needs it */
|
2009-04-16 00:45:26 +00:00
|
|
|
if ((pos + len) > gstr->len)
|
2005-09-21 03:28:22 +00:00
|
|
|
g_string_truncate(gstr, pos);
|
|
|
|
else
|
|
|
|
g_string_erase(gstr, pos, len);
|
|
|
|
|
|
|
|
g_string_insert(gstr, pos, text_to_insert);
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2013-05-14 21:53:57 +00:00
|
|
|
static gboolean
|
|
|
|
dialog_graph_dump_to_file(char *pathname, graph_analysis_data_t *user_data)
|
2005-04-07 09:14:35 +00:00
|
|
|
{
|
2013-03-04 16:36:40 +00:00
|
|
|
guint32 i, first_node, display_items, display_nodes;
|
|
|
|
guint32 start_position, end_position, item_width, header_length;
|
2005-09-21 03:28:22 +00:00
|
|
|
graph_analysis_item_t *gai;
|
2010-07-30 00:17:49 +00:00
|
|
|
guint16 first_conv_num = 0;
|
2013-03-04 16:36:40 +00:00
|
|
|
gboolean several_convs = FALSE;
|
|
|
|
gboolean first_packet = TRUE;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
GString *label_string, *empty_line, *separator_line, *tmp_str, *tmp_str2;
|
2012-12-26 05:57:06 +00:00
|
|
|
const char *empty_header;
|
2013-03-04 16:36:40 +00:00
|
|
|
char src_port[8], dst_port[8];
|
|
|
|
gchar *time_str;
|
|
|
|
GList *list;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2010-07-30 00:17:49 +00:00
|
|
|
FILE *of;
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-05-14 21:53:57 +00:00
|
|
|
of = ws_fopen(pathname, "w");
|
2013-03-04 16:36:40 +00:00
|
|
|
if (of==NULL) {
|
2013-05-14 21:53:57 +00:00
|
|
|
open_failure_alert_box(pathname, errno, TRUE);
|
2005-09-21 03:28:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-03-10 16:56:40 +00:00
|
|
|
time_str = (gchar *)g_malloc(COL_MAX_LEN);
|
2005-09-21 03:28:22 +00:00
|
|
|
label_string = g_string_new("");
|
|
|
|
empty_line = g_string_new("");
|
|
|
|
separator_line = g_string_new("");
|
|
|
|
tmp_str = g_string_new("");
|
|
|
|
tmp_str2 = g_string_new("");
|
|
|
|
|
2010-08-11 16:42:21 +00:00
|
|
|
display_items = 0;
|
2005-09-21 03:28:22 +00:00
|
|
|
list = g_list_first(user_data->graph_info->list);
|
2010-08-11 16:42:21 +00:00
|
|
|
while (list)
|
2005-09-21 03:28:22 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
gai = (graph_analysis_item_t *)list->data;
|
2005-09-21 03:28:22 +00:00
|
|
|
list = g_list_next(list);
|
2010-08-11 16:42:21 +00:00
|
|
|
|
|
|
|
if (!gai->display)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
display_items += 1;
|
2013-03-04 16:36:40 +00:00
|
|
|
if (first_packet) {
|
2010-08-11 16:42:21 +00:00
|
|
|
first_conv_num = gai->conv_num;
|
2013-03-04 16:36:40 +00:00
|
|
|
first_packet = FALSE;
|
2010-08-11 16:42:21 +00:00
|
|
|
}
|
2013-03-04 16:36:40 +00:00
|
|
|
else if (gai->conv_num != first_conv_num) {
|
2010-08-11 16:42:21 +00:00
|
|
|
several_convs = TRUE;
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* if not items to display */
|
2009-06-01 14:00:09 +00:00
|
|
|
if (display_items == 0)
|
|
|
|
goto exit;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
display_nodes = user_data->num_nodes;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
first_node = user_data->dlg.first_node;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Write the conv. and time headers */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (several_convs) {
|
2008-10-29 07:28:44 +00:00
|
|
|
fprintf(of, CONV_TIME_HEADER);
|
2005-09-21 03:28:22 +00:00
|
|
|
empty_header = CONV_TIME_EMPTY_HEADER;
|
|
|
|
header_length = CONV_TIME_HEADER_LENGTH;
|
|
|
|
}
|
|
|
|
else{
|
2008-10-29 07:28:44 +00:00
|
|
|
fprintf(of, TIME_HEADER);
|
2005-09-21 03:28:22 +00:00
|
|
|
empty_header = TIME_EMPTY_HEADER;
|
|
|
|
header_length = TIME_HEADER_LENGTH;
|
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Write the node names on top */
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<display_nodes; i+=2) {
|
2005-09-21 03:28:22 +00:00
|
|
|
/* print the node identifiers */
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_printf(label_string, "| %s",
|
2005-09-21 03:28:22 +00:00
|
|
|
get_addr_name(&(user_data->nodes[i+first_node])));
|
2008-10-29 07:28:44 +00:00
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' ');
|
|
|
|
fprintf(of, "%s", label_string->str);
|
|
|
|
g_string_printf(label_string, "| ");
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH, ' ');
|
2008-10-29 07:28:44 +00:00
|
|
|
g_string_append(empty_line, label_string->str);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(of, "|\n%s", empty_header);
|
|
|
|
g_string_printf(label_string, "| ");
|
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH, ' ');
|
|
|
|
fprintf(of, "%s", label_string->str);
|
|
|
|
|
|
|
|
/* Write the node names on top */
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=1; i<display_nodes; i+=2) {
|
2008-10-29 07:28:44 +00:00
|
|
|
/* print the node identifiers */
|
|
|
|
g_string_printf(label_string, "| %s",
|
|
|
|
get_addr_name(&(user_data->nodes[i+first_node])));
|
|
|
|
if (label_string->len < NODE_CHARS_WIDTH)
|
|
|
|
{
|
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH, ' ');
|
|
|
|
g_string_append(label_string, "| ");
|
|
|
|
}
|
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH*2, ' ');
|
2005-09-21 03:28:22 +00:00
|
|
|
fprintf(of, "%s", label_string->str);
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_printf(label_string, "| ");
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(label_string, NODE_CHARS_WIDTH, ' ');
|
|
|
|
g_string_append(empty_line, label_string->str);
|
|
|
|
}
|
2008-10-29 07:28:44 +00:00
|
|
|
|
|
|
|
fprintf(of, "\n");
|
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
g_string_append_c(empty_line, '|');
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2009-04-16 00:45:26 +00:00
|
|
|
enlarge_string(separator_line, (guint32) empty_line->len + header_length, '-');
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/*
|
|
|
|
* Draw the items
|
|
|
|
*/
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2010-08-11 16:42:21 +00:00
|
|
|
list = g_list_first(user_data->graph_info->list);
|
|
|
|
while (list)
|
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
gai = (graph_analysis_item_t *)list->data;
|
2010-08-11 16:42:21 +00:00
|
|
|
list = g_list_next(list);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2010-08-11 16:42:21 +00:00
|
|
|
if (!gai->display)
|
|
|
|
continue;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2010-08-11 16:42:21 +00:00
|
|
|
start_position = (gai->src_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2;
|
|
|
|
|
|
|
|
end_position = (gai->dst_node-first_node)*NODE_CHARS_WIDTH+NODE_CHARS_WIDTH/2;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_position > end_position) {
|
|
|
|
item_width = start_position-end_position;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2013-03-04 16:36:40 +00:00
|
|
|
else if (start_position < end_position) {
|
|
|
|
item_width = end_position-start_position;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
else{ /* same origin and destination address */
|
|
|
|
end_position = start_position+NODE_CHARS_WIDTH;
|
|
|
|
item_width = NODE_CHARS_WIDTH;
|
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* separator between conversations */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gai->conv_num != first_conv_num) {
|
2005-09-21 03:28:22 +00:00
|
|
|
fprintf(of, "%s\n", separator_line->str);
|
2013-03-04 16:36:40 +00:00
|
|
|
first_conv_num = gai->conv_num;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* write the conversation number */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (several_convs) {
|
2010-08-11 16:42:21 +00:00
|
|
|
g_string_printf(label_string, "%i", gai->conv_num);
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(label_string, 5, ' ');
|
|
|
|
fprintf(of, "%s", label_string->str);
|
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2012-01-15 22:09:43 +00:00
|
|
|
#if 0
|
2005-09-21 03:28:22 +00:00
|
|
|
/* write the time */
|
2011-09-13 12:39:11 +00:00
|
|
|
g_string_printf(label_string, "|%.3f", nstime_to_sec(&gai->fd->rel_ts));
|
2012-01-15 22:09:43 +00:00
|
|
|
#endif
|
|
|
|
/* Write the time, using the same format as in the time col */
|
2011-09-22 08:46:09 +00:00
|
|
|
set_fd_time(gai->fd, time_str);
|
|
|
|
g_string_printf(label_string, "|%s", time_str);
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(label_string, 10, ' ');
|
|
|
|
fprintf(of, "%s", label_string->str);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* write the frame label */
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2009-08-12 00:02:23 +00:00
|
|
|
g_string_printf(tmp_str, "%s", empty_line->str);
|
2013-03-04 16:36:40 +00:00
|
|
|
overwrite(tmp_str, gai->frame_label,
|
2005-09-21 03:28:22 +00:00
|
|
|
start_position,
|
|
|
|
end_position
|
|
|
|
);
|
|
|
|
fprintf(of, "%s", tmp_str->str);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* write the comments */
|
2010-08-11 16:42:21 +00:00
|
|
|
fprintf(of, "%s\n", gai->comment);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* write the arrow and frame label*/
|
|
|
|
fprintf(of, "%s", empty_header);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2009-08-12 00:02:23 +00:00
|
|
|
g_string_printf(tmp_str, "%s", empty_line->str);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
g_string_truncate(tmp_str2, 0);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_position<end_position) {
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(tmp_str2, item_width-2, '-');
|
|
|
|
g_string_append_c(tmp_str2, '>');
|
|
|
|
}
|
|
|
|
else{
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_printf(tmp_str2, "<");
|
2005-09-21 03:28:22 +00:00
|
|
|
enlarge_string(tmp_str2, item_width-1, '-');
|
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
overwrite(tmp_str, tmp_str2->str,
|
2005-09-21 03:28:22 +00:00
|
|
|
start_position,
|
|
|
|
end_position
|
|
|
|
);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
g_snprintf(src_port, sizeof(src_port), "(%i)", gai->port_src);
|
|
|
|
g_snprintf(dst_port, sizeof(dst_port), "(%i)", gai->port_dst);
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_position<end_position) {
|
|
|
|
overwrite(tmp_str, src_port, start_position-9, start_position-1);
|
|
|
|
overwrite(tmp_str, dst_port, end_position+1, end_position+9);
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
else{
|
2013-03-04 16:36:40 +00:00
|
|
|
overwrite(tmp_str, src_port, start_position+1, start_position+9);
|
|
|
|
overwrite(tmp_str, dst_port, end_position-9, end_position+1);
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
fprintf(of, "%s\n", tmp_str->str);
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
|
2006-03-08 07:06:42 +00:00
|
|
|
exit:
|
2005-09-21 14:20:43 +00:00
|
|
|
g_string_free(label_string, TRUE);
|
|
|
|
g_string_free(empty_line, TRUE);
|
|
|
|
g_string_free(separator_line, TRUE);
|
|
|
|
g_string_free(tmp_str, TRUE);
|
|
|
|
g_string_free(tmp_str2, TRUE);
|
2011-09-22 08:46:09 +00:00
|
|
|
g_free(time_str);
|
2005-09-21 03:28:22 +00:00
|
|
|
fclose (of);
|
|
|
|
return TRUE;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* save in a file */
|
|
|
|
|
2013-05-14 21:53:57 +00:00
|
|
|
static char *
|
|
|
|
gtk_save_graph_as_plain_text_file(graph_analysis_data_t *user_data)
|
2005-04-07 09:14:35 +00:00
|
|
|
{
|
2013-05-14 21:53:57 +00:00
|
|
|
GtkWidget *save_to_file_w;
|
|
|
|
char *pathname;
|
2005-04-07 09:14:35 +00:00
|
|
|
|
2013-05-14 21:53:57 +00:00
|
|
|
save_to_file_w = file_selection_new("Wireshark: Save graph to plain text file",
|
|
|
|
GTK_WINDOW(user_data->dlg.window),
|
|
|
|
FILE_SELECTION_SAVE);
|
|
|
|
gtk_dialog_set_default_response(GTK_DIALOG(save_to_file_w),
|
|
|
|
GTK_RESPONSE_ACCEPT);
|
|
|
|
|
|
|
|
pathname = file_selection_run(save_to_file_w);
|
|
|
|
if (pathname == NULL) {
|
|
|
|
/* User cancelled or closed the dialog. */
|
|
|
|
return NULL;
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 21:53:57 +00:00
|
|
|
/* We've crosed the Rubicon; get rid of the dialog box. */
|
|
|
|
window_destroy(save_to_file_w);
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-05-14 21:53:57 +00:00
|
|
|
return pathname;
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
static void
|
2009-02-22 20:10:17 +00:00
|
|
|
on_save_bt_clicked (GtkWidget *button _U_,
|
2013-03-04 16:36:40 +00:00
|
|
|
graph_analysis_data_t *user_data)
|
2005-04-07 09:14:35 +00:00
|
|
|
{
|
2013-05-14 21:53:57 +00:00
|
|
|
char *pathname;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop until the user either selects a file or gives up.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
pathname = gtk_save_graph_as_plain_text_file(user_data);
|
|
|
|
if (pathname == NULL) {
|
|
|
|
/* User gave up. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dialog_graph_dump_to_file(pathname, user_data)) {
|
|
|
|
/* We succeeded. */
|
|
|
|
g_free(pathname);
|
|
|
|
break;
|
2009-06-01 14:00:09 +00:00
|
|
|
}
|
2013-05-14 21:53:57 +00:00
|
|
|
/* Dump failed; let the user select another file
|
|
|
|
or give up. */
|
|
|
|
g_free(pathname);
|
2009-02-22 20:10:17 +00:00
|
|
|
}
|
2005-04-07 09:14:35 +00:00
|
|
|
}
|
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void dialog_graph_draw(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2008-10-20 20:24:01 +00:00
|
|
|
guint32 i, last_item, first_item, display_items;
|
2005-09-21 03:28:22 +00:00
|
|
|
guint32 start_arrow, end_arrow, label_x, src_port_x, dst_port_x, arrow_width;
|
2008-10-20 20:24:01 +00:00
|
|
|
guint32 current_item;
|
|
|
|
guint32 left_x_border;
|
|
|
|
guint32 right_x_border;
|
|
|
|
guint32 top_y_border;
|
|
|
|
guint32 bottom_y_border;
|
2005-09-21 03:28:22 +00:00
|
|
|
graph_analysis_item_t *gai;
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
PangoLayout *layout;
|
|
|
|
PangoLayout *middle_layout;
|
|
|
|
PangoLayout *small_layout;
|
2009-11-15 20:13:08 +00:00
|
|
|
PangoFontDescription *middle_font_desc;
|
|
|
|
gint middle_font_size;
|
|
|
|
PangoFontDescription *small_font_desc;
|
|
|
|
gint small_font_size;
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
gint label_width, label_height;
|
|
|
|
guint32 draw_width, draw_height;
|
|
|
|
char label_string[MAX_COMMENT];
|
|
|
|
GList *list;
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_t *cr;
|
2012-04-14 07:36:47 +00:00
|
|
|
gchar *time_str;
|
2011-08-09 12:17:06 +00:00
|
|
|
|
2013-01-06 16:36:22 +00:00
|
|
|
#if 0
|
2011-08-09 14:32:41 +00:00
|
|
|
GdkColor *color_p, *bg_color_p;
|
2011-08-09 12:17:06 +00:00
|
|
|
GdkColor black_color = {0, 0, 0, 0};
|
|
|
|
GdkColor white_color = {0, 0xffff, 0xffff, 0xffff};
|
2011-08-03 14:54:03 +00:00
|
|
|
/* gray and soft gray colors */
|
|
|
|
GdkColor grey_color0 = {0, 0x64ff, 0x64ff, 0x64ff};
|
|
|
|
GdkColor grey_color1 = {0, 0x25ff, 0x25ff, 0x25ff};
|
|
|
|
|
2011-08-09 14:32:41 +00:00
|
|
|
/* the first color is blue to highlight the selected item */
|
|
|
|
static GdkColor background_color[MAX_NUM_COL_CONV+1] = {
|
|
|
|
{0, 0x00FF, 0x00FF, 0xFFFF},
|
|
|
|
{0, 0x90FF, 0xEEFF, 0x90FF},
|
|
|
|
{0, 0xFFFF, 0xA0FF, 0x7AFF},
|
|
|
|
{0, 0xFFFF, 0xB6FF, 0xC1FF},
|
|
|
|
{0, 0xFAFF, 0xFAFF, 0xD2FF},
|
|
|
|
{0, 0xFFFF, 0xFFFF, 0x33FF},
|
|
|
|
{0, 0x66FF, 0xCDFF, 0xAAFF},
|
|
|
|
{0, 0xE0FF, 0xFFFF, 0xFFFF},
|
|
|
|
{0, 0xB0FF, 0xC4FF, 0xDEFF},
|
|
|
|
{0, 0x87FF, 0xCEFF, 0xFAFF},
|
|
|
|
{0, 0xD3FF, 0xD3FF, 0xD3FF}
|
|
|
|
};
|
|
|
|
|
2013-01-06 16:36:22 +00:00
|
|
|
#endif
|
|
|
|
GdkRGBA *color_p, *bg_color_p;
|
|
|
|
|
|
|
|
GdkRGBA black_color = {0.0, 0.0, 0.0, 1.0}; /* Black */
|
|
|
|
GdkRGBA white_color = {1.0, 1.0, 1.0, 1.0 };
|
|
|
|
/* gray and soft gray colors */
|
|
|
|
GdkRGBA grey_color0 = {0.3945, 0.3945, 0.3945, 1.0};
|
|
|
|
GdkRGBA grey_color1 = {0.1484, 0.1484, 0.1484, 1.0};
|
|
|
|
|
|
|
|
static GdkRGBA background_color[MAX_NUM_COL_CONV+1] = {
|
2013-03-04 16:36:40 +00:00
|
|
|
/* Red, Green, Blue Alpha */
|
|
|
|
{0.0039, 0.0039, 1.0000, 1.0},
|
|
|
|
{0.5664, 0.6289, 0.5664, 1.0},
|
|
|
|
{1.0000, 0.6289, 0.4805, 1.0},
|
|
|
|
{1.0000, 0.7148, 0.7578, 1.0},
|
|
|
|
{0.9805, 0.9805, 0.8242, 1.0},
|
|
|
|
{1.0000, 1.0000, 0.2031, 1.0},
|
|
|
|
{0.4023, 0.8046, 0.6680, 1.0},
|
|
|
|
{0.8789, 1.0000, 1.0000, 1.0},
|
|
|
|
{0.6914, 0.7695, 0.8710, 1.0},
|
|
|
|
{0.8281, 0.8281, 0.8281, 1.0},
|
2013-01-06 16:36:22 +00:00
|
|
|
};
|
|
|
|
|
2011-08-09 14:53:20 +00:00
|
|
|
/* XXX can't we just set the background color ? */
|
2012-04-14 07:36:47 +00:00
|
|
|
GdkPixbuf *bg_pixbuf;
|
2011-08-03 14:54:03 +00:00
|
|
|
|
|
|
|
/* Dashed line pattern */
|
|
|
|
static const double dashed1[] = {5.0, 4.0};
|
|
|
|
static int len1 = sizeof(dashed1) / sizeof(dashed1[0]);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-02-08 00:56:22 +00:00
|
|
|
GtkAllocation draw_area_time_alloc, draw_area_alloc, draw_area_comments_alloc;
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if(!user_data->dlg.needs_redraw) {
|
2008-10-20 20:24:01 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-04-14 07:36:47 +00:00
|
|
|
|
|
|
|
bg_pixbuf = gdk_pixbuf_new_from_xpm_data(voip_bg_xpm);
|
2013-03-10 16:56:40 +00:00
|
|
|
time_str = (gchar *)g_malloc(COL_MAX_LEN);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.needs_redraw = FALSE;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-02-08 00:56:22 +00:00
|
|
|
gtk_widget_get_allocation(user_data->dlg.draw_area_time, &draw_area_time_alloc);
|
|
|
|
gtk_widget_get_allocation(user_data->dlg.draw_area, &draw_area_alloc);
|
|
|
|
gtk_widget_get_allocation(user_data->dlg.draw_area_comments, &draw_area_comments_alloc);
|
|
|
|
|
2011-08-09 12:17:06 +00:00
|
|
|
/* Clear out old plot */
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_time);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_time_alloc.width, draw_area_time_alloc.height);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, draw_area_alloc.height);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
cr = cairo_create (user_data->dlg.surface_comments);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, draw_area_comments_alloc.height);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_time) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_time);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_time_alloc.width, draw_area_time_alloc.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, draw_area_alloc.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_comments) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_comments);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, draw_area_comments_alloc.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Calculate the y border */
|
2013-03-04 16:36:40 +00:00
|
|
|
top_y_border = TOP_Y_BORDER; /* to display the node address */
|
|
|
|
bottom_y_border = BOTTOM_Y_BORDER;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
draw_height = draw_area_alloc.height-top_y_border-bottom_y_border;
|
2005-09-21 03:28:22 +00:00
|
|
|
|
|
|
|
first_item = user_data->dlg.first_item;
|
|
|
|
display_items = draw_height/ITEM_HEIGHT;
|
|
|
|
|
|
|
|
/* get the items to display and fill the matrix array */
|
|
|
|
list = g_list_first(user_data->graph_info->list);
|
|
|
|
current_item = 0;
|
|
|
|
i = 0;
|
|
|
|
while (list)
|
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
gai = (graph_analysis_item_t *)list->data;
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gai->display) {
|
2005-09-21 03:28:22 +00:00
|
|
|
if (current_item>=display_items) break; /* the item is outside the display */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (i>=first_item) {
|
2011-09-22 08:46:09 +00:00
|
|
|
user_data->dlg.items[current_item].fd = gai->fd;
|
2005-09-21 03:28:22 +00:00
|
|
|
user_data->dlg.items[current_item].port_src = gai->port_src;
|
|
|
|
user_data->dlg.items[current_item].port_dst = gai->port_dst;
|
|
|
|
/* Add "..." if the length is 50 characters */
|
|
|
|
if (strlen(gai->frame_label) > 48) {
|
|
|
|
gai->frame_label[48] = '.';
|
|
|
|
gai->frame_label[47] = '.';
|
|
|
|
gai->frame_label[46] = '.';
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
user_data->dlg.items[current_item].frame_label = gai->frame_label;
|
|
|
|
user_data->dlg.items[current_item].comment = gai->comment;
|
|
|
|
user_data->dlg.items[current_item].conv_num = gai->conv_num;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
user_data->dlg.items[current_item].src_node = gai->src_node;
|
|
|
|
user_data->dlg.items[current_item].dst_node = gai->dst_node;
|
|
|
|
user_data->dlg.items[current_item].line_style = gai->line_style;
|
|
|
|
current_item++;
|
|
|
|
}
|
|
|
|
i++;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
list = g_list_next(list);
|
|
|
|
}
|
2011-06-07 22:50:49 +00:00
|
|
|
/* in case the window is resized we might have to move the top item */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ((first_item + display_items) > user_data->num_items) {
|
2005-09-21 03:28:22 +00:00
|
|
|
if (display_items>user_data->num_items)
|
2013-03-04 16:36:40 +00:00
|
|
|
first_item = 0;
|
2005-09-21 03:28:22 +00:00
|
|
|
else
|
|
|
|
first_item = user_data->num_items - display_items;
|
|
|
|
}
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* in case there are less items than possible displayed */
|
|
|
|
display_items = current_item;
|
|
|
|
last_item = first_item+display_items-1;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-29 07:28:44 +00:00
|
|
|
/* if no items to display */
|
2012-05-29 07:27:35 +00:00
|
|
|
if (display_items == 0) {
|
|
|
|
g_free(time_str);
|
|
|
|
return;
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Calculate the x borders */
|
|
|
|
/* We use time from the last display item to calcultate the x left border */
|
2012-01-15 21:59:11 +00:00
|
|
|
#if 0
|
2012-01-15 22:09:43 +00:00
|
|
|
g_snprintf(label_string, MAX_LABEL, "%.3f", nstime_to_sec(&user_data->dlg.items[display_items-1].fd->rel_ts));
|
|
|
|
#endif
|
2011-09-22 08:46:09 +00:00
|
|
|
/* Write the time, using the same format as in th etime col */
|
|
|
|
set_fd_time(user_data->dlg.items[display_items-1].fd, time_str);
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "%s", time_str);
|
2008-10-20 20:24:01 +00:00
|
|
|
layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string);
|
2009-11-15 20:13:08 +00:00
|
|
|
middle_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string);
|
2008-10-20 20:24:01 +00:00
|
|
|
small_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2009-11-16 06:53:05 +00:00
|
|
|
middle_font_desc = pango_font_description_copy(pango_context_get_font_description(pango_layout_get_context(middle_layout)));
|
|
|
|
middle_font_size = pango_font_description_get_size(middle_font_desc);
|
2013-03-04 16:36:40 +00:00
|
|
|
pango_font_description_set_size(middle_font_desc, (gint)(middle_font_size*0.8));
|
|
|
|
pango_layout_set_font_description(middle_layout, middle_font_desc);
|
2009-11-15 20:13:08 +00:00
|
|
|
|
2009-11-16 06:53:05 +00:00
|
|
|
small_font_desc = pango_font_description_copy(pango_context_get_font_description(pango_layout_get_context(small_layout)));
|
|
|
|
small_font_size = pango_font_description_get_size(small_font_desc);
|
2013-03-04 16:36:40 +00:00
|
|
|
pango_font_description_set_size(small_font_desc, (gint)(small_font_size*0.7));
|
|
|
|
pango_layout_set_font_description(small_layout, small_font_desc);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* resize the "time" draw area */
|
2013-03-04 16:36:40 +00:00
|
|
|
left_x_border = 0;
|
2005-09-21 03:28:22 +00:00
|
|
|
user_data->dlg.left_x_border = left_x_border;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
right_x_border = 0;
|
|
|
|
draw_width = user_data->dlg.surface_width-right_x_border-left_x_border;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Paint time title background */
|
2011-08-12 12:32:18 +00:00
|
|
|
cr = cairo_create (user_data->dlg.surface_time);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_time_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
/* Paint main title background */
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
/* Paint main comment background */
|
|
|
|
cr = cairo_create (user_data->dlg.surface_comments);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
#else
|
|
|
|
/* Paint time title background */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_time) ) {
|
2011-08-09 13:08:20 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_time);
|
2011-08-09 14:53:20 +00:00
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-09 13:08:20 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_time_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2011-08-03 14:54:03 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Paint main title background */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-09 13:08:20 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2011-08-09 14:53:20 +00:00
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-09 13:08:20 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
2011-08-03 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Paint main comment background */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_comments) ) {
|
2011-08-09 13:08:20 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_comments);
|
2011-08-09 14:53:20 +00:00
|
|
|
gdk_cairo_set_source_pixbuf (cr, bg_pixbuf, 0, 0);
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
|
2011-08-09 13:08:20 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, top_y_border);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
2011-08-03 14:54:03 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Draw the word "Time" on top of time column */
|
2009-11-15 20:13:08 +00:00
|
|
|
g_snprintf(label_string, label_width, "%s", " Time");
|
2005-09-21 03:28:22 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
2008-10-20 20:24:01 +00:00
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_time);
|
|
|
|
cairo_move_to (cr, left_x_border, top_y_border/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_time)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_time);
|
|
|
|
cairo_move_to (cr, left_x_border, top_y_border/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Draw the word "Comment" on top of comment column */
|
|
|
|
g_snprintf(label_string, label_width, "%s", "Comment");
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
2008-10-20 20:24:01 +00:00
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_comments);
|
|
|
|
cairo_move_to (cr, MAX_COMMENT/2-label_width/2, top_y_border/2-((i&1)?0:label_height));
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* Paint the background items */
|
2013-03-04 16:36:40 +00:00
|
|
|
for (current_item=0; current_item<display_items; current_item++) {
|
2005-09-21 03:28:22 +00:00
|
|
|
/*select the color. if it is the selected item select blue color */
|
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2011-08-09 14:32:41 +00:00
|
|
|
bg_color_p = &background_color[0]; /* blue */
|
2005-09-21 03:28:22 +00:00
|
|
|
} else {
|
2011-08-09 14:32:41 +00:00
|
|
|
bg_color_p = &background_color[1+user_data->dlg.items[current_item].conv_num%MAX_NUM_COL_CONV];
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
/* Paint background */
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, bg_color_p);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_rectangle (cr, left_x_border, top_y_border+current_item*ITEM_HEIGHT, draw_width, ITEM_HEIGHT);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main)) {
|
2011-08-09 14:32:41 +00:00
|
|
|
/* Paint background */
|
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, bg_color_p);
|
2011-08-09 14:32:41 +00:00
|
|
|
cairo_rectangle (cr, left_x_border, top_y_border+current_item*ITEM_HEIGHT, draw_width, ITEM_HEIGHT);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
/* Draw the node names on top and the division lines */
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<user_data->num_nodes; i++) {
|
2005-09-21 03:28:22 +00:00
|
|
|
/* print the node identifiers */
|
|
|
|
/* XXX we assign 5 pixels per character in the node identity */
|
2009-03-12 07:56:42 +00:00
|
|
|
g_strlcpy(label_string, get_addr_name(&(user_data->nodes[i])), NODE_WIDTH/5);
|
2005-09-21 03:28:22 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
2008-10-20 20:24:01 +00:00
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
cairo_move_to (cr, left_x_border+NODE_WIDTH/2-label_width/2+NODE_WIDTH*i, top_y_border/2-((i&1)?0:label_height));
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
|
|
|
cairo_move_to (cr, left_x_border+NODE_WIDTH/2-label_width/2+NODE_WIDTH*i, top_y_border/2-((i&1)?0:label_height));
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
/* draw the node division lines */
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
|
|
|
|
cairo_set_dash(cr, dashed1, len1, 0);
|
|
|
|
cairo_move_to(cr, left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, top_y_border);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_line_to(cr, (left_x_border+NODE_WIDTH/2+NODE_WIDTH*i), draw_area_alloc.height-bottom_y_border);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
|
|
|
#else
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the node division lines */
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
|
|
|
|
cairo_set_dash(cr, dashed1, len1, 0);
|
|
|
|
cairo_move_to(cr, left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, top_y_border);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_line_to(cr, (left_x_border+NODE_WIDTH/2+NODE_WIDTH*i), draw_area_alloc.height-bottom_y_border);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the items */
|
2013-03-04 16:36:40 +00:00
|
|
|
for (current_item=0; current_item<display_items; current_item++) {
|
2012-01-15 22:09:43 +00:00
|
|
|
#if 0
|
2011-09-22 08:46:09 +00:00
|
|
|
/* Draw the time */
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "%.3f", nstime_to_sec(&user_data->dlg.items[current_item].fd->rel_ts));
|
2012-01-15 22:09:43 +00:00
|
|
|
#endif
|
|
|
|
/* Draw the time */
|
2011-09-22 08:46:09 +00:00
|
|
|
set_fd_time(user_data->dlg.items[current_item].fd, time_str);
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "%s", time_str);
|
2005-09-21 03:28:22 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
2008-10-20 20:24:01 +00:00
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_time);
|
|
|
|
cairo_move_to (cr, 3, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_time)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_time);
|
|
|
|
cairo_move_to (cr, 3, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-09-23 11:35:37 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/*draw the comments */
|
|
|
|
g_snprintf(label_string, MAX_COMMENT, "%s", user_data->dlg.items[current_item].comment);
|
2009-11-15 20:13:08 +00:00
|
|
|
pango_layout_set_text(middle_layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(middle_layout, &label_width, &label_height);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_comments);
|
|
|
|
cairo_move_to (cr, 2, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, middle_layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_comments)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_comments);
|
|
|
|
cairo_move_to (cr, 2, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2);
|
|
|
|
pango_cairo_show_layout (cr, middle_layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the arrow line */
|
|
|
|
start_arrow = left_x_border+(user_data->dlg.items[current_item].src_node)*NODE_WIDTH+NODE_WIDTH/2;
|
|
|
|
end_arrow = left_x_border+(user_data->dlg.items[current_item].dst_node)*NODE_WIDTH+NODE_WIDTH/2;
|
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
if (user_data->dlg.items[current_item].line_style == 2) {
|
|
|
|
/* draw a line thick */
|
|
|
|
cairo_set_line_width (cr, 2.0);
|
|
|
|
}else{
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
}
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2011-08-12 12:32:18 +00:00
|
|
|
/* draw white line */
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
}else{
|
|
|
|
/* draw black line */
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
}
|
|
|
|
cairo_move_to(cr, start_arrow, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)+0.5);
|
|
|
|
cairo_line_to(cr, end_arrow, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)+0.5);
|
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-09 08:15:04 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2006-03-08 07:06:42 +00:00
|
|
|
if (user_data->dlg.items[current_item].line_style == 2) {
|
2011-08-09 08:15:04 +00:00
|
|
|
/* draw a line thick */
|
|
|
|
cairo_set_line_width (cr, 2.0);
|
|
|
|
}else{
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
}
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2011-08-09 08:15:04 +00:00
|
|
|
/* draw white line */
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
}else{
|
|
|
|
/* draw black line */
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
2006-03-08 07:06:42 +00:00
|
|
|
}
|
2011-08-09 08:15:04 +00:00
|
|
|
cairo_move_to(cr, start_arrow, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)+0.5);
|
|
|
|
cairo_line_to(cr, end_arrow, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)+0.5);
|
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-08-09 08:15:04 +00:00
|
|
|
/* select colors */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2011-08-09 12:17:06 +00:00
|
|
|
color_p = &white_color;
|
2011-08-09 08:15:04 +00:00
|
|
|
} else {
|
2011-08-09 12:17:06 +00:00
|
|
|
color_p = &black_color;
|
2011-08-09 08:15:04 +00:00
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the arrow */
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
if (start_arrow<end_arrow)
|
|
|
|
draw_arrow(user_data->dlg.surface_main, color_p, end_arrow-WIDTH_ARROW, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)-(HEIGHT_ARROW/2), RIGHT_ARROW);
|
|
|
|
else
|
|
|
|
draw_arrow(user_data->dlg.surface_main, color_p, end_arrow, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7-(HEIGHT_ARROW/2), LEFT_ARROW);
|
|
|
|
#else
|
2005-09-21 03:28:22 +00:00
|
|
|
if (start_arrow<end_arrow)
|
2011-08-09 12:17:06 +00:00
|
|
|
draw_arrow(user_data->dlg.pixmap_main, color_p, end_arrow-WIDTH_ARROW, (top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7)-(HEIGHT_ARROW/2), RIGHT_ARROW);
|
2005-09-21 03:28:22 +00:00
|
|
|
else
|
2011-08-09 12:17:06 +00:00
|
|
|
draw_arrow(user_data->dlg.pixmap_main, color_p, end_arrow, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7-(HEIGHT_ARROW/2), LEFT_ARROW);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the frame comment */
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "%s", user_data->dlg.items[current_item].frame_label);
|
2009-11-15 20:13:08 +00:00
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_arrow<end_arrow) {
|
2005-09-21 03:28:22 +00:00
|
|
|
arrow_width = end_arrow-start_arrow;
|
|
|
|
label_x = arrow_width/2+start_arrow;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
arrow_width = start_arrow-end_arrow;
|
|
|
|
label_x = arrow_width/2+end_arrow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((int)left_x_border > ((int)label_x-(int)label_width/2))
|
|
|
|
label_x = left_x_border + label_width/2;
|
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, color_p);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_move_to (cr, label_x - label_width/2, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2-3);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, color_p);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_move_to (cr, label_x - label_width/2, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2-3);
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the source port number */
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_src);
|
|
|
|
pango_layout_set_text(small_layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(small_layout, &label_width, &label_height);
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_arrow<end_arrow) {
|
2005-09-21 03:28:22 +00:00
|
|
|
src_port_x = start_arrow - label_width - 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
src_port_x = start_arrow + 2;
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
/* select color */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-12 12:32:18 +00:00
|
|
|
} else {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-12 12:32:18 +00:00
|
|
|
}
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_move_to (cr, src_port_x, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2);
|
|
|
|
pango_cairo_show_layout (cr, small_layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
|
|
|
/* select color */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-03 14:54:03 +00:00
|
|
|
} else {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-03 14:54:03 +00:00
|
|
|
}
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_move_to (cr, src_port_x, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2);
|
|
|
|
pango_cairo_show_layout (cr, small_layout);
|
|
|
|
cairo_destroy (cr);
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the destination port number */
|
|
|
|
g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_dst);
|
|
|
|
pango_layout_set_text(small_layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(small_layout, &label_width, &label_height);
|
2013-03-04 16:36:40 +00:00
|
|
|
if (start_arrow<end_arrow) {
|
2005-09-21 03:28:22 +00:00
|
|
|
dst_port_x = end_arrow + 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dst_port_x = end_arrow - label_width - 2;
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
/* select color */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-12 12:32:18 +00:00
|
|
|
} else {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-12 12:32:18 +00:00
|
|
|
}
|
|
|
|
cairo_move_to (cr, dst_port_x, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2);
|
|
|
|
pango_cairo_show_layout (cr, small_layout);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
|
|
|
/* select color */
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item ) {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-03 14:54:03 +00:00
|
|
|
} else {
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color0);
|
2011-08-03 14:54:03 +00:00
|
|
|
}
|
|
|
|
cairo_move_to (cr, dst_port_x, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2);
|
|
|
|
pango_cairo_show_layout (cr, small_layout);
|
|
|
|
cairo_destroy (cr);
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
/* draw the div line of the selected item with soft gray*/
|
|
|
|
if ( current_item+first_item == user_data->dlg.selected_item )
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<user_data->num_nodes; i++) {
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
|
|
|
|
cairo_set_dash(cr, dashed1, len1, 0);
|
|
|
|
cairo_move_to(cr, left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_line_to(cr, (left_x_border+NODE_WIDTH/2+NODE_WIDTH*i), (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER+ITEM_HEIGHT);
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
|
|
|
#else
|
2011-08-12 20:51:53 +00:00
|
|
|
if (GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
2013-01-06 16:36:22 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &grey_color1);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
|
|
|
|
cairo_set_dash(cr, dashed1, len1, 0);
|
|
|
|
cairo_move_to(cr, left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER);
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_line_to(cr, (left_x_border+NODE_WIDTH/2+NODE_WIDTH*i), (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER+ITEM_HEIGHT);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_stroke(cr);
|
|
|
|
cairo_destroy(cr);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref(G_OBJECT(layout));
|
2011-09-22 08:46:09 +00:00
|
|
|
g_free(time_str);
|
2012-01-15 22:09:43 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* refresh the draw areas */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(user_data->dlg.draw_area_time) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area_time));
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_time, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2011-08-03 14:54:03 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_time, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_time_alloc.width, draw_area_time_alloc.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2011-02-08 00:56:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(user_data->dlg.draw_area) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area));
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_main, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2011-08-03 14:54:03 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_main, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, draw_area_alloc.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2011-02-08 00:56:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(user_data->dlg.draw_area_comments) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area_comments));
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_comments, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2011-08-03 14:54:03 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_comments, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, draw_area_comments_alloc.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2005-09-21 03:28:22 +00:00
|
|
|
|
|
|
|
/* update the v_scrollbar */
|
2011-02-08 00:56:22 +00:00
|
|
|
gtk_adjustment_set_upper(user_data->dlg.v_scrollbar_adjustment, (gdouble) user_data->num_items-1);
|
|
|
|
gtk_adjustment_set_step_increment(user_data->dlg.v_scrollbar_adjustment, 1);
|
|
|
|
gtk_adjustment_set_page_increment(user_data->dlg.v_scrollbar_adjustment, (gdouble) (last_item-first_item));
|
|
|
|
gtk_adjustment_set_page_size(user_data->dlg.v_scrollbar_adjustment, (gdouble) (last_item-first_item));
|
|
|
|
gtk_adjustment_set_value(user_data->dlg.v_scrollbar_adjustment, (gdouble) first_item);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_adjustment_changed(user_data->dlg.v_scrollbar_adjustment);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_adjustment_value_changed(user_data->dlg.v_scrollbar_adjustment);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void dialog_graph_redraw(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.needs_redraw = TRUE;
|
2008-10-20 20:24:01 +00:00
|
|
|
dialog_graph_draw(user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gboolean button_press_event(GtkWidget *widget _U_, GdkEventButton *event, gpointer data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2008-04-11 16:44:31 +00:00
|
|
|
guint32 item;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
if (event->type != GDK_BUTTON_PRESS) return TRUE;
|
|
|
|
|
|
|
|
if (event->y<TOP_Y_BORDER) return TRUE;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* get the item clicked */
|
|
|
|
item = ((guint32)event->y - TOP_Y_BORDER) / ITEM_HEIGHT;
|
2007-12-05 13:32:09 +00:00
|
|
|
if (item >= user_data->num_items) return TRUE;
|
2005-09-21 03:28:22 +00:00
|
|
|
user_data->dlg.selected_item = item + user_data->dlg.first_item;
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.needs_redraw = TRUE;
|
2005-09-21 03:28:22 +00:00
|
|
|
dialog_graph_draw(user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-09-22 08:46:09 +00:00
|
|
|
cf_goto_frame(&cfile, user_data->dlg.items[item].fd->num);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return TRUE;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2005-02-21 03:06:41 +00:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gboolean key_press_event(GtkWidget *widget _U_, GdkEventKey *event, gpointer data)
|
2005-02-21 03:06:41 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2005-03-07 19:10:21 +00:00
|
|
|
|
|
|
|
/* if there is nothing selected, just return */
|
2005-09-21 03:28:22 +00:00
|
|
|
if (user_data->dlg.selected_item == 0xFFFFFFFF) return TRUE;
|
2005-03-07 19:10:21 +00:00
|
|
|
|
2005-02-21 03:06:41 +00:00
|
|
|
/* Up arrow */
|
2013-03-04 16:36:40 +00:00
|
|
|
if (event->keyval == GDK_Up) {
|
2005-02-21 03:06:41 +00:00
|
|
|
if (user_data->dlg.selected_item == 0) return TRUE;
|
|
|
|
user_data->dlg.selected_item--;
|
2011-02-08 00:56:22 +00:00
|
|
|
if ( (user_data->dlg.selected_item<user_data->dlg.first_item) || (user_data->dlg.selected_item>user_data->dlg.first_item+gtk_adjustment_get_page_size(user_data->dlg.v_scrollbar_adjustment)) )
|
2005-02-21 03:06:41 +00:00
|
|
|
user_data->dlg.first_item = user_data->dlg.selected_item;
|
|
|
|
/* Down arrow */
|
2013-03-04 16:36:40 +00:00
|
|
|
} else if (event->keyval == GDK_Down) {
|
2005-02-21 03:06:41 +00:00
|
|
|
if (user_data->dlg.selected_item == user_data->num_items-1) return TRUE;
|
|
|
|
user_data->dlg.selected_item++;
|
2011-02-08 00:56:22 +00:00
|
|
|
if ( (user_data->dlg.selected_item<user_data->dlg.first_item) || (user_data->dlg.selected_item>user_data->dlg.first_item+gtk_adjustment_get_page_size(user_data->dlg.v_scrollbar_adjustment)) )
|
|
|
|
user_data->dlg.first_item = (guint32)user_data->dlg.selected_item-(guint32)gtk_adjustment_get_page_size(user_data->dlg.v_scrollbar_adjustment);
|
2013-03-04 16:36:40 +00:00
|
|
|
} else if (event->keyval == GDK_Left) {
|
2005-02-21 03:06:41 +00:00
|
|
|
if (user_data->dlg.first_node == 0) return TRUE;
|
|
|
|
user_data->dlg.first_node--;
|
2005-03-07 19:10:21 +00:00
|
|
|
} else return TRUE;
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.needs_redraw = TRUE;
|
2005-02-21 03:06:41 +00:00
|
|
|
dialog_graph_draw(user_data);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2011-09-22 08:46:09 +00:00
|
|
|
cf_goto_frame(&cfile, user_data->dlg.items[user_data->dlg.selected_item-user_data->dlg.first_item].fd->num);
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2005-02-21 03:06:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2011-09-23 17:29:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-24 04:53:50 +00:00
|
|
|
/****************************************************************************/
|
2011-08-24 05:37:51 +00:00
|
|
|
static gboolean draw_area_draw(GtkWidget *widget, cairo_t *cr, gpointer data)
|
2011-08-24 04:53:50 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2011-08-24 04:53:50 +00:00
|
|
|
GtkAllocation allocation;
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2011-09-23 17:33:04 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_main, 0, 0);
|
2011-09-23 17:33:04 +00:00
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_main, 0, 0);
|
2011-09-23 17:33:04 +00:00
|
|
|
#endif
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
2011-08-24 04:53:50 +00:00
|
|
|
cairo_fill (cr);
|
2005-02-21 03:06:41 +00:00
|
|
|
|
2011-08-24 04:53:50 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-09-23 17:29:01 +00:00
|
|
|
#if !GTK_CHECK_VERSION(3,0,0)
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
2012-01-14 14:47:37 +00:00
|
|
|
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event _U_, gpointer data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2012-01-14 12:52:56 +00:00
|
|
|
GtkAllocation allocation;
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
|
2011-02-08 00:56:22 +00:00
|
|
|
|
2012-01-14 12:52:56 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(widget)) {
|
2012-01-14 12:52:56 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_main, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2012-01-14 12:52:56 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_main, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return FALSE;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-09-23 17:29:01 +00:00
|
|
|
static gboolean
|
2011-09-24 00:26:58 +00:00
|
|
|
draw_area_scrolled(GtkAdjustment *adjustment _U_, gpointer data)
|
2011-09-23 17:29:01 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2011-09-23 17:29:01 +00:00
|
|
|
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area));
|
|
|
|
|
|
|
|
|
|
|
|
draw_area_draw(user_data->dlg.draw_area, cr, data);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-08-24 04:53:50 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
static gboolean draw_comments(GtkWidget *widget, cairo_t *cr, gpointer data)
|
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation allocation;
|
2011-08-24 04:53:50 +00:00
|
|
|
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
2011-09-23 17:33:04 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_comments, 0, 0);
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_comments, 0, 0);
|
2011-09-23 17:33:04 +00:00
|
|
|
#endif
|
2011-08-24 04:53:50 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-09-23 17:29:01 +00:00
|
|
|
#if !GTK_CHECK_VERSION(3,0,0)
|
2005-03-01 16:19:46 +00:00
|
|
|
/****************************************************************************/
|
2012-01-14 14:47:37 +00:00
|
|
|
static gboolean expose_event_comments(GtkWidget *widget, GdkEventExpose *event _U_, gpointer data)
|
2005-03-01 16:19:46 +00:00
|
|
|
{
|
2012-01-14 12:52:56 +00:00
|
|
|
GtkAllocation allocation;
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
|
2011-02-08 00:56:22 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(widget)) {
|
2012-01-14 12:52:56 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_comments, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_comments, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return FALSE;
|
2005-03-01 16:19:46 +00:00
|
|
|
}
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-23 17:29:01 +00:00
|
|
|
static gboolean
|
2011-09-24 00:26:58 +00:00
|
|
|
comments_area_scrolled(GtkAdjustment *adjustment _U_, gpointer data)
|
2011-09-23 17:29:01 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2011-09-23 17:29:01 +00:00
|
|
|
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area_comments));
|
|
|
|
|
|
|
|
|
|
|
|
draw_comments(user_data->dlg.draw_area_comments, cr, data);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-24 04:53:50 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
/****************************************************************************/
|
|
|
|
static gboolean draw_time(GtkWidget *widget, cairo_t *cr, gpointer data)
|
|
|
|
{
|
2013-03-24 23:03:21 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation allocation;
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2011-08-24 04:53:50 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
2011-08-24 05:37:51 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_time, 0, 0);
|
2011-08-24 04:53:50 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
#else
|
2005-06-06 14:01:04 +00:00
|
|
|
/****************************************************************************/
|
2012-01-14 14:47:37 +00:00
|
|
|
static gboolean expose_event_time(GtkWidget *widget, GdkEventExpose *event _U_, gpointer data)
|
2005-06-06 14:01:04 +00:00
|
|
|
{
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation allocation;
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(widget) ) {
|
2012-01-14 12:52:56 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_time, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#else
|
2012-01-14 12:52:56 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_time, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2012-01-14 12:52:56 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_fill (cr);
|
2011-02-08 00:56:22 +00:00
|
|
|
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return FALSE;
|
2005-06-06 14:01:04 +00:00
|
|
|
}
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation widget_alloc;
|
|
|
|
cairo_t *cr;
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.surface_main) {
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_surface_destroy (user_data->dlg.surface_main);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_main = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
}
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.pixmap_main) {
|
2011-07-14 08:11:16 +00:00
|
|
|
g_object_unref(user_data->dlg.pixmap_main);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_main = NULL;
|
2008-10-20 20:24:01 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-02-08 00:56:22 +00:00
|
|
|
gtk_widget_get_allocation(widget, &widget_alloc);
|
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
user_data->dlg.surface_main = gdk_window_create_similar_surface (gtk_widget_get_window(widget),
|
|
|
|
CAIRO_CONTENT_COLOR,
|
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height);
|
|
|
|
|
|
|
|
cr = cairo_create (user_data->dlg.surface_main);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_main = gdk_pixmap_new(gtk_widget_get_window(widget),
|
2011-02-08 00:56:22 +00:00
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height,
|
2008-10-20 20:24:01 +00:00
|
|
|
-1);
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_main);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2005-09-13 04:53:36 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return TRUE;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
2005-03-01 16:19:46 +00:00
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gboolean configure_event_comments(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer data)
|
2005-03-01 16:19:46 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation widget_alloc;
|
|
|
|
cairo_t *cr;
|
2011-02-08 00:56:22 +00:00
|
|
|
|
|
|
|
gtk_widget_get_allocation(widget, &widget_alloc);
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.surface_comments) {
|
2011-08-12 12:32:18 +00:00
|
|
|
cairo_surface_destroy (user_data->dlg.surface_comments);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_comments = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
}
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.pixmap_comments) {
|
2011-07-14 08:11:16 +00:00
|
|
|
g_object_unref(user_data->dlg.pixmap_comments);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_comments = NULL;
|
2008-10-20 20:24:01 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_comments = gdk_window_create_similar_surface (gtk_widget_get_window(widget),
|
2011-08-12 12:32:18 +00:00
|
|
|
CAIRO_CONTENT_COLOR,
|
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height);
|
|
|
|
|
|
|
|
cr = cairo_create (user_data->dlg.surface_comments);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_comments = gdk_pixmap_new(gtk_widget_get_window(widget),
|
2011-02-08 00:56:22 +00:00
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height,
|
2008-10-20 20:24:01 +00:00
|
|
|
-1);
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_main) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_comments);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-09-21 03:28:22 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2008-10-20 20:24:01 +00:00
|
|
|
return TRUE;
|
2005-03-01 16:19:46 +00:00
|
|
|
}
|
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gboolean configure_event_time(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation widget_alloc;
|
|
|
|
cairo_t *cr;
|
2011-02-08 00:56:22 +00:00
|
|
|
|
|
|
|
gtk_widget_get_allocation(widget, &widget_alloc);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.surface_time) {
|
2012-01-13 20:43:07 +00:00
|
|
|
cairo_surface_destroy (user_data->dlg.surface_time);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_time = NULL;
|
2011-08-12 12:32:18 +00:00
|
|
|
}
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
if(user_data->dlg.pixmap_time) {
|
2011-07-14 08:11:16 +00:00
|
|
|
g_object_unref(user_data->dlg.pixmap_time);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_time = NULL;
|
2008-10-20 20:24:01 +00:00
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.surface_time = gdk_window_create_similar_surface(gtk_widget_get_window(widget),
|
2011-08-12 12:32:18 +00:00
|
|
|
CAIRO_CONTENT_COLOR,
|
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height);
|
|
|
|
|
|
|
|
cr = cairo_create (user_data->dlg.surface_time);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.pixmap_time = gdk_pixmap_new(gtk_widget_get_window(widget),
|
2011-02-08 00:56:22 +00:00
|
|
|
widget_alloc.width,
|
|
|
|
widget_alloc.height,
|
2008-10-20 20:24:01 +00:00
|
|
|
-1);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if ( GDK_IS_DRAWABLE(user_data->dlg.pixmap_time) ) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (user_data->dlg.pixmap_time);
|
|
|
|
cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cr = NULL;
|
|
|
|
}
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2005-09-13 04:53:36 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
return TRUE;
|
2005-06-06 14:01:04 +00:00
|
|
|
}
|
2008-10-20 20:24:01 +00:00
|
|
|
|
2005-06-06 14:01:04 +00:00
|
|
|
/****************************************************************************/
|
2011-08-03 15:39:16 +00:00
|
|
|
static gboolean pane_callback(GtkWidget *widget _U_, GParamSpec *pspec _U_, gpointer data)
|
2005-06-06 14:01:04 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkAllocation draw_area_comments_alloc, draw_area_alloc;
|
|
|
|
cairo_t *cr;
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2013-03-24 14:10:43 +00:00
|
|
|
/* If we want to limit minimum and maximum size of graph window, we can include this code. */
|
|
|
|
#if 0
|
2011-08-12 12:32:18 +00:00
|
|
|
if (gtk_paned_get_position(GTK_PANED(user_data->dlg.hpane)) > user_data->dlg.surface_width)
|
|
|
|
gtk_paned_set_position(GTK_PANED(user_data->dlg.hpane), user_data->dlg.surface_width);
|
2005-09-21 03:28:22 +00:00
|
|
|
else if (gtk_paned_get_position(GTK_PANED(user_data->dlg.hpane)) < NODE_WIDTH*2)
|
|
|
|
gtk_paned_set_position(GTK_PANED(user_data->dlg.hpane), NODE_WIDTH*2);
|
2013-03-24 14:10:43 +00:00
|
|
|
#endif
|
2010-07-30 00:17:49 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* repaint the comment area because when moving the pane position there are times that the expose_event_comments is not called */
|
2011-02-08 00:56:22 +00:00
|
|
|
|
|
|
|
gtk_widget_get_allocation(user_data->dlg.draw_area_comments, &draw_area_comments_alloc);
|
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(user_data->dlg.draw_area_comments)) {
|
2011-08-03 14:54:03 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window(user_data->dlg.draw_area_comments));
|
2011-08-12 12:32:18 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_comments, 0, 0);
|
|
|
|
#else
|
2011-08-03 14:54:03 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_comments, 0, 0);
|
2011-08-12 12:32:18 +00:00
|
|
|
#endif
|
2011-08-03 14:54:03 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_comments_alloc.width, draw_area_comments_alloc.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2013-03-04 16:36:40 +00:00
|
|
|
/* repaint the draw area because when moving the pane position there are times that the
|
|
|
|
expose_event_comments is not called */
|
|
|
|
gtk_widget_get_allocation(user_data->dlg.draw_area, &draw_area_alloc);
|
2011-09-23 14:55:26 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
if (gtk_widget_is_drawable(user_data->dlg.draw_area)) {
|
|
|
|
cr = gdk_cairo_create(gtk_widget_get_window(user_data->dlg.draw_area));
|
2011-09-23 14:55:26 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_set_source_surface (cr, user_data->dlg.surface_main, 0, 0);
|
2011-09-23 14:55:26 +00:00
|
|
|
#else
|
2013-03-04 16:36:40 +00:00
|
|
|
gdk_cairo_set_source_pixmap (cr, user_data->dlg.pixmap_main, 0, 0);
|
2011-09-23 14:55:26 +00:00
|
|
|
#endif
|
2013-03-04 16:36:40 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, draw_area_alloc.width, draw_area_alloc.height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_destroy (cr);
|
|
|
|
}
|
2011-09-23 14:55:26 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void v_scrollbar_changed(GtkWidget *widget _U_, gpointer data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
graph_analysis_data_t *user_data = (graph_analysis_data_t *)data;
|
2009-11-15 20:13:08 +00:00
|
|
|
|
2011-02-08 00:56:22 +00:00
|
|
|
if ((user_data->dlg.first_item+gtk_adjustment_get_page_size(user_data->dlg.v_scrollbar_adjustment)+1 == user_data->num_items)
|
|
|
|
&& (gtk_adjustment_get_value(user_data->dlg.v_scrollbar_adjustment) >= user_data->dlg.first_item ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (user_data->dlg.first_item == gtk_adjustment_get_value(user_data->dlg.v_scrollbar_adjustment))
|
|
|
|
return;
|
|
|
|
|
|
|
|
user_data->dlg.first_item = (guint32) gtk_adjustment_get_value(user_data->dlg.v_scrollbar_adjustment);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
|
|
|
dialog_graph_redraw(user_data);
|
2008-10-20 20:24:01 +00:00
|
|
|
|
2010-07-30 00:17:49 +00:00
|
|
|
return;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void create_draw_area(graph_analysis_data_t *user_data, GtkWidget *box)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkWidget *hbox;
|
2013-03-24 14:10:43 +00:00
|
|
|
GtkWidget *hpane_l;
|
2013-03-04 16:36:40 +00:00
|
|
|
GtkWidget *viewport;
|
|
|
|
GtkWidget *scroll_window_comments;
|
|
|
|
GtkWidget *viewport_comments;
|
|
|
|
GtkWidget *frame_time;
|
|
|
|
GtkWidget *scroll_vbox;
|
|
|
|
GtkWidget *frame_box;
|
|
|
|
GtkRequisition scroll_requisition;
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_widget_show(hbox);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
/* create "time" draw area */
|
|
|
|
user_data->dlg.draw_area_time = gtk_drawing_area_new();
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.draw_area_time, TIME_WIDTH, user_data->dlg.surface_height);
|
2009-11-16 06:53:05 +00:00
|
|
|
frame_time = gtk_frame_new(NULL);
|
|
|
|
gtk_widget_show(frame_time);
|
2013-03-04 16:36:40 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(frame_time), user_data->dlg.draw_area_time);
|
2005-09-21 03:28:22 +00:00
|
|
|
|
|
|
|
/* create "comments" draw area */
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.draw_area_comments = gtk_drawing_area_new();
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.draw_area_comments, COMMENT_WIDTH, user_data->dlg.surface_height);
|
2013-03-04 16:36:40 +00:00
|
|
|
scroll_window_comments = gtk_scrolled_window_new(NULL, NULL);
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(scroll_window_comments, (gint)(COMMENT_WIDTH/1.5), user_data->dlg.surface_height);
|
2011-06-07 22:50:49 +00:00
|
|
|
/*
|
2010-09-02 19:23:01 +00:00
|
|
|
* Set the scrollbar policy for the horizontal and vertical scrollbars
|
|
|
|
* The policy determines when the scrollbar should appear
|
|
|
|
*/
|
2011-06-07 22:50:49 +00:00
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll_window_comments),
|
2010-09-02 19:23:01 +00:00
|
|
|
GTK_POLICY_ALWAYS, /* Policy for horizontal bar. */
|
|
|
|
GTK_POLICY_NEVER); /* Policy for vertical bar */
|
|
|
|
|
|
|
|
/* Changes the type of shadow drawn around the contents of scrolled_window. */
|
2011-06-07 22:50:49 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window_comments),
|
2010-09-02 19:23:01 +00:00
|
|
|
GTK_SHADOW_ETCHED_IN);
|
2011-06-07 22:50:49 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scroll_window_comments)),
|
2011-09-23 17:29:01 +00:00
|
|
|
"value-changed", G_CALLBACK(comments_area_scrolled), user_data);
|
|
|
|
|
|
|
|
|
2010-07-30 00:17:49 +00:00
|
|
|
viewport_comments = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scroll_window_comments)),
|
|
|
|
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll_window_comments)));
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(viewport_comments), user_data->dlg.draw_area_comments);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scroll_window_comments), viewport_comments);
|
|
|
|
gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport_comments), GTK_SHADOW_NONE);
|
|
|
|
gtk_widget_add_events (user_data->dlg.draw_area_comments, GDK_BUTTON_PRESS_MASK);
|
2010-07-30 00:17:49 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
/* create main Graph draw area */
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.draw_area = gtk_drawing_area_new();
|
2013-03-24 14:10:43 +00:00
|
|
|
/* allow a little extra space (2*NODE_WIDTH) for wide labels */
|
|
|
|
user_data->dlg.surface_width = user_data->num_nodes * NODE_WIDTH + 2*NODE_WIDTH;
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.draw_area, user_data->dlg.surface_width, user_data->dlg.surface_height);
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.scroll_window = gtk_scrolled_window_new(NULL, NULL);
|
2005-09-21 03:28:22 +00:00
|
|
|
if ( user_data->num_nodes < 6)
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*user_data->num_nodes, user_data->dlg.surface_height);
|
2005-09-21 03:28:22 +00:00
|
|
|
else
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*5, user_data->dlg.surface_height);
|
2010-09-02 19:23:01 +00:00
|
|
|
|
2011-06-07 22:50:49 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window),
|
|
|
|
GTK_POLICY_ALWAYS,
|
2010-09-02 19:23:01 +00:00
|
|
|
GTK_POLICY_NEVER);
|
|
|
|
|
2011-06-07 22:50:49 +00:00
|
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window),
|
2010-09-02 19:23:01 +00:00
|
|
|
GTK_SHADOW_ETCHED_IN);
|
2011-09-23 17:29:01 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window)),
|
2011-09-23 17:29:01 +00:00
|
|
|
"value-changed", G_CALLBACK(draw_area_scrolled), user_data);
|
|
|
|
|
|
|
|
|
2010-07-30 00:17:49 +00:00
|
|
|
viewport = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window)),
|
|
|
|
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(user_data->dlg.scroll_window)));
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(viewport), user_data->dlg.draw_area);
|
|
|
|
gtk_container_add(GTK_CONTAINER(user_data->dlg.scroll_window), viewport);
|
|
|
|
gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
|
2011-02-08 00:56:22 +00:00
|
|
|
gtk_widget_set_can_focus(user_data->dlg.draw_area, TRUE);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_grab_focus(user_data->dlg.draw_area);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* signals needed to handle backing pixmap */
|
2011-08-24 04:53:50 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
g_signal_connect(user_data->dlg.draw_area, "draw", G_CALLBACK(draw_area_draw), user_data);
|
|
|
|
#else
|
2010-07-30 00:17:49 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area, "expose_event", G_CALLBACK(expose_event), user_data);
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
2008-10-20 20:24:01 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area, "configure_event", G_CALLBACK(configure_event), user_data);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* signals needed to handle backing pixmap comments */
|
2011-08-24 04:53:50 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
g_signal_connect(user_data->dlg.draw_area_comments, "draw", G_CALLBACK(draw_comments), user_data);
|
|
|
|
#else
|
2010-07-30 00:17:49 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area_comments, "expose_event", G_CALLBACK(expose_event_comments), user_data);
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
2008-10-20 20:24:01 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area_comments, "configure_event", G_CALLBACK(configure_event_comments), user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* signals needed to handle backing pixmap time */
|
2011-08-24 04:53:50 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
g_signal_connect(user_data->dlg.draw_area_time, "draw", G_CALLBACK(draw_time), user_data);
|
|
|
|
#else
|
2010-07-30 00:17:49 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area_time, "expose_event", G_CALLBACK(expose_event_time), user_data);
|
2011-08-24 04:53:50 +00:00
|
|
|
#endif
|
2008-10-20 20:24:01 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area_time, "configure_event", G_CALLBACK(configure_event_time), user_data);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_add_events (user_data->dlg.draw_area, GDK_BUTTON_PRESS_MASK);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(user_data->dlg.draw_area, "button_press_event", G_CALLBACK(button_press_event), user_data);
|
|
|
|
g_signal_connect(user_data->dlg.draw_area, "key_press_event", G_CALLBACK(key_press_event), user_data);
|
2005-03-01 16:19:46 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(user_data->dlg.draw_area_time);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_widget_show(user_data->dlg.draw_area);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(viewport);
|
|
|
|
gtk_widget_show(user_data->dlg.draw_area_comments);
|
|
|
|
gtk_widget_show(viewport_comments);
|
|
|
|
|
|
|
|
gtk_widget_show(user_data->dlg.scroll_window);
|
|
|
|
gtk_widget_show(scroll_window_comments);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2012-04-21 20:45:35 +00:00
|
|
|
user_data->dlg.hpane = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_paned_pack1(GTK_PANED (user_data->dlg.hpane), user_data->dlg.scroll_window, FALSE, TRUE);
|
|
|
|
gtk_paned_pack2(GTK_PANED (user_data->dlg.hpane), scroll_window_comments, TRUE, TRUE);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(user_data->dlg.hpane, "notify::position", G_CALLBACK(pane_callback), user_data);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(user_data->dlg.hpane);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2013-03-24 14:10:43 +00:00
|
|
|
/* Allow the hbox with time to expand (TRUE, TRUE) */
|
|
|
|
hpane_l = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_paned_pack1(GTK_PANED (hpane_l), frame_time, FALSE, TRUE);
|
|
|
|
gtk_paned_pack2(GTK_PANED (hpane_l), user_data->dlg.hpane, TRUE, TRUE);
|
|
|
|
g_signal_connect(hpane_l, "notify::position", G_CALLBACK(pane_callback), user_data);
|
|
|
|
gtk_widget_show(hpane_l);
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), hpane_l, TRUE, TRUE, 0);
|
2005-06-06 14:01:04 +00:00
|
|
|
|
2010-07-30 00:17:49 +00:00
|
|
|
/* Create the scroll_vbox to include the vertical scroll and a box at the bottom */
|
2013-03-04 16:36:40 +00:00
|
|
|
scroll_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
2010-08-11 16:42:21 +00:00
|
|
|
gtk_widget_show(scroll_vbox);
|
2009-11-15 20:13:08 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* create the associated v_scrollbar */
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.v_scrollbar_adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 0, 0, 0);
|
|
|
|
user_data->dlg.v_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, user_data->dlg.v_scrollbar_adjustment);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_widget_show(user_data->dlg.v_scrollbar);
|
2009-11-15 20:13:08 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(scroll_vbox), user_data->dlg.v_scrollbar, TRUE, TRUE, 0);
|
2010-08-11 16:42:21 +00:00
|
|
|
g_signal_connect(user_data->dlg.v_scrollbar_adjustment, "value_changed",
|
|
|
|
G_CALLBACK(v_scrollbar_changed), user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2009-11-16 06:53:05 +00:00
|
|
|
frame_box = gtk_frame_new(NULL);
|
2011-08-17 14:05:54 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
gtk_widget_get_preferred_size(user_data->dlg.v_scrollbar, &scroll_requisition, NULL);
|
|
|
|
#else
|
2009-11-15 20:13:08 +00:00
|
|
|
gtk_widget_size_request(user_data->dlg.v_scrollbar, &scroll_requisition);
|
2011-08-17 14:05:54 +00:00
|
|
|
#endif
|
2009-11-16 06:53:05 +00:00
|
|
|
gtk_widget_set_size_request(frame_box, 1, scroll_requisition.width+2);
|
2009-11-15 20:13:08 +00:00
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(frame_box), GTK_SHADOW_NONE);
|
2009-11-16 06:53:05 +00:00
|
|
|
gtk_widget_show(frame_box);
|
|
|
|
gtk_box_pack_end(GTK_BOX(scroll_vbox), frame_box, FALSE, FALSE, 0);
|
2009-11-15 20:13:08 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(hbox), scroll_vbox, FALSE, FALSE, 3);
|
|
|
|
|
|
|
|
/* Frame around the main area */
|
2009-11-16 06:53:05 +00:00
|
|
|
frame = gtk_frame_new(NULL);
|
|
|
|
gtk_widget_show(frame);
|
2010-07-30 00:17:49 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
|
2009-11-15 20:13:08 +00:00
|
|
|
|
|
|
|
/*gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 15);*/
|
|
|
|
/*gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 15);*/
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
|
2010-07-30 00:17:49 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(box), 10);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
2005-07-17 23:12:12 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
/* PUBLIC */
|
|
|
|
/****************************************************************************/
|
2005-02-01 12:12:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void dialog_graph_create_window(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2008-10-20 20:24:01 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbuttonbox;
|
|
|
|
GtkWidget *bt_close;
|
|
|
|
GtkWidget *bt_save;
|
2013-03-04 16:36:40 +00:00
|
|
|
gchar *title_name_ptr;
|
|
|
|
gchar *win_name;
|
2007-10-08 00:31:26 +00:00
|
|
|
|
|
|
|
title_name_ptr = cf_get_display_name(&cfile);
|
2007-12-01 02:10:03 +00:00
|
|
|
win_name = g_strdup_printf("%s - Graph Analysis", title_name_ptr);
|
2012-06-03 22:03:05 +00:00
|
|
|
g_free(title_name_ptr);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* create the main window */
|
2013-03-04 16:36:40 +00:00
|
|
|
user_data->dlg.window = dlg_window_new((user_data->dlg.title)?user_data->dlg.title:win_name);
|
2009-08-17 19:10:19 +00:00
|
|
|
gtk_window_set_destroy_with_parent(GTK_WINDOW(user_data->dlg.window), TRUE);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(user_data->dlg.window), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
create_draw_area(user_data, vbox);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
/* button row */
|
2012-04-21 20:45:35 +00:00
|
|
|
hbuttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
|
2009-11-15 20:13:08 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbuttonbox, FALSE, FALSE, 10);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
|
2008-07-08 02:43:40 +00:00
|
|
|
gtk_box_set_spacing (GTK_BOX (hbuttonbox), 30);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(hbuttonbox);
|
|
|
|
|
2008-04-11 18:58:19 +00:00
|
|
|
bt_save = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS);
|
2012-07-20 15:08:27 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbuttonbox), bt_save, TRUE, TRUE, 0);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(bt_save);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(bt_save, "clicked", G_CALLBACK(on_save_bt_clicked), user_data);
|
2011-07-12 06:15:24 +00:00
|
|
|
gtk_widget_set_tooltip_text(bt_save, "Save an ASCII representation of the graph to a file");
|
2005-09-21 03:28:22 +00:00
|
|
|
|
2008-04-11 18:58:19 +00:00
|
|
|
bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
2012-07-20 15:08:27 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbuttonbox), bt_close, TRUE, TRUE, 0);
|
2011-02-08 00:56:22 +00:00
|
|
|
gtk_widget_set_can_default(bt_close, TRUE);
|
2005-09-21 03:28:22 +00:00
|
|
|
gtk_widget_show(bt_close);
|
2011-07-12 06:15:24 +00:00
|
|
|
gtk_widget_set_tooltip_text(bt_close, "Close this dialog");
|
2008-10-20 20:24:01 +00:00
|
|
|
window_set_cancel_button(user_data->dlg.window, bt_close, window_cancel_button_cb);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
g_signal_connect(user_data->dlg.window, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(user_data->dlg.window, "destroy", G_CALLBACK(on_destroy), user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
gtk_widget_show(user_data->dlg.window);
|
|
|
|
window_present(user_data->dlg.window);
|
2007-05-29 23:09:09 +00:00
|
|
|
|
|
|
|
/* Destroy our graph window with our parent if the caller specified the parent */
|
|
|
|
if(user_data->dlg.parent_w) {
|
|
|
|
gtk_window_set_transient_for(GTK_WINDOW(user_data->dlg.window),
|
|
|
|
GTK_WINDOW(user_data->dlg.parent_w));
|
2008-04-09 23:06:01 +00:00
|
|
|
/* Destruction of this child window */
|
2007-05-29 23:09:09 +00:00
|
|
|
gtk_window_set_destroy_with_parent(GTK_WINDOW(user_data->dlg.window), TRUE);
|
|
|
|
}
|
2007-10-08 00:31:26 +00:00
|
|
|
g_free(win_name);
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the index array if the node is in the array. Return -1 if there is room in the array
|
|
|
|
* and Return -2 if the array is full
|
|
|
|
*/
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static gint add_or_get_node(graph_analysis_data_t *user_data, address *node) {
|
2007-03-19 00:36:42 +00:00
|
|
|
guint i;
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2007-03-19 00:36:42 +00:00
|
|
|
if (node->type == AT_NONE) return NODE_OVERFLOW;
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2013-03-04 16:36:40 +00:00
|
|
|
for (i=0; i<MAX_NUM_NODES && i < user_data->num_nodes ; i++) {
|
2007-03-19 00:36:42 +00:00
|
|
|
if ( CMP_ADDRESS(&(user_data->nodes[i]), node) == 0 ) return i; /* it is in the array */
|
|
|
|
}
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2007-03-19 00:36:42 +00:00
|
|
|
if (i == MAX_NUM_NODES) {
|
|
|
|
return NODE_OVERFLOW;
|
|
|
|
} else {
|
|
|
|
user_data->num_nodes++;
|
2013-03-04 16:36:40 +00:00
|
|
|
COPY_ADDRESS(&(user_data->nodes[i]), node);
|
2007-03-19 00:36:42 +00:00
|
|
|
return i;
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-24 21:31:20 +00:00
|
|
|
/* Get the nodes from the list */
|
2005-02-01 12:12:35 +00:00
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
static void get_nodes(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2010-07-30 00:17:49 +00:00
|
|
|
GList *list;
|
2005-02-01 12:12:35 +00:00
|
|
|
graph_analysis_item_t *gai;
|
|
|
|
|
|
|
|
/* fill the node array */
|
|
|
|
list = g_list_first(user_data->graph_info->list);
|
|
|
|
while (list)
|
|
|
|
{
|
2013-03-10 16:56:40 +00:00
|
|
|
gai = (graph_analysis_item_t *)list->data;
|
2007-03-19 00:36:42 +00:00
|
|
|
if (gai->display) {
|
2005-02-01 12:12:35 +00:00
|
|
|
user_data->num_items++;
|
2005-09-13 04:53:36 +00:00
|
|
|
if (!user_data->dlg.inverse) {
|
2007-03-19 00:36:42 +00:00
|
|
|
gai->src_node = (guint16)add_or_get_node(user_data, &(gai->src_addr));
|
|
|
|
gai->dst_node = (guint16)add_or_get_node(user_data, &(gai->dst_addr));
|
2005-09-13 04:53:36 +00:00
|
|
|
} else {
|
2007-03-19 00:36:42 +00:00
|
|
|
gai->dst_node = (guint16)add_or_get_node(user_data, &(gai->src_addr));
|
|
|
|
gai->src_node = (guint16)add_or_get_node(user_data, &(gai->dst_addr));
|
2005-02-01 12:12:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
list = g_list_next(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
graph_analysis_data_t *graph_analysis_init(void)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
2010-07-30 00:17:49 +00:00
|
|
|
graph_analysis_data_t *user_data;
|
2005-02-01 12:12:35 +00:00
|
|
|
/* init */
|
2013-03-10 16:56:40 +00:00
|
|
|
user_data = g_new(graph_analysis_data_t,1);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
|
|
|
/* init user_data */
|
|
|
|
graph_analysis_init_dlg(user_data);
|
|
|
|
|
|
|
|
return user_data;
|
|
|
|
}
|
2005-07-17 23:12:12 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
/* PUBLIC */
|
|
|
|
/****************************************************************************/
|
2005-02-01 12:12:35 +00:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
void graph_analysis_create(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
|
|
|
/* reset the data */
|
|
|
|
graph_analysis_reset(user_data);
|
|
|
|
|
2005-02-24 21:31:20 +00:00
|
|
|
/* get nodes (each node is an address) */
|
2005-02-01 12:12:35 +00:00
|
|
|
get_nodes(user_data);
|
|
|
|
|
|
|
|
/* create the graph windows */
|
|
|
|
dialog_graph_create_window(user_data);
|
|
|
|
|
|
|
|
/* redraw the graph */
|
2005-09-21 03:28:22 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
void graph_analysis_update(graph_analysis_data_t *user_data)
|
2005-02-01 12:12:35 +00:00
|
|
|
{
|
|
|
|
/* reset the data */
|
|
|
|
graph_analysis_reset(user_data);
|
|
|
|
|
2005-02-24 21:31:20 +00:00
|
|
|
/* get nodes (each node is an address) */
|
2005-02-01 12:12:35 +00:00
|
|
|
get_nodes(user_data);
|
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
user_data->dlg.surface_width = user_data->num_nodes * NODE_WIDTH;
|
2013-03-24 14:10:43 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.draw_area, user_data->dlg.surface_width, user_data->dlg.surface_height);
|
2008-10-20 20:24:01 +00:00
|
|
|
if (user_data->num_nodes < 6)
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*user_data->num_nodes, user_data->dlg.surface_height);
|
2005-09-21 03:28:22 +00:00
|
|
|
else
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*5, user_data->dlg.surface_height);
|
From Alejandro Vaquero
- avoid the clist of the calls dlg to be refreshed multiple times when
first appear.
- destroy the Graph window when the data is not valid anymore.
- fixes an H245 packet count error
- resizing the Graph windows when is displayed (up to 5 columns).
With a change to leave static voip_calls_tapinfo_t the_tapinfo_struct =
{0, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0};
alone.
svn path=/trunk/; revision=14852
2005-07-05 05:16:28 +00:00
|
|
|
|
2005-02-01 12:12:35 +00:00
|
|
|
/* redraw the graph */
|
2005-09-21 03:28:22 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2005-02-01 12:12:35 +00:00
|
|
|
|
2005-09-21 03:28:22 +00:00
|
|
|
window_present(user_data->dlg.window);
|
2005-02-01 12:12:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-07-17 23:12:12 +00:00
|
|
|
|
2005-10-03 05:55:26 +00:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2010-07-30 00:17:49 +00:00
|
|
|
void graph_analysis_redraw(graph_analysis_data_t *user_data)
|
2005-10-03 05:55:26 +00:00
|
|
|
{
|
|
|
|
/* get nodes (each node is an address) */
|
|
|
|
get_nodes(user_data);
|
|
|
|
|
2011-08-12 12:32:18 +00:00
|
|
|
user_data->dlg.surface_width = user_data->num_nodes * NODE_WIDTH;
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.draw_area, user_data->dlg.surface_width, user_data->dlg.surface_height);
|
2008-10-20 20:24:01 +00:00
|
|
|
if (user_data->num_nodes < 6)
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*user_data->num_nodes, user_data->dlg.surface_height);
|
2008-10-20 20:24:01 +00:00
|
|
|
else
|
2012-01-14 03:56:22 +00:00
|
|
|
gtk_widget_set_size_request(user_data->dlg.scroll_window, NODE_WIDTH*5, user_data->dlg.surface_height);
|
2005-10-03 05:55:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* redraw the graph */
|
2008-05-22 15:46:27 +00:00
|
|
|
dialog_graph_redraw(user_data);
|
2005-10-03 05:55:26 +00:00
|
|
|
|
2008-10-20 20:24:01 +00:00
|
|
|
window_present(user_data->dlg.window);
|
2005-10-03 05:55:26 +00:00
|
|
|
return;
|
|
|
|
}
|