#endif
#include "ev-application.h"
+#include "ev-utils.h"
+#include "ev-document-types.h"
#include <glib.h>
#include <glib/gi18n.h>
{
EvWindow *ev_window;
GtkWidget *chooser;
- GtkFileFilter *documents_filter;
- GtkFileFilter *pdf_filter;
- GtkFileFilter *ps_filter;
- GtkFileFilter *pixbuf_filter;
- GtkFileFilter *all_filter;
- static gchar *folder = NULL;
-#ifdef ENABLE_DJVU
- GtkFileFilter *djvu_filter;
-#endif
-#ifdef ENABLE_DVI
- GtkFileFilter *dvi_filter;
-#endif
+ static char *folder = NULL;
ev_window = ev_application_get_empty_window (application);
NULL);
if (folder) {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
- folder);
- }
-
- documents_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (documents_filter,
- _("All Documents"));
- gtk_file_filter_add_mime_type (documents_filter, "application/postscript");
- gtk_file_filter_add_mime_type (documents_filter, "application/x-gzpostscript");
- gtk_file_filter_add_mime_type (documents_filter, "image/x-eps");
- gtk_file_filter_add_mime_type (documents_filter, "application/pdf");
-#ifdef ENABLE_DVI
- gtk_file_filter_add_mime_type (documents_filter, "application/x-dvi");
-#endif
- gtk_file_filter_add_pixbuf_formats (documents_filter);
-#ifdef ENABLE_DJVU
- gtk_file_filter_add_mime_type (documents_filter, "image/vnd.djvu");
-#endif
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), documents_filter);
-
- ps_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (ps_filter, _("PostScript Documents"));
- gtk_file_filter_add_mime_type (ps_filter, "application/postscript");
- gtk_file_filter_add_mime_type (ps_filter, "application/x-gzpostscript");
- gtk_file_filter_add_mime_type (ps_filter, "image/x-eps");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), ps_filter);
-
- pdf_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
- gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pdf_filter);
-
-#ifdef ENABLE_DVI
- dvi_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (dvi_filter, _("DVI Documents"));
- gtk_file_filter_add_mime_type (dvi_filter, "application/x-dvi");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), dvi_filter);
-#endif
-
- pixbuf_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (pixbuf_filter, _("Images"));
- gtk_file_filter_add_pixbuf_formats (pixbuf_filter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pixbuf_filter);
-
-#ifdef ENABLE_DJVU
- djvu_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (djvu_filter, _("Djvu Documents"));
- gtk_file_filter_add_mime_type (djvu_filter, "image/vnd.djvu");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), djvu_filter);
-#endif
-
- all_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (all_filter, _("All Files"));
- gtk_file_filter_add_pattern (all_filter, "*");
-
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), all_filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), documents_filter);
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (chooser),
+ folder);
+ }
+ ev_document_types_add_filters (chooser);
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
GSList *uris;
uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
- folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (chooser));
+
+ if (folder != NULL)
+ g_free (folder);
+
+ folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser));
ev_window_open_uri_list (ev_window, uris);
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gtk/gtkfilechooserdialog.h>
typedef struct _EvDocumentType EvDocumentType;
struct _EvDocumentType
return type;
}
+
+void
+ev_document_types_add_filters (GtkWidget *chooser)
+{
+ GtkFileFilter *documents_filter;
+ GtkFileFilter *pdf_filter;
+ GtkFileFilter *ps_filter;
+ GtkFileFilter *pixbuf_filter;
+ GtkFileFilter *all_filter;
+#ifdef ENABLE_DJVU
+ GtkFileFilter *djvu_filter;
+#endif
+#ifdef ENABLE_DVI
+ GtkFileFilter *dvi_filter;
+#endif
+
+ documents_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (documents_filter,
+ _("All Documents"));
+ gtk_file_filter_add_mime_type (documents_filter, "application/postscript");
+ gtk_file_filter_add_mime_type (documents_filter, "application/x-gzpostscript");
+ gtk_file_filter_add_mime_type (documents_filter, "image/x-eps");
+ gtk_file_filter_add_mime_type (documents_filter, "application/pdf");
+#ifdef ENABLE_DVI
+ gtk_file_filter_add_mime_type (documents_filter, "application/x-dvi");
+#endif
+ gtk_file_filter_add_pixbuf_formats (documents_filter);
+#ifdef ENABLE_DJVU
+ gtk_file_filter_add_mime_type (documents_filter, "image/vnd.djvu");
+#endif
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), documents_filter);
+
+ ps_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (ps_filter, _("PostScript Documents"));
+ gtk_file_filter_add_mime_type (ps_filter, "application/postscript");
+ gtk_file_filter_add_mime_type (ps_filter, "application/x-gzpostscript");
+ gtk_file_filter_add_mime_type (ps_filter, "image/x-eps");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), ps_filter);
+
+ pdf_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
+ gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pdf_filter);
+
+#ifdef ENABLE_DVI
+ dvi_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (dvi_filter, _("DVI Documents"));
+ gtk_file_filter_add_mime_type (dvi_filter, "application/x-dvi");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), dvi_filter);
+#endif
+
+ pixbuf_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pixbuf_filter, _("Images"));
+ gtk_file_filter_add_pixbuf_formats (pixbuf_filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pixbuf_filter);
+
+#ifdef ENABLE_DJVU
+ djvu_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (djvu_filter, _("Djvu Documents"));
+ gtk_file_filter_add_mime_type (djvu_filter, "image/vnd.djvu");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), djvu_filter);
+#endif
+
+ all_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (all_filter, _("All Files"));
+ gtk_file_filter_add_pattern (all_filter, "*");
+
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), all_filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), documents_filter);
+}
+
+void
+ev_document_types_add_filters_for_type (GtkWidget *chooser, GType type)
+{
+ GtkFileFilter *documents_filter;
+ GtkFileFilter *pdf_filter;
+ GtkFileFilter *ps_filter;
+ GtkFileFilter *pixbuf_filter;
+ GtkFileFilter *all_filter;
+#ifdef ENABLE_DJVU
+ GtkFileFilter *djvu_filter;
+#endif
+#ifdef ENABLE_DVI
+ GtkFileFilter *dvi_filter;
+#endif
+ GtkFileFilter *default_filter;
+
+ documents_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (documents_filter,
+ _("All Documents"));
+ gtk_file_filter_add_mime_type (documents_filter, "application/postscript");
+ gtk_file_filter_add_mime_type (documents_filter, "application/x-gzpostscript");
+ gtk_file_filter_add_mime_type (documents_filter, "image/x-eps");
+ gtk_file_filter_add_mime_type (documents_filter, "application/pdf");
+#ifdef ENABLE_DVI
+ gtk_file_filter_add_mime_type (documents_filter, "application/x-dvi");
+#endif
+ gtk_file_filter_add_pixbuf_formats (documents_filter);
+#ifdef ENABLE_DJVU
+ gtk_file_filter_add_mime_type (documents_filter, "image/vnd.djvu");
+#endif
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), documents_filter);
+
+ if (type == PS_TYPE_DOCUMENT) {
+ ps_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (ps_filter, _("PostScript Documents"));
+ gtk_file_filter_add_mime_type (ps_filter, "application/postscript");
+ gtk_file_filter_add_mime_type (ps_filter, "application/x-gzpostscript");
+ gtk_file_filter_add_mime_type (ps_filter, "image/x-eps");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), ps_filter);
+ default_filter = ps_filter;
+ } else if (type == PDF_TYPE_DOCUMENT) {
+ pdf_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
+ gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pdf_filter);
+ default_filter = pdf_filter;
+#ifdef ENABLE_DVI
+ } else if (type == DVI_TYPE_DOCUMENT) {
+ dvi_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (dvi_filter, _("DVI Documents"));
+ gtk_file_filter_add_mime_type (dvi_filter, "application/x-dvi");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), dvi_filter);
+ default_filter = dvi_filter;
+#endif
+ } else if (type == PIXBUF_TYPE_DOCUMENT) {
+ pixbuf_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pixbuf_filter, _("Images"));
+ gtk_file_filter_add_pixbuf_formats (pixbuf_filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pixbuf_filter);
+ default_filter = pixbuf_filter;
+#ifdef ENABLE_DJVU
+ } else if (type == DJVU_TYPE_DOCUMENT) {
+ djvu_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (djvu_filter, _("Djvu Documents"));
+ gtk_file_filter_add_mime_type (djvu_filter, "image/vnd.djvu");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), djvu_filter);
+ default_filter = djvu_filter;
+#endif
+ } else {
+ default_filter = documents_filter;
+ }
+
+ all_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (all_filter, _("All Files"));
+ gtk_file_filter_add_pattern (all_filter, "*");
+
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), all_filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), default_filter);
+}
+
#include "ev-document-fonts.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
+#include "ev-document-types.h"
#include "ev-job-queue.h"
#include "ev-jobs.h"
#include "ev-statusbar.h"
#include "ev-application.h"
#include "ev-stock-icons.h"
#include "ev-file-helpers.h"
+
#include <poppler.h>
#include <glib/gi18n.h>
ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
{
GtkWidget *fc;
- GtkFileFilter *pdf_filter, *all_filter;
- gchar *uri = NULL;
+
+ gchar *uri;
+ gchar *basename;
+ static char* folder = NULL;
+
gboolean success;
fc = gtk_file_chooser_dialog_new (
NULL);
gtk_window_set_modal (GTK_WINDOW (fc), TRUE);
- pdf_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
- gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
-
- all_filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (all_filter, _("All Files"));
- gtk_file_filter_add_pattern (all_filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), all_filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
-
+ ev_document_types_add_filters_for_type (fc, G_TYPE_FROM_INSTANCE (ev_window->priv->document));
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+
+ if (folder) {
+ gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER (fc),
+ folder);
+ }
+
+ basename = g_path_get_basename (ev_window->priv->uri);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), basename);
+ g_free (basename);
gtk_widget_show (fc);
else
save_error_dialog (GTK_WINDOW (fc), uri);
}
+
+ if (folder != NULL)
+ g_free (folder);
+
+ folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (fc));
+
gtk_widget_destroy (fc);
}