* src/modest-ui-actions.c:
[modest] / src / maemo / modest-msg-edit-window.c
index e192d8a..2331b8c 100644 (file)
@@ -127,9 +127,6 @@ static void modest_msg_edit_window_show_toolbar   (ModestWindow *window,
 static void modest_msg_edit_window_clipboard_owner_change (GtkClipboard *clipboard,
                                                           GdkEvent *event,
                                                           ModestMsgEditWindow *window);
-static void modest_msg_edit_window_system_clipboard_owner_change (GtkClipboard *clipboard,
-                                                                 GdkEvent *event,
-                                                                 ModestMsgEditWindow *window);
 static void update_window_title (ModestMsgEditWindow *window);
 static void update_dimmed (ModestMsgEditWindow *window);
 static void update_paste_dimming (ModestMsgEditWindow *window);
@@ -209,7 +206,6 @@ struct _ModestMsgEditWindowPrivate {
        gdouble zoom_level;
        
        gulong      clipboard_change_handler_id;
-       gulong      system_clipboard_change_handler_id;
 
        TnyMsg      *draft_msg;
        gboolean    sent;
@@ -315,7 +311,6 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
 
        priv->draft_msg = NULL;
        priv->clipboard_change_handler_id = 0;
-       priv->system_clipboard_change_handler_id = 0;
        priv->sent = FALSE;
 }
 
@@ -520,8 +515,6 @@ init_window (ModestMsgEditWindow *obj)
 
        priv->clipboard_change_handler_id = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change",
                                                              G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
-       priv->system_clipboard_change_handler_id = g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)), "owner-change",
-                                                             G_CALLBACK (modest_msg_edit_window_system_clipboard_owner_change), obj);
 }
        
 
@@ -536,12 +529,6 @@ modest_msg_edit_window_finalize (GObject *obj)
                priv->clipboard_change_handler_id = 0;
        }
        
-       if (priv->system_clipboard_change_handler_id > 0) {
-               g_signal_handler_disconnect (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), 
-                                            priv->system_clipboard_change_handler_id);
-               priv->system_clipboard_change_handler_id = 0;
-       }
-       
        if (priv->draft_msg != NULL) {
                TnyHeader *header = tny_msg_get_header (priv->draft_msg);
                if (TNY_IS_HEADER (header)) {
@@ -1512,14 +1499,22 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window)
                        GdkPixbufLoader *loader;
                        GdkPixbuf *pixbuf;
                        GnomeVFSFileInfo info;
-                       gchar *filename, *basename;
+                       gchar *filename, *basename, *escaped_filename;
                        TnyMimePart *mime_part;
                        TnyStream *stream;
                        gchar *content_id;
                        const gchar *mime_type = NULL;
+                       GnomeVFSURI *vfs_uri;
+
+                       vfs_uri = gnome_vfs_uri_new (uri);
+
+                       escaped_filename = g_path_get_basename (gnome_vfs_uri_get_path (vfs_uri));
+                       filename = gnome_vfs_unescape_string_for_display (escaped_filename);
+                       g_free (escaped_filename);
+                       gnome_vfs_uri_unref (vfs_uri);
 
-                       filename = g_filename_from_uri (uri, NULL, NULL);
-                       if (gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE) 
+                       if (gnome_vfs_get_file_info (uri, &info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE
+                                                    | GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE) 
                            == GNOME_VFS_OK)
                                mime_type = gnome_vfs_file_info_get_mime_type (&info);
 
@@ -1618,13 +1613,25 @@ modest_msg_edit_window_attach_file (ModestMsgEditWindow *window)
                        TnyStream *stream;
                        const gchar *mime_type = NULL;
                        gchar *basename;
+                       gchar *escaped_filename;
                        gchar *filename;
                        gchar *content_id;
                        GnomeVFSFileInfo info;
+                       GnomeVFSURI *vfs_uri;
 
-                       filename = g_filename_from_uri (uri, NULL, NULL);
+                       vfs_uri = gnome_vfs_uri_new (uri);
                        
-                       if (gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE) == GNOME_VFS_OK)
+
+                       escaped_filename = g_path_get_basename (gnome_vfs_uri_get_path (vfs_uri));
+                       filename = gnome_vfs_unescape_string_for_display (escaped_filename);
+                       g_free (escaped_filename);
+                       gnome_vfs_uri_unref (vfs_uri);
+                       
+                       if (gnome_vfs_get_file_info (uri, 
+                                                    &info, 
+                                                    GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
+                                                    GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE)
+                           == GNOME_VFS_OK)
                                mime_type = gnome_vfs_file_info_get_mime_type (&info);
                        mime_part = tny_platform_factory_new_mime_part
                                (modest_runtime_get_platform_factory ());
@@ -2865,15 +2872,6 @@ update_paste_dimming (ModestMsgEditWindow *window)
 
 }
 
-
-static void
-modest_msg_edit_window_system_clipboard_owner_change (GtkClipboard *clipboard,
-                                                     GdkEvent *event,
-                                                     ModestMsgEditWindow *window)
-{
-       update_paste_dimming (window);
-}
-
 static void 
 update_select_all_dimming (ModestMsgEditWindow *window)
 {
@@ -2918,6 +2916,7 @@ edit_menu_activated (GtkAction *action,
        ModestMsgEditWindow *window = MODEST_MSG_EDIT_WINDOW (userdata);
 
        update_select_all_dimming (window);
+       update_paste_dimming (window);
 }
 static void
 view_menu_activated (GtkAction *action,