Reverted again the gdk_threads_enter/leave sentences:
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 27 Jun 2007 14:13:18 +0000 (14:13 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 27 Jun 2007 14:13:18 +0000 (14:13 +0000)
* src/widgets/modest-attachment-view.c
* src/widgets/modest-header-view.c
* src/maemo/modest-maemo-global-settings-dialog.c
* src/modest-mail-operation.c

Misc changes (mainly work to implement attachment purging):
* src/widgets/modest-msg-view.c:
        * Added find toolbar scroll fix, disabled as we're waiting
          for the new gtkhtml gtk_html_get_selection_area API.
        * Now we don't remove the attached part on removing attachments
          from view.
* src/widgets/modest-attachment-view.c:
        * Added support for showing purged files as purged. The icon is
          the default document one, and the text is a currently non
          translated string.
        * Now size is only shown for file attachments (if they're not
          purged).
* src/maemo/modest-msg-view-window.c:
        * Use the new Tinymail mime part purge API. It purges really the
          attachments. The UI is a work in progress still, but the
          cache seems to get updated as expected. This implementation
          replaces the old delete_attachments tinymail API based
          implementation.
* src/ui/modest-ui-dimming-rules.c:
        * Added some dimming rules for remove attachments in message view.
          It's not complete yet.
        * Now "move to" operation does not check if the source folder is
          writeable (fixes NB#61860).

pmo-trunk-r2460

src/maemo/modest-address-book.c
src/maemo/modest-maemo-global-settings-dialog.c
src/maemo/modest-msg-view-window.c
src/modest-mail-operation.c
src/modest-ui-dimming-rules.c
src/widgets/modest-attachment-view.c
src/widgets/modest-header-view.c
src/widgets/modest-msg-view.c

index fc4d186..ddb1a7e 100644 (file)
@@ -163,7 +163,6 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
 
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (recpt_editor));
 
-       contact_model = osso_abook_contact_model_new ();
        if (!open_addressbook ()) {
                if (contact_model) {
                        g_object_unref (contact_model);
@@ -171,6 +170,7 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
                }
                return;
        }
+       contact_model = osso_abook_contact_model_new ();
 
        contact_view = osso_abook_contact_selector_new_basic (contact_model);
        osso_abook_contact_selector_set_minimum_selection (OSSO_ABOOK_CONTACT_SELECTOR (contact_view), 1);
index a6d1601..5b967bb 100644 (file)
@@ -151,6 +151,8 @@ typedef struct {
 static gboolean
 idle_select_default_focus (gpointer data) 
 {
+       gdk_threads_enter ();
+
        ModestGlobalSettingsDialogPrivate *ppriv;
        ModestMaemoGlobalSettingsDialogPrivate *priv;
        SwitchPageHelper *helper;
@@ -167,6 +169,8 @@ idle_select_default_focus (gpointer data)
 
        g_free (helper);
 
+       gdk_threads_leave ();
+
        return FALSE;
 }
 
index 793c423..29e67b6 100644 (file)
@@ -1773,6 +1773,8 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window)
        gchar *confirmation_message;
        gint response;
        gint n_attachments;
+       TnyMsg *msg;
+/*     TnyFolder *folder; */
 
        g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window));
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
@@ -1808,11 +1810,23 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window)
        if (response != GTK_RESPONSE_OK)
                return;
 
+       msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view));
+/*     folder = tny_msg_get_folder (msg); */
+/*     tny_msg_uncache_attachments (msg); */
+/*     tny_folder_refresh (folder, NULL); */
+/*     g_object_unref (folder); */
+       
+       modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), msg);
+
        for (node = mime_parts; node != NULL; node = g_list_next (node)) {
-               modest_msg_view_remove_attachment (MODEST_MSG_VIEW (priv->msg_view), node->data);
+               tny_mime_part_set_purged (TNY_MIME_PART (node->data));
+/*             modest_msg_view_remove_attachment (MODEST_MSG_VIEW (priv->msg_view), node->data); */
        }
