From f1b6fa21b9bfb030ad838f36abf2107ae190036c Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Sun, 7 Oct 2007 01:26:26 +0000 Subject: ** Fix for bug #455862 Plugged memory leaks. 2007-10-07 Hiroyuki Ikezoe ** Fix for bug #455862 Plugged memory leaks. * gui/comp-util.c: * gui/comp-util.h:(cal_comp_util_get_n_icons): A new function to get the number of icons owned by ECalComponent. * gui/e-day-view-main-item.c: * gui/e-day-view.c: * gui/e-week-view-event-item.c: * gui/e-week-view.c: Use cal_comp_util_get_n_icons. svn path=/trunk/; revision=34359 --- calendar/gui/comp-util.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'calendar/gui/comp-util.c') diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 61f2260949..6919302b73 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -28,6 +28,8 @@ #include "calendar-config.h" #include "comp-util.h" #include "dialogs/delete-comp.h" +#include +#include "e-util/e-categories-config.h" @@ -394,3 +396,39 @@ cal_comp_memo_new_with_defaults (ECal *client) return comp; } + +/** + * cal_comp_util_get_n_icons: + * @comp: A calendar component object. + * + * Get the number of icons owned by the component. + * + * Returns: the number of icons owned by the component. + **/ +gint +cal_comp_util_get_n_icons (ECalComponent *comp) +{ + GSList *categories_list, *elem; + gint num_icons = 0; + + g_return_val_if_fail (comp != NULL, 0); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), 0); + + e_cal_component_get_categories_list (comp, &categories_list); + for (elem = categories_list; elem; elem = elem->next) { + char *category; + GdkPixmap *pixmap = NULL; + GdkBitmap *mask = NULL; + + category = (char *) elem->data; + if (e_categories_config_get_icon_for (category, &pixmap, &mask)) { + num_icons++; + g_object_unref (pixmap); + if (mask) + g_object_unref (mask); + } + } + e_cal_component_free_categories_list (categories_list); + + return num_icons; +} -- cgit v1.2.3