Ethereal-dev: [Ethereal-dev] Voip Graph analysis enhancement
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Alejandro Vaquero <alejandrovaquero@xxxxxxxxx>
Date: Sat, 04 Jun 2005 13:31:22 -0600
Hi List, find attached a patch to graph_analysis to:- Add a pane to contain the main graph and the comments to be able to split them
- Change the main graph area to be a scrolled_window - Change the look of the selected item to be blue with white text color - Gray color the title area- Change the conversations color to more "soft" colors (it was difficult to read in some cases before)
Regards Alejandro
Index: gtk/graph_analysis.c =================================================================== --- gtk/graph_analysis.c (revision 14550) +++ gtk/graph_analysis.c (working copy) @@ -44,6 +44,8 @@ /* in /gtk ... */ #include <gtk/gtk.h> +#include <glib-object.h> + #include <gdk/gdkkeysyms.h> #include "gtkglobals.h" @@ -76,7 +78,20 @@ static GtkWidget *save_to_file_w = NULL; +#define MAX_LABEL 50 +#define MAX_COMMENT 100 +#define ITEM_HEIGHT 20 +#define NODE_WIDTH 100 +#define TOP_Y_BORDER 40 +#define BOTTOM_Y_BORDER 0 +#define COMMENT_WIDTH 400 +#define TIME_WIDTH 50 +#define NODE_CHARS_WIDTH 20 +#define CONV_TIME_HEADER "Conv.| Time " +#define EMPTY_HEADER " | " +#define HEADER_LENGTH 16 + /****************************************************************************/ /* Reset the user_data structure */ static void graph_analysis_reset(graph_analysis_data_t* user_data) @@ -118,15 +133,16 @@ user_data->dlg.selected_item=0xFFFFFFFF; /*not item selected */ /* init dialog_graph */ user_data->dlg.needs_redraw=TRUE; + user_data->dlg.draw_area_time=NULL; user_data->dlg.draw_area=NULL; user_data->dlg.pixmap=NULL; + user_data->dlg.pixmap_time=NULL; user_data->dlg.draw_area_comments=NULL; user_data->dlg.pixmap_comments=NULL; - user_data->dlg.h_scrollbar=NULL; - user_data->dlg.h_scrollbar_adjustment=NULL; user_data->dlg.v_scrollbar=NULL; user_data->dlg.v_scrollbar_adjustment=NULL; - user_data->dlg.pixmap_width=350; + user_data->dlg.hpane=NULL; + user_data->dlg.pixmap_width = 350; user_data->dlg.pixmap_height=400; user_data->dlg.first_node=0; user_data->dlg.first_item=0; @@ -194,19 +210,6 @@ arrow_point, 3); } -#define MAX_LABEL 50 -#define MAX_COMMENT 100 -#define ITEM_HEIGHT 20 -#define NODE_WIDTH 100 -#define TOP_Y_BORDER 40 -#define BOTTOM_Y_BORDER 0 -#define COMMENT_WIDTH 400 - -#define NODE_CHARS_WIDTH 20 -#define CONV_TIME_HEADER "Conv.| Time " -#define EMPTY_HEADER " | " -#define HEADER_LENGTH 16 - /****************************************************************************/ /* adds trailing characters to complete the requested length */ /* NB: does not allocate new memory for the string, there must be enough */ @@ -565,7 +568,7 @@ /****************************************************************************/ static void dialog_graph_draw(graph_analysis_data_t* user_data) { - guint32 i, last_item, first_item, last_node, first_node, display_items, display_nodes; + guint32 i, last_item, first_item, display_items; guint32 start_arrow, end_arrow, label_x, src_port_x, dst_port_x, arrow_width; guint32 current_item; guint32 left_x_border; @@ -573,7 +576,9 @@ guint32 top_y_border; guint32 bottom_y_border; graph_analysis_item_t *gai; - gboolean display_label; + GdkGC *frame_fg_color; + GdkGC *frame_bg_color; + GdkGC *div_line_color; #if GTK_MAJOR_VERSION < 2 GdkFont *font; @@ -601,9 +606,14 @@ } user_data->dlg.needs_redraw=FALSE; - /* - * Clear out old plot - */ + /* Clear out old plt */ + gdk_draw_rectangle(user_data->dlg.pixmap_time, + user_data->dlg.draw_area_time->style->white_gc, + TRUE, + 0, 0, + user_data->dlg.draw_area_time->allocation.width, + user_data->dlg.draw_area_time->allocation.height); + gdk_draw_rectangle(user_data->dlg.pixmap, user_data->dlg.draw_area->style->white_gc, TRUE, @@ -615,8 +625,8 @@ user_data->dlg.draw_area->style->white_gc, TRUE, 0, 0, - COMMENT_WIDTH, - user_data->dlg.draw_area->allocation.height); + user_data->dlg.draw_area_comments->allocation.width, + user_data->dlg.draw_area_comments->allocation.height); /* Calculate the y border */ @@ -685,9 +695,9 @@ label_width=gdk_string_width(font, label_string); label_height=gdk_string_height(font, label_string); #else - layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area, label_string); - big_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area, label_string); - small_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area, label_string); + layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string); + big_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string); + small_layout = gtk_widget_create_pango_layout(user_data->dlg.draw_area_time, label_string); /* XXX - to prevent messages like "Couldn't load font x, falling back to y", I've changed font description from "Helvetica-Bold 8" to "Helvetica,Sans,Bold 8", this seems to be @@ -697,34 +707,96 @@ pango_layout_get_pixel_size(layout, &label_width, &label_height); #endif - left_x_border=label_width+10; + + /* resize the "time" draw area */ + WIDGET_SET_SIZE(user_data->dlg.draw_area_time, label_width + 6, user_data->dlg.pixmap_height); + gtk_widget_show(user_data->dlg.draw_area_time); + + left_x_border=3; user_data->dlg.left_x_border = left_x_border; right_x_border=2; - - /* Calculate the number of nodes to display */ draw_width=user_data->dlg.pixmap_width-right_x_border-left_x_border; - display_nodes = draw_width/NODE_WIDTH; - first_node = user_data->dlg.first_node; - /* in case the windows is resized so we have to move the left node */ - if ((first_node + display_nodes) > user_data->num_nodes){ - if (display_nodes>user_data->num_nodes) - first_node=0; - else - first_node=user_data->num_nodes - display_nodes; - } + /* Paint time title background */ + gdk_draw_rectangle(user_data->dlg.pixmap_time, + user_data->dlg.draw_area_time->style->bg_gc[2], + TRUE, + 0, + 0, + user_data->dlg.draw_area_time->allocation.width, + top_y_border); + /* Paint main title background */ + gdk_draw_rectangle(user_data->dlg.pixmap, + user_data->dlg.draw_area->style->bg_gc[2], + TRUE, + 0, + 0, + user_data->dlg.draw_area->allocation.width, + top_y_border); + /* Paint main comment background */ + gdk_draw_rectangle(user_data->dlg.pixmap_comments, + user_data->dlg.draw_area_comments->style->bg_gc[2], + TRUE, + 0, + 0, + user_data->dlg.draw_area_comments->allocation.width, + top_y_border); - /* in case there are less nodes than possible displayed */ - if (display_nodes>user_data->num_nodes) display_nodes=user_data->num_nodes; - last_node = first_node + display_nodes-1; + /* Draw the word "Time" on top of time column */ + g_snprintf(label_string, label_width, "%s", "Time"); +#if GTK_MAJOR_VERSION < 2 + label_width=gdk_string_width(font, label_string); + label_height=gdk_string_height(font, label_string); + gdk_draw_string(user_data->dlg.pixmap_time, + font, + user_data->dlg.draw_area_time->style->black_gc, + left_x_border+4, + top_y_border/2-label_height/2, + label_string); +#else + pango_layout_set_text(layout, label_string, -1); + pango_layout_get_pixel_size(layout, &label_width, &label_height); + gdk_draw_layout(user_data->dlg.pixmap_time, + user_data->dlg.draw_area_time->style->black_gc, + left_x_border, + top_y_border/2-label_height/2, + layout); +#endif + /* Draw the word "Comment" on top of comment column */ + g_snprintf(label_string, label_width, "%s", "Comment"); +#if GTK_MAJOR_VERSION < 2 + label_width=gdk_string_width(font, label_string); + label_height=gdk_string_height(font, label_string); + gdk_draw_string(user_data->dlg.pixmap_comments, + font, + user_data->dlg.draw_area_comments->style->black_gc, + MAX_COMMENT/2-label_width/2, + top_y_border/2-label_height/2, + label_string); +#else + pango_layout_set_text(layout, label_string, -1); + pango_layout_get_pixel_size(layout, &label_width, &label_height); + gdk_draw_layout(user_data->dlg.pixmap_comments, + user_data->dlg.draw_area_comments->style->black_gc, + MAX_COMMENT/2-label_width/2, + top_y_border/2-label_height/2, + layout); +#endif + /* Paint the background items */ for (current_item=0; current_item<display_items; current_item++){ + /*select the color. if it is the selected item select blue color */ + if ( current_item+first_item == user_data->dlg.selected_item ) + frame_bg_color = user_data->dlg.bg_gc[0]; + else + frame_bg_color = user_data->dlg.bg_gc[1+user_data->dlg.items[current_item].conv_num%MAX_NUM_COL_CONV]; + /* Paint background */ gdk_draw_rectangle(user_data->dlg.pixmap, - user_data->dlg.bg_gc[user_data->dlg.items[current_item].conv_num%MAX_NUM_COL_CONV], + frame_bg_color, TRUE, left_x_border, top_y_border+current_item*ITEM_HEIGHT, @@ -732,13 +804,12 @@ ITEM_HEIGHT); } - /* Draw the node names on top and the division lines */ - for (i=0; i<display_nodes; i++){ + for (i=0; i<user_data->num_nodes; i++){ /* print the node identifiers */ /* XXX we assign 5 pixels per character in the node identity */ g_snprintf(label_string, NODE_WIDTH/5, "%s", - get_addr_name(&(user_data->nodes[i+first_node]))); + get_addr_name(&(user_data->nodes[i]))); #if GTK_MAJOR_VERSION < 2 label_width=gdk_string_width(font, label_string); label_height=gdk_string_height(font, label_string); @@ -759,7 +830,7 @@ #endif /* draw the node division lines */ - gdk_draw_line(user_data->dlg.pixmap, user_data->dlg.div_line_gc, + gdk_draw_line(user_data->dlg.pixmap, user_data->dlg.div_line_gc[0], left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, top_y_border, left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, @@ -767,33 +838,29 @@ } - /* - * Draw the items - */ - - + /* Draw the items */ for (current_item=0; current_item<display_items; current_item++){ /* draw the time */ g_snprintf(label_string, MAX_LABEL, "%.3f", user_data->dlg.items[current_item].time); #if GTK_MAJOR_VERSION < 2 label_width=gdk_string_width(font, label_string); label_height=gdk_string_height(font, label_string); - gdk_draw_string(user_data->dlg.pixmap, + gdk_draw_string(user_data->dlg.pixmap_time, font, user_data->dlg.draw_area->style->black_gc, - left_x_border-label_width-4, + 3, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2+label_height/4, label_string); #else pango_layout_set_text(layout, label_string, -1); pango_layout_get_pixel_size(layout, &label_width, &label_height); - gdk_draw_layout(user_data->dlg.pixmap, + gdk_draw_layout(user_data->dlg.pixmap_time, user_data->dlg.draw_area->style->black_gc, - left_x_border-label_width-4, + 3, top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2, layout); #endif - + /*draw the comments */ g_snprintf(label_string, MAX_COMMENT, "%s", user_data->dlg.items[current_item].comment); #if GTK_MAJOR_VERSION < 2 @@ -814,204 +881,175 @@ top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2, small_layout); #endif - - /* draw the arrow an frame label*/ - display_label = FALSE; - if (user_data->dlg.items[current_item].src_node>=first_node){ - if (user_data->dlg.items[current_item].src_node<=last_node){ - start_arrow = left_x_border+(user_data->dlg.items[current_item].src_node-first_node)*NODE_WIDTH+NODE_WIDTH/2; - display_label = TRUE; - } else { - start_arrow = user_data->dlg.pixmap_width - right_x_border; - } + /* select colors */ + if ( current_item+first_item == user_data->dlg.selected_item ){ + frame_fg_color = user_data->dlg.draw_area->style->white_gc; + div_line_color = user_data->dlg.div_line_gc[1]; } else { - start_arrow = left_x_border; + frame_fg_color = user_data->dlg.draw_area->style->black_gc; + div_line_color = user_data->dlg.div_line_gc[0]; } + /* 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; - if (user_data->dlg.items[current_item].dst_node>=first_node){ - if (user_data->dlg.items[current_item].dst_node<=last_node){ - end_arrow = left_x_border+(user_data->dlg.items[current_item].dst_node-first_node)*NODE_WIDTH+NODE_WIDTH/2; - display_label = TRUE; - } else { - end_arrow = user_data->dlg.pixmap_width - right_x_border; - } - } else { - end_arrow = left_x_border; - } + gdk_draw_line(user_data->dlg.pixmap, frame_fg_color, + start_arrow, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, + end_arrow, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7); - if (start_arrow != end_arrow){ - /* draw the arrow line */ - gdk_draw_line(user_data->dlg.pixmap, user_data->dlg.draw_area->style->black_gc, + /* draw the additional line when line style is 2 pixels width */ + if (user_data->dlg.items[current_item].line_style == 2){ + gdk_draw_line(user_data->dlg.pixmap, frame_fg_color, start_arrow, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-6, end_arrow, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7); + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-6); + } - /* draw the additional line when line style is 2 pixels width */ - if (user_data->dlg.items[current_item].line_style == 2){ - gdk_draw_line(user_data->dlg.pixmap, user_data->dlg.draw_area->style->black_gc, - start_arrow, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-6, - end_arrow, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-6); - } + /* draw the arrow */ + if (start_arrow<end_arrow) + draw_arrow(user_data->dlg.pixmap, frame_fg_color, end_arrow-WIDTH_ARROW,top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, RIGHT_ARROW); + else + draw_arrow(user_data->dlg.pixmap, frame_fg_color, end_arrow+WIDTH_ARROW,top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, LEFT_ARROW); - /* draw the arrow */ - if (start_arrow<end_arrow) - draw_arrow(user_data->dlg.pixmap, user_data->dlg.draw_area->style->black_gc, end_arrow-WIDTH_ARROW,top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, RIGHT_ARROW); - else - draw_arrow(user_data->dlg.pixmap, user_data->dlg.draw_area->style->black_gc, end_arrow+WIDTH_ARROW,top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-7, LEFT_ARROW); - } - /* draw the frame comment */ - if (display_label){ - g_snprintf(label_string, MAX_LABEL, "%s", user_data->dlg.items[current_item].frame_label); + g_snprintf(label_string, MAX_LABEL, "%s", user_data->dlg.items[current_item].frame_label); #if GTK_MAJOR_VERSION < 2 - label_width=gdk_string_width(big_font, label_string); - label_height=gdk_string_height(big_font, label_string); + label_width=gdk_string_width(big_font, label_string); + label_height=gdk_string_height(big_font, label_string); #else - pango_layout_set_text(big_layout, label_string, -1); - pango_layout_get_pixel_size(big_layout, &label_width, &label_height); + pango_layout_set_text(big_layout, label_string, -1); + pango_layout_get_pixel_size(big_layout, &label_width, &label_height); #endif - - if (start_arrow<end_arrow){ - 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 (label_width>arrow_width) arrow_width = label_width; - - if (left_x_border > (label_x-label_width/2)) label_x = left_x_border + label_width/2; - - if ((user_data->dlg.pixmap_width - right_x_border) < (label_x+label_width/2)) label_x = user_data->dlg.pixmap_width - right_x_border - label_width/2; - + if (start_arrow<end_arrow){ + 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 (label_width>arrow_width) arrow_width = label_width; + + if ((int)left_x_border > ((int)label_x-(int)label_width/2)) + label_x = left_x_border + label_width/2; + #if GTK_MAJOR_VERSION < 2 - gdk_draw_string(user_data->dlg.pixmap, - big_font, - user_data->dlg.draw_area->style->black_gc, - label_x - label_width/2, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2+label_height/4-3, - label_string); + gdk_draw_string(user_data->dlg.pixmap, + big_font, + frame_fg_color, + label_x - label_width/2, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2+label_height/4-3, + label_string); #else - gdk_draw_layout(user_data->dlg.pixmap, - user_data->dlg.draw_area->style->black_gc, - label_x - label_width/2, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2-3, - big_layout); + gdk_draw_layout(user_data->dlg.pixmap, + frame_fg_color, + label_x - label_width/2, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT/2-label_height/2-3, + big_layout); #endif - /* draw the source port number */ - if ((start_arrow != left_x_border) && (start_arrow != (user_data->dlg.pixmap_width - right_x_border))){ - g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_src); + + /* draw the source port number */ + g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_src); #if GTK_MAJOR_VERSION < 2 - label_width=gdk_string_width(small_font, label_string); - label_height=gdk_string_height(small_font, label_string); + label_width=gdk_string_width(small_font, label_string); + label_height=gdk_string_height(small_font, label_string); #else - pango_layout_set_text(small_layout, label_string, -1); - pango_layout_get_pixel_size(small_layout, &label_width, &label_height); + pango_layout_set_text(small_layout, label_string, -1); + pango_layout_get_pixel_size(small_layout, &label_width, &label_height); #endif - if (start_arrow<end_arrow){ - src_port_x = start_arrow - label_width - 2; - } - else { - src_port_x = start_arrow + 2; - } + if (start_arrow<end_arrow){ + src_port_x = start_arrow - label_width - 2; + } + else { + src_port_x = start_arrow + 2; + } #if GTK_MAJOR_VERSION < 2 - gdk_draw_string(user_data->dlg.pixmap, - small_font, - user_data->dlg.div_line_gc, - src_port_x, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2+label_height/4-2, - label_string); + gdk_draw_string(user_data->dlg.pixmap, + small_font, + div_line_color, + src_port_x, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2+label_height/4-2, + label_string); #else - gdk_draw_layout(user_data->dlg.pixmap, - user_data->dlg.div_line_gc, - src_port_x, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2, - small_layout); + gdk_draw_layout(user_data->dlg.pixmap, + div_line_color, + src_port_x, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2, + small_layout); #endif - } - /* draw the destination port number */ - if ((end_arrow != left_x_border) && (end_arrow != (user_data->dlg.pixmap_width - right_x_border))){ - g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_dst); + /* draw the destination port number */ + g_snprintf(label_string, MAX_LABEL, "(%i)", user_data->dlg.items[current_item].port_dst); #if GTK_MAJOR_VERSION < 2 - label_width=gdk_string_width(small_font, label_string); - label_height=gdk_string_height(small_font, label_string); + label_width=gdk_string_width(small_font, label_string); + label_height=gdk_string_height(small_font, label_string); #else - pango_layout_set_text(small_layout, label_string, -1); - pango_layout_get_pixel_size(small_layout, &label_width, &label_height); + pango_layout_set_text(small_layout, label_string, -1); + pango_layout_get_pixel_size(small_layout, &label_width, &label_height); #endif - if (start_arrow<end_arrow){ - dst_port_x = end_arrow + 2; - } - else { - dst_port_x = end_arrow - label_width - 2; - } + if (start_arrow<end_arrow){ + dst_port_x = end_arrow + 2; + } + else { + dst_port_x = end_arrow - label_width - 2; + } #if GTK_MAJOR_VERSION < 2 - gdk_draw_string(user_data->dlg.pixmap, - small_font, - user_data->dlg.div_line_gc, - dst_port_x, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2+label_height/4-2, - label_string); + gdk_draw_string(user_data->dlg.pixmap, + small_font, + div_line_color, + dst_port_x, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2+label_height/4-2, + label_string); #else - gdk_draw_layout(user_data->dlg.pixmap, - user_data->dlg.div_line_gc, - dst_port_x, - top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2, - small_layout); + gdk_draw_layout(user_data->dlg.pixmap, + div_line_color, + dst_port_x, + top_y_border+current_item*ITEM_HEIGHT+ITEM_HEIGHT-2-label_height/2-2, + small_layout); #endif + /* draw the div line of the selected item with soft gray*/ + if ( current_item+first_item == user_data->dlg.selected_item ) + for (i=0; i<user_data->num_nodes; i++){ + gdk_draw_line(user_data->dlg.pixmap, user_data->dlg.div_line_gc[1], + left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, + (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER, + left_x_border+NODE_WIDTH/2+NODE_WIDTH*i, + (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER+ITEM_HEIGHT); } - - } } + #if GTK_MAJOR_VERSION >= 2 g_object_unref(G_OBJECT(layout)); #endif - /* draw the border on the selected item */ - if ( (user_data->dlg.selected_item != 0xFFFFFFFF) && ( (user_data->dlg.selected_item>=first_item) && (user_data->dlg.selected_item<=last_item) )){ - gdk_draw_rectangle(user_data->dlg.pixmap, user_data->dlg.draw_area->style->black_gc, - FALSE, - left_x_border-1, - (user_data->dlg.selected_item-first_item)*ITEM_HEIGHT+TOP_Y_BORDER, - user_data->dlg.pixmap_width-left_x_border-right_x_border+1, - ITEM_HEIGHT); - } + /* refresh the draw areas */ + gdk_draw_pixmap(user_data->dlg.draw_area_time->window, + user_data->dlg.draw_area_time->style->fg_gc[GTK_WIDGET_STATE(user_data->dlg.draw_area_time)], + user_data->dlg.pixmap_time, + 0, 0, + 0, 0, + user_data->dlg.draw_area_time->allocation.width, user_data->dlg.draw_area_time->allocation.height); - - /* refresh the draw areas */ gdk_draw_pixmap(user_data->dlg.draw_area->window, user_data->dlg.draw_area->style->fg_gc[GTK_WIDGET_STATE(user_data->dlg.draw_area)], user_data->dlg.pixmap, 0, 0, 0, 0, - user_data->dlg.pixmap_width, user_data->dlg.pixmap_height); + user_data->dlg.draw_area->allocation.width, user_data->dlg.draw_area->allocation.height); gdk_draw_pixmap(user_data->dlg.draw_area_comments->window, user_data->dlg.draw_area_comments->style->fg_gc[GTK_WIDGET_STATE(user_data->dlg.draw_area_comments)], user_data->dlg.pixmap_comments, 0, 0, 0, 0, - COMMENT_WIDTH, user_data->dlg.pixmap_height); + user_data->dlg.draw_area_comments->allocation.width, user_data->dlg.draw_area_comments->allocation.height); - - /* update the h_scrollbar */ - user_data->dlg.h_scrollbar_adjustment->upper=(gfloat) user_data->num_nodes-1; - user_data->dlg.h_scrollbar_adjustment->step_increment=1; - user_data->dlg.h_scrollbar_adjustment->page_increment=(gfloat) (last_node-first_node); - user_data->dlg.h_scrollbar_adjustment->page_size=(gfloat) (last_node-first_node); - user_data->dlg.h_scrollbar_adjustment->value=(gfloat) first_node; - - gtk_adjustment_changed(user_data->dlg.h_scrollbar_adjustment); - gtk_adjustment_value_changed(user_data->dlg.h_scrollbar_adjustment); - /* update the v_scrollbar */ user_data->dlg.v_scrollbar_adjustment->upper=(gfloat) user_data->num_items-1; user_data->dlg.v_scrollbar_adjustment->step_increment=1; @@ -1115,14 +1153,11 @@ } else if (event->keyval == GDK_Left){ if (user_data->dlg.first_node == 0) return TRUE; user_data->dlg.first_node--; - } else if (event->keyval == GDK_Right){ - if ((user_data->dlg.first_node+user_data->dlg.h_scrollbar_adjustment->page_size+1 == user_data->num_nodes)) return TRUE; - user_data->dlg.first_node++; } else return TRUE; user_data->dlg.needs_redraw=TRUE; dialog_graph_draw(user_data); - + cf_goto_frame(&cfile, user_data->dlg.items[user_data->dlg.selected_item-user_data->dlg.first_item].frame_num); return TRUE; @@ -1170,26 +1205,52 @@ return FALSE; } -static const GdkColor COLOR_GRAY = {0, 0x7fff, 0x7fff, 0x7fff}; +/****************************************************************************/ +static gint expose_event_time(GtkWidget *widget, GdkEventExpose *event) +{ + graph_analysis_data_t *user_data; + user_data=(graph_analysis_data_t *)OBJECT_GET_DATA(widget, "graph_analysis_data_t"); + if(!user_data){ + exit(10); + } + + + gdk_draw_pixmap(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + user_data->dlg.pixmap_time, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height); + + return FALSE; +} + /****************************************************************************/ static gint configure_event(GtkWidget *widget, GdkEventConfigure *event _U_) { graph_analysis_data_t *user_data; int i; - GdkColor color_div_line = COLOR_GRAY; - static GdkColor col[MAX_NUM_COL_CONV] = { - {0, 0x00FF, 0xFFFF, 0x00FF}, - {0, 0xFFFF, 0xFFFF, 0x00FF}, - {0, 0xFFFF, 0x00FF, 0x00FF}, - {0, 0xFFFF, 0x00FF, 0xFFFF}, + /* gray and soft gray colors */ + static GdkColor color_div_line[2] = { + {0, 0x64ff, 0x64ff, 0x64ff}, + {0, 0x7fff, 0x7fff, 0x7fff} + }; + + /* the first calor is blue to highlight the selected item */ + static GdkColor col[MAX_NUM_COL_CONV+1] = { {0, 0x00FF, 0x00FF, 0xFFFF}, - {0, 0x00FF, 0xFFFF, 0xFFFF}, - {0, 0xFFFF, 0x80FF, 0x00FF}, - {0, 0x80FF, 0x00FF, 0xFFFF}, - {0, 0x00FF, 0x80FF, 0xFFFF}, - {0, 0xFFFF, 0x00FF, 0x80FF} + {0, 0x33FF, 0xFFFF, 0x33FF}, + {0, 0x00FF, 0xCCFF, 0xCCFF}, + {0, 0x66FF, 0xFFFF, 0xFFFF}, + {0, 0x99FF, 0x66FF, 0xFFFF}, + {0, 0xFFFF, 0xFFFF, 0x33FF}, + {0, 0xCCFF, 0x99FF, 0xFFFF}, + {0, 0xCCFF, 0xFFFF, 0x33FF}, + {0, 0xFFFF, 0xCCFF, 0xCCFF}, + {0, 0xFFFF, 0x99FF, 0x66FF}, + {0, 0xFFFF, 0xFFFF, 0x99FF} }; user_data=(graph_analysis_data_t *)OBJECT_GET_DATA(widget, "graph_analysis_data_t"); @@ -1207,7 +1268,6 @@ widget->allocation.width, widget->allocation.height, -1); - user_data->dlg.pixmap_width=widget->allocation.width; user_data->dlg.pixmap_height=widget->allocation.height; gdk_draw_rectangle(user_data->dlg.pixmap, @@ -1218,21 +1278,22 @@ widget->allocation.height); /* create gc for division lines and set the line stype to dash*/ - user_data->dlg.div_line_gc=gdk_gc_new(user_data->dlg.pixmap); - gdk_gc_set_line_attributes(user_data->dlg.div_line_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0); + for (i=0; i<2; i++){ + user_data->dlg.div_line_gc[i]=gdk_gc_new(user_data->dlg.pixmap); + gdk_gc_set_line_attributes(user_data->dlg.div_line_gc[i], 1, GDK_LINE_ON_OFF_DASH, 0, 0); #if GTK_MAJOR_VERSION < 2 - colormap = gtk_widget_get_colormap (widget); - if (!gdk_color_alloc (colormap, &color_div_line)){ - g_warning ("Couldn't allocate color"); - } - gdk_gc_set_foreground(user_data->dlg.div_line_gc, &color_div_line); + colormap = gtk_widget_get_colormap (widget); + if (!gdk_color_alloc (colormap, &color_div_line[i])){ + g_warning ("Couldn't allocate color"); + } + gdk_gc_set_foreground(user_data->dlg.div_line_gc[i], &color_div_line[i]); #else - gdk_gc_set_rgb_fg_color(user_data->dlg.div_line_gc, &color_div_line); + gdk_gc_set_rgb_fg_color(user_data->dlg.div_line_gc[i], &color_div_line[i]); #endif - + } + /* create gcs for the background items */ - - for (i=0; i<MAX_NUM_COL_CONV; i++){ + for (i=0; i<MAX_NUM_COL_CONV+1; i++){ user_data->dlg.bg_gc[i]=gdk_gc_new(user_data->dlg.pixmap); #if GTK_MAJOR_VERSION < 2 colormap = gtk_widget_get_colormap (widget); @@ -1245,7 +1306,7 @@ #endif } - dialog_graph_redraw(user_data); + dialog_graph_redraw(user_data); return TRUE; } @@ -1266,7 +1327,7 @@ } user_data->dlg.pixmap_comments=gdk_pixmap_new(widget->window, - COMMENT_WIDTH, + widget->allocation.width, widget->allocation.height, -1); @@ -1274,7 +1335,7 @@ widget->style->white_gc, TRUE, 0, 0, - COMMENT_WIDTH, + widget->allocation.width, widget->allocation.height); dialog_graph_redraw(user_data); @@ -1282,23 +1343,61 @@ } /****************************************************************************/ -static gint h_scrollbar_changed(GtkWidget *widget _U_, gpointer data) +static gint configure_event_time(GtkWidget *widget, GdkEventConfigure *event _U_) { - graph_analysis_data_t *user_data=(graph_analysis_data_t *)data; + graph_analysis_data_t *user_data; - if ((user_data->dlg.first_node+user_data->dlg.h_scrollbar_adjustment->page_size+1 == user_data->num_nodes) - && (user_data->dlg.h_scrollbar_adjustment->value >= user_data->dlg.first_node )) - return TRUE; + user_data=(graph_analysis_data_t *)OBJECT_GET_DATA(widget, "graph_analysis_data_t"); - if (user_data->dlg.first_node == (guint16) user_data->dlg.h_scrollbar_adjustment->value) - return TRUE; + if(!user_data){ + exit(10); + } - user_data->dlg.first_node = (guint16) user_data->dlg.h_scrollbar_adjustment->value; + if(user_data->dlg.pixmap_time){ + gdk_pixmap_unref(user_data->dlg.pixmap_time); + user_data->dlg.pixmap_time=NULL; + } - dialog_graph_redraw(user_data); - return TRUE; + user_data->dlg.pixmap_time=gdk_pixmap_new(widget->window, + widget->allocation.width, + widget->allocation.height, + -1); + + gdk_draw_rectangle(user_data->dlg.pixmap_time, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + dialog_graph_redraw(user_data); + return TRUE; } +/****************************************************************************/ +static gint pane_callback(GtkWidget *widget, GParamSpec *pspec, gpointer data) +{ + graph_analysis_data_t *user_data=(graph_analysis_data_t *)data; + if(!user_data){ + exit(10); + } +#if GTK_MAJOR_VERSION >= 2 + if (gtk_paned_get_position(GTK_PANED(user_data->dlg.hpane)) > user_data->dlg.pixmap_width) + gtk_paned_set_position(GTK_PANED(user_data->dlg.hpane), user_data->dlg.pixmap_width); + 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); +#endif + /* repaint the comment area because when moving the pane position thre are times that the expose_event_comments is not called */ + gdk_draw_pixmap(user_data->dlg.draw_area_comments->window, + user_data->dlg.draw_area_comments->style->fg_gc[GTK_WIDGET_STATE(widget)], + user_data->dlg.pixmap_comments, + 0,0, + 0,0, + user_data->dlg.draw_area_comments->allocation.width, + user_data->dlg.draw_area_comments->allocation.height); + return TRUE; +} + /****************************************************************************/ static gint v_scrollbar_changed(GtkWidget *widget _U_, gpointer data) { @@ -1323,6 +1422,9 @@ GtkWidget *hbox; GtkWidget *scroll_window; GtkWidget *viewport; + GtkWidget *scroll_window_comments; + GtkWidget *viewport_comments; + GValue value = { 0, }; hbox=gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox); @@ -1330,35 +1432,54 @@ vbox=gtk_vbox_new(FALSE, 0); gtk_widget_show(vbox); + /* create "time" draw area */ + user_data->dlg.draw_area_time=gtk_drawing_area_new(); + WIDGET_SET_SIZE(user_data->dlg.draw_area_time, TIME_WIDTH, user_data->dlg.pixmap_height); + OBJECT_SET_DATA(user_data->dlg.draw_area_time, "graph_analysis_data_t", user_data); + /* create "comments" draw area */ user_data->dlg.draw_area_comments=gtk_drawing_area_new(); WIDGET_SET_SIZE(user_data->dlg.draw_area_comments, COMMENT_WIDTH, user_data->dlg.pixmap_height); - scroll_window=gtk_scrolled_window_new(NULL, NULL); - WIDGET_SET_SIZE(scroll_window, COMMENT_WIDTH/2, user_data->dlg.pixmap_height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER); - viewport = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scroll_window)), gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll_window))); - gtk_container_add(GTK_CONTAINER(viewport), user_data->dlg.draw_area_comments); - gtk_container_add(GTK_CONTAINER(scroll_window), viewport); - gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); + scroll_window_comments=gtk_scrolled_window_new(NULL, NULL); + WIDGET_SET_SIZE(scroll_window_comments, COMMENT_WIDTH/2, user_data->dlg.pixmap_height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window_comments), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER); + 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))); + 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); OBJECT_SET_DATA(user_data->dlg.draw_area_comments, "graph_analysis_data_t", user_data); gtk_widget_add_events (user_data->dlg.draw_area_comments, GDK_BUTTON_PRESS_MASK); + #if GTK_MAJOR_VERSION >= 2 SIGNAL_CONNECT(user_data->dlg.draw_area_comments, "scroll_event", scroll_event, user_data); #endif /* create main Graph draw area */ user_data->dlg.draw_area=gtk_drawing_area_new(); + user_data->dlg.pixmap_width = user_data->num_nodes * NODE_WIDTH; + WIDGET_SET_SIZE(user_data->dlg.draw_area, user_data->dlg.pixmap_width, user_data->dlg.pixmap_height); + scroll_window=gtk_scrolled_window_new(NULL, NULL); + WIDGET_SET_SIZE(scroll_window, NODE_WIDTH*2, user_data->dlg.pixmap_height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER); + viewport = gtk_viewport_new(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scroll_window)), gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll_window))); + gtk_container_add(GTK_CONTAINER(viewport), user_data->dlg.draw_area); + gtk_container_add(GTK_CONTAINER(scroll_window), viewport); + gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); + OBJECT_SET_DATA(user_data->dlg.draw_area, "graph_analysis_data_t", user_data); GTK_WIDGET_SET_FLAGS(user_data->dlg.draw_area, GTK_CAN_FOCUS); gtk_widget_grab_focus(user_data->dlg.draw_area); - OBJECT_SET_DATA(user_data->dlg.draw_area, "graph_analysis_data_t", user_data); - WIDGET_SET_SIZE(user_data->dlg.draw_area, user_data->dlg.pixmap_width, user_data->dlg.pixmap_height); /* signals needed to handle backing pixmap */ SIGNAL_CONNECT(user_data->dlg.draw_area, "expose_event", expose_event, NULL); SIGNAL_CONNECT(user_data->dlg.draw_area, "configure_event", configure_event, user_data); + /* signals needed to handle backing pixmap comments*/ SIGNAL_CONNECT(user_data->dlg.draw_area_comments, "expose_event", expose_event_comments, NULL); SIGNAL_CONNECT(user_data->dlg.draw_area_comments, "configure_event", configure_event_comments, user_data); + /* signals needed to handle backing pixmap time*/ + SIGNAL_CONNECT(user_data->dlg.draw_area_time, "expose_event", expose_event_time, NULL); + SIGNAL_CONNECT(user_data->dlg.draw_area_time, "configure_event", configure_event_time, user_data); + gtk_widget_add_events (user_data->dlg.draw_area, GDK_BUTTON_PRESS_MASK); SIGNAL_CONNECT(user_data->dlg.draw_area, "button_press_event", button_press_event, user_data); #if GTK_MAJOR_VERSION >= 2 @@ -1366,31 +1487,39 @@ #endif SIGNAL_CONNECT(user_data->dlg.draw_area, "key_press_event", key_press_event, user_data); + gtk_widget_show(user_data->dlg.draw_area_time); gtk_widget_show(user_data->dlg.draw_area); + gtk_widget_show(viewport); gtk_widget_show(user_data->dlg.draw_area_comments); - gtk_widget_show(viewport); + gtk_widget_show(viewport_comments); - gtk_box_pack_start(GTK_BOX(vbox), user_data->dlg.draw_area, TRUE, TRUE, 0); gtk_widget_show(scroll_window); + gtk_widget_show(scroll_window_comments); - /* create the associated h_scrollbar */ - user_data->dlg.h_scrollbar_adjustment=(GtkAdjustment *)gtk_adjustment_new(0,0,0,0,0,0); - user_data->dlg.h_scrollbar=gtk_hscrollbar_new(user_data->dlg.h_scrollbar_adjustment); - gtk_widget_show(user_data->dlg.h_scrollbar); - gtk_box_pack_end(GTK_BOX(vbox), user_data->dlg.h_scrollbar, FALSE, FALSE, 0); - SIGNAL_CONNECT(user_data->dlg.h_scrollbar_adjustment, "value_changed", h_scrollbar_changed, user_data); + gtk_box_pack_start(GTK_BOX(hbox), user_data->dlg.draw_area_time, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); + user_data->dlg.hpane = gtk_hpaned_new(); + gtk_paned_pack1(GTK_PANED (user_data->dlg.hpane), scroll_window, TRUE, TRUE); + gtk_paned_pack2(GTK_PANED (user_data->dlg.hpane), scroll_window_comments, FALSE, TRUE); - gtk_box_pack_start(GTK_BOX(hbox), scroll_window, FALSE, FALSE, 0); + SIGNAL_CONNECT(user_data->dlg.hpane, "notify::position", pane_callback, user_data); + gtk_widget_show(user_data->dlg.hpane); + + gtk_box_pack_start(GTK_BOX(hbox), user_data->dlg.hpane, TRUE, TRUE, 0); + +#if GTK_MAJOR_VERSION >= 2 + gtk_container_child_get_property(GTK_CONTAINER(user_data->dlg.hpane), scroll_window, "resize", &value); +#endif + /* create the associated v_scrollbar */ - user_data->dlg.v_scrollbar_adjustment=(GtkAdjustment *)gtk_adjustment_new(0,0,0,0,0,0); + user_data->dlg.v_scrollbar_adjustment=(GtkAdjustment *)gtk_adjustment_new(0,0,0,0,0,0); user_data->dlg.v_scrollbar=gtk_vscrollbar_new(user_data->dlg.v_scrollbar_adjustment); gtk_widget_show(user_data->dlg.v_scrollbar); gtk_box_pack_end(GTK_BOX(hbox), user_data->dlg.v_scrollbar, FALSE, FALSE, 0); SIGNAL_CONNECT(user_data->dlg.v_scrollbar_adjustment, "value_changed", v_scrollbar_changed, user_data); + gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0); } Index: gtk/graph_analysis.h =================================================================== --- gtk/graph_analysis.h (revision 14550) +++ gtk/graph_analysis.h (working copy) @@ -83,16 +83,17 @@ GtkWidget *window; gboolean needs_redraw; gint selected_row; + GtkWidget *draw_area_time; GtkWidget *draw_area; GtkWidget *draw_area_comments; + GdkPixmap *pixmap_time; GdkPixmap *pixmap; GdkPixmap *pixmap_comments; - GtkAdjustment *h_scrollbar_adjustment; - GtkWidget *h_scrollbar; GtkWidget *v_scrollbar; GtkAdjustment *v_scrollbar_adjustment; - GdkGC *div_line_gc; - GdkGC *bg_gc[MAX_NUM_COL_CONV]; + GtkWidget *hpane; + GdkGC *div_line_gc[2]; + GdkGC *bg_gc[MAX_NUM_COL_CONV+1]; int pixmap_width; int pixmap_height; guint16 first_node; /* the first node on the left to show in the screen */
- Follow-Ups:
- SV: [Ethereal-dev] Voip Graph analysis enhancement
- From: Anders Broman
- SV: [Ethereal-dev] Voip Graph analysis enhancement
- Prev by Date: [Ethereal-dev] Buildbot crash output
- Next by Date: [Ethereal-dev] Voip graph analysis "Save as" button
- Previous by thread: [Ethereal-dev] Re: yahoo messenger
- Next by thread: SV: [Ethereal-dev] Voip Graph analysis enhancement
- Index(es):