+       tny_msg_rewrite_cache (msg);
        g_list_foreach (mime_parts, (GFunc) g_object_unref, NULL);
        g_list_free (mime_parts);
+       modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
+
 }
 
 
index 4423453..f88ff79 100644 (file)
@@ -795,6 +795,8 @@ recurse_folders (TnyFolderStore *store, TnyFolderStoreQuery *query, TnyList *all
 static gboolean
 idle_notify_progress (gpointer data)
 {
+       gdk_threads_enter ();
+
        ModestMailOperation *mail_op = MODEST_MAIL_OPERATION (data);
        ModestMailOperationState *state;
 
@@ -802,6 +804,8 @@ idle_notify_progress (gpointer data)
        g_signal_emit (G_OBJECT (mail_op), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
        g_slice_free (ModestMailOperationState, state);
        
+       gdk_threads_leave ();
+
        return TRUE;
 }
 
@@ -813,6 +817,8 @@ idle_notify_progress (gpointer data)
 static gboolean
 idle_notify_progress_once (gpointer data)
 {
+       gdk_threads_enter ();
+
        ModestPair *pair;
 
        pair = (ModestPair *) data;
@@ -823,6 +829,8 @@ idle_notify_progress_once (gpointer data)
        g_slice_free (ModestMailOperationState, (ModestMailOperationState*)pair->second);
        g_object_unref (pair->first);
 
+       gdk_threads_leave ();
+
        return FALSE;
 }
 
@@ -880,6 +888,8 @@ set_last_updated_idle (gpointer data)
                                    time(NULL), 
                                    TRUE);
 
+       gdk_threads_leave ();
+
        return FALSE;
 }
 
index 3150c8a..bf20d71 100644 (file)
@@ -44,6 +44,7 @@
 static gboolean _folder_is_any_of_type (TnyFolder *folder, TnyFolderType types[], guint ntypes);
 static gboolean _invalid_msg_selected (ModestMainWindow *win, gboolean unique, ModestDimmingRule *rule);
 static gboolean _invalid_attach_selected (ModestWindow *win, gboolean unique, gboolean for_view, ModestDimmingRule *rule);
+static gboolean _purged_attach_selected (ModestWindow *win);
 static gboolean _clipboard_is_empty (ModestWindow *win);
 static gboolean _invalid_clipboard_selected (ModestWindow *win, ModestDimmingRule *rule);
 static gboolean _already_opened_msg (ModestWindow *win, guint *n_messages);
@@ -546,7 +547,6 @@ modest_ui_dimming_rules_on_main_window_move_to (ModestWindow *win, gpointer user
        GtkWidget *folder_view = NULL;
        GtkWidget *header_view = NULL;
        ModestDimmingRule *rule = NULL;
-       const gchar *message = NULL;
        gboolean dimmed = FALSE;
        
        g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(win), TRUE);
