X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=79dff08b97c30cec70e01d00e2811a816802b548;hb=3e9c324a5f8be62b6e360cfc358bbd3d24986e22;hp=a9d7bdc063777277d585383881c6cdd02c227560;hpb=ec8b42c7daf3f2727a6d2d517922dfa699b35bbc;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index a9d7bdc0..79dff08b 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -46,6 +46,7 @@ #include "ev-document-links.h" #include "ev-document-fonts.h" #include "ev-document-find.h" +#include "ev-document-images.h" #include "ev-document-security.h" #include "ev-document-factory.h" #include "ev-job-queue.h" @@ -64,6 +65,7 @@ #include "ev-utils.h" #include "ev-history.h" #include "ev-image.h" +#include "ev-message-area.h" #ifdef WITH_GNOME_PRINT #include "ev-print-job.h" @@ -91,10 +93,6 @@ #include #include -#include "ev-message-area.h" - -#include "eggfileformatchooser.h" - #if !GLIB_CHECK_VERSION (2, 13, 3) char *xdg_user_dir_lookup (char *type); #endif @@ -674,7 +672,8 @@ ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error) GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); - ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message); + if (error) + ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message); g_signal_connect (area, "response", G_CALLBACK (ev_window_error_message_response_cb), window); @@ -1827,12 +1826,15 @@ ev_window_get_recent_file_label (gint index, const gchar *filename) gint length; const gchar *p; const gchar *end; - + gboolean is_rtl; + + is_rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); + g_return_val_if_fail (filename != NULL, NULL); length = strlen (filename); str = g_string_sized_new (length + 10); - g_string_printf (str, "_%d. ", index); + g_string_printf (str, "%s_%d. ", is_rtl ? "\xE2\x80\x8F" : "", index); p = filename; end = filename + length; @@ -4597,6 +4599,7 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group) "is_important", TRUE, "short_label", _("Back"), "stock_id", GTK_STOCK_GO_DOWN, + /*translators: this is the history action*/ "tooltip", _("Move across visited pages"), NULL); g_signal_connect (action, "activate_link", @@ -4971,34 +4974,52 @@ ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window) gtk_clipboard_set_text (clipboard, uri, -1); } + static void image_save_dialog_response_cb (GtkWidget *fc, gint response_id, EvWindow *ev_window) { - GtkWidget *format_chooser; - GnomeVFSURI *target_uri; - gchar *uri; - gchar *uri_extension; - gchar *filename; - gchar *file_format; - gboolean is_local; - GError *error = NULL; - guint format; + GnomeVFSURI *target_uri; + gboolean is_local; + GError *error = NULL; + GdkPixbuf *pixbuf; + gchar *uri; + gchar *uri_extension; + gchar **extensions; + gchar *filename; + gchar *file_format; + GdkPixbufFormat *format; + GtkFileFilter *filter; if (response_id != GTK_RESPONSE_OK) { gtk_widget_destroy (fc); return; } - format_chooser = gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (fc)); - uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc)); - format = egg_file_format_chooser_get_format (EGG_FILE_FORMAT_CHOOSER (format_chooser), uri); - uri_extension = egg_file_format_chooser_append_extension (EGG_FILE_FORMAT_CHOOSER (format_chooser), - uri, format); - file_format = (char *)egg_file_format_chooser_get_format_data (EGG_FILE_FORMAT_CHOOSER (format_chooser), - format); + filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (fc)); + format = g_object_get_data (G_OBJECT (filter), "pixbuf-format"); + + if (format == NULL) { + format = get_gdk_pixbuf_format_by_extension (uri); + } + + if (format == NULL) { + ev_window_error_message (GTK_WINDOW (ev_window), + _("Couldn't find appropriate format to save image"), + NULL); + g_free (uri); + gtk_widget_destroy (fc); + + return; + } + + extensions = gdk_pixbuf_format_get_extensions (format); + uri_extension = g_strconcat (uri, ".", extensions[0], NULL); + g_strfreev(extensions); + file_format = gdk_pixbuf_format_get_name (format); + target_uri = gnome_vfs_uri_new (uri_extension); is_local = gnome_vfs_uri_is_local (target_uri); @@ -5010,9 +5031,14 @@ image_save_dialog_response_cb (GtkWidget *fc, g_free (uri); g_free (uri_extension); + + ev_document_doc_mutex_lock (); + pixbuf = ev_document_images_get_image (EV_DOCUMENT_IMAGES (ev_window->priv->document), + ev_window->priv->image); + ev_document_doc_mutex_unlock (); - gdk_pixbuf_save (ev_image_get_pixbuf (ev_window->priv->image), - filename, file_format, &error, NULL); + gdk_pixbuf_save (pixbuf, filename, file_format, &error, NULL); + g_object_unref (pixbuf); if (error) { ev_window_error_message (GTK_WINDOW (ev_window), @@ -5045,8 +5071,7 @@ image_save_dialog_response_cb (GtkWidget *fc, static void ev_view_popup_cmd_save_image_as (GtkAction *action, EvWindow *window) { - GtkWidget *fc, *format_chooser; - GtkFileFilter *filter; + GtkWidget *fc; if (!window->priv->image) return; @@ -5063,12 +5088,8 @@ ev_view_popup_cmd_save_image_as (GtkAction *action, EvWindow *window) gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE); - format_chooser = egg_file_format_chooser_new (); - egg_file_format_chooser_add_pixbuf_formats (EGG_FILE_FORMAT_CHOOSER (format_chooser), - 0, NULL); + file_chooser_dialog_add_writable_pixbuf_formats (GTK_FILE_CHOOSER (fc)); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (fc), format_chooser); - g_signal_connect (fc, "response", G_CALLBACK (image_save_dialog_response_cb), window); @@ -5080,14 +5101,20 @@ static void ev_view_popup_cmd_copy_image (GtkAction *action, EvWindow *window) { GtkClipboard *clipboard; + GdkPixbuf *pixbuf; if (!window->priv->image) return; clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_image (clipboard, - ev_image_get_pixbuf (window->priv->image)); + ev_document_doc_mutex_lock (); + pixbuf = ev_document_images_get_image (EV_DOCUMENT_IMAGES (window->priv->document), + window->priv->image); + ev_document_doc_mutex_unlock (); + + gtk_clipboard_set_image (clipboard, pixbuf); + g_object_unref (pixbuf); } static void