* revmoed the merge that was to fix 86564
authorVivek Sekar <viveksekar@gmail.com>
Mon, 22 Sep 2008 15:13:20 +0000 (15:13 +0000)
committerVivek Sekar <viveksekar@gmail.com>
Mon, 22 Sep 2008 15:13:20 +0000 (15:13 +0000)
pmo-diablo-r5678

src/modest-ui-actions.c
src/modest-ui-dimming-manager.c
src/modest-ui-dimming-rules.c

index 8d05b52..e3511e8 100644 (file)
@@ -4086,9 +4086,9 @@ modest_ui_actions_on_select_all (GtkAction *action,
                /* Set focuse on header view */
                gtk_widget_grab_focus (header_view);
 
+
                /* Enable window dimming management */
                modest_window_enable_dimming (MODEST_WINDOW(window));
-               modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
                modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window));
        }
 
index 3f33a2c..27384c6 100644 (file)
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "modest-debug.h"
 #include "modest-ui-dimming-manager.h"
 #include "modest-dimming-rules-group-priv.h"
 
@@ -41,7 +40,6 @@ static void _process_all_rules (gpointer key, gpointer value, gpointer user_data
 typedef struct _ModestUIDimmingManagerPrivate ModestUIDimmingManagerPrivate;
 struct _ModestUIDimmingManagerPrivate {
        GHashTable *groups_map;
-       GHashTable *delayed_calls;
 };
 
 #define MODEST_UI_DIMMING_MANAGER_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
@@ -98,10 +96,6 @@ modest_ui_dimming_manager_init (ModestUIDimmingManager *obj)
                                                  (GEqualFunc) g_str_equal,
                                                  (GDestroyNotify) g_free,
                                                  (GDestroyNotify) g_object_unref);
-       priv->delayed_calls = g_hash_table_new_full (g_str_hash,
-                                                    g_str_equal,
-                                                    g_free,
-                                                    NULL);
 }
 
 static void
@@ -112,10 +106,7 @@ modest_ui_dimming_manager_finalize (GObject *obj)
        priv = MODEST_UI_DIMMING_MANAGER_GET_PRIVATE(obj);
 
        if (priv->groups_map != NULL)
-               g_hash_table_unref (priv->groups_map);
-
-       if (priv->delayed_calls != NULL)
-               g_hash_table_unref (priv->delayed_calls);
+               g_hash_table_destroy (priv->groups_map);
 
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
@@ -168,56 +159,12 @@ modest_ui_dimming_manager_process_dimming_rules (ModestUIDimmingManager *self)
        g_hash_table_foreach (priv->groups_map, _process_all_rules, NULL);
 }
 
-typedef struct
-{
-       ModestDimmingRulesGroup *group;
-       ModestUIDimmingManager *manager;
-       gchar *name;
-} DelayedDimmingRules;
-
-static gboolean
-process_dimming_rules_delayed (gpointer data)
-{
-       DelayedDimmingRules *helper = (DelayedDimmingRules *) data;
-       gpointer timeout_handler;
-       ModestUIDimmingManagerPrivate *priv;
-
-       /* We remove the timeout here because the execute action could
-          take too much time, and so this will be called again */
-       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));
-       }
-
-       modest_dimming_rules_group_execute (helper->group);
-
-       return FALSE;
-}
-
-static void
-process_dimming_rules_delayed_destroyer (gpointer data)
-{
-       DelayedDimmingRules *helper = (DelayedDimmingRules *) data;
-       ModestUIDimmingManagerPrivate *priv;
-
-       priv = MODEST_UI_DIMMING_MANAGER_GET_PRIVATE(helper->manager);
-       g_hash_table_remove (priv->delayed_calls, helper->name);
-       g_free (helper->name);
-       g_slice_free (DelayedDimmingRules, helper);
-}
-
 void
 modest_ui_dimming_manager_process_dimming_rules_group (ModestUIDimmingManager *self,
                                                       const gchar *group_name)
 {
        ModestDimmingRulesGroup *group = NULL;
        ModestUIDimmingManagerPrivate *priv;
-       guint *handler, new_handler;
-       DelayedDimmingRules *helper;
        
        g_return_if_fail (group_name != NULL);
 
@@ -226,22 +173,9 @@ modest_ui_dimming_manager_process_dimming_rules_group (ModestUIDimmingManager *s
        /* Search group by name */
        group = MODEST_DIMMING_RULES_GROUP(g_hash_table_lookup (priv->groups_map, group_name));
        g_return_if_fail (group != NULL);
-
-       /* If there was another pending dimming operation check then ignore this */
-       handler = g_hash_table_lookup (priv->delayed_calls, group_name);
-       if (!handler) {
-               /* Create the helper and start the timeout */
-               helper = g_slice_new (DelayedDimmingRules);
-               helper->group = group;
-               helper->manager = self;
-               helper->name = g_strdup (group_name);
-               new_handler = g_timeout_add_full (G_PRIORITY_DEFAULT, 500, 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););
-       } else {
-               MODEST_DEBUG_BLOCK(g_print ("---------------------Ignoring\n"););
-       }
+       
+       /* Performs group dimming rules checking */
+       modest_dimming_rules_group_execute (group);
 }
 
 
index 447b57b..ffd97f6 100644 (file)
@@ -99,7 +99,6 @@ _define_main_window_dimming_state (ModestMainWindow *window)
        gboolean all_seen = TRUE;
        gboolean all_cached = TRUE;
        gboolean all_has_attach = TRUE;
-       TnyFolder *folder = NULL;
 
        g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(window), NULL);
 
@@ -174,28 +173,23 @@ _define_main_window_dimming_state (ModestMainWindow *window)
                        state->any_has_attachments = flags & TNY_HEADER_FLAG_ATTACHMENTS;
        
                /* sent in progress */
-               folder = tny_header_get_folder (header);
-               if (folder) {
-                       if (modest_tny_folder_guess_folder_type (folder) == TNY_FOLDER_TYPE_OUTBOX) {
-                               msg_uid = modest_tny_send_queue_get_msg_id (header);
-                               if (!state->sent_in_progress) {
-                                       cache_mgr = modest_runtime_get_cache_mgr ();
-                                       send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
-                                                                                      MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
+               msg_uid = modest_tny_send_queue_get_msg_id (header);
+               if (!state->sent_in_progress) {
+                       cache_mgr = modest_runtime_get_cache_mgr ();
+                       send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
+                                                                      MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
                        
-                                       g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
-                                       
-                                       for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) {
-                                               send_queue = MODEST_TNY_SEND_QUEUE (node->data);
-                                               
-                                               /* Check if msg uid is being processed inside send queue */
-                                               found = modest_tny_send_queue_msg_is_being_sent (send_queue, msg_uid);          
-                                       }
-                                       state->sent_in_progress = found;
-                               }
+                       g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
+                       
+                       for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) {
+                               send_queue = MODEST_TNY_SEND_QUEUE (node->data);
+                               
+                               /* Check if msg uid is being processed inside send queue */
+                               found = modest_tny_send_queue_msg_is_being_sent (send_queue, msg_uid);          
                        }
-                       g_object_unref (folder);
+                       state->sent_in_progress = found;
                }
+
                tny_iterator_next (iter);
                g_object_unref (header);
        }