From db4f91b169792df8f53384f481e4aee60457e5dd Mon Sep 17 00:00:00 2001 From: rds <rds> Date: Fri, 5 Jun 2009 13:18:05 +0000 Subject: [PATCH] Mainly compiler warning cures, but debug removal too. --- src/zmapWindow/items/zmapWindowCanvasItem.c | 5 +- .../items/zmapWindowContainerBlock.c | 22 +- .../items/zmapWindowContainerGroup.c | 199 +++++++++++++----- .../items/zmapWindowContainerGroup.h | 11 +- .../items/zmapWindowContainerGroup_I.h | 7 +- .../items/zmapWindowContainerUtils.c | 25 +-- .../items/zmapWindowContainerUtils.h | 11 +- 7 files changed, 175 insertions(+), 105 deletions(-) diff --git a/src/zmapWindow/items/zmapWindowCanvasItem.c b/src/zmapWindow/items/zmapWindowCanvasItem.c index 5b282066f..7dfb072ff 100755 --- a/src/zmapWindow/items/zmapWindowCanvasItem.c +++ b/src/zmapWindow/items/zmapWindowCanvasItem.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 3 22:10 2009 (rds) + * Last edited: Jun 5 10:57 2009 (rds) * Created: Wed Dec 3 09:00:20 2008 (rds) - * CVS info: $Id: zmapWindowCanvasItem.c,v 1.5 2009-06-03 22:29:08 rds Exp $ + * CVS info: $Id: zmapWindowCanvasItem.c,v 1.6 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -1254,7 +1254,6 @@ static void zmap_window_canvas_item_update (FooCanvasItem *item, double i2w_dx, if(flags & ZMAP_CANVAS_UPDATE_CROP_REQUIRED) { - g_warning("canvas item cropping!"); crop_background_rectangle(canvas_item, item, bg_rect); } } diff --git a/src/zmapWindow/items/zmapWindowContainerBlock.c b/src/zmapWindow/items/zmapWindowContainerBlock.c index ba9692776..05cf6031f 100755 --- a/src/zmapWindow/items/zmapWindowContainerBlock.c +++ b/src/zmapWindow/items/zmapWindowContainerBlock.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 10:05 2009 (rds) + * Last edited: Jun 4 13:53 2009 (rds) * Created: Mon Jul 30 13:09:33 2007 (rds) - * CVS info: $Id: zmapWindowContainerBlock.c,v 1.3 2009-06-04 09:13:04 rds Exp $ + * CVS info: $Id: zmapWindowContainerBlock.c,v 1.4 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -125,8 +125,11 @@ void zmapWindowContainerBlockAddBumpedColumn(ZMapWindowContainerBlock block_data FooCanvasGroup *container) { - block_data->bumped_cols = g_list_append(block_data->bumped_cols, container) ; - + if(ZMAP_IS_CONTAINER_FEATURESET(container)) + { + block_data->bumped_cols = g_list_append(block_data->bumped_cols, container) ; + } + return ; } @@ -192,9 +195,12 @@ void zmapWindowContainerBlockMark(ZMapWindowContainerBlock container_block, (background = zmapWindowContainerGetBackground(container))) { FooCanvasGroup *parent; - GdkColor outline; double x1, x2, y1, y2; +#ifdef DEBUG_MARK_WITH_OUTLINE + GdkColor outline; + gdk_color_parse("red", &outline); +#endif /* DEBUG_MARK_WITH_OUTLINE */ parent = (FooCanvasGroup *)overlay; /* We get the current bounds of the background. It will have @@ -202,15 +208,15 @@ void zmapWindowContainerBlockMark(ZMapWindowContainerBlock container_block, * of maximising it. */ foo_canvas_item_get_bounds((FooCanvasItem *)background, &x1, &y1, &x2, &y2); - gdk_color_parse("red", &outline); - container_block->mark.start = start; container_block->mark.top_item = foo_canvas_item_new(parent, FOO_TYPE_CANVAS_RECT, +#ifdef DEBUG_MARK_WITH_OUTLINE "outline_color_gdk", &outline, "width_pixels", 1, +#endif /* DEBUG_MARK_WITH_OUTLINE */ "fill_color_gdk", mark_colour, "fill_stipple", mark_stipple, "x1", x1, @@ -224,8 +230,10 @@ void zmapWindowContainerBlockMark(ZMapWindowContainerBlock container_block, container_block->mark.bottom_item = foo_canvas_item_new(parent, FOO_TYPE_CANVAS_RECT, +#ifdef DEBUG_MARK_WITH_OUTLINE "outline_color_gdk", &outline, "width_pixels", 1, +#endif /* DEBUG_MARK_WITH_OUTLINE */ "fill_color_gdk", mark_colour, "fill_stipple", mark_stipple, "x1", x1, diff --git a/src/zmapWindow/items/zmapWindowContainerGroup.c b/src/zmapWindow/items/zmapWindowContainerGroup.c index 9776a9dfb..563e30ddf 100755 --- a/src/zmapWindow/items/zmapWindowContainerGroup.c +++ b/src/zmapWindow/items/zmapWindowContainerGroup.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 3 22:00 2009 (rds) + * Last edited: Jun 5 14:17 2009 (rds) * Created: Wed Dec 3 10:02:22 2008 (rds) - * CVS info: $Id: zmapWindowContainerGroup.c,v 1.2 2009-06-03 22:29:08 rds Exp $ + * CVS info: $Id: zmapWindowContainerGroup.c,v 1.3 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -87,8 +87,15 @@ static void zmap_window_container_update_with_crop(FooCanvasItem *item, double i2w_dx, double i2w_dy, FooCanvasPoints *itemised_scroll_region, int flags); -static void zmap_window_container_invoke_update_hooks(ZMapWindowContainerGroup container, - double x1, double y1, double x2, double y2); +static void invoke_update_hooks(ZMapWindowContainerGroup container, GSList *hooks_list, + double x1, double y1, double x2, double y2); +#ifdef NOT_IMPLEMENTED +static void zmap_window_container_invoke_pre_update_hooks(ZMapWindowContainerGroup container, + double x1, double y1, double x2, double y2); +#endif /* NOT_IMPLEMENTED */ +static void zmap_window_container_invoke_post_update_hooks(ZMapWindowContainerGroup container, + double x1, double y1, double x2, double y2); + static gint find_update_hook_cb(gconstpointer list_data, gconstpointer query_data); @@ -126,12 +133,27 @@ GType zmapWindowContainerGroupGetType(void) return group_type; } +ZMapWindowContainerGroup zmapWindowContainerGroupCreate(ZMapWindowContainerFeatures parent, + ZMapContainerLevelType level, + double child_spacing, + GdkColor *background_fill_colour, + GdkColor *background_border_colour) +{ + ZMapWindowContainerGroup container; + + container = zmapWindowContainerGroupCreateFromFoo((FooCanvasGroup *)parent, + level, child_spacing, + background_fill_colour, + background_border_colour); + + return container; +} -ZMapWindowContainerGroup zmapWindowContainerGroupCreate(FooCanvasGroup *parent, - ZMapContainerLevelType level, - double child_spacing, - GdkColor *background_fill_colour, - GdkColor *background_border_colour) +ZMapWindowContainerGroup zmapWindowContainerGroupCreateFromFoo(FooCanvasGroup *parent, + ZMapContainerLevelType level, + double child_spacing, + GdkColor *background_fill_colour, + GdkColor *background_border_colour) { ZMapWindowContainerGroup container = NULL; ZMapWindowContainerGroup parent_container = NULL; @@ -289,6 +311,52 @@ void zmapWindowContainerGroupResetBackgroundColour(ZMapWindowContainerGroup cont return ; } +#ifdef NOT_IMPLEMENTED + +/* The idea with the pre and post hooks was to allow for essentially + * what the container execute code does, but on a more permanent basis + * (every time the container is updated). I haven't got a use case for + * the pre that I can robustly test it with, so it's dead in the water + * at them moment, to be resurrected when I have. */ + +void zmapWindowContainerGroupAddPreUpdateHook(ZMapWindowContainerGroup container, + ZMapWindowContainerUpdateHook hook, + gpointer user_data) +{ + ContainerUpdateHook update_hook = NULL; + + if((update_hook = g_new0(ContainerUpdateHookStruct, 1))) + { + update_hook->hook_func = hook; + update_hook->hook_data = user_data; + + container->pre_update_hooks = g_slist_append(container->pre_update_hooks, + update_hook); + } + + return ; +} + +void zmapWindowContainerGroupRemovePreUpdateHook(ZMapWindowContainerGroup container, + ZMapWindowContainerUpdateHook hook, + gpointer user_data) +{ + ContainerUpdateHookStruct update_hook = {NULL}; + GSList *slist = NULL; + + update_hook.hook_func = hook; + update_hook.hook_data = user_data; + + if((slist = g_slist_find_custom(container->pre_update_hooks, + &update_hook, + find_update_hook_cb))) + { + g_free(slist->data); + container->pre_update_hooks = g_slist_remove(container->pre_update_hooks, slist->data); + } +} +#endif /* NOT_IMPLEMENTED */ + void zmapWindowContainerGroupAddUpdateHook(ZMapWindowContainerGroup container, ZMapWindowContainerUpdateHook hook, gpointer user_data) @@ -300,8 +368,8 @@ void zmapWindowContainerGroupAddUpdateHook(ZMapWindowContainerGroup container, update_hook->hook_func = hook; update_hook->hook_data = user_data; - container->update_hooks = g_slist_append(container->update_hooks, - update_hook); + container->post_update_hooks = g_slist_append(container->post_update_hooks, + update_hook); } return ; @@ -317,15 +385,16 @@ void zmapWindowContainerGroupRemoveUpdateHook(ZMapWindowContainerGroup container update_hook.hook_func = hook; update_hook.hook_data = user_data; - if((slist = g_slist_find_custom(container->update_hooks, + if((slist = g_slist_find_custom(container->post_update_hooks, &update_hook, find_update_hook_cb))) { g_free(slist->data); - container->update_hooks = g_slist_remove(container->update_hooks, slist->data); + container->post_update_hooks = g_slist_remove(container->post_update_hooks, slist->data); } } + ZMapWindowContainerGroup zmapWindowContainerGroupDestroy(ZMapWindowContainerGroup container) { g_object_unref(G_OBJECT(container)); @@ -571,9 +640,13 @@ static void zmap_window_container_group_destroy (GObject *object) container = (ZMapWindowContainerGroup)object; - g_slist_foreach(container->update_hooks, (GFunc)g_free, NULL); - g_slist_free(container->update_hooks); - container->update_hooks = NULL; + g_slist_foreach(container->pre_update_hooks, (GFunc)g_free, NULL); + g_slist_free(container->pre_update_hooks); + container->pre_update_hooks = NULL; + + g_slist_foreach(container->post_update_hooks, (GFunc)g_free, NULL); + g_slist_free(container->post_update_hooks); + container->post_update_hooks = NULL; if(object_class->dispose) (object_class->dispose)(object); @@ -648,7 +721,7 @@ static void crop_rectangle_to_scroll_region(gpointer rectangle_data, gpointer po iwy1 = rect->y1; iwx2 = rect->x2; iwy2 = rect->y2; - + if((scroll_region == NULL)) { /* x unused ATM */ @@ -715,12 +788,6 @@ static void zmap_window_container_scroll_region_get_item_bounds(FooCanvasItem *i return ; } -/* container update flags */ -enum - { - CONTAINER_UPDATE_CROP_REQUIRED = 1 << 3, - }; - static void zmap_window_container_update_with_crop(FooCanvasItem *item, double i2w_dx, double i2w_dy, FooCanvasPoints *itemised_scroll_region, @@ -760,7 +827,7 @@ static void zmap_window_container_update_with_crop(FooCanvasItem *item, } } - else if(flags & CONTAINER_UPDATE_CROP_REQUIRED) + else if(flags & ZMAP_CANVAS_UPDATE_CROP_REQUIRED) { if(FOO_IS_CANVAS_RE(item)) crop_rectangle_to_scroll_region((FooCanvasRE *)item, NULL); @@ -772,36 +839,57 @@ static void zmap_window_container_update_with_crop(FooCanvasItem *item, return ; } -static void zmap_window_container_invoke_update_hooks(ZMapWindowContainerGroup container, - double x1, double y1, double x2, double y2) +static void invoke_update_hooks(ZMapWindowContainerGroup container, GSList *hooks_list, + double x1, double y1, double x2, double y2) { - if(container->update_hooks) - { - FooCanvasPoints bounds; - double coords[4] = {0.0}; - GSList *hooks; - - hooks = container->update_hooks; + FooCanvasPoints bounds; + double coords[4] = {0.0}; + GSList *hooks; + + hooks = hooks_list; - coords[0] = x1; - coords[1] = y1; - coords[2] = x2; - coords[3] = y2; + coords[0] = x1; + coords[1] = y1; + coords[2] = x2; + coords[3] = y2; + + bounds.coords = &coords[0]; + bounds.ref_count = 1; + bounds.num_points = 2; + + do + { + ContainerUpdateHook update_hook; - bounds.coords = &coords[0]; - bounds.ref_count = 1; - bounds.num_points = 2; + update_hook = (ContainerUpdateHook)(hooks->data); - do - { - ContainerUpdateHook update_hook; - - update_hook = (ContainerUpdateHook)(hooks->data); - - if(update_hook->hook_func) - (update_hook->hook_func)(container, &bounds, container->level, update_hook->hook_data); - } - while((hooks = hooks->next)); + if(update_hook->hook_func) + (update_hook->hook_func)(container, &bounds, container->level, update_hook->hook_data); + } + while((hooks = hooks->next)); + + return ; +} + +#ifdef NOT_IMPLEMENTED +static void zmap_window_container_invoke_pre_update_hooks(ZMapWindowContainerGroup container, + double x1, double y1, double x2, double y2) +{ + if(container->pre_update_hooks) + { + invoke_update_hooks(container, container->pre_update_hooks, x1, y1, x2, y2); + } + + return ; +} +#endif /* NOT_IMPLEMENTED */ + +static void zmap_window_container_invoke_post_update_hooks(ZMapWindowContainerGroup container, + double x1, double y1, double x2, double y2) +{ + if(container->post_update_hooks) + { + invoke_update_hooks(container, container->post_update_hooks, x1, y1, x2, y2); } return ; @@ -973,16 +1061,16 @@ static void zmap_window_container_group_update (FooCanvasItem *item, double i2w_ parent_container->reposition_y += dy; } - zmap_window_container_invoke_update_hooks(this_container, - rect->x1, rect->y1, - rect->x2, rect->y2); + zmap_window_container_invoke_post_update_hooks(this_container, + rect->x1, rect->y1, + rect->x2, rect->y2); } /* The background needs updating now so that the canvas knows * where it is (canvas coords) for events. We are only setting * the points to match the containers bounds or within so no * need to re-update the whole tree...phew... */ - if(need_2nd_update || need_cropping) + if(need_2nd_update) { FooCanvasItem *update_items[3] = {NULL}; FooCanvasPoints scroll_region; @@ -996,9 +1084,6 @@ static void zmap_window_container_group_update (FooCanvasItem *item, double i2w_ update_items[i++] = (FooCanvasItem *)overlay; update_items[i++] = (FooCanvasItem *)underlay; - if(need_cropping) - update_flags |= CONTAINER_UPDATE_CROP_REQUIRED; - zmap_window_container_scroll_region_get_item_bounds(update_items[0], &coords[0], &coords[1], &coords[2], &coords[3]); diff --git a/src/zmapWindow/items/zmapWindowContainerGroup.h b/src/zmapWindow/items/zmapWindowContainerGroup.h index 8cf58da38..94b97b63d 100755 --- a/src/zmapWindow/items/zmapWindowContainerGroup.h +++ b/src/zmapWindow/items/zmapWindowContainerGroup.h @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 09:58 2009 (rds) + * Last edited: Jun 4 14:57 2009 (rds) * Created: Wed Dec 3 08:21:03 2008 (rds) - * CVS info: $Id: zmapWindowContainerGroup.h,v 1.3 2009-06-04 09:13:04 rds Exp $ + * CVS info: $Id: zmapWindowContainerGroup.h,v 1.4 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -129,11 +129,16 @@ typedef gboolean (* ZMapWindowContainerUpdateHook)(ZMapWindowContainerGroup grou /* Public funcs */ GType zmapWindowContainerGroupGetType(void); -ZMapWindowContainerGroup zmapWindowContainerGroupCreate(FooCanvasGroup *parent, +ZMapWindowContainerGroup zmapWindowContainerGroupCreate(ZMapWindowContainerFeatures parent, ZMapContainerLevelType level, double child_spacing, GdkColor *background_fill_colour, GdkColor *background_border_colour); +ZMapWindowContainerGroup zmapWindowContainerGroupCreateFromFoo(FooCanvasGroup *parent, + ZMapContainerLevelType level, + double child_spacing, + GdkColor *background_fill_colour, + GdkColor *background_border_colour); gboolean zmapWindowContainerSetVisibility(FooCanvasGroup *container_parent, gboolean visible); void zmapWindowContainerRequestReposition(ZMapWindowContainerGroup container); void zmapWindowContainerGroupBackgroundSize(ZMapWindowContainerGroup container, double height); diff --git a/src/zmapWindow/items/zmapWindowContainerGroup_I.h b/src/zmapWindow/items/zmapWindowContainerGroup_I.h index 3b41cbd16..8ef014ba1 100755 --- a/src/zmapWindow/items/zmapWindowContainerGroup_I.h +++ b/src/zmapWindow/items/zmapWindowContainerGroup_I.h @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 08:47 2009 (rds) + * Last edited: Jun 5 11:21 2009 (rds) * Created: Wed Dec 3 08:38:10 2008 (rds) - * CVS info: $Id: zmapWindowContainerGroup_I.h,v 1.3 2009-06-04 09:13:04 rds Exp $ + * CVS info: $Id: zmapWindowContainerGroup_I.h,v 1.4 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -82,7 +82,8 @@ typedef struct _zmapWindowContainerGroupStruct ZMapWindowStats stats; #endif - GSList *update_hooks; /* list of ContainerUpdateHooks */ + GSList *pre_update_hooks; /* list of ContainerUpdateHooks */ + GSList *post_update_hooks; /* list of ContainerUpdateHooks */ double child_spacing; double this_spacing; diff --git a/src/zmapWindow/items/zmapWindowContainerUtils.c b/src/zmapWindow/items/zmapWindowContainerUtils.c index de03126bd..6cca9482e 100755 --- a/src/zmapWindow/items/zmapWindowContainerUtils.c +++ b/src/zmapWindow/items/zmapWindowContainerUtils.c @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 09:41 2009 (rds) + * Last edited: Jun 4 15:58 2009 (rds) * Created: Tue Apr 28 16:10:46 2009 (rds) - * CVS info: $Id: zmapWindowContainerUtils.c,v 1.3 2009-06-04 09:13:04 rds Exp $ + * CVS info: $Id: zmapWindowContainerUtils.c,v 1.4 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -70,27 +70,6 @@ static void set_column_lists_cb(ZMapWindowContainerGroup container, FooCanvasPoi ZMapContainerLevelType level, gpointer user_data); -FooCanvasGroup *zmapWindowContainerCreate(FooCanvasGroup *parent, - ZMapContainerLevelType level, - double child_spacing, - GdkColor *background_fill_colour, - GdkColor *background_border_colour, - gpointer long_items) -{ - ZMapWindowContainerGroup container_group; - FooCanvasGroup *new_container = NULL; - - if((container_group = zmapWindowContainerGroupCreate(parent, level, child_spacing, - background_fill_colour, - background_border_colour))) - { - new_container = (FooCanvasGroup *)container_group; - } - - return new_container; -} - - gboolean zmapWindowContainerUtilsIsValid(FooCanvasGroup *any_group) { gboolean valid = FALSE; diff --git a/src/zmapWindow/items/zmapWindowContainerUtils.h b/src/zmapWindow/items/zmapWindowContainerUtils.h index edbf13e53..118f4f761 100755 --- a/src/zmapWindow/items/zmapWindowContainerUtils.h +++ b/src/zmapWindow/items/zmapWindowContainerUtils.h @@ -27,9 +27,9 @@ * * Exported functions: See XXXXXXXXXXXXX.h * HISTORY: - * Last edited: Jun 4 09:44 2009 (rds) + * Last edited: Jun 4 15:58 2009 (rds) * Created: Thu Apr 30 14:40:12 2009 (rds) - * CVS info: $Id: zmapWindowContainerUtils.h,v 1.3 2009-06-04 09:13:04 rds Exp $ + * CVS info: $Id: zmapWindowContainerUtils.h,v 1.4 2009-06-05 13:18:05 rds Exp $ *------------------------------------------------------------------- */ @@ -44,13 +44,6 @@ typedef void (*ZMapContainerUtilsExecFunc)(ZMapWindowContainerGroup container, ZMapContainerLevelType container_level, gpointer func_data); -FooCanvasGroup *zmapWindowContainerCreate(FooCanvasGroup *parent, - ZMapContainerLevelType level, - double child_spacing, - GdkColor *background_fill_colour, - GdkColor *background_border_colour, - gpointer long_items); - /* Check a canvas group is a valid container */ gboolean zmapWindowContainerUtilsIsValid(FooCanvasGroup *any_group); -- GitLab