From 189a5d08183ffed5caf82d625a3b9a86bda96989 Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 4 Jan 2004 19:03:18 +0000 Subject: [PATCH] draw icon working git-svn-id: http://ltt.polymtl.ca/svn@350 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/guiControlFlow/CFV-private.h | 3 +- .../poly/lttv/modules/guiControlFlow/CFV.c | 24 +++++++--- .../poly/lttv/modules/guiControlFlow/CFV.h | 4 +- .../lttv/modules/guiControlFlow/Draw_Item.c | 6 ++- .../lttv/modules/guiControlFlow/Drawing.c | 2 + .../lttv/modules/guiControlFlow/Drawing.h | 11 ++++- .../lttv/modules/guiControlFlow/Event_Hooks.c | 44 +++++++++++++++---- .../poly/lttv/modules/guiControlFlow/module.c | 9 ++-- 8 files changed, 79 insertions(+), 24 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h index 822b194b..04fe2f56 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV-private.h @@ -6,7 +6,8 @@ struct _ControlFlowData { GtkWidget *Scrolled_Window_VC; - + MainWindow *Parent_Window; + ProcessList *Process_List; Drawing_t *Drawing; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c index 253b17bc..fa8b6a3f 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.c @@ -10,6 +10,9 @@ #include "CFV-private.h" +#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) + extern GSList *gControl_Flow_Data_List; /***************************************************************************** @@ -132,28 +135,35 @@ guicontrolflow(void) void guicontrolflow_destructor_full(ControlFlowData *Control_Flow_Data) { + g_info("CFV.c : guicontrolflow_destructor_full, %p", Control_Flow_Data); /* May already have been done by GTK window closing */ if(GTK_IS_WIDGET(Control_Flow_Data->Scrolled_Window_VC)) gtk_widget_destroy(Control_Flow_Data->Scrolled_Window_VC); - - guicontrolflow_destructor(Control_Flow_Data); + //Control_Flow_Data->Parent_Window = NULL; + //FIXME guicontrolflow_destructor(Control_Flow_Data); } +/* When this destructor is called, the widgets are already disconnected */ void guicontrolflow_destructor(ControlFlowData *Control_Flow_Data) { guint index; + g_info("CFV.c : guicontrolflow_destructor, %p", Control_Flow_Data); + g_info("%p, %p, %p", update_time_window_hook, Control_Flow_Data, Control_Flow_Data->Parent_Window); /* Process List is removed with it's widget */ //ProcessList_destroy(Control_Flow_Data->Process_List); - unreg_update_time_window(update_time_window_hook, + if(Control_Flow_Data->Parent_Window != NULL) + { + unreg_update_time_window(update_time_window_hook, Control_Flow_Data, - Control_Flow_Data->Scrolled_Window_VC->parent); + Control_Flow_Data->Parent_Window); - unreg_update_current_time(update_current_time_hook, + unreg_update_current_time(update_current_time_hook, Control_Flow_Data, - Control_Flow_Data->Scrolled_Window_VC->parent); - + Control_Flow_Data->Parent_Window); + } + g_info("CFV.c : guicontrolflow_destructor, %p", Control_Flow_Data); g_slist_remove(gControl_Flow_Data_List,Control_Flow_Data); g_free(Control_Flow_Data); } diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h index b77b632c..fa596413 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/CFV.h @@ -2,8 +2,8 @@ #define _CFV_H #include -#include "lttv/common.h" -#include "lttv/mainWindow.h" +#include +#include #include "Process_List.h" typedef struct _ControlFlowData ControlFlowData; diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c index b363b675..6a1e25bd 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Draw_Item.c @@ -37,9 +37,13 @@ * GQuark.) The habitual place for xpm icons is in * ${prefix}/share/LinuxTraceToolkit.) + position (over or under line) * - line (color, width, style) - * - Arc (can be seen as points) (color, size) + * - Arc (big points) (color, size) * - background color (color) * + * An item is a leaf of the attributes tree. It is, in that case, including + * all kind of events categories we can have. It then associates each category + * with one or more actions (drawing something) or nothing. + * * Each item has an array of hooks (hook list). Each hook represents an * operation to perform. We seek the array each time we want to * draw an item. We execute each operation in order. An operation type diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c index cacabf5c..4f6ce62a 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.c @@ -444,3 +444,5 @@ void drawing_remove_square(Drawing_t *Drawing, update_rect.height = Drawing->height - y ; gtk_widget_draw( Drawing->Drawing_Area_V, &update_rect); } + + diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h index 283a2338..dda39fb3 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Drawing.h @@ -12,10 +12,19 @@ * Copy region of the screen into another. * Modify the boundaries to reflect a scale change. (resize) * Refresh the physical screen with the pixmap - * A helper function is provided here to convert from time and process + * A helper function is provided here to convert from time to process * identifier to pixels and the contrary (will be useful for mouse selection). * Insert an empty square in the drawing, moving the bottom part. * + * Note: The last point is exactly why it would not be so easy to add the + * vertical line functionnality as in the original version of LTT. In order + * to do so, we should keep all processes in the list for the duration of + * all the trace instead of dynamically adding and removing them when we + * scroll. Another possibility is to redraw all the visible area when a new + * process is added to the list. The second solution seems more appropriate + * to me. + * + * * The pixmap used has the width of the physical window, but the height * of the shown processes. */ diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c index 4f543508..9dc103a8 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/Event_Hooks.c @@ -3,6 +3,9 @@ *****************************************************************************/ +#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) + //#define PANGO_ENABLE_BACKEND #include #include @@ -20,7 +23,7 @@ #include "CFV-private.h" -/* NOTE : no drawing data should be sent there, as the drawing widget +/* NOTE : no drawing data should be sent there, since the drawing widget * has not been initialized */ void send_test_drawing(ProcessList *Process_List, Drawing_t *Drawing, @@ -38,6 +41,11 @@ void send_test_drawing(ProcessList *Process_List, PangoFontDescription *FontDesc;// = pango_font_description_new(); gint Font_Size; + //icon + GdkBitmap *mask = g_new(GdkBitmap, 1); + GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1); + GdkGC * gc = gdk_gc_new(Pixmap); + /* Sent text data */ layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, NULL); @@ -52,14 +60,14 @@ void send_test_drawing(ProcessList *Process_List, LttTime birth; birth.tv_sec = 12000; birth.tv_nsec = 55500; - g_critical("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height); + g_info("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height); processlist_get_process_pixels(Process_List, 1, &birth, &y, &height); - g_critical("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height); + g_info("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height); drawing_draw_line( Drawing, Pixmap, x, y+(height/2), x + width, y+(height/2), @@ -84,7 +92,23 @@ void send_test_drawing(ProcessList *Process_List, y+(height/2), x + width, y+(height/2), Drawing->Drawing_Area_V->style->black_gc); - g_critical("y : %u, height : %u", y, height); + + /* Draw icon */ + icon_pixmap = gdk_pixmap_create_from_xpm(Pixmap, &mask, NULL, +// "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm"); + "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm"); + gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc); + gdk_gc_set_clip_mask(gc, mask); + gdk_draw_drawable(Pixmap, + gc, + icon_pixmap, + 0, 0, 0, 0, -1, -1); + + g_free(icon_pixmap); + g_free(mask); + g_free(gc); + + g_info("y : %u, height : %u", y, height); birth.tv_sec = 12000; birth.tv_nsec = 55700; @@ -101,7 +125,7 @@ void send_test_drawing(ProcessList *Process_List, y+(height/2), x + width, y+(height/2), Drawing->Drawing_Area_V->style->black_gc); - g_critical("y : %u, height : %u", y, height); + g_info("y : %u, height : %u", y, height); for(i=0; i<10; i++) { @@ -139,7 +163,7 @@ void send_test_drawing(ProcessList *Process_List, y+(height/2), x + width, y+(height/2), Drawing->Drawing_Area_V->style->black_gc); - g_critical("y : %u, height : %u", y, height); + g_info("y : %u, height : %u", y, height); pango_font_description_set_size(FontDesc, Font_Size); @@ -304,8 +328,10 @@ void send_test_process(ProcessList *Process_List, Drawing_t *Drawing) GtkWidget * h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key) { - g_critical("hGuiControlFlow"); + g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); ControlFlowData *Control_Flow_Data = guicontrolflow() ; + + Control_Flow_Data->Parent_Window = pmParentWindow; get_time_window(pmParentWindow, guicontrolflow_get_time_window(Control_Flow_Data)); @@ -402,7 +428,7 @@ void update_time_window_hook(void *hook_data, void *call_data) *Time_Window = *New_Time_Window; - g_critical("New time window HOOK : %u, %u to %u, %u", + g_info("New time window HOOK : %u, %u to %u, %u", Time_Window->start_time.tv_sec, Time_Window->start_time.tv_nsec, Time_Window->time_width.tv_sec, @@ -427,7 +453,7 @@ void update_current_time_hook(void *hook_data, void *call_data) LttTime* Current_Time = guicontrolflow_get_current_time(Control_Flow_Data); *Current_Time = *((LttTime*)call_data); - g_critical("New Current time HOOK : %u, %u", Current_Time->tv_sec, + g_info("New Current time HOOK : %u, %u", Current_Time->tv_sec, Current_Time->tv_nsec); /* If current time is inside time interval, just move the highlight diff --git a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c index 5ac3077e..dde25f28 100644 --- a/ltt/branches/poly/lttv/modules/guiControlFlow/module.c +++ b/ltt/branches/poly/lttv/modules/guiControlFlow/module.c @@ -17,6 +17,9 @@ * Author : Mathieu Desnoyers, June 2003 */ +#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) + #include #include #include @@ -55,7 +58,7 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { return; } - g_critical("GUI ControlFlow Viewer init()"); + g_info("GUI ControlFlow Viewer init()"); /* Register the toolbar insert button */ toolbar_item_reg(hGuiControlFlowInsert_xpm, "Insert Control Flow Viewer", @@ -68,8 +71,8 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { void destroy_walk(gpointer data, gpointer user_data) { + g_info("Walk destroy GUI Control Flow Viewer"); guicontrolflow_destructor_full((ControlFlowData*)data); - g_critical("Walk destroy GUI Control Flow Viewer"); } @@ -81,7 +84,7 @@ void destroy_walk(gpointer data, gpointer user_data) * everything that has been registered in the gtkTraceSet API. */ G_MODULE_EXPORT void destroy() { - g_critical("GUI Control Flow Viewer destroy()"); + g_info("GUI Control Flow Viewer destroy()"); int i; g_slist_foreach(gControl_Flow_Data_List, destroy_walk, NULL ); -- 2.34.1