restore_settings (ModestMsgEditWindow *self)
{
ModestConf *conf = NULL;
- GtkAction *action;
- ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
conf = modest_runtime_get_conf ();
/* Dim at start clipboard actions */
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CutMenu");
- gtk_action_set_sensitive (action, FALSE);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/EditMenu/CopyMenu");
- gtk_action_set_sensitive (action, FALSE);
- action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/AttachmentsMenu/RemoveAttachmentsMenu");
- gtk_action_set_sensitive (action, FALSE);
-
modest_widget_memory_restore (conf, G_OBJECT(self), MODEST_CONF_EDIT_WINDOW_KEY);
}
}
static GdkPixbuf *
-pixbuf_from_stream (TnyStream *stream, const gchar *mime_type, guint64 *stream_size)
+pixbuf_from_stream (TnyStream *stream,
+ const gchar *mime_type,
+ guint64 *stream_size,
+ ModestMsgEditWindow *self)
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
guint64 size;
-
+ GError *error = NULL;
+
size = 0;
loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, NULL);
return NULL;
}
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
+
tny_stream_reset (TNY_STREAM (stream));
while (!tny_stream_is_eos (TNY_STREAM (stream))) {
- GError *error = NULL;
unsigned char read_buffer[128];
gint readed;
readed = tny_stream_read (TNY_STREAM (stream), (char *) read_buffer, 128);
size += readed;
if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, &error)) {
- if (error)
- g_error_free (error);
break;
}
+ /* Allow some UI responsiveness */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
}
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), FALSE);
+
+ gdk_pixbuf_loader_close (loader, &error);
+ if (error)
+ g_error_free (error);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (pixbuf)
g_object_ref (pixbuf);
- gdk_pixbuf_loader_close (loader, NULL);
g_object_unref (loader);
if (!pixbuf)
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+ g_object_ref (self);
for (iter = tny_list_create_iterator (attachments);
!tny_iterator_is_done (iter);
tny_iterator_next (iter)) {
if ((cid != NULL)&&(mime_type != NULL)) {
guint64 stream_size;
TnyStream *stream = tny_mime_part_get_decoded_stream (part);
- GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
+ GdkPixbuf *pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size, self);
g_object_unref (stream);
g_object_unref (part);
}
g_object_unref (iter);
+ g_object_unref (self);
}
static void
ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
content_type = tny_mime_part_get_content_type (TNY_MIME_PART (msg));
-
+
if (content_type && !g_strcasecmp (content_type, "multipart/related")) {
parent = g_object_ref (msg);
} else if (content_type && !g_strcasecmp (content_type, "multipart/mixed")) {
g_free (bcc);
}
-static void
-menu_tool_button_dont_expand (GtkMenuToolButton *item)
-{
- GtkWidget *box;
- GList *item_children, *node;
-
- box = gtk_bin_get_child (GTK_BIN (item));
- gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
- item_children = gtk_container_get_children (GTK_CONTAINER (box));
-
- for (node = item_children; node != NULL; node = g_list_next (node)) {
- gtk_box_set_child_packing (GTK_BOX (box), GTK_WIDGET (node->data), TRUE, TRUE, 0, GTK_PACK_START);
- if (GTK_IS_TOGGLE_BUTTON (node->data))
- gtk_button_set_alignment (GTK_BUTTON (node->data), 0.0, 0.5);
- else if (GTK_IS_BUTTON (node->data))
- gtk_button_set_alignment (GTK_BUTTON (node->data), 1.0, 0.5);
- }
- g_list_free (item_children);
-}
-
static void
modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
GtkWidget *sizes_menu;
GtkWidget *fonts_menu;
gchar *markup;
- gchar ldots[8];
- gint ldots_len;
-
- ldots_len = g_unichar_to_utf8 (0x2026, ldots);
- ldots[ldots_len] = '\0';
/* Toolbar */
parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
/* font_size */
tool_item = GTK_WIDGET (gtk_tool_button_new (NULL, NULL));
priv->size_tool_button_label = gtk_label_new (NULL);
- hildon_helper_set_logical_color (GTK_WIDGET (priv->size_tool_button_label), GTK_RC_TEXT,
- GTK_STATE_INSENSITIVE, "SecondaryTextColor");
- hildon_helper_set_logical_color (GTK_WIDGET (priv->size_tool_button_label), GTK_RC_FG,
- GTK_STATE_INSENSITIVE, "SecondaryTextColor");
snprintf(size_text, sizeof(size_text), "%d", wp_font_size[DEFAULT_FONT_SIZE]);
markup = g_strconcat ("<span font_family='", DEFAULT_SIZE_BUTTON_FONT_FAMILY, "'>",
- size_text, ldots, "</span>", NULL);
+ size_text, "</span>", NULL);
gtk_label_set_markup (GTK_LABEL (priv->size_tool_button_label), markup);
g_free (markup);
hildon_helper_set_logical_font (priv->size_tool_button_label, "LargeSystemFont");
g_signal_connect (G_OBJECT (tool_item), "clicked", G_CALLBACK (font_size_clicked), window);
gtk_toolbar_insert (GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index);
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE);
- gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE);
- menu_tool_button_dont_expand (GTK_MENU_TOOL_BUTTON (tool_item));
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
priv->font_size_toolitem = tool_item;
/* font face */
tool_item = GTK_WIDGET (gtk_tool_button_new (NULL, NULL));
priv->font_tool_button_label = gtk_label_new (NULL);
- hildon_helper_set_logical_color (GTK_WIDGET (priv->font_tool_button_label), GTK_RC_TEXT,
- GTK_STATE_INSENSITIVE, "SecondaryTextColor");
- hildon_helper_set_logical_color (GTK_WIDGET (priv->font_tool_button_label), GTK_RC_FG,
- GTK_STATE_INSENSITIVE, "SecondaryTextColor");
- markup = g_strconcat ("<span font_family='", wp_get_font_name(DEFAULT_FONT), "'>Tt",ldots,"</span>", NULL);
+ markup = g_strconcat ("<span font_family='", wp_get_font_name(DEFAULT_FONT), "'>Tt</span>", NULL);
gtk_label_set_markup (GTK_LABEL (priv->font_tool_button_label), markup);
g_free(markup);
hildon_helper_set_logical_font (priv->font_tool_button_label, "LargeSystemFont");
}
g_signal_connect (G_OBJECT (tool_item), "clicked", G_CALLBACK (font_face_clicked), window);
gtk_toolbar_insert (GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index);
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE);
- gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE);
- menu_tool_button_dont_expand (GTK_MENU_TOOL_BUTTON (tool_item));
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
priv->font_face_toolitem = tool_item;
/* Set expand and homogeneous for remaining items */
GtkAction *action;
ModestWindowPrivate *parent_priv;
ModestMsgEditWindowPrivate *priv;
- gchar ldots[8];
- gint ldots_len;
parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
- ldots_len = g_unichar_to_utf8 (0x2026, ldots);
- ldots[ldots_len] = '\0';
-
if (wp_text_buffer_is_rich_text (WP_TEXT_BUFFER (priv->text_buffer))) {
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/FileFormatFormattedTextMenu");
if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
gtk_tree_model_get (priv->sizes_model, &iter, 0, &size_text, -1);
markup = g_strconcat ("<span font_family='Sans'>",
- size_text, ldots, "</span>", NULL);
+ size_text, "</span>", NULL);
gtk_label_set_markup (GTK_LABEL (priv->size_tool_button_label), markup);
g_free (markup);
priv->current_face_index = buffer_format->font;
gtk_tree_model_get (priv->faces_model, &iter, 0, &face_name, -1);
- markup = g_strconcat ("<span font_family='", face_name, "'>Tt", ldots, "</span>", NULL);
+ markup = g_strconcat ("<span font_family='", face_name, "'>Tt</span>", NULL);
gtk_label_set_markup (GTK_LABEL (priv->font_tool_button_label), markup);
g_free (face_name);
g_free (markup);
gint response = 0;
GSList *uris = NULL;
GSList *uri_node = NULL;
-
+
priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
+
dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_window_set_title (GTK_WINDOW (dialog), _("mcen_ia_select_inline_image_title"));
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
}
gtk_widget_destroy (dialog);
+ g_object_ref (window);
+ /* The operation could take some time so allow the dialog to be closed */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+
for (uri_node = uris; uri_node != NULL; uri_node = g_slist_next (uri_node)) {
const gchar *uri;
GnomeVFSHandle *handle = NULL;
modest_platform_information_banner (NULL, NULL,
_FM("sfil_ib_opening_not_allowed"));
-
+ g_free (filename);
g_object_unref (mime_part);
gnome_vfs_file_info_unref (info);
continue;
tny_mime_part_set_filename (mime_part, basename);
g_free (basename);
- pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
+ pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size, window);
if (pixbuf != NULL) {
priv->images_size += stream_size;
priv->images_count ++;
insert_mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (priv->text_buffer));
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->text_buffer), &position, insert_mark);
- wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position, g_strdup (tny_mime_part_get_content_id (mime_part)), pixbuf);
+ wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position,
+ tny_mime_part_get_content_id (mime_part), pixbuf);
g_object_unref (pixbuf);
- }
- tny_list_prepend (priv->images, (GObject *) mime_part);
- gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+ tny_list_prepend (priv->images, (GObject *) mime_part);
+ gtk_text_buffer_set_modified (priv->text_buffer, TRUE);
+ } else {
+ modest_platform_information_banner (NULL, NULL,
+ _("mail_ib_file_operation_failed"));
+ }
+
g_free (filename);
g_object_unref (mime_part);
gnome_vfs_file_info_unref (info);
}
}
-
-
+ g_object_unref (window);
}
static void
if (size > allowed_size) {
modest_platform_information_banner (NULL, NULL,
_FM("sfil_ib_opening_not_allowed"));
+ g_free (filename);
return 0;
}
} else
modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed"));
g_object_unref (mime_part);
+ g_free (filename);
gnome_vfs_file_info_unref (info);
return 0;
}
gchar *size_text;
gchar *markup;
WPTextBufferFormat format;
- gchar ldots[8];
- gint ldots_len;
new_index = hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (selector), 0);
text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (window));
size_text = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
- ldots_len = g_unichar_to_utf8 (0x2026, ldots);
- ldots[ldots_len] = '\0';
markup = g_strconcat ("<span font_family='", DEFAULT_SIZE_BUTTON_FONT_FAMILY, "'>",
- size_text, ldots, "</span>", NULL);
+ size_text, "</span>", NULL);
g_free (size_text);
gtk_label_set_markup (GTK_LABEL (priv->size_tool_button_label), markup);
g_free (markup);
if (gtk_tree_model_get_iter (priv->faces_model, &iter, path)) {
gchar *face_name;
gchar *markup;
- gchar ldots[8];
- gint ldots_len;
gtk_tree_model_get (priv->faces_model, &iter, 0, &face_name, -1);
GINT_TO_POINTER(new_font_index)))
wp_text_view_reset_and_show_im (WP_TEXT_VIEW (priv->msg_body));
- ldots_len = g_unichar_to_utf8 (0x2026, ldots);
- ldots[ldots_len] = '\0';
- markup = g_strconcat ("<span font_family='", face_name, "'>Tt", ldots, "</span>", NULL);
+ markup = g_strconcat ("<span font_family='", face_name, "'>Tt</span>", NULL);
gtk_label_set_markup (GTK_LABEL (priv->font_tool_button_label), markup);
text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (window));