X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-ui-dimming-manager.c;h=52f6cfc929a58789c32df1733a22f2c01ce03919;hb=1af71def5c36fe8e558669834ad7e5a0f55025f3;hp=c256a2aa20b72594e6a60ed32e427a22fd2d78f4;hpb=6200b3e877f1b5979d9cd75487e9bf5012ba116d;p=modest diff --git a/src/modest-ui-dimming-manager.c b/src/modest-ui-dimming-manager.c index c256a2a..52f6cfc 100644 --- a/src/modest-ui-dimming-manager.c +++ b/src/modest-ui-dimming-manager.c @@ -34,6 +34,7 @@ static void modest_ui_dimming_manager_class_init (ModestUIDimmingManagerClass *klass); static void modest_ui_dimming_manager_init (ModestUIDimmingManager *obj); static void modest_ui_dimming_manager_finalize (GObject *obj); +static void modest_ui_dimming_manager_dispose (GObject *obj); static void _process_all_rules (gpointer key, gpointer value, gpointer user_data); @@ -83,6 +84,7 @@ modest_ui_dimming_manager_class_init (ModestUIDimmingManagerClass *klass) parent_class = g_type_class_peek_parent (klass); gobject_class->finalize = modest_ui_dimming_manager_finalize; + gobject_class->dispose = modest_ui_dimming_manager_dispose; g_type_class_add_private (gobject_class, sizeof(ModestUIDimmingManagerPrivate)); } @@ -135,6 +137,24 @@ modest_ui_dimming_manager_finalize (GObject *obj) G_OBJECT_CLASS(parent_class)->finalize (obj); } +static void +modest_ui_dimming_manager_dispose (GObject *obj) +{ + ModestUIDimmingManagerPrivate *priv; + + priv = MODEST_UI_DIMMING_MANAGER_GET_PRIVATE(obj); + + if (priv->delayed_calls != NULL) { + /* Remove all pending calls */ + g_hash_table_foreach (priv->delayed_calls, + remove_all_timeouts, + NULL); + g_hash_table_remove_all (priv->delayed_calls); + } + + G_OBJECT_CLASS(parent_class)->dispose (obj); +} + ModestUIDimmingManager* modest_ui_dimming_manager_new() @@ -202,13 +222,13 @@ process_dimming_rules_delayed (gpointer data) priv = MODEST_UI_DIMMING_MANAGER_GET_PRIVATE(helper->manager); timeout_handler = g_hash_table_lookup (priv->delayed_calls, helper->name); - MODEST_DEBUG_BLOCK(g_print ("---------------------HIT %d\n", GPOINTER_TO_INT (timeout_handler));); - if (GPOINTER_TO_INT (timeout_handler) > 0) { g_source_remove (GPOINTER_TO_INT (timeout_handler)); } + gdk_threads_enter (); modest_dimming_rules_group_execute (helper->group); + gdk_threads_leave (); return FALSE; } @@ -251,7 +271,7 @@ modest_ui_dimming_manager_process_dimming_rules_group (ModestUIDimmingManager *s helper->group = group; helper->manager = g_object_ref (self); helper->name = g_strdup (group_name); - new_handler = g_timeout_add_full (G_PRIORITY_DEFAULT, 500, process_dimming_rules_delayed, + new_handler = g_timeout_add_full (G_PRIORITY_DEFAULT, 100, process_dimming_rules_delayed, helper, process_dimming_rules_delayed_destroyer); g_hash_table_insert (priv->delayed_calls, g_strdup (group_name), GINT_TO_POINTER (new_handler)); MODEST_DEBUG_BLOCK(g_print ("---------------------Adding %d\n", new_handler););