From f16a5569e0071a47d2f658225045e8c75de1a7c6 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 12 Aug 2004 21:31:41 +0000 Subject: [PATCH] color allocation fixed git-svn-id: http://ltt.polymtl.ca/svn@719 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/lttv/modules/gui/controlflow/drawing.c | 14 ++++++++++++++ .../poly/lttv/modules/gui/controlflow/drawitem.c | 13 ++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 64abc0bd..28934be2 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -858,6 +858,12 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) gtk_widget_show(drawing->scrollbar); gtk_widget_show(drawing->hbox); + /* Allocate the colors */ + GdkColormap* colormap = gdk_colormap_get_system(); + + gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE, + TRUE, NULL); + return drawing; } @@ -865,6 +871,14 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data) void drawing_destroy(Drawing_t *drawing) { g_info("drawing_destroy %p", drawing); + + /* Free the colors */ + GdkColormap* colormap = gdk_colormap_get_system(); + + gdk_colormap_free_colors(colormap, drawing_colors, NUM_COLORS); + + + // Do not unref here, Drawing_t destroyed by it's widget. //g_object_unref( G_OBJECT(drawing->drawing_area)); if(drawing->gc != NULL) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c index 7284a2e8..f7dd664b 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c @@ -316,9 +316,8 @@ __inline gboolean draw_line( void *hook_data, void *call_data) PropertiesLine *properties = (PropertiesLine*)hook_data; DrawContext *draw_context = (DrawContext*)call_data; - //gdk_gc_set_foreground(draw_context->gc, properties->color); - gdk_gc_set_rgb_fg_color(draw_context->gc, &properties->color); - //gdk_gc_set_foreground(gc, properties->color); + gdk_gc_set_foreground(draw_context->gc, &properties->color); + //gdk_gc_set_rgb_fg_color(draw_context->gc, &properties->color); gdk_gc_set_line_attributes( draw_context->gc, properties->line_width, properties->style, @@ -363,8 +362,8 @@ __inline gboolean draw_arc( void *hook_data, void *call_data) PropertiesArc *properties = (PropertiesArc*)hook_data; DrawContext *draw_context = (DrawContext*)call_data; - //gdk_gc_set_foreground(draw_context->gc, properties->color); - gdk_gc_set_rgb_fg_color(draw_context->gc, properties->color); + gdk_gc_set_foreground(draw_context->gc, properties->color); + //gdk_gc_set_rgb_fg_color(draw_context->gc, properties->color); gint x=0, y=0; gint *offset=NULL; @@ -439,8 +438,8 @@ __inline gboolean draw_bg( void *hook_data, void *call_data) PropertiesBG *properties = (PropertiesBG*)hook_data; DrawContext *draw_context = (DrawContext*)call_data; - //gdk_gc_set_foreground(draw_context->gc, properties->color); - gdk_gc_set_rgb_fg_color(draw_context->gc, properties->color); + gdk_gc_set_foreground(draw_context->gc, properties->color); + //gdk_gc_set_rgb_fg_color(draw_context->gc, properties->color); //g_critical("DRAWING RECT : x: %i, y: %i, w:%i, h:%i, val1 :%i, val2:%i ", // draw_context->previous->over->x, -- 2.34.1