From 918cfb0b28bb47ae0ffd3f921e7399aa75b61530 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 8 May 2000 05:22:28 +0000 Subject: Made a minimal number of things be destroyed and recreated when updating a 2000-05-08 Christopher James Lahey * gui/minicard/e-minicard-view.c, gui/minicard/e-minicard.c, gui/minicard/e-minicard.h, gui/minicard/e-reflow-sorted.c, gui/minicard/e-reflow-sorted.h: Made a minimal number of things be destroyed and recreated when updating a field. svn path=/trunk/; revision=2904 --- widgets/e-reflow/e-reflow-sorted.c | 61 ++++++++++++++++++++++++++++++++------ widgets/e-reflow/e-reflow-sorted.h | 8 +++-- 2 files changed, 57 insertions(+), 12 deletions(-) (limited to 'widgets/e-reflow') diff --git a/widgets/e-reflow/e-reflow-sorted.c b/widgets/e-reflow/e-reflow-sorted.c index c70d7b2739..688cf87c98 100644 --- a/widgets/e-reflow/e-reflow-sorted.c +++ b/widgets/e-reflow/e-reflow-sorted.c @@ -136,8 +136,8 @@ e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) } } -void -e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id) +static GList * +e_reflow_sorted_get_list(EReflowSorted *e_reflow_sorted, const gchar *id) { if (e_reflow_sorted->string_func) { EReflow *reflow = E_REFLOW(e_reflow_sorted); @@ -146,16 +146,32 @@ e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id) GnomeCanvasItem *item = list->data; char *string = e_reflow_sorted->string_func (item); if (string && !strcmp(string, id)) { - reflow->items = g_list_remove_link(reflow->items, list); - g_list_free_1(list); - gtk_object_destroy(GTK_OBJECT(item)); - if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) { - e_canvas_item_request_reflow(item); - } - return; + return list; } } } + return NULL; +} + +void +e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id) +{ + GList *list; + GnomeCanvasItem *item = NULL; + + list = e_reflow_sorted_get_list(e_reflow_sorted, id); + if (list) + item = list->data; + + if (item) { + EReflow *reflow = E_REFLOW(e_reflow_sorted); + reflow->items = g_list_remove_link(reflow->items, list); + g_list_free_1(list); + gtk_object_destroy(GTK_OBJECT(item)); + if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) { + e_canvas_item_request_reflow(item); + } + } } void @@ -168,6 +184,33 @@ e_reflow_sorted_replace_item(EReflowSorted *e_reflow_sorted, GnomeCanvasItem *it } } +GnomeCanvasItem * +e_reflow_sorted_get_item(EReflowSorted *e_reflow_sorted, const gchar *id) +{ + GList *list; + list = e_reflow_sorted_get_list(e_reflow_sorted, id); + if (list) + return list->data; + else + return NULL; +} + +void +e_reflow_sorted_reorder_item(EReflowSorted *e_reflow_sorted, const gchar *id) +{ + GList *list; + GnomeCanvasItem *item = NULL; + + list = e_reflow_sorted_get_list(e_reflow_sorted, id); + if (list) + item = list->data; + if (item) { + EReflow *reflow = E_REFLOW(e_reflow_sorted); + reflow->items = g_list_remove_link(reflow->items, list); + g_list_free_1(list); + e_reflow_sorted_add_item(reflow, item); + } +} static void e_reflow_sorted_add_item(EReflow *reflow, GnomeCanvasItem *item) diff --git a/widgets/e-reflow/e-reflow-sorted.h b/widgets/e-reflow/e-reflow-sorted.h index 4ffec7579b..d9b4acc747 100644 --- a/widgets/e-reflow/e-reflow-sorted.h +++ b/widgets/e-reflow/e-reflow-sorted.h @@ -76,9 +76,11 @@ struct _EReflowSortedClass * should also do an ECanvas parent reflow request if its size * changes. */ -void e_reflow_sorted_remove_item (EReflowSorted *sorted, const char *id); -void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasItem *item); -GtkType e_reflow_sorted_get_type (void); +void e_reflow_sorted_remove_item (EReflowSorted *sorted, const char *id); +void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasItem *item); +void e_reflow_sorted_reorder_item (EReflowSorted *e_reflow_sorted, const gchar *id); +GnomeCanvasItem *e_reflow_sorted_get_item (EReflowSorted *e_reflow_sorted, const gchar *id); +GtkType e_reflow_sorted_get_type (void); #ifdef __cplusplus } -- cgit