@@ -563,16 +563,6 @@ modest_ui_dimming_rules_on_main_window_move_to (ModestWindow *win, gpointer user
        
        /* Check diming rules for folders and messages transfer  */
        if (!dimmed) {
-               dimmed = _selected_folder_not_writeable(MODEST_MAIN_WINDOW(win));
-               if (dimmed) {
-                       if (gtk_widget_is_focus (folder_view))
-                               message = _("mail_in_ui_folder_move_target_error");
-                       else
-                               message = ngettext ("mail_in_ui_folder_move_target_error", "mail_in_ui_folder_move_targets_error",
-                                                   modest_header_view_count_selected_headers (MODEST_HEADER_VIEW(header_view)) > 1);                                   
-               }
-       }               
-       if (!dimmed) {
                dimmed = _invalid_msg_selected (MODEST_MAIN_WINDOW(win), FALSE, user_data);
                
        }
@@ -701,10 +691,13 @@ modest_ui_dimming_rules_on_remove_attachments (ModestWindow *win, gpointer user_
        g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
        rule = MODEST_DIMMING_RULE (user_data);
 
-       /* Check dimmed rule */ 
+       /* Check dimmed rule */
        if (!dimmed) {
-               dimmed = _invalid_attach_selected (win, TRUE, TRUE, rule);                      
+               dimmed = _purged_attach_selected (win);
+               if (dimmed)
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_attachment_already_purged"));
        }
+
        if (!dimmed) {
                dimmed = _invalid_attachment_for_purge (win, rule);
        }
@@ -1357,6 +1350,34 @@ _invalid_attach_selected (ModestWindow *win,
 }
 
 static gboolean
+_purged_attach_selected (ModestWindow *win) 
+{
+       GList *attachments, *node;
+       gint n_selected;
+       gboolean result = FALSE;
+
+       if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+               
+               /* Get selected atachments */
+               attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
+               n_selected = g_list_length (attachments);
+
+               for (node = attachments; node != NULL && !result; node = g_list_next (node)) {
+                       TnyMimePart *mime_part = TNY_MIME_PART (node->data);
+                       if (tny_mime_part_is_purged (mime_part)) {
+                               result = TRUE;
+                               break;
+                       }
+               }
+               
+               /* Free */
+               g_list_free (attachments);
+       }
+
+       return result;
+}
+
+static gboolean
 _invalid_msg_selected (ModestMainWindow *win,
                       gboolean unique,
                       ModestDimmingRule *rule) 
@@ -1660,7 +1681,7 @@ _invalid_attachment_for_purge (ModestWindow *win,
        TnyMsg *msg = NULL;
        TnyFolder *folder = NULL;
        TnyAccount *account = NULL;
-       gboolean result = TRUE;
+       gboolean result = FALSE;
 
        if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
 
index b89bc5e..c92bbdb 100644 (file)
@@ -160,8 +160,9 @@ get_size_idle_func (gpointer data)
                priv->get_size_idle_id = 0;
        }
 
+       gdk_threads_leave ();
+
        return (priv->get_size_stream != NULL);
-       
 }
 
 static void
@@ -170,6 +171,7 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
        ModestAttachmentViewPriv *priv = NULL;
        const gchar *filename = NULL;
        gchar *file_icon_name = NULL;
+       gboolean show_size = FALSE;
        
        g_return_if_fail (TNY_IS_MIME_PART_VIEW (self));
        g_return_if_fail (TNY_IS_MIME_PART (mime_part));
@@ -192,8 +194,11 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
        }
 
        priv->size = 0;
-
-       if (TNY_IS_MSG (mime_part)) {
+       
+       if (tny_mime_part_is_purged (mime_part)) {
+               filename = _("TODO: purged file");
+               file_icon_name = modest_platform_get_file_icon_name (NULL, NULL, NULL);
+       } else if (TNY_IS_MSG (mime_part)) {
                TnyHeader *header = tny_msg_get_header (TNY_MSG (mime_part));
                if (TNY_IS_HEADER (header)) {
                        filename = tny_header_get_subject (header);
@@ -207,6 +212,7 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
                file_icon_name = modest_platform_get_file_icon_name (filename, 
                                                                     tny_mime_part_get_content_type (mime_part), 
                                                                     NULL);
+               show_size = TRUE;
        }
 
        if (file_icon_name) {
@@ -219,9 +225,10 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim
        gtk_label_set_text (GTK_LABEL (priv->filename_view), filename);
        update_filename_request (MODEST_ATTACHMENT_VIEW (self));
 
-       gtk_label_set_text (GTK_LABEL (priv->size_view), " ");
+       gtk_label_set_text (GTK_LABEL (priv->size_view), "");
 
-       priv->get_size_idle_id = g_idle_add ((GSourceFunc) get_size_idle_func, (gpointer) self);
+       if (show_size)
+               priv->get_size_idle_id = g_idle_add ((GSourceFunc) get_size_idle_func, (gpointer) self);
 
        gtk_widget_queue_draw (GTK_WIDGET (self));
 }
index ed2d8ec..acf8f72 100644 (file)
@@ -1397,6 +1397,8 @@ on_focus_in (GtkWidget     *self,
 static void
 idle_notify_headers_count_changed_destroy (gpointer data)
 {
+       gdk_threads_enter ();
+
        HeadersCountChangedHelper *helper = NULL;
 
        g_return_if_fail (data != NULL);
@@ -1404,11 +1406,15 @@ idle_notify_headers_count_changed_destroy (gpointer data)
 
        g_object_unref (helper->change);
        g_slice_free (HeadersCountChangedHelper, helper);
+
+       gdk_threads_leave ();
 }
 
 static gboolean
 idle_notify_headers_count_changed (gpointer data)
 {
+       gdk_threads_enter ();
+
        TnyFolder *folder = NULL;
        ModestHeaderViewPrivate *priv = NULL;
        HeadersCountChangedHelper *helper = NULL;
@@ -1432,6 +1438,8 @@ idle_notify_headers_count_changed (gpointer data)
            
        g_mutex_unlock (priv->observers_lock);
 
+       gdk_threads_leave ();
+
        return FALSE;
 }
 
index 24bfebb..728ec5d 100644 (file)
@@ -1440,6 +1440,21 @@ modest_msg_view_search (ModestMsgView *self, const gchar *search)
        result = gtk_html_engine_search (GTK_HTML (priv->gtkhtml),
                                         search,
                                         FALSE, TRUE, TRUE);
+#if 0
+       if (result) {
+               gint x, y, w, h;
+               gdouble offset_top, offset_bottom;
+               GtkAdjustment *adj;
+               gtk_html_get_selection_area (GTK_HTML (priv->gtkhtml), &x, &y, &w, &h);
+               offset_top = (gdouble) (priv->headers_box->requisition.height + y);
+               offset_bottom = (gdouble) (priv->headers_box->requisition.height + y + h);
+               adj = GTK_ADJUSTMENT (priv->vadj);
+               if (offset_top < adj->value)
+                       gtk_adjustment_set_value (adj, offset_top + adj->page_increment - adj->page_size);
+               else if (offset_bottom > adj->value + adj->page_increment)
+                       gtk_adjustment_set_value (adj, offset_bottom - adj->page_increment);
+       }
+#endif
        y_offset = tmp_vadj->value;
        gtk_layout_set_vadjustment (GTK_LAYOUT (priv->gtkhtml), vadj);
        g_object_unref (vadj);
@@ -1457,14 +1472,22 @@ modest_msg_view_search_next (ModestMsgView *self)
 
        priv = MODEST_MSG_VIEW_GET_PRIVATE (self);
        result = gtk_html_engine_search_next (GTK_HTML (priv->gtkhtml));
-
-/*
-       {
+#if 0
+       if (result) {
+               gint x, y, w, h;
+               gdouble offset_top, offset_bottom;
                GtkAdjustment *adj;
-
-               adj = gtk_container_get_focus_vadjustment (GTK_CONTAINER (priv->gtkhtml));
+               gtk_html_get_selection_area (GTK_HTML (priv->gtkhtml), &x, &y, &w, &h);
+               g_message ("SELECTION AREA x%d y%d w%d h%d", x, y, w, h);
+               offset_top = (gdouble) (priv->headers_box->requisition.height + y);
+               offset_bottom = (gdouble) (priv->headers_box->requisition.height + y + h);
+               adj = GTK_ADJUSTMENT (priv->vadj);
+               if (offset_top < adj->value)
+                       gtk_adjustment_set_value (adj, offset_top + adj->page_increment - adj->page_size);
+               else if (offset_bottom > adj->value + adj->page_increment)
+                       gtk_adjustment_set_value (adj, offset_bottom - adj->page_increment);
        }
-*/
+#endif
 
        return result;
 }
@@ -1557,5 +1580,5 @@ modest_msg_view_remove_attachment (ModestMsgView *view, TnyMimePart *attachment)
        msg = modest_msg_view_get_message (view);
        modest_attachments_view_remove_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
                                                   attachment);
-       tny_mime_part_del_part (TNY_MIME_PART (msg), attachment);
+       
 }