evince r2827 - in trunk: . cut-n-paste cut-n-paste/fileformatchooser help help/reference po shell
- From: nshmyrev svn gnome org
- To: svn-commits-list gnome org
- Subject: evince r2827 - in trunk: . cut-n-paste cut-n-paste/fileformatchooser help help/reference po shell
- Date: Tue, 15 Jan 2008 00:58:19 +0000 (GMT)
Author: nshmyrev
Date: Tue Jan 15 00:58:18 2008
New Revision: 2827
URL: http://svn.gnome.org/viewvc/evince?rev=2827&view=rev
Log:
2008-01-15 Nickolay V. Shmyrev <nshmyrev yandex ru>
* configure.ac:
* cut-n-paste/Makefile.am:
* cut-n-paste/fileformatchooser/Makefile.am:
* cut-n-paste/fileformatchooser/egg-macros.h:
* cut-n-paste/fileformatchooser/eggfileformatchooser.c:
* cut-n-paste/fileformatchooser/eggfileformatchooser.h:
* shell/Makefile.am:
* shell/ev-utils.c:
(file_chooser_dialog_add_writable_pixbuf_formats),
(get_gdk_pixbuf_format_by_extension):
* shell/ev-utils.h:
* shell/ev-window.c: (ev_window_error_message),
(image_save_dialog_response_cb), (ev_view_popup_cmd_save_image_as):
Simplify image format selection on save.
Removed:
trunk/cut-n-paste/fileformatchooser/
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/cut-n-paste/Makefile.am
trunk/help/ChangeLog
trunk/help/reference/Makefile.am
trunk/po/POTFILES.in
trunk/shell/Makefile.am
trunk/shell/ev-utils.c
trunk/shell/ev-utils.h
trunk/shell/ev-window.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Jan 15 00:58:18 2008
@@ -466,7 +466,6 @@
cut-n-paste/toolbar-editor/Makefile
cut-n-paste/zoom-control/Makefile
cut-n-paste/totem-screensaver/Makefile
-cut-n-paste/fileformatchooser/Makefile
data/evince.desktop.in
data/Makefile
data/icons/Makefile
Modified: trunk/cut-n-paste/Makefile.am
==============================================================================
--- trunk/cut-n-paste/Makefile.am (original)
+++ trunk/cut-n-paste/Makefile.am Tue Jan 15 00:58:18 2008
@@ -1 +1 @@
-SUBDIRS = zoom-control toolbar-editor totem-screensaver gedit-message-area fileformatchooser
+SUBDIRS = zoom-control toolbar-editor totem-screensaver gedit-message-area
Modified: trunk/help/reference/Makefile.am
==============================================================================
--- trunk/help/reference/Makefile.am (original)
+++ trunk/help/reference/Makefile.am Tue Jan 15 00:58:18 2008
@@ -90,7 +90,6 @@
$(GTK_PRINT_CFLAGS)
GTKDOC_LIBS= \
- $(top_builddir)/cut-n-paste/fileformatchooser/libfileformatchooser.la \
$(top_builddir)/cut-n-paste/zoom-control/libephyzoom.la \
$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la \
$(top_builddir)/cut-n-paste/totem-screensaver/libtotemscrsaver.la \
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Tue Jan 15 00:58:18 2008
@@ -19,7 +19,6 @@
backend/ps/psdocument.evince-backend.in
libdocument/ev-attachment.c
libdocument/ev-document-factory.c
-cut-n-paste/fileformatchooser/eggfileformatchooser.c
cut-n-paste/toolbar-editor/egg-editable-toolbar.c
cut-n-paste/toolbar-editor/egg-toolbar-editor.c
cut-n-paste/totem-screensaver/totem-scrsaver.c
@@ -51,6 +50,7 @@
shell/ev-view.c
shell/ev-window.c
shell/ev-window-title.c
+shell/ev-utils.c
shell/main.c
thumbnailer/evince-thumbnailer-comics.schemas.in
thumbnailer/evince-thumbnailer-djvu.schemas.in
Modified: trunk/shell/Makefile.am
==============================================================================
--- trunk/shell/Makefile.am (original)
+++ trunk/shell/Makefile.am Tue Jan 15 00:58:18 2008
@@ -5,7 +5,6 @@
-I$(top_srcdir)/cut-n-paste/toolbar-editor/ \
-I$(top_srcdir)/cut-n-paste/totem-screensaver/ \
-I$(top_srcdir)/cut-n-paste/gedit-message-area/ \
- -I$(top_srcdir)/cut-n-paste/fileformatchooser/ \
-I$(top_srcdir)/libdocument \
-I$(top_srcdir)/properties \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
@@ -102,7 +101,6 @@
$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la \
$(top_builddir)/cut-n-paste/totem-screensaver/libtotemscrsaver.la \
$(top_builddir)/cut-n-paste/gedit-message-area/libgeditmsgarea.la \
- $(top_builddir)/cut-n-paste/fileformatchooser/libfileformatchooser.la \
$(top_builddir)/properties/libevproperties.la \
$(top_builddir)/libdocument/libevbackend.la \
$(SHELL_LIBS) \
Modified: trunk/shell/ev-utils.c
==============================================================================
--- trunk/shell/ev-utils.c (original)
+++ trunk/shell/ev-utils.c Tue Jan 15 00:58:18 2008
@@ -25,6 +25,7 @@
#include <string.h>
#include <math.h>
+#include <glib/gi18n.h>
#define PRINT_CONFIG_FILENAME "ev-print-config.xml"
@@ -410,3 +411,86 @@
return (xdpi + ydpi) / 2.0;
}
+
+void
+file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser)
+{
+ GSList *pixbuf_formats = NULL;
+ GSList *iter;
+ GtkFileFilter *filter;
+ int i;
+
+ filter = gtk_file_filter_new();
+ gtk_file_filter_set_name (filter, _("By extension"));
+ g_object_set_data (G_OBJECT(filter), "pixbuf-format", NULL);
+ gtk_file_chooser_add_filter (chooser, filter);
+
+ pixbuf_formats = gdk_pixbuf_get_formats ();
+
+ for (iter = pixbuf_formats; iter; iter = iter->next) {
+ GdkPixbufFormat *format = iter->data;
+
+ gchar *description, *name, *extensions;
+ gchar **extension_list, **mime_types;
+
+ if (gdk_pixbuf_format_is_disabled (format) ||
+ !gdk_pixbuf_format_is_writable (format))
+ continue;
+
+ name = gdk_pixbuf_format_get_description (format);
+ extension_list = gdk_pixbuf_format_get_extensions (format);
+ extensions = g_strjoinv (", ", extension_list);
+ g_strfreev (extension_list);
+ description = g_strdup_printf ("%s (%s)", name, extensions);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, description);
+ g_object_set_data (G_OBJECT (filter), "pixbuf-format", format);
+ gtk_file_chooser_add_filter (chooser, filter);
+
+ g_free (description);
+ g_free (extensions);
+ g_free (name);
+
+ mime_types = gdk_pixbuf_format_get_mime_types (format);
+ for (i = 0; mime_types[i] != 0; i++)
+ gtk_file_filter_add_mime_type (filter, mime_types[i]);
+ g_strfreev (mime_types);
+ }
+
+ g_slist_free (pixbuf_formats);
+}
+
+GdkPixbufFormat*
+get_gdk_pixbuf_format_by_extension (gchar *uri)
+{
+ GSList *pixbuf_formats = NULL;
+ GSList *iter;
+ int i;
+
+ pixbuf_formats = gdk_pixbuf_get_formats ();
+
+ for (iter = pixbuf_formats; iter; iter = iter->next) {
+ gchar **extension_list;
+ GdkPixbufFormat *format = iter->data;
+
+ if (gdk_pixbuf_format_is_disabled (format) ||
+ !gdk_pixbuf_format_is_writable (format))
+ continue;
+
+ extension_list = gdk_pixbuf_format_get_extensions (format);
+
+ for (i = 0; extension_list[i] != 0; i++) {
+ if (g_str_has_suffix (uri, extension_list[i])) {
+ g_slist_free (pixbuf_formats);
+ g_strfreev (extension_list);
+ return format;
+ }
+ }
+ g_strfreev (extension_list);
+ }
+
+ g_slist_free (pixbuf_formats);
+ return NULL;
+}
+
Modified: trunk/shell/ev-utils.h
==============================================================================
--- trunk/shell/ev-utils.h (original)
+++ trunk/shell/ev-utils.h Tue Jan 15 00:58:18 2008
@@ -50,6 +50,9 @@
gdouble get_screen_dpi (GtkWindow * window);
+void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser);
+GdkPixbufFormat* get_gdk_pixbuf_format_by_extension (gchar *uri);
+
G_END_DECLS
#endif /* __EV_VIEW_H__ */
Modified: trunk/shell/ev-window.c
==============================================================================
--- trunk/shell/ev-window.c (original)
+++ trunk/shell/ev-window.c Tue Jan 15 00:58:18 2008
@@ -64,6 +64,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 +92,6 @@
#include <string.h>
#include <unistd.h>
-#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 +671,8 @@
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);
@@ -4974,34 +4972,52 @@
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;
+
+ 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);
@@ -5048,7 +5064,7 @@
static void
ev_view_popup_cmd_save_image_as (GtkAction *action, EvWindow *window)
{
- GtkWidget *fc, *format_chooser;
+ GtkWidget *fc;
if (!window->priv->image)
return;
@@ -5065,12 +5081,8 @@
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]