Send receive all dimming if send receive in progress
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 17 Dec 2008 15:21:31 +0000 (15:21 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 17 Dec 2008 15:21:31 +0000 (15:21 +0000)
pmo-drop-split-view-r6921

src/hildon2/modest-accounts-window.c
src/modest-ui-dimming-rules.c

index 4166204..65c9eb7 100644 (file)
@@ -370,7 +370,7 @@ static void setup_menu (ModestAccountsWindow *self, ModestDimmingRulesGroup *gro
                     group, G_CALLBACK (modest_ui_dimming_rules_on_new_msg));
        add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_sendandreceive"),
                     G_CALLBACK (modest_ui_actions_on_send_receive),
-                    group, G_CALLBACK (modest_ui_dimming_rules_on_send_receive));
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_send_receive_all));
        add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_outbox_cancelsend"),
                     G_CALLBACK (modest_ui_actions_cancel_send),
                     group, G_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
index 9261942..a30754a 100644 (file)
@@ -47,6 +47,7 @@
 #include <tny-simple-list.h>
 #include <widgets/modest-recpt-editor.h>
 #include <gtkhtml/gtkhtml.h>
+#include <modest-runtime.h>
 #ifdef MODEST_TOOLKIT_HILDON2
 #include <modest-header-window.h>
 #endif
@@ -78,6 +79,7 @@ static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule
 static gboolean _transfer_mode_enabled (ModestWindow *win);
 static gboolean _selected_folder_has_subfolder_with_same_name (ModestWindow *win);
 static void fill_list_of_caches (gpointer key, gpointer value, gpointer userdata);
+static gboolean _send_receive_in_progress (ModestWindow *win);
 
 
 static DimmedState *
@@ -1883,7 +1885,9 @@ modest_ui_dimming_rules_on_send_receive_all (ModestWindow *win, gpointer user_da
        
        modest_account_mgr_free_account_names (account_names);
 
-       /* TODO: should dim if send receive is in progress */
+       if (!dimmed) {
+               dimmed = _send_receive_in_progress (win);
+       }
 
        return dimmed;
 }
@@ -2823,3 +2827,30 @@ modest_ui_dimming_rules_on_insert_image (ModestWindow *win,
 
        return (format != MODEST_MSG_EDIT_FORMAT_HTML);
 }
+
+static gboolean 
+_send_receive_in_progress (ModestWindow *win)
+{
+       ModestMailOperationQueue *queue;
+       GSList *op_list, *node;
+       gboolean found_send_receive;
+
+       queue = modest_runtime_get_mail_operation_queue ();
+       op_list = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (win));
+
+       found_send_receive = FALSE;
+       for (node = op_list; node != NULL; node = g_slist_next (node)) {
+               ModestMailOperation *op;
+
+               op = (ModestMailOperation *) node->data;
+               if (modest_mail_operation_get_type_operation (op) == MODEST_MAIL_OPERATION_TYPE_SEND_AND_RECEIVE) {
+                       found_send_receive = TRUE;
+                       break;
+               }
+       }
+
+       g_slist_foreach (op_list, (GFunc) g_object_unref, NULL);
+       g_slist_free (op_list);
+
+       return found_send_receive;
+}