/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
/* this file is part of evince, a gnome document viewer
*
+ * Copyright (C) 2008 Carlos Garcia Campos
* Copyright (C) 2004 Martin Kretzschmar
* Copyright (C) 2004 Red Hat, Inc.
* Copyright (C) 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
#include "config.h"
#endif
-#include "ev-window.h"
-#include "ev-window-title.h"
-#include "ev-navigation-action.h"
-#include "ev-page-action.h"
-#include "ev-open-recent-action.h"
-#include "ev-sidebar.h"
-#include "ev-sidebar-links.h"
-#include "ev-sidebar-attachments.h"
-#include "ev-sidebar-thumbnails.h"
-#include "ev-view.h"
-#include "ev-password.h"
-#include "ev-password-view.h"
-#include "ev-properties-dialog.h"
-#include "ev-file-exporter.h"
-#include "ev-document-thumbnails.h"
-#include "ev-document-links.h"
-#include "ev-document-fonts.h"
-#include "ev-document-find.h"
-#include "ev-document-security.h"
-#include "ev-document-factory.h"
-#include "ev-job-queue.h"
-#include "ev-jobs.h"
-#include "ev-sidebar-page.h"
-#include "eggfindbar.h"
-#include "egg-toolbar-editor.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (2, 14, 0)
+#include <gtk/gtkunixprint.h>
+#else
+#include <gtk/gtkprintunixdialog.h>
+#endif
+#ifdef WITH_GCONF
+#include <gconf/gconf-client.h>
+#endif
+
#include "egg-editable-toolbar.h"
+#include "egg-toolbar-editor.h"
#include "egg-toolbars-model.h"
-#include "ephy-zoom.h"
+
+#include "eggfindbar.h"
+
#include "ephy-zoom-action.h"
+#include "ephy-zoom.h"
+
#include "ev-application.h"
-#include "ev-stock-icons.h"
-#include "ev-metadata-manager.h"
+#include "ev-document-factory.h"
+#include "ev-document-find.h"
+#include "ev-document-fonts.h"
+#include "ev-document-images.h"
+#include "ev-document-links.h"
+#include "ev-document-thumbnails.h"
+#include "ev-document-type-builtins.h"
+#include "ev-file-exporter.h"
#include "ev-file-helpers.h"
-#include "ev-utils.h"
+#include "ev-file-monitor.h"
#include "ev-history.h"
#include "ev-image.h"
+#include "ev-job-scheduler.h"
+#include "ev-jobs.h"
+#include "ev-message-area.h"
+#include "ev-metadata-manager.h"
+#include "ev-mount-operation.h"
+#include "ev-navigation-action.h"
+#include "ev-open-recent-action.h"
+#include "ev-page-action.h"
+#include "ev-password-view.h"
+#include "ev-properties-dialog.h"
+#include "ev-sidebar-attachments.h"
+#include "ev-sidebar.h"
+#include "ev-sidebar-links.h"
+#include "ev-sidebar-page.h"
+#include "ev-sidebar-thumbnails.h"
+#include "ev-sidebar-layers.h"
+#include "ev-stock-icons.h"
+#include "ev-utils.h"
+#include "ev-keyring.h"
+#include "ev-view.h"
+#include "ev-view-type-builtins.h"
+#include "ev-window.h"
+#include "ev-window-title.h"
+#include "ev-print-operation.h"
+#include "ev-progress-message-area.h"
-#ifdef WITH_GNOME_PRINT
-#include "ev-print-job.h"
-#include <libgnomeprintui/gnome-print-dialog.h>
-#endif
-
-#ifdef WITH_GTK_PRINT
-#include <gtk/gtkprintunixdialog.h>
-#endif
+#ifdef ENABLE_DBUS
+#include "ev-media-player-keys.h"
+#endif /* ENABLE_DBUS */
#ifdef ENABLE_PDF
#include <poppler.h>
#endif
-#include <glib/gstdio.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <gconf/gconf-client.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "ev-message-area.h"
-
-#if !GLIB_CHECK_VERSION (2, 13, 3)
-char *xdg_user_dir_lookup (char *type);
-#endif
-
typedef enum {
PAGE_MODE_DOCUMENT,
PAGE_MODE_PASSWORD
EV_CHROME_RAISE_TOOLBAR = 1 << 3,
EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4,
EV_CHROME_SIDEBAR = 1 << 5,
- EV_CHROME_PREVIEW_TOOLBAR = 1 << 6,
EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
} EvChrome;
+typedef enum {
+ EV_SAVE_DOCUMENT,
+ EV_SAVE_ATTACHMENT,
+ EV_SAVE_IMAGE
+} EvSaveType;
+
struct _EvWindowPrivate {
/* UI */
EvChrome chrome;
GtkWidget *sidebar_thumbs;
GtkWidget *sidebar_links;
GtkWidget *sidebar_attachments;
+ GtkWidget *sidebar_layers;
+
+ /* Progress Messages */
+ guint progress_idle;
+ GCancellable *progress_cancellable;
/* Dialogs */
GtkWidget *properties;
-#ifdef WITH_PRINT
GtkWidget *print_dialog;
-#endif
- GtkWidget *password_dialog;
/* UI Builders */
GtkActionGroup *action_group;
/* Presentation mode */
guint presentation_timeout_id;
- /* Preview mode */
- GtkWidget *preview_toolbar;
- gchar *print_settings_file;
-
/* Popup view */
GtkWidget *view_popup;
EvLink *link;
/* Document */
char *uri;
+ glong uri_mtime;
char *local_uri;
- EvLinkDest *dest;
- gboolean unlink_temp_file;
gboolean in_reload;
+ EvFileMonitor *monitor;
+ guint setup_document_idle;
EvDocument *document;
EvHistory *history;
EvWindowPageMode page_mode;
EvWindowTitle *title;
- EvJob *load_job;
- EvJob *thumbnail_job;
- EvJob *save_job;
-#ifdef WITH_GNOME_PRINT
- GnomePrintJob *print_job;
-#endif
+ /* Load params */
+ EvLinkDest *dest;
+ gchar *search_string;
+ EvWindowRunMode window_mode;
+
+ EvJob *load_job;
+ EvJob *reload_job;
+ EvJob *thumbnail_job;
+ EvJob *save_job;
+ EvJob *find_job;
-#ifdef WITH_GTK_PRINT
- EvJob *print_job;
- gboolean print_preview;
- GtkPrintJob *gtk_print_job;
+ /* Printing */
+ GQueue *print_queue;
GtkPrinter *printer;
GtkPrintSettings *print_settings;
GtkPageSetup *print_page_setup;
-#endif
+ gboolean close_after_print;
};
#define EV_WINDOW_GET_PRIVATE(object) \
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define ATTACHMENTS_SIDEBAR_ID "attachments"
+#define LAYERS_SIDEBAR_ID "layers"
-#ifdef WITH_GTK_PRINT
static const gchar *document_print_settings[] = {
GTK_PRINT_SETTINGS_N_COPIES,
GTK_PRINT_SETTINGS_COLLATE,
GTK_PRINT_SETTINGS_SCALE,
GTK_PRINT_SETTINGS_PRINT_PAGES,
GTK_PRINT_SETTINGS_PAGE_RANGES,
- GTK_PRINT_SETTINGS_PAGE_SET
+ GTK_PRINT_SETTINGS_PAGE_SET,
+ GTK_PRINT_SETTINGS_OUTPUT_URI
};
-#endif /* WITH_GTK_PRINT */
static void ev_window_update_actions (EvWindow *ev_window);
static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
-static void ev_window_load_job_cb (EvJobLoad *job,
+static void ev_window_load_job_cb (EvJob *job,
gpointer data);
+static void ev_window_reload_document (EvWindow *window);
+static void ev_window_reload_job_cb (EvJob *job,
+ EvWindow *window);
static void ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
EvWindow *ev_window);
-#ifdef WITH_GTK_PRINT
-static void ev_window_print_job_cb (EvJobPrint *job,
- EvWindow *window);
-#endif
-static void ev_window_save_job_cb (EvJobSave *save,
+static void ev_window_save_job_cb (EvJob *save,
EvWindow *window);
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
static void ev_window_add_recent (EvWindow *window,
const char *filename);
static void ev_window_run_fullscreen (EvWindow *window);
-static void ev_window_stop_fullscreen (EvWindow *window);
+static void ev_window_stop_fullscreen (EvWindow *window,
+ gboolean unfullscreen_window);
static void ev_window_cmd_view_fullscreen (GtkAction *action,
EvWindow *window);
static void ev_window_run_presentation (EvWindow *window);
-static void ev_window_stop_presentation (EvWindow *window);
+static void ev_window_stop_presentation (EvWindow *window,
+ gboolean unfullscreen_window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
-static void ev_window_run_preview (EvWindow *window);
static void ev_view_popup_cmd_open_link (GtkAction *action,
EvWindow *window);
static void ev_view_popup_cmd_open_link_new_window (GtkAction *action,
static void view_handle_link_cb (EvView *view,
EvLink *link,
EvWindow *window);
+static void ev_window_update_find_status_message (EvWindow *ev_window);
static void ev_window_cmd_edit_find (GtkAction *action,
EvWindow *ev_window);
static void find_bar_search_changed_cb (EggFindBar *find_bar,
GParamSpec *param,
EvWindow *ev_window);
+static void ev_window_load_file_remote (EvWindow *ev_window,
+ GFile *source_file);
+static void ev_window_media_player_key_pressed (EvWindow *window,
+ const gchar *key,
+ gpointer user_data);
+static void ev_window_save_print_page_setup (EvWindow *window);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
gboolean ok_to_print = TRUE;
gboolean ok_to_copy = TRUE;
gboolean has_properties = TRUE;
- gboolean override_restrictions = FALSE;
+ gboolean override_restrictions = TRUE;
gboolean can_get_text = FALSE;
gboolean has_pages = FALSE;
gboolean can_find = FALSE;
-
+#ifdef WITH_GCONF
GConfClient *client;
+#endif
if (document) {
has_document = TRUE;
can_find = TRUE;
}
+#ifdef WITH_GCONF
client = gconf_client_get_default ();
override_restrictions = gconf_client_get_bool (client,
GCONF_OVERRIDE_RESTRICTIONS,
NULL);
+#endif
if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
if (has_document && !EV_IS_FILE_EXPORTER(document))
ok_to_print = FALSE;
-
+#ifdef WITH_GCONF
if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
ok_to_copy = FALSE;
}
if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
ok_to_print = FALSE;
}
-#ifndef WITH_PRINT
- ok_to_print = FALSE;
-#endif
- g_object_unref (client);
+ g_object_unref (client);
+#endif
/* File menu */
ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
-
-#ifdef WITH_GTK_PRINT
ev_window_set_action_sensitive (ev_window, "FilePrintSetup", has_pages && ok_to_print);
-#endif
-
-#ifdef WITH_GNOME_PRINT
- ev_window_set_action_sensitive (ev_window, "FilePrintSetup", FALSE);
-#endif
-
ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages);
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
- ev_window_set_action_sensitive (ev_window, "PreviewPrint", has_pages && ok_to_print);
ev_window_update_actions (ev_window);
}
int n_pages = 0, page = -1;
gboolean has_pages = FALSE;
gboolean presentation_mode;
+ gboolean can_find_in_page = FALSE;
if (ev_window->priv->document && ev_window->priv->page_cache) {
page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
has_pages = n_pages > 0;
}
+ can_find_in_page = (ev_window->priv->find_job &&
+ ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
+
ev_window_set_action_sensitive (ev_window, "EditCopy",
has_pages &&
ev_view_get_has_selection (view));
ev_window_set_action_sensitive (ev_window, "EditFindNext",
- ev_view_can_find_next (view));
+ has_pages && can_find_in_page);
ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
- ev_view_can_find_previous (view));
+ has_pages && can_find_in_page);
presentation_mode = ev_view_get_presentation (view);
EvWindowPrivate *priv = window->priv;
gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
- gboolean preview_toolbar;
presentation = ev_view_get_presentation (EV_VIEW (priv->view));
fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !presentation;
- preview_toolbar = (priv->chrome& EV_CHROME_PREVIEW_TOOLBAR);
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar, toolbar);
set_widget_visibility (priv->find_bar, findbar);
set_widget_visibility (priv->sidebar, sidebar);
- if (priv->preview_toolbar)
- set_widget_visibility (priv->preview_toolbar, preview_toolbar);
-
ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
gtk_widget_set_sensitive (priv->menubar, menubar);
}
static void
-ev_window_error_message_response_cb (EvMessageArea *area,
- gint response_id,
- EvWindow *window)
+ev_window_message_area_response_cb (EvMessageArea *area,
+ gint response_id,
+ EvWindow *window)
{
ev_window_set_message_area (window, NULL);
}
static void
-ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error)
+ev_window_error_message (EvWindow *window,
+ GError *error,
+ const gchar *format,
+ ...)
{
GtkWidget *area;
+ va_list args;
+ gchar *msg = NULL;
- if (EV_WINDOW (window)->priv->message_area)
+ if (window->priv->message_area)
return;
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
area = ev_message_area_new (GTK_MESSAGE_ERROR,
msg,
GTK_STOCK_CLOSE,
- GTK_RESPONSE_CANCEL,
+ GTK_RESPONSE_CLOSE,
NULL);
- ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message);
+ g_free (msg);
+
+ 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),
+ G_CALLBACK (ev_window_message_area_response_cb),
window);
gtk_widget_show (area);
- ev_window_set_message_area (EV_WINDOW (window), area);
+ ev_window_set_message_area (window, area);
}
static void
-find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
+ev_window_warning_message (EvWindow *window,
+ const gchar *format,
+ ...)
{
- ev_window_update_actions (ev_window);
+ GtkWidget *area;
+ va_list args;
+ gchar *msg = NULL;
+
+ if (window->priv->message_area)
+ return;
+
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ area = ev_message_area_new (GTK_MESSAGE_WARNING,
+ msg,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL);
+ g_free (msg);
+
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_message_area_response_cb),
+ window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (window, area);
}
static void
EvWindow *ev_window)
{
ev_window_update_actions (ev_window);
-
+
+ ev_window_update_find_status_message (ev_window);
+
if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
}
}
}
-static void
-setup_document_from_metadata (EvWindow *window)
-{
- char *uri = window->priv->uri;
- GValue page = { 0, };
- gint n_pages;
- gint new_page;
-
- /* View the previously shown page, but make sure to not open a document on
- * the last page, since closing it on the last page most likely means the
- * user was finished reading the document. In that case, reopening should
- * show the first page. */
- if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
- n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
- new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
- if (!window->priv->in_reload && new_page == n_pages - 1)
- new_page = 0;
- ev_page_cache_set_current_page (window->priv->page_cache,
- new_page);
- g_value_unset (&page);
- }
-}
-
static void
setup_chrome_from_metadata (EvWindow *window)
{
}
static void
-setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
+setup_sidebar_from_metadata (EvWindow *window)
{
- char *uri = window->priv->uri;
- GtkWidget *sidebar = window->priv->sidebar;
- GtkWidget *links = window->priv->sidebar_links;
- GtkWidget *thumbs = window->priv->sidebar_thumbs;
- GtkWidget *attachments = window->priv->sidebar_attachments;
- GValue sidebar_size = { 0, };
- GValue sidebar_page = { 0, };
- GValue sidebar_visibility = { 0, };
+ gchar *uri = window->priv->uri;
+ EvDocument *document = window->priv->document;
+ GtkWidget *sidebar = window->priv->sidebar;
+ GtkWidget *links = window->priv->sidebar_links;
+ GtkWidget *thumbs = window->priv->sidebar_thumbs;
+ GtkWidget *attachments = window->priv->sidebar_attachments;
+ GtkWidget *layers = window->priv->sidebar_layers;
+ GValue sidebar_size = { 0, };
+ GValue sidebar_page = { 0, };
+ GValue sidebar_visibility = { 0, };
if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
g_value_unset(&sidebar_size);
}
- if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
+ if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, TRUE)) {
const char *page_id = g_value_get_string (&sidebar_page);
-
+
if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
- } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
- } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+ } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+ } else if (strcmp (page_id, LAYERS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
}
g_value_unset (&sidebar_page);
- } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
- ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (document) {
+ if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
+ }
}
if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
}
static void
-setup_size_from_metadata (EvWindow *window)
+setup_document_from_metadata (EvWindow *window)
{
- char *uri = window->priv->uri;
+ gchar *uri = window->priv->uri;
+ GValue page = { 0, };
GValue width = { 0, };
GValue height = { 0, };
GValue width_ratio = { 0, };
GValue height_ratio = { 0, };
- GValue maximized = { 0, };
- GValue x = { 0, };
- GValue y = { 0, };
- if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
- if (g_value_get_boolean (&maximized)) {
- gtk_window_maximize (GTK_WINDOW (window));
- return;
- } else {
- gtk_window_unmaximize (GTK_WINDOW (window));
- }
- g_value_unset (&maximized);
+ /* View the previously shown page, but make sure to not open a document on
+ * the last page, since closing it on the last page most likely means the
+ * user was finished reading the document. In that case, reopening should
+ * show the first page. */
+ if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
+ gint n_pages;
+ gint new_page;
+
+ n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
+ new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
+ ev_page_cache_set_current_page (window->priv->page_cache,
+ new_page);
+ g_value_unset (&page);
}
- if (ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
- ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
- gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
- g_value_get_int (&y));
- g_value_unset (&x);
- g_value_unset (&y);
- }
+ setup_sidebar_from_metadata (window);
- if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
- ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
- gtk_window_resize (GTK_WINDOW (window),
- g_value_get_int (&width),
- g_value_get_int (&height));
- g_value_unset (&width);
- g_value_unset (&height);
- return;
- }
+ if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
+ ev_metadata_manager_get (uri, "window_height", &height, TRUE))
+ return; /* size was already set in setup_size_from_metadata */
- if (window->priv->page_cache &&
- ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
+ if (ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
ev_metadata_manager_get (uri, "window_height_ratio", &height_ratio, FALSE)) {
-
- gint document_width;
- gint document_height;
-
+ gint document_width;
+ gint document_height;
GdkScreen *screen;
-
- gint request_width;
- gint request_height;
+ gint request_width;
+ gint request_height;
ev_page_cache_get_max_width (window->priv->page_cache,
0, 1.0,
}
static void
-setup_view_from_metadata (EvWindow *window)
+setup_size_from_metadata (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
char *uri = window->priv->uri;
- GEnumValue *enum_value;
- GValue sizing_mode = { 0, };
- GValue zoom = { 0, };
- GValue continuous = { 0, };
- GValue dual_page = { 0, };
- GValue presentation = { 0, };
- GValue fullscreen = { 0, };
- GValue rotation = { 0, };
+ GValue width = { 0, };
+ GValue height = { 0, };
GValue maximized = { 0, };
+ GValue x = { 0, };
+ GValue y = { 0, };
- /* Maximized */
if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
if (g_value_get_boolean (&maximized)) {
gtk_window_maximize (GTK_WINDOW (window));
+ g_value_unset (&maximized);
+ return;
} else {
gtk_window_unmaximize (GTK_WINDOW (window));
}
g_value_unset (&maximized);
}
+ if (ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
+ ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
+ gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
+ g_value_get_int (&y));
+ g_value_unset (&x);
+ g_value_unset (&y);
+ }
+
+ if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
+ ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
+ gtk_window_resize (GTK_WINDOW (window),
+ g_value_get_int (&width),
+ g_value_get_int (&height));
+ g_value_unset (&width);
+ g_value_unset (&height);
+ }
+}
+
+static void
+setup_view_from_metadata (EvWindow *window)
+{
+ EvView *view = EV_VIEW (window->priv->view);
+ gchar *uri = window->priv->uri;
+ GEnumValue *enum_value;
+ GValue sizing_mode = { 0, };
+ GValue zoom = { 0, };
+ GValue continuous = { 0, };
+ GValue dual_page = { 0, };
+ GValue presentation = { 0, };
+ GValue fullscreen = { 0, };
+ GValue rotation = { 0, };
+
/* Sizing mode */
if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode, FALSE)) {
enum_value = g_enum_get_value_by_nick
- (EV_SIZING_MODE_CLASS, g_value_get_string (&sizing_mode));
+ (g_type_class_peek (EV_TYPE_SIZING_MODE), g_value_get_string (&sizing_mode));
g_value_unset (&sizing_mode);
ev_view_set_sizing_mode (view, enum_value->value);
}
ev_window_clear_thumbnail_job (EvWindow *ev_window)
{
if (ev_window->priv->thumbnail_job != NULL) {
- ev_job_queue_remove_job (ev_window->priv->thumbnail_job);
-
+ if (!ev_job_is_finished (ev_window->priv->thumbnail_job))
+ ev_job_cancel (ev_window->priv->thumbnail_job);
+
g_signal_handlers_disconnect_by_func (ev_window->priv->thumbnail_job,
ev_window_set_icon_from_thumbnail,
ev_window);
static void
ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
{
-
- EvRenderContext *rc;
gint page_width, page_height;
gdouble scale;
EvDocument *document = ev_window->priv->document;
- if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ if (!EV_IS_DOCUMENT_THUMBNAILS (document) ||
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache) <= 0) {
return;
}
&page_width, &page_height);
scale = (gdouble)128 / (gdouble)page_width;
- rc = ev_render_context_new (rotation, 0, scale);
-
- ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+ ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
G_CALLBACK (ev_window_set_icon_from_thumbnail),
ev_window);
- ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
- g_object_unref (rc);
+ ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
}
static gboolean
EvDocument *document = ev_window->priv->document;
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
GtkAction *action;
-
- if (EV_IS_DOCUMENT_FIND (document)) {
- g_signal_connect_object (G_OBJECT (document),
- "find_changed",
- G_CALLBACK (find_changed_cb),
- ev_window, 0);
- }
+
+ ev_window->priv->setup_document_idle = 0;
ev_window_refresh_window_thumbnail (ev_window, 0);
if (ev_window->priv->properties) {
ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->uri,
ev_window->priv->document);
}
g_signal_connect (ev_window->priv->page_cache, "history-changed",
G_CALLBACK (history_changed_cb), ev_window);
- setup_size_from_metadata (ev_window);
- setup_sidebar_from_metadata (ev_window, document);
- setup_document_from_metadata (ev_window);
+ if (ev_window->priv->in_reload && ev_window->priv->dest) {
+ gint page;
+
+ /* Restart the current page */
+ page = CLAMP (ev_link_dest_get_page (ev_window->priv->dest),
+ 0,
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache) - 1);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = NULL;
+ }
if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
ev_view_set_document (view, document);
+ } else {
+ ev_window_warning_message (ev_window, "%s",
+ _("The document contains no pages"));
}
- g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
+ if (ev_window->priv->setup_document_idle > 0)
+ g_source_remove (ev_window->priv->setup_document_idle);
+ ev_window->priv->setup_document_idle = g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
}
static void
-password_dialog_response (GtkWidget *password_dialog,
- gint response_id,
- EvWindow *ev_window)
+ev_window_document_changed (EvWindow *ev_window,
+ gpointer user_data)
{
- char *password;
-
- if (response_id == GTK_RESPONSE_OK) {
-
- password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog));
- if (password) {
- ev_document_doc_mutex_lock ();
- ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->load_job->document),
- password);
- ev_document_doc_mutex_unlock ();
- }
- g_free (password);
-
- ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
-
- ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
-
- gtk_widget_destroy (password_dialog);
-
- return;
- }
-
- gtk_widget_set_sensitive (ev_window->priv->password_view, TRUE);
- gtk_widget_destroy (password_dialog);
+ ev_window_reload_document (ev_window);
}
-/* Called either by ev_window_load_job_cb or by the "unlock" callback on the
- * password_view page. It assumes that ev_window->priv->password_* has been set
- * correctly. These are cleared by password_dialog_response() */
-
static void
-ev_window_popup_password_dialog (EvWindow *ev_window)
+ev_window_password_view_unlock (EvWindow *ev_window)
{
+ const gchar *password;
+
g_assert (ev_window->priv->load_job);
- gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
-
- ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
- ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_PASSWORD);
-
- if (ev_window->priv->password_dialog == NULL) {
- ev_window->priv->password_dialog =
- g_object_new (EV_TYPE_PASSWORD_DIALOG, "uri", ev_window->priv->uri, NULL);
- gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->password_dialog), GTK_WINDOW (ev_window));
-
- g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
- (gpointer) &(ev_window->priv->password_dialog));
- g_signal_connect (ev_window->priv->password_dialog,
- "response",
- G_CALLBACK (password_dialog_response),
- ev_window);
- gtk_widget_show (ev_window->priv->password_dialog);
- } else {
- ev_password_dialog_set_bad_pass (EV_PASSWORD_DIALOG (ev_window->priv->password_dialog));
- }
+ password = ev_password_view_get_password (EV_PASSWORD_VIEW (ev_window->priv->password_view));
+ ev_job_load_set_password (EV_JOB_LOAD (ev_window->priv->load_job), password);
+ ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
}
static void
ev_window_clear_load_job (EvWindow *ev_window)
{
if (ev_window->priv->load_job != NULL) {
-
- if (!ev_window->priv->load_job->finished)
- ev_job_queue_remove_job (ev_window->priv->load_job);
+ if (!ev_job_is_finished (ev_window->priv->load_job))
+ ev_job_cancel (ev_window->priv->load_job);
g_signal_handlers_disconnect_by_func (ev_window->priv->load_job, ev_window_load_job_cb, ev_window);
g_object_unref (ev_window->priv->load_job);
}
static void
-ev_window_clear_local_uri (EvWindow *ev_window)
+ev_window_clear_reload_job (EvWindow *ev_window)
{
- if (ev_window->priv->local_uri) {
- ev_tmp_uri_unlink (ev_window->priv->local_uri);
- g_free (ev_window->priv->local_uri);
- ev_window->priv->local_uri = NULL;
+ if (ev_window->priv->reload_job != NULL) {
+ if (!ev_job_is_finished (ev_window->priv->reload_job))
+ ev_job_cancel (ev_window->priv->reload_job);
+
+ g_signal_handlers_disconnect_by_func (ev_window->priv->reload_job, ev_window_reload_job_cb, ev_window);
+ g_object_unref (ev_window->priv->reload_job);
+ ev_window->priv->reload_job = NULL;
}
}
static void
-ev_window_clear_print_settings_file (EvWindow *ev_window)
+ev_window_clear_local_uri (EvWindow *ev_window)
{
- if (ev_window->priv->print_settings_file) {
- g_unlink (ev_window->priv->print_settings_file);
- g_free (ev_window->priv->print_settings_file);
- ev_window->priv->print_settings_file = NULL;
+ if (ev_window->priv->local_uri) {
+ ev_tmp_uri_unlink (ev_window->priv->local_uri);
+ g_free (ev_window->priv->local_uri);
+ ev_window->priv->local_uri = NULL;
}
}
static void
-ev_window_clear_temp_file (EvWindow *ev_window)
+ev_window_clear_temp_symlink (EvWindow *ev_window)
{
- GnomeVFSURI *uri;
- gchar *filename;
- const gchar *tempdir;
+ GFile *file, *tempdir;
if (!ev_window->priv->uri)
return;
- uri = gnome_vfs_uri_new (ev_window->priv->uri);
- if (!gnome_vfs_uri_is_local (uri)) {
- gnome_vfs_uri_unref (uri);
- return;
- }
- gnome_vfs_uri_unref (uri);
-
- filename = g_filename_from_uri (ev_window->priv->uri, NULL, NULL);
- if (!filename)
- return;
-
- tempdir = g_get_tmp_dir ();
- if (g_ascii_strncasecmp (filename, tempdir, strlen (tempdir)) == 0) {
- g_unlink (filename);
+ file = g_file_new_for_uri (ev_window->priv->uri);
+ tempdir = g_file_new_for_path (ev_tmp_dir ());
+
+ if (g_file_has_prefix (file, tempdir)) {
+ GFileInfo *file_info;
+ GError *error = NULL;
+
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, &error);
+ if (file_info) {
+ if (g_file_info_get_is_symlink (file_info))
+ g_file_delete (file, NULL, NULL);
+ g_object_unref (file_info);
+ } else {
+ g_warning ("Error deleting temp symlink: %s\n", error->message);
+ g_error_free (error);
+ }
}
- g_free (filename);
+ g_object_unref (file);
+ g_object_unref (tempdir);
}
/* This callback will executed when load job will be finished.
* function should _not_ necessarily expect those to exist after being
* called. */
static void
-ev_window_load_job_cb (EvJobLoad *job,
- gpointer data)
+ev_window_load_job_cb (EvJob *job,
+ gpointer data)
{
EvWindow *ev_window = EV_WINDOW (data);
EvDocument *document = EV_JOB (job)->document;
+ EvJobLoad *job_load = EV_JOB_LOAD (job);
+
+ g_assert (job_load->uri);
- g_assert (job->uri);
-
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
/* Success! */
- if (job->error == NULL) {
+ if (!ev_job_is_failed (job)) {
ev_window_set_document (ev_window, document);
-
- if (job->mode != EV_WINDOW_MODE_PREVIEW) {
- setup_view_from_metadata (ev_window);
- }
- if (!ev_window->priv->unlink_temp_file) {
- ev_window_add_recent (ev_window, ev_window->priv->uri);
+ setup_document_from_metadata (ev_window);
+ setup_view_from_metadata (ev_window);
+
+ ev_window_add_recent (ev_window, ev_window->priv->uri);
+
+ ev_window_title_set_type (ev_window->priv->title,
+ EV_WINDOW_TITLE_DOCUMENT);
+ if (job_load->password) {
+ GPasswordSave flags;
+
+ flags = ev_password_view_get_password_save_flags (
+ EV_PASSWORD_VIEW (ev_window->priv->password_view));
+ ev_keyring_save_password (ev_window->priv->uri,
+ job_load->password,
+ flags);
}
- if (job->dest) {
+ if (ev_window->priv->dest) {
EvLink *link;
EvLinkAction *link_action;
- link_action = ev_link_action_new_dest (g_object_ref (job->dest));
+ link_action = ev_link_action_new_dest (ev_window->priv->dest);
link = ev_link_new (NULL, link_action);
ev_view_handle_link (EV_VIEW (ev_window->priv->view), link);
g_object_unref (link);
+
+ /* Already unrefed by ev_link_action
+ * FIXME: link action should inc dest ref counting
+ * or not unref it at all
+ */
+ ev_window->priv->dest = NULL;
}
- switch (job->mode) {
+ switch (ev_window->priv->window_mode) {
case EV_WINDOW_MODE_FULLSCREEN:
ev_window_run_fullscreen (ev_window);
break;
case EV_WINDOW_MODE_PRESENTATION:
ev_window_run_presentation (ev_window);
break;
- case EV_WINDOW_MODE_PREVIEW:
- ev_window_run_preview (ev_window);
- break;
default:
break;
}
- /* Restart the search after reloading */
- if (ev_window->priv->in_reload) {
- GtkWidget *widget;
-
- widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
- if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
- find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
- NULL, ev_window);
- }
- } else if (job->search_string && EV_IS_DOCUMENT_FIND (document)) {
+ if (ev_window->priv->search_string && EV_IS_DOCUMENT_FIND (document)) {
ev_window_cmd_edit_find (NULL, ev_window);
egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar),
- job->search_string);
+ ev_window->priv->search_string);
}
+ g_free (ev_window->priv->search_string);
+ ev_window->priv->search_string = NULL;
+
+ /* Create a monitor for the document */
+ ev_window->priv->monitor = ev_file_monitor_new (ev_window->priv->uri);
+ g_signal_connect_swapped (ev_window->priv->monitor, "changed",
+ G_CALLBACK (ev_window_document_changed),
+ ev_window);
+
ev_window_clear_load_job (ev_window);
- ev_window->priv->in_reload = FALSE;
return;
}
- if (job->error->domain == EV_DOCUMENT_ERROR &&
- job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
- gchar *base_name, *file_name;
-
+ if (g_error_matches (job->error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_ENCRYPTED)) {
+ gchar *password;
+
setup_view_from_metadata (ev_window);
+
+ /* First look whether password is in keyring */
+ password = ev_keyring_lookup_password (ev_window->priv->uri);
+ if (password) {
+ if (job_load->password && strcmp (password, job_load->password) == 0) {
+ /* Password in kering is wrong */
+ ev_job_load_set_password (job_load, NULL);
+ /* FIXME: delete password from keyring? */
+ } else {
+ ev_job_load_set_password (job_load, password);
+ ev_job_scheduler_push_job (job, EV_JOB_PRIORITY_NONE);
+ g_free (password);
+ return;
+ }
+
+ g_free (password);
+ }
+
+ /* We need to ask the user for a password */
+ ev_window_title_set_uri (ev_window->priv->title,
+ ev_window->priv->uri);
+ ev_window_title_set_type (ev_window->priv->title,
+ EV_WINDOW_TITLE_PASSWORD);
+
+ ev_password_view_set_uri (EV_PASSWORD_VIEW (ev_window->priv->password_view),
+ job_load->uri);
- file_name = gnome_vfs_format_uri_for_display (job->uri);
- base_name = g_path_get_basename (file_name);
- ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
- base_name);
- g_free (file_name);
- g_free (base_name);
ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
-
- ev_window_popup_password_dialog (ev_window);
+
+ ev_job_load_set_password (job_load, NULL);
+ ev_password_view_ask_password (EV_PASSWORD_VIEW (ev_window->priv->password_view));
} else {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("Unable to open document"),
- job->error);
+ ev_window_error_message (ev_window, job->error,
+ "%s", _("Unable to open document"));
ev_window_clear_load_job (ev_window);
- ev_window->priv->in_reload = FALSE;
}
+}
- return;
+static void
+ev_window_reload_job_cb (EvJob *job,
+ EvWindow *ev_window)
+{
+ GtkWidget *widget;
+
+ if (ev_job_is_failed (job)) {
+ ev_window_clear_reload_job (ev_window);
+ ev_window->priv->in_reload = FALSE;
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = NULL;
+
+ return;
+ }
+
+ ev_window_set_document (ev_window, job->document);
+
+ /* Restart the search after reloading */
+ widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
+ if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
+ find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
+ NULL, ev_window);
+ }
+
+ ev_window_clear_reload_job (ev_window);
+ ev_window->priv->in_reload = FALSE;
}
/**
static void
ev_window_close_dialogs (EvWindow *ev_window)
{
- if (ev_window->priv->password_dialog)
- gtk_widget_destroy (ev_window->priv->password_dialog);
- ev_window->priv->password_dialog = NULL;
-
-#ifdef WITH_PRINT
if (ev_window->priv->print_dialog)
gtk_widget_destroy (ev_window->priv->print_dialog);
ev_window->priv->print_dialog = NULL;
-#endif
-
-#ifdef WITH_GNOME_PRINT
- if (ev_window->priv->print_job)
- g_object_unref (ev_window->priv->print_job);
- ev_window->priv->print_job = NULL;
-#endif
if (ev_window->priv->properties)
gtk_widget_destroy (ev_window->priv->properties);
ev_window->priv->properties = NULL;
}
-static gint
-open_xfer_update_progress_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSXferProgressInfo *info,
- EvWindow *ev_window)
-{
- switch (info->status) {
- case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
- if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
- }
+static void
+ev_window_clear_progress_idle (EvWindow *ev_window)
+{
+ if (ev_window->priv->progress_idle > 0)
+ g_source_remove (ev_window->priv->progress_idle);
+ ev_window->priv->progress_idle = 0;
+}
- return 1;
- case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
- case GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE:
- case GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE:
- return 1;
- default:
- g_assert_not_reached ();
+static void
+reset_progress_idle (EvWindow *ev_window)
+{
+ ev_window->priv->progress_idle = 0;
+}
+
+static void
+ev_window_show_progress_message (EvWindow *ev_window,
+ guint interval,
+ GSourceFunc function)
+{
+ if (ev_window->priv->progress_idle > 0)
+ g_source_remove (ev_window->priv->progress_idle);
+ ev_window->priv->progress_idle =
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ interval, function,
+ ev_window,
+ (GDestroyNotify)reset_progress_idle);
+}
+
+static void
+ev_window_reset_progress_cancellable (EvWindow *ev_window)
+{
+ if (ev_window->priv->progress_cancellable)
+ g_cancellable_reset (ev_window->priv->progress_cancellable);
+ else
+ ev_window->priv->progress_cancellable = g_cancellable_new ();
+}
+
+static void
+ev_window_progress_response_cb (EvProgressMessageArea *area,
+ gint response,
+ EvWindow *ev_window)
+{
+ if (response == GTK_RESPONSE_CANCEL)
+ g_cancellable_cancel (ev_window->priv->progress_cancellable);
+ ev_window_set_message_area (ev_window, NULL);
+}
+
+static gboolean
+show_loading_progress (EvWindow *ev_window)
+{
+ GtkWidget *area;
+ gchar *text;
+
+ if (ev_window->priv->message_area)
+ return FALSE;
+
+ text = g_strdup_printf (_("Loading document from %s"),
+ ev_window->priv->uri);
+ area = ev_progress_message_area_new (GTK_STOCK_OPEN,
+ text,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_progress_response_cb),
+ ev_window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (ev_window, area);
+ g_free (text);
+
+ return FALSE;
+}
+
+static void
+ev_window_load_remote_failed (EvWindow *ev_window,
+ GError *error)
+{
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+ ev_window->priv->in_reload = FALSE;
+ ev_window_error_message (ev_window, error,
+ "%s", _("Unable to open document"));
+ g_free (ev_window->priv->local_uri);
+ ev_window->priv->local_uri = NULL;
+ ev_window->priv->uri_mtime = 0;
+}
+
+static void
+set_uri_mtime (GFile *source,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GFileInfo *info;
+ GError *error = NULL;
+
+ info = g_file_query_info_finish (source, async_result, &error);
+
+ if (error) {
+ ev_window->priv->uri_mtime = 0;
+ g_error_free (error);
+ } else {
+ GTimeVal mtime;
+
+ g_file_info_get_modification_time (info, &mtime);
+ ev_window->priv->uri_mtime = mtime.tv_sec;
+ g_object_unref (info);
}
- return 0;
+ g_object_unref (source);
+}
+
+static void
+mount_volume_ready_cb (GFile *source,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ g_file_mount_enclosing_volume_finish (source, async_result, &error);
+
+ if (error) {
+ ev_window_load_remote_failed (ev_window, error);
+ g_object_unref (source);
+ g_error_free (error);
+ } else {
+ /* Volume successfully mounted,
+ try opening the file again */
+ ev_window_load_file_remote (ev_window, source);
+ }
+}
+
+static void
+window_open_file_copy_ready_cb (GFile *source,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ ev_window_clear_progress_idle (ev_window);
+
+ g_file_copy_finish (source, async_result, &error);
+ if (!error) {
+ ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
+ g_file_query_info_async (source,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ 0, G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback)set_uri_mtime,
+ ev_window);
+ return;
+ }
+
+ if (error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_NOT_MOUNTED) {
+ GMountOperation *operation;
+
+ operation = ev_mount_operation_new (GTK_WINDOW (ev_window));
+ g_file_mount_enclosing_volume (source,
+ G_MOUNT_MOUNT_NONE,
+ operation, NULL,
+ (GAsyncReadyCallback)mount_volume_ready_cb,
+ ev_window);
+ g_object_unref (operation);
+ } else if (error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_CANCELLED) {
+ ev_window_clear_load_job (ev_window);
+ ev_window_clear_local_uri (ev_window);
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = NULL;
+ g_object_unref (source);
+
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+ } else {
+ ev_window_load_remote_failed (ev_window, error);
+ g_object_unref (source);
+ }
+
+ g_error_free (error);
+}
+
+static void
+window_open_file_copy_progress_cb (goffset n_bytes,
+ goffset total_bytes,
+ EvWindow *ev_window)
+{
+ gchar *status;
+ gdouble fraction;
+
+ if (!ev_window->priv->message_area)
+ return;
+
+ fraction = n_bytes / (gdouble)total_bytes;
+ status = g_strdup_printf (_("Downloading document (%d%%)"),
+ (gint)(fraction * 100));
+
+ ev_progress_message_area_set_status (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ status);
+ ev_progress_message_area_set_fraction (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ fraction);
+
+ g_free (status);
+}
+
+static void
+ev_window_load_file_remote (EvWindow *ev_window,
+ GFile *source_file)
+{
+ GFile *target_file;
+
+ if (!ev_window->priv->local_uri) {
+ gchar *tmp_name;
+ gchar *base_name;
+
+ /* We'd like to keep extension of source uri since
+ * it helps to resolve some mime types, say cbz */
+ tmp_name = ev_tmp_filename (NULL);
+ base_name = g_file_get_basename (source_file);
+ ev_window->priv->local_uri = g_strconcat ("file:", tmp_name, "-",
+ base_name, NULL);
+ ev_job_load_set_uri (EV_JOB_LOAD (ev_window->priv->load_job),
+ ev_window->priv->local_uri);
+ g_free (base_name);
+ g_free (tmp_name);
+ }
+
+ ev_window_reset_progress_cancellable (ev_window);
+
+ target_file = g_file_new_for_uri (ev_window->priv->local_uri);
+ g_file_copy_async (source_file, target_file,
+ 0, G_PRIORITY_DEFAULT,
+ ev_window->priv->progress_cancellable,
+ (GFileProgressCallback)window_open_file_copy_progress_cb,
+ ev_window,
+ (GAsyncReadyCallback)window_open_file_copy_ready_cb,
+ ev_window);
+ g_object_unref (target_file);
+
+ ev_window_show_progress_message (ev_window, 1,
+ (GSourceFunc)show_loading_progress);
}
void
const char *uri,
EvLinkDest *dest,
EvWindowRunMode mode,
- const gchar *search_string,
- gboolean unlink_temp_file,
- const gchar *print_settings)
+ const gchar *search_string)
{
- GnomeVFSURI *source_uri;
- GnomeVFSURI *target_uri;
+ GFile *source_file;
+ ev_window->priv->in_reload = FALSE;
+
if (ev_window->priv->uri &&
g_ascii_strcasecmp (ev_window->priv->uri, uri) == 0) {
- ev_window->priv->in_reload = TRUE;
+ ev_window_reload_document (ev_window);
+ return;
+ }
+
+ if (ev_window->priv->monitor) {
+ g_object_unref (ev_window->priv->monitor);
+ ev_window->priv->monitor = NULL;
}
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
- ev_window_clear_print_settings_file (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
- ev_window->priv->unlink_temp_file = unlink_temp_file;
-
- if (mode == EV_WINDOW_MODE_PREVIEW) {
- ev_window->priv->print_settings_file = print_settings ?
- g_strdup (print_settings) : NULL;
- }
+ ev_window->priv->window_mode = mode;
if (ev_window->priv->uri)
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
+ if (ev_window->priv->search_string)
+ g_free (ev_window->priv->search_string);
+ ev_window->priv->search_string = search_string ?
+ g_strdup (search_string) : NULL;
+
+ if (ev_window->priv->dest)
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = dest ? g_object_ref (dest) : NULL;
+
setup_size_from_metadata (ev_window);
-
- ev_window->priv->load_job = ev_job_load_new (uri, dest, mode, search_string);
+
+ ev_window->priv->load_job = ev_job_load_new (uri);
g_signal_connect (ev_window->priv->load_job,
"finished",
G_CALLBACK (ev_window_load_job_cb),
ev_window);
- source_uri = gnome_vfs_uri_new (uri);
- if (!gnome_vfs_uri_is_local (source_uri) && !ev_window->priv->local_uri) {
- GnomeVFSAsyncHandle *handle;
- GList *slist = NULL;
- GList *tlist = NULL;
- char *tmp_name;
- char *base_name;
+ source_file = g_file_new_for_uri (uri);
+ if (!g_file_is_native (source_file) && !ev_window->priv->local_uri) {
+ ev_window_load_file_remote (ev_window, source_file);
+ } else {
+ g_object_unref (source_file);
+ ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
+ }
+}
- /* We'd like to keep extension of source uri since
- * it helps to resolve some mime types, say cbz */
+static void
+ev_window_reload_local (EvWindow *ev_window)
+{
+ const gchar *uri;
+
+ uri = ev_window->priv->local_uri ? ev_window->priv->local_uri : ev_window->priv->uri;
+ ev_window->priv->reload_job = ev_job_load_new (uri);
+ g_signal_connect (ev_window->priv->reload_job, "finished",
+ G_CALLBACK (ev_window_reload_job_cb),
+ ev_window);
+ ev_job_scheduler_push_job (ev_window->priv->reload_job, EV_JOB_PRIORITY_NONE);
+}
- tmp_name = ev_tmp_filename (NULL);
- base_name = gnome_vfs_uri_extract_short_name (source_uri);
- ev_window->priv->local_uri = g_strconcat ("file:", tmp_name, "-", base_name, NULL);
- ev_job_load_set_uri (EV_JOB_LOAD (ev_window->priv->load_job),
- ev_window->priv->local_uri);
- g_free (base_name);
- g_free (tmp_name);
-
- target_uri = gnome_vfs_uri_new (ev_window->priv->local_uri);
-
- slist = g_list_prepend (slist, source_uri);
- tlist = g_list_prepend (tlist, target_uri);
- gnome_vfs_async_xfer (&handle, slist, tlist,
- GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
- GNOME_VFS_XFER_ERROR_MODE_ABORT,
- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
- GNOME_VFS_PRIORITY_DEFAULT,
- (GnomeVFSAsyncXferProgressCallback)
- open_xfer_update_progress_callback,
- ev_window,
- NULL, NULL);
-
- g_list_free (slist);
- g_list_free (tlist);
- gnome_vfs_uri_unref (target_uri);
- gnome_vfs_uri_unref (source_uri);
+static gboolean
+show_reloading_progress (EvWindow *ev_window)
+{
+ GtkWidget *area;
+ gchar *text;
+
+ if (ev_window->priv->message_area)
+ return FALSE;
+
+ text = g_strdup_printf (_("Reloading document from %s"),
+ ev_window->priv->uri);
+ area = ev_progress_message_area_new (GTK_STOCK_REFRESH,
+ text,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_progress_response_cb),
+ ev_window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (ev_window, area);
+ g_free (text);
+
+ return FALSE;
+}
+
+static void
+reload_remote_copy_ready_cb (GFile *remote,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ ev_window_clear_progress_idle (ev_window);
+
+ g_file_copy_finish (remote, async_result, &error);
+ if (error) {
+ if (error->domain != G_IO_ERROR ||
+ error->code != G_IO_ERROR_CANCELLED)
+ ev_window_error_message (ev_window, error,
+ "%s", _("Failed to reload document."));
+ g_error_free (error);
+ } else {
+ ev_window_reload_local (ev_window);
+ }
+ g_object_unref (remote);
+}
+
+static void
+reload_remote_copy_progress_cb (goffset n_bytes,
+ goffset total_bytes,
+ EvWindow *ev_window)
+{
+ gchar *status;
+ gdouble fraction;
+
+ if (!ev_window->priv->message_area)
+ return;
+
+ fraction = n_bytes / (gdouble)total_bytes;
+ status = g_strdup_printf (_("Downloading document (%d%%)"),
+ (gint)(fraction * 100));
+
+ ev_progress_message_area_set_status (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ status);
+ ev_progress_message_area_set_fraction (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ fraction);
+
+ g_free (status);
+}
+
+static void
+query_remote_uri_mtime_cb (GFile *remote,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GFileInfo *info;
+ GTimeVal mtime;
+ GError *error = NULL;
+
+ info = g_file_query_info_finish (remote, async_result, &error);
+ if (error) {
+ g_error_free (error);
+ g_object_unref (remote);
+ ev_window_reload_local (ev_window);
+
return;
}
+
+ g_file_info_get_modification_time (info, &mtime);
+ if (ev_window->priv->uri_mtime != mtime.tv_sec) {
+ GFile *target_file;
+
+ /* Remote file has changed */
+ ev_window->priv->uri_mtime = mtime.tv_sec;
- gnome_vfs_uri_unref (source_uri);
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
+ ev_window_reset_progress_cancellable (ev_window);
+
+ target_file = g_file_new_for_uri (ev_window->priv->local_uri);
+ g_file_copy_async (remote, target_file,
+ G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT,
+ ev_window->priv->progress_cancellable,
+ (GFileProgressCallback)reload_remote_copy_progress_cb,
+ ev_window,
+ (GAsyncReadyCallback)reload_remote_copy_ready_cb,
+ ev_window);
+ g_object_unref (target_file);
+ ev_window_show_progress_message (ev_window, 1,
+ (GSourceFunc)show_reloading_progress);
+ } else {
+ g_object_unref (remote);
+ ev_window_reload_local (ev_window);
+ }
+
+ g_object_unref (info);
+}
+
+static void
+ev_window_reload_remote (EvWindow *ev_window)
+{
+ GFile *remote;
+
+ remote = g_file_new_for_uri (ev_window->priv->uri);
+ /* Reload the remote uri only if it has changed */
+ g_file_query_info_async (remote,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ 0, G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback)query_remote_uri_mtime_cb,
+ ev_window);
+}
+
+static void
+ev_window_reload_document (EvWindow *ev_window)
+{
+ gint page;
+
+
+ ev_window_clear_reload_job (ev_window);
+ ev_window->priv->in_reload = TRUE;
+
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+
+ if (ev_window->priv->dest)
+ g_object_unref (ev_window->priv->dest);
+ /* FIXME: save the scroll position too (xyz dest) */
+ ev_window->priv->dest = ev_link_dest_new_page (page);
+
+ if (ev_window->priv->local_uri) {
+ ev_window_reload_remote (ev_window);
+ } else {
+ ev_window_reload_local (ev_window);
+ }
}
static void
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser),
window->priv->uri);
} else {
-#if GLIB_CHECK_VERSION (2, 13, 3)
const gchar *folder;
folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
folder ? folder : g_get_home_dir ());
-#else
- char *folder;
-
- folder = xdg_user_dir_lookup ("DOCUMENTS");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
- folder);
- free (folder);
-#endif
}
g_signal_connect (chooser, "response",
new_filename = ev_window_create_tmp_symlink (old_filename, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (window),
- _("Cannot open a copy."),
- error);
-
+ ev_window_error_message (window, error,
+ "%s", _("Cannot open a copy."));
g_error_free (error);
g_free (old_filename);
g_free (new_filename);
dest,
0,
NULL,
- TRUE,
- NULL,
GDK_CURRENT_TIME);
g_free (symlink_uri);
}
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, FALSE, NULL,
- GDK_CURRENT_TIME);
+ NULL, 0, NULL, GDK_CURRENT_TIME);
}
static void
{
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, FALSE, NULL,
- GDK_CURRENT_TIME);
+ NULL, 0, NULL, GDK_CURRENT_TIME);
}
static void
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;
gtk_recent_info_ref (info),
(GDestroyNotify) gtk_recent_info_unref);
- g_signal_connect (G_OBJECT (action), "activate",
+ g_signal_connect (action, "activate",
G_CALLBACK (ev_window_cmd_recent_file_activate),
(gpointer) ev_window);
g_list_free (items);
}
-static gint
-save_xfer_update_progress_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSXferProgressInfo *info,
- GnomeVFSURI *tmp_uri)
-{
- switch (info->status) {
- case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
- if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
- gchar *uri;
-
- uri = gnome_vfs_uri_to_string (tmp_uri, 0);
- ev_tmp_uri_unlink (uri);
- g_free (uri);
- gnome_vfs_uri_unref (tmp_uri);
- }
- return 1;
- case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
- if (info->vfs_status != GNOME_VFS_OK) {
- GtkWidget *dialog;
- gchar *uri;
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("The file could not be saved as “%s”."),
- info->target_name);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- gnome_vfs_result_to_string (info->vfs_status));
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (dialog);
-
- uri = gnome_vfs_uri_to_string (tmp_uri, 0);
- ev_tmp_uri_unlink (uri);
- g_free (uri);
- gnome_vfs_uri_unref (tmp_uri);
- }
- return 1;
- case GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE:
- case GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE:
- return 1;
- default:
- g_assert_not_reached ();
+static gboolean
+show_saving_progress (GFile *dst)
+{
+ EvWindow *ev_window;
+ GtkWidget *area;
+ gchar *text;
+ gchar *uri;
+ EvSaveType save_type;
+
+ ev_window = EV_WINDOW (g_object_get_data (G_OBJECT (dst), "ev-window"));
+ ev_window->priv->progress_idle = 0;
+
+ if (ev_window->priv->message_area)
+ return FALSE;
+
+ save_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dst), "save-type"));
+ uri = g_file_get_uri (dst);
+ switch (save_type) {
+ case EV_SAVE_DOCUMENT:
+ text = g_strdup_printf (_("Saving document to %s"), uri);
+ break;
+ case EV_SAVE_ATTACHMENT:
+ text = g_strdup_printf (_("Saving attachment to %s"), uri);
+ break;
+ case EV_SAVE_IMAGE:
+ text = g_strdup_printf (_("Saving image to %s"), uri);
+ break;
+ default:
+ g_assert_not_reached ();
}
+ g_free (uri);
+ area = ev_progress_message_area_new (GTK_STOCK_SAVE,
+ text,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_progress_response_cb),
+ ev_window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (ev_window, area);
+ g_free (text);
- return 0;
+ return FALSE;
}
static void
-ev_window_save_remote (EvWindow *ev_window,
- GnomeVFSURI *src,
- GnomeVFSURI *dst)
+window_save_file_copy_ready_cb (GFile *src,
+ GAsyncResult *async_result,
+ GFile *dst)
{
- GnomeVFSAsyncHandle *handle;
- GList *slist = NULL;
- GList *tlist = NULL;
+ EvWindow *ev_window;
+ GError *error = NULL;
+
+ ev_window = EV_WINDOW (g_object_get_data (G_OBJECT (dst), "ev-window"));
+ ev_window_clear_progress_idle (ev_window);
- slist = g_list_prepend (slist, src);
- tlist = g_list_prepend (tlist, dst);
- gnome_vfs_async_xfer (&handle, slist, tlist,
- GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
- GNOME_VFS_XFER_ERROR_MODE_ABORT,
- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
- GNOME_VFS_PRIORITY_DEFAULT,
- (GnomeVFSAsyncXferProgressCallback)
- save_xfer_update_progress_callback,
- gnome_vfs_uri_ref (src),
- NULL, NULL);
- g_list_free (slist);
- g_list_free (tlist);
+ if (g_file_copy_finish (src, async_result, &error)) {
+ ev_tmp_file_unlink (src);
+ return;
+ }
+
+ if (error->domain != G_IO_ERROR ||
+ error->code != G_IO_ERROR_CANCELLED) {
+ gchar *name;
+
+ name = g_file_get_basename (dst);
+ ev_window_error_message (ev_window, error,
+ _("The file could not be saved as “%s”."),
+ name);
+ g_free (name);
+ }
+ ev_tmp_file_unlink (src);
+ g_error_free (error);
+}
+
+static void
+window_save_file_copy_progress_cb (goffset n_bytes,
+ goffset total_bytes,
+ GFile *dst)
+{
+ EvWindow *ev_window;
+ EvSaveType save_type;
+ gchar *status;
+ gdouble fraction;
+
+ ev_window = EV_WINDOW (g_object_get_data (G_OBJECT (dst), "ev-window"));
+
+ if (!ev_window->priv->message_area)
+ return;
+
+ fraction = n_bytes / (gdouble)total_bytes;
+ save_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dst), "save-type"));
+
+ switch (save_type) {
+ case EV_SAVE_DOCUMENT:
+ status = g_strdup_printf (_("Uploading document (%d%%)"),
+ (gint)(fraction * 100));
+ break;
+ case EV_SAVE_ATTACHMENT:
+ status = g_strdup_printf (_("Uploading attachment (%d%%)"),
+ (gint)(fraction * 100));
+ break;
+ case EV_SAVE_IMAGE:
+ status = g_strdup_printf (_("Uploading image (%d%%)"),
+ (gint)(fraction * 100));
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ ev_progress_message_area_set_status (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ status);
+ ev_progress_message_area_set_fraction (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ fraction);
+
+ g_free (status);
+}
+
+static void
+ev_window_save_remote (EvWindow *ev_window,
+ EvSaveType save_type,
+ GFile *src,
+ GFile *dst)
+{
+ ev_window_reset_progress_cancellable (ev_window);
+ g_object_set_data (G_OBJECT (dst), "ev-window", ev_window);
+ g_object_set_data (G_OBJECT (dst), "save-type", GINT_TO_POINTER (save_type));
+ g_file_copy_async (src, dst,
+ G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT,
+ ev_window->priv->progress_cancellable,
+ (GFileProgressCallback)window_save_file_copy_progress_cb,
+ dst,
+ (GAsyncReadyCallback)window_save_file_copy_ready_cb,
+ dst);
+ ev_window->priv->progress_idle =
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ 1,
+ (GSourceFunc)show_saving_progress,
+ dst,
+ NULL);
}
static void
ev_window_clear_save_job (EvWindow *ev_window)
{
if (ev_window->priv->save_job != NULL) {
- if (!ev_window->priv->save_job->finished)
- ev_job_queue_remove_job (ev_window->priv->save_job);
+ if (!ev_job_is_finished (ev_window->priv->save_job))
+ ev_job_cancel (ev_window->priv->save_job);
g_signal_handlers_disconnect_by_func (ev_window->priv->save_job,
ev_window_save_job_cb,
}
static void
-ev_window_save_job_cb (EvJobSave *job,
+ev_window_save_job_cb (EvJob *job,
EvWindow *window)
{
- if (job->error) {
- gchar *msg;
-
- msg = g_strdup_printf (_("The file could not be saved as “%s”."), job->uri);
- ev_window_error_message (GTK_WINDOW (window), msg, job->error);
- g_free (msg);
+ if (ev_job_is_failed (job)) {
+ ev_window_error_message (window, job->error,
+ _("The file could not be saved as “%s”."),
+ EV_JOB_SAVE (job)->uri);
}
ev_window_clear_save_job (window);
}
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+ /* FIXME: remote copy should be done here rather than in the save job,
+ * so that we can track progress and cancel the operation
+ */
ev_window_clear_save_job (ev_window);
ev_window->priv->save_job = ev_job_save_new (ev_window->priv->document,
G_CALLBACK (ev_window_save_job_cb),
ev_window);
/* The priority doesn't matter for this job */
- ev_job_queue_add_job (ev_window->priv->save_job, EV_JOB_PRIORITY_LOW);
+ ev_job_scheduler_push_job (ev_window->priv->save_job, EV_JOB_PRIORITY_NONE);
g_free (uri);
-
gtk_widget_destroy (fc);
}
{
GtkWidget *fc;
gchar *base_name;
- gchar *file_name;
-#if GLIB_CHECK_VERSION (2, 13, 3)
+ GFile *file;
const gchar *folder;
-#else
- gchar *folder;
-#endif
fc = gtk_file_chooser_dialog_new (
_("Save a Copy"),
ev_document_factory_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
- file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri);
- base_name = g_path_get_basename (file_name);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
+ file = g_file_new_for_uri (ev_window->priv->uri);
+ base_name = g_file_get_basename (file);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
-#if GLIB_CHECK_VERSION (2, 13, 3)
folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc),
folder ? folder : g_get_home_dir ());
-#else
- folder = xdg_user_dir_lookup ("DOCUMENTS");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc), folder);
- free (folder);
-#endif
- g_free (file_name);
+ g_object_unref (file);
g_free (base_name);
g_signal_connect (fc, "response",
gtk_widget_show (fc);
}
-#ifdef WITH_GTK_PRINT
-static void
-ev_window_print_page_setup_done_cb (GtkPageSetup *page_setup,
- EvWindow *window)
-{
- /* Dialog was canceled */
- if (!page_setup)
- return;
-
- if (window->priv->print_page_setup)
- g_object_unref (window->priv->print_page_setup);
- window->priv->print_page_setup = g_object_ref (page_setup);
-}
-#endif /* WITH_GTK_PRINT */
-
-static void
-ev_window_cmd_file_print_setup (GtkAction *action, EvWindow *ev_window)
-{
-#ifdef WITH_GTK_PRINT
- gtk_print_run_page_setup_dialog_async (
- GTK_WINDOW (ev_window),
- ev_window->priv->print_page_setup,
- ev_window->priv->print_settings,
- (GtkPageSetupDoneFunc) ev_window_print_page_setup_done_cb,
- ev_window);
-#endif /* WITH_GTK_PRINT */
-}
-
-#ifdef WITH_GTK_PRINT
-static void
-ev_window_clear_print_job (EvWindow *window)
-{
- if (window->priv->print_job) {
- if (!window->priv->print_job->finished)
- ev_job_queue_remove_job (window->priv->print_job);
-
- g_signal_handlers_disconnect_by_func (window->priv->print_job,
- ev_window_print_job_cb,
- window);
- g_object_unref (window->priv->print_job);
- window->priv->print_job = NULL;
- }
-
- if (window->priv->gtk_print_job) {
- g_object_unref (window->priv->gtk_print_job);
- window->priv->gtk_print_job = NULL;
- }
-}
-
static void
ev_window_load_print_settings_from_metadata (EvWindow *window)
{
gtk_print_settings_set (window->priv->print_settings,
document_print_settings[i],
success ? g_value_get_string (&value) : NULL);
+ if (success)
+ g_value_unset (&value);
}
}
}
static void
-ev_window_print_finished (GtkPrintJob *print_job,
- EvWindow *window,
- GError *error)
+ev_window_save_print_page_setup (EvWindow *window)
{
- ev_window_clear_print_job (window);
-
- if (error) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to print document"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message);
+ gchar *uri = window->priv->uri;
+ GtkPageSetup *page_setup = window->priv->print_page_setup;
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- } else {
- /* If printed successfully, save print settings */
- ev_application_set_print_settings (EV_APP,
- window->priv->print_settings);
- ev_window_save_print_settings (window);
- }
+ /* Save page setup options that are specific to the document */
+ ev_metadata_manager_set_int (uri, "page-setup-orientation",
+ gtk_page_setup_get_orientation (page_setup));
+ ev_metadata_manager_set_double (uri, "page-setup-margin-top",
+ gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_MM));
+ ev_metadata_manager_set_double (uri, "page-setup-margin-bottom",
+ gtk_page_setup_get_bottom_margin (page_setup, GTK_UNIT_MM));
+ ev_metadata_manager_set_double (uri, "page-setup-margin-left",
+ gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_MM));
+ ev_metadata_manager_set_double (uri, "page-setup-margin-right",
+ gtk_page_setup_get_right_margin (page_setup, GTK_UNIT_MM));
}
static void
-ev_window_print_send (EvWindow *window,
- const gchar *filename)
+ev_window_load_print_page_setup_from_metadata (EvWindow *window)
{
- GtkPrintSettings *settings;
- EvFileExporterCapabilities capabilities;
+ gchar *uri = window->priv->uri;
+ GtkPageSetup *page_setup = window->priv->print_page_setup;
+ GtkPaperSize *paper_size;
+ GValue value = { 0, };
+
+ paper_size = gtk_page_setup_get_paper_size (page_setup);
- /* Some printers take into account some print settings,
- * and others don't. However we have exported the document
- * to a ps or pdf file according to such print settings. So,
- * we want to send the exported file to printer with those
- * settings set to default values.
- */
- settings = gtk_print_settings_copy (window->priv->print_settings);
- capabilities = ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (window->priv->document));
-
- gtk_print_settings_set_page_ranges (settings, NULL, 0);
- gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL);
- if (capabilities & EV_FILE_EXPORTER_CAN_COPIES)
- gtk_print_settings_set_n_copies (settings, 1);
- if (capabilities & EV_FILE_EXPORTER_CAN_PAGE_SET)
- gtk_print_settings_set_page_set (settings, GTK_PAGE_SET_ALL);
- if (capabilities & EV_FILE_EXPORTER_CAN_SCALE)
- gtk_print_settings_set_scale (settings, 1.0);
- if (capabilities & EV_FILE_EXPORTER_CAN_COLLATE)
- gtk_print_settings_set_collate (settings, FALSE);
- if (capabilities & EV_FILE_EXPORTER_CAN_REVERSE)
- gtk_print_settings_set_reverse (settings, FALSE);
- if (capabilities & EV_FILE_EXPORTER_CAN_NUMBER_UP) {
- gtk_print_settings_set_number_up (settings, 1);
- gtk_print_settings_set_int (settings, "cups-"GTK_PRINT_SETTINGS_NUMBER_UP, 1);
- }
-
- if (window->priv->print_preview) {
- gchar *uri;
- gchar *print_settings_file = NULL;
-
- ev_application_set_print_settings (EV_APP,
- window->priv->print_settings);
-
-#if GTK_CHECK_VERSION (2, 11, 0)
- print_settings_file = ev_tmp_filename ("print-settings");
- gtk_print_settings_to_file (settings, print_settings_file, NULL);
-#endif
- uri = g_filename_to_uri (filename, NULL, NULL);
- ev_application_open_uri_at_dest (EV_APP,
- uri,
- gtk_window_get_screen (GTK_WINDOW (window)),
- NULL,
- EV_WINDOW_MODE_PREVIEW,
- NULL,
- TRUE,
- print_settings_file,
- GDK_CURRENT_TIME);
- g_free (print_settings_file);
- g_free (uri);
+ /* Load page setup options that are specific to the document */
+ if (ev_metadata_manager_get (uri, "page-setup-orientation", &value, TRUE)) {
+ gtk_page_setup_set_orientation (page_setup, g_value_get_int (&value));
+ g_value_unset (&value);
} else {
- GtkPrintJob *job;
- GError *error = NULL;
-
- job = gtk_print_job_new ("evince-print",
- window->priv->printer,
- settings,
- window->priv->print_page_setup);
-
- if (window->priv->gtk_print_job)
- g_object_unref (window->priv->gtk_print_job);
- window->priv->gtk_print_job = job;
-
- if (gtk_print_job_set_source_file (job, filename, &error)) {
- gtk_print_job_send (job,
- (GtkPrintJobCompleteFunc)ev_window_print_finished,
- window, NULL);
- } else {
- ev_window_clear_print_job (window);
- g_warning (error->message);
- g_error_free (error);
- }
+ gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
+ }
+
+ if (ev_metadata_manager_get (uri, "page-setup-margin-top", &value, TRUE)) {
+ gtk_page_setup_set_top_margin (page_setup, g_value_get_double (&value), GTK_UNIT_MM);
+ g_value_unset (&value);
+ } else {
+ gtk_page_setup_set_top_margin (page_setup,
+ gtk_paper_size_get_default_top_margin (paper_size, GTK_UNIT_MM),
+ GTK_UNIT_MM);
}
- g_object_unref (settings);
+ if (ev_metadata_manager_get (uri, "page-setup-margin-bottom", &value, TRUE)) {
+ gtk_page_setup_set_bottom_margin (page_setup, g_value_get_double (&value), GTK_UNIT_MM);
+ g_value_unset (&value);
+ } else {
+ gtk_page_setup_set_bottom_margin (page_setup,
+ gtk_paper_size_get_default_bottom_margin (paper_size, GTK_UNIT_MM),
+ GTK_UNIT_MM);
+ }
+
+ if (ev_metadata_manager_get (uri, "page-setup-margin-left", &value, TRUE)) {
+ gtk_page_setup_set_left_margin (page_setup, g_value_get_double (&value), GTK_UNIT_MM);
+ g_value_unset (&value);
+ } else {
+ gtk_page_setup_set_left_margin (page_setup,
+ gtk_paper_size_get_default_left_margin (paper_size, GTK_UNIT_MM),
+ GTK_UNIT_MM);
+ }
+
+ if (ev_metadata_manager_get (uri, "page-setup-margin-right", &value, TRUE)) {
+ gtk_page_setup_set_right_margin (page_setup, g_value_get_double (&value), GTK_UNIT_MM);
+ g_value_unset (&value);
+ } else {
+ gtk_page_setup_set_right_margin (page_setup,
+ gtk_paper_size_get_default_right_margin (paper_size, GTK_UNIT_MM),
+ GTK_UNIT_MM);
+ }
}
static void
-ev_window_print_job_cb (EvJobPrint *job,
- EvWindow *window)
+ev_window_print_page_setup_done_cb (GtkPageSetup *page_setup,
+ EvWindow *window)
{
- if (job->error) {
- g_warning (job->error->message);
- ev_window_clear_print_job (window);
+ /* Dialog was canceled */
+ if (!page_setup)
return;
- }
- g_assert (job->temp_file != NULL);
+ if (window->priv->print_page_setup != page_setup) {
+ if (window->priv->print_page_setup)
+ g_object_unref (window->priv->print_page_setup);
+ window->priv->print_page_setup = g_object_ref (page_setup);
+ }
+
+ ev_application_set_page_setup (EV_APP, page_setup);
+ ev_window_save_print_page_setup (window);
+}
- ev_window_print_send (window, job->temp_file);
+static void
+ev_window_cmd_file_print_setup (GtkAction *action, EvWindow *ev_window)
+{
+ if (!ev_window->priv->print_page_setup) {
+ ev_window->priv->print_page_setup = gtk_page_setup_copy (
+ ev_application_get_page_setup (EV_APP));
+ ev_window_load_print_page_setup_from_metadata (ev_window);
+ }
+
+ gtk_print_run_page_setup_dialog_async (
+ GTK_WINDOW (ev_window),
+ ev_window->priv->print_page_setup,
+ ev_window->priv->print_settings,
+ (GtkPageSetupDoneFunc) ev_window_print_page_setup_done_cb,
+ ev_window);
}
-static gboolean
-ev_window_print_dialog_response_cb (GtkDialog *dialog,
- gint response,
- EvWindow *window)
+static void
+ev_window_print_cancel (EvWindow *ev_window)
{
- EvPrintRange *ranges = NULL;
- EvPrintPageSet page_set;
- gint n_ranges = 0;
- gint copies;
- gint pages_per_sheet;
- gboolean collate;
- gboolean reverse;
- gdouble scale;
- gint current_page;
- gdouble width;
- gdouble height;
- GtkPrintPages print_pages;
- const gchar *file_format;
+ EvPrintOperation *op;
- if (response == GTK_RESPONSE_CANCEL) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- window->priv->print_dialog = NULL;
+ if (!ev_window->priv->print_queue)
+ return;
- return FALSE;
+ while ((op = g_queue_peek_tail (ev_window->priv->print_queue))) {
+ ev_print_operation_cancel (op);
}
+}
- window->priv->print_preview = (response == GTK_RESPONSE_APPLY);
-
- if (window->priv->printer)
- g_object_unref (window->priv->printer);
- if (window->priv->print_settings)
- g_object_unref (window->priv->print_settings);
- if (window->priv->print_page_setup)
- g_object_unref (window->priv->print_page_setup);
-
- window->priv->printer = g_object_ref (
- gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (dialog)));
- window->priv->print_settings = g_object_ref (
- gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (dialog)));
- window->priv->print_page_setup = g_object_ref (
- gtk_print_unix_dialog_get_page_setup (GTK_PRINT_UNIX_DIALOG (dialog)));
-
- file_format = gtk_print_settings_get (window->priv->print_settings,
- GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
+static void
+ev_window_print_update_pending_jobs_message (EvWindow *ev_window,
+ gint n_jobs)
+{
+ gchar *text = NULL;
- if (!gtk_printer_accepts_ps (window->priv->printer)) {
- GtkWidget *msgdialog;
-
- msgdialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Printing is not supported on this printer."));
-
- gtk_dialog_run (GTK_DIALOG (msgdialog));
- gtk_widget_destroy (msgdialog);
+ if (!EV_IS_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area) ||
+ !ev_window->priv->print_queue)
+ return;
- return FALSE;
+ if (n_jobs == 0) {
+ ev_window_set_message_area (ev_window, NULL);
+ return;
+ }
+
+ if (n_jobs > 1) {
+ text = g_strdup_printf (ngettext ("%d pending job in queue",
+ "%d pending jobs in queue",
+ n_jobs - 1), n_jobs - 1);
}
- ev_window_clear_print_job (window);
+ ev_message_area_set_secondary_text (EV_MESSAGE_AREA (ev_window->priv->message_area),
+ text);
+ g_free (text);
+}
+
+static gboolean
+destroy_window (GtkWidget *window)
+{
+ gtk_widget_destroy (window);
- current_page = gtk_print_unix_dialog_get_current_page (GTK_PRINT_UNIX_DIALOG (dialog));
- print_pages = gtk_print_settings_get_print_pages (window->priv->print_settings);
+ return FALSE;
+}
+
+static void
+ev_window_print_operation_done (EvPrintOperation *op,
+ GtkPrintOperationResult result,
+ EvWindow *ev_window)
+{
+ gint n_jobs;
- switch (print_pages) {
- case GTK_PRINT_PAGES_CURRENT:
- ranges = g_new0 (EvPrintRange, 1);
+ switch (result) {
+ case GTK_PRINT_OPERATION_RESULT_APPLY: {
+ GtkPrintSettings *print_settings;
- ranges->start = current_page;
- ranges->end = current_page;
- n_ranges = 1;
-
- break;
- case GTK_PRINT_PAGES_RANGES: {
- GtkPageRange *page_range;
+ print_settings = ev_print_operation_get_print_settings (op);
+ if (ev_window->priv->print_settings != print_settings) {
+ if (ev_window->priv->print_settings)
+ g_object_unref (ev_window->priv->print_settings);
+ ev_window->priv->print_settings = g_object_ref (print_settings);
+ }
- page_range = gtk_print_settings_get_page_ranges (window->priv->print_settings,
- &n_ranges);
- if (n_ranges > 0)
- ranges = g_memdup (page_range, n_ranges * sizeof (GtkPageRange));
+ ev_application_set_print_settings (EV_APP, print_settings);
+ ev_window_save_print_settings (ev_window);
}
+
break;
- case GTK_PRINT_PAGES_ALL: {
- gint n_pages;
+ case GTK_PRINT_OPERATION_RESULT_ERROR: {
+ GtkWidget *dialog;
+ GError *error = NULL;
- n_pages = ev_page_cache_get_n_pages (ev_page_cache_get (window->priv->document));
-
- ranges = g_new0 (EvPrintRange, 1);
- ranges->start = 0;
- ranges->end = n_pages - 1;
- n_ranges = 1;
+ ev_print_operation_get_error (op, &error);
+
+ /* The message area is already used by
+ * the printing progress, so it's better to
+ * use a popup dialog in this case
+ */
+ dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", _("Failed to print document"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", error->message);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+ gtk_widget_show (dialog);
+
+ g_error_free (error);
}
break;
+ case GTK_PRINT_OPERATION_RESULT_CANCEL:
+ default:
+ break;
}
- page_set = (EvPrintPageSet)gtk_print_settings_get_page_set (window->priv->print_settings);
+ g_queue_remove (ev_window->priv->print_queue, op);
+ g_object_unref (op);
+ n_jobs = g_queue_get_length (ev_window->priv->print_queue);
+ ev_window_print_update_pending_jobs_message (ev_window, n_jobs);
- scale = gtk_print_settings_get_scale (window->priv->print_settings) * 0.01;
-
- width = gtk_page_setup_get_paper_width (window->priv->print_page_setup,
- GTK_UNIT_POINTS);
- height = gtk_page_setup_get_paper_height (window->priv->print_page_setup,
- GTK_UNIT_POINTS);
-
- if (scale != 1.0) {
- width *= scale;
- height *= scale;
+ if (n_jobs == 0 && ev_window->priv->close_after_print)
+ g_idle_add ((GSourceFunc)destroy_window,
+ ev_window);
+}
+
+static void
+ev_window_print_progress_response_cb (EvProgressMessageArea *area,
+ gint response,
+ EvWindow *ev_window)
+{
+ if (response == GTK_RESPONSE_CANCEL) {
+ EvPrintOperation *op;
+
+ op = g_queue_peek_tail (ev_window->priv->print_queue);
+ ev_print_operation_cancel (op);
+ } else {
+ gtk_widget_hide (GTK_WIDGET (area));
}
+}
- pages_per_sheet = gtk_print_settings_get_number_up (window->priv->print_settings);
-
- copies = gtk_print_settings_get_n_copies (window->priv->print_settings);
- collate = gtk_print_settings_get_collate (window->priv->print_settings);
- reverse = gtk_print_settings_get_reverse (window->priv->print_settings);
-
- window->priv->print_job = ev_job_print_new (window->priv->document,
- file_format ? file_format : "ps",
- width, height,
- ranges, n_ranges,
- page_set,
- pages_per_sheet,
- copies, collate,
- reverse);
+static void
+ev_window_print_operation_status_changed (EvPrintOperation *op,
+ EvWindow *ev_window)
+{
+ const gchar *status;
+ gdouble fraction;
+
+ status = ev_print_operation_get_status (op);
+ fraction = ev_print_operation_get_progress (op);
- g_signal_connect (window->priv->print_job, "finished",
- G_CALLBACK (ev_window_print_job_cb),
- window);
- /* The priority doesn't matter for this job */
- ev_job_queue_add_job (window->priv->print_job, EV_JOB_PRIORITY_LOW);
+ if (!ev_window->priv->message_area) {
+ GtkWidget *area;
+ const gchar *job_name;
+ gchar *text;
+
+ job_name = ev_print_operation_get_job_name (op);
+ text = g_strdup_printf (_("Printing job “%s”"), job_name);
+
+ area = ev_progress_message_area_new (GTK_STOCK_PRINT,
+ text,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+ ev_window_print_update_pending_jobs_message (ev_window, 1);
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_print_progress_response_cb),
+ ev_window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (ev_window, area);
+ g_free (text);
+ }
+
+ ev_progress_message_area_set_status (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ status);
+ ev_progress_message_area_set_fraction (EV_PROGRESS_MESSAGE_AREA (ev_window->priv->message_area),
+ fraction);
+}
+
+static void
+ev_window_print_operation_begin_print (EvPrintOperation *op,
+ EvWindow *ev_window)
+{
+ GtkPrintSettings *print_settings;
- gtk_widget_destroy (GTK_WIDGET (dialog));
- window->priv->print_dialog = NULL;
+ if (!ev_window->priv->print_queue)
+ ev_window->priv->print_queue = g_queue_new ();
- return TRUE;
+ g_queue_push_head (ev_window->priv->print_queue, op);
+ ev_window_print_update_pending_jobs_message (ev_window,
+ g_queue_get_length (ev_window->priv->print_queue));
+
+ if (ev_window->priv->print_settings)
+ g_object_unref (ev_window->priv->print_settings);
+ print_settings = ev_print_operation_get_print_settings (op);
+ ev_window->priv->print_settings = g_object_ref (print_settings);
}
void
-ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
+ev_window_print_range (EvWindow *ev_window,
+ gint first_page,
+ gint last_page)
{
- GtkWidget *dialog;
- EvPageCache *page_cache;
- gint current_page;
- gint document_last_page;
- GtkPrintCapabilities capabilities;
+ EvPrintOperation *op;
+ EvPageCache *page_cache;
+ gint current_page;
+ gint document_last_page;
g_return_if_fail (EV_IS_WINDOW (ev_window));
g_return_if_fail (ev_window->priv->document != NULL);
- if (ev_window->priv->print_dialog) {
- gtk_window_present (GTK_WINDOW (ev_window->priv->print_dialog));
- return;
- }
-
+ if (!ev_window->priv->print_queue)
+ ev_window->priv->print_queue = g_queue_new ();
+
+ op = ev_print_operation_new (ev_window->priv->document);
+ g_signal_connect (op, "begin_print",
+ G_CALLBACK (ev_window_print_operation_begin_print),
+ (gpointer)ev_window);
+ g_signal_connect (op, "status_changed",
+ G_CALLBACK (ev_window_print_operation_status_changed),
+ (gpointer)ev_window);
+ g_signal_connect (op, "done",
+ G_CALLBACK (ev_window_print_operation_done),
+ (gpointer)ev_window);
+
page_cache = ev_page_cache_get (ev_window->priv->document);
current_page = ev_page_cache_get_current_page (page_cache);
document_last_page = ev_page_cache_get_n_pages (page_cache);
&range, 1);
}
- dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
- ev_window->priv->print_dialog = dialog;
-
- capabilities = GTK_PRINT_CAPABILITY_PREVIEW |
- ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (ev_window->priv->document));
- gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
- capabilities);
-
- gtk_print_unix_dialog_set_current_page (GTK_PRINT_UNIX_DIALOG (dialog),
- current_page);
-
- gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG (dialog),
- ev_window->priv->print_settings);
-
+ ev_print_operation_set_job_name (op, gtk_window_get_title (GTK_WINDOW (ev_window)));
+ ev_print_operation_set_current_page (op, current_page);
+ ev_print_operation_set_print_settings (op, ev_window->priv->print_settings);
if (ev_window->priv->print_page_setup)
- gtk_print_unix_dialog_set_page_setup (GTK_PRINT_UNIX_DIALOG (dialog),
- ev_window->priv->print_page_setup);
-
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (ev_window_print_dialog_response_cb),
- ev_window);
-
- gtk_widget_show (dialog);
-}
-#endif /* WITH_GTK_PRINT */
-
-#ifdef WITH_GNOME_PRINT
-static gboolean
-ev_window_print_dialog_response_cb (GtkDialog *print_dialog,
- gint response,
- EvWindow *ev_window)
-{
- EvPrintJob *print_job;
- GnomePrintConfig *config;
-
- if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) {
- gtk_widget_destroy (GTK_WIDGET (print_dialog));
- ev_window->priv->print_dialog = NULL;
- g_object_unref (ev_window->priv->print_job);
- ev_window->priv->print_job = NULL;
-
- return FALSE;
- }
-
- config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (print_dialog));
-
- /* FIXME: Change this when we have the first backend
- * that can print more than postscript
- */
- if (using_pdf_printer (config)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Generating PDF is not supported"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- } else if (!using_postscript_printer (config)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Printing is not supported on this printer."));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("You were trying to print to a printer using the “%s” driver. "
- "This program requires a PostScript printer driver."),
- gnome_print_config_get (config, (guchar *)"Settings.Engine.Backend.Driver"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- }
-
- save_print_config_to_file (config);
-
- print_job = g_object_new (EV_TYPE_PRINT_JOB,
- "gnome_print_job", ev_window->priv->print_job,
- "document", ev_window->priv->document,
- "print_dialog", print_dialog,
- NULL);
-
- if (print_job != NULL) {
- ev_print_job_print (print_job, GTK_WINDOW (ev_window));
- g_object_unref (print_job);
- }
-
- g_object_unref (config);
-
- gtk_widget_destroy (GTK_WIDGET (print_dialog));
- ev_window->priv->print_dialog = NULL;
- g_object_unref (ev_window->priv->print_job);
- ev_window->priv->print_job = NULL;
-
- return FALSE;
-}
-
-void
-ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
-{
- GnomePrintConfig *config;
- gchar *pages_label;
+ ev_print_operation_set_default_page_setup (op, ev_window->priv->print_page_setup);
- g_return_if_fail (EV_IS_WINDOW (ev_window));
- g_return_if_fail (ev_window->priv->document != NULL);
-
- config = load_print_config_from_file ();
-
- if (ev_window->priv->print_job == NULL)
- ev_window->priv->print_job = gnome_print_job_new (config);
-
- if (ev_window->priv->print_dialog == NULL) {
- ev_window->priv->print_dialog =
- gnome_print_dialog_new (ev_window->priv->print_job,
- (guchar *) _("Print"),
- (GNOME_PRINT_DIALOG_RANGE |
- GNOME_PRINT_DIALOG_COPIES));
- }
-
- gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->print_dialog),
- GTK_WINDOW (ev_window));
- g_object_unref (config);
-
- pages_label = g_strconcat (_("Pages"), " ", NULL);
- gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (ev_window->priv->print_dialog),
- GNOME_PRINT_RANGE_ALL |
- GNOME_PRINT_RANGE_RANGE,
- first_page, last_page,
- NULL, (const guchar *)pages_label);
- g_free (pages_label);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (ev_window->priv->print_dialog),
- GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
- FALSE);
-
- g_signal_connect (G_OBJECT (ev_window->priv->print_dialog), "response",
- G_CALLBACK (ev_window_print_dialog_response_cb),
- ev_window);
- gtk_widget_show (ev_window->priv->print_dialog);
+ ev_print_operation_run (op, GTK_WINDOW (ev_window));
}
-#endif /* WITH_GNOME_PRINT */
static void
ev_window_print (EvWindow *window)
page_cache = ev_page_cache_get (window->priv->document);
last_page = ev_page_cache_get_n_pages (page_cache);
-#ifdef WITH_PRINT
ev_window_print_range (window, 1, last_page);
-#endif
}
static void
if (ev_window->priv->properties == NULL) {
ev_window->priv->properties = ev_properties_dialog_new ();
ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->uri,
ev_window->priv->document);
g_object_add_weak_pointer (G_OBJECT (ev_window->priv->properties),
(gpointer) &(ev_window->priv->properties));
gtk_widget_show (ev_window->priv->properties);
ev_document_fc_mutex_unlock ();
}
-
+
+static void
+print_jobs_confirmation_dialog_response (GtkDialog *dialog,
+ gint response,
+ EvWindow *ev_window)
+{
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ switch (response) {
+ case GTK_RESPONSE_YES:
+ if (!ev_window->priv->print_queue ||
+ g_queue_is_empty (ev_window->priv->print_queue))
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+ else
+ ev_window->priv->close_after_print = TRUE;
+ break;
+ case GTK_RESPONSE_NO:
+ ev_window->priv->close_after_print = TRUE;
+ if (ev_window->priv->print_queue &&
+ !g_queue_is_empty (ev_window->priv->print_queue)) {
+ gtk_widget_set_sensitive (GTK_WIDGET (ev_window), FALSE);
+ ev_window_print_cancel (ev_window);
+ } else {
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+ }
+ break;
+ case GTK_RESPONSE_CANCEL:
+ default:
+ ev_window->priv->close_after_print = FALSE;
+ }
+}
+
static void
ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
{
- g_return_if_fail (EV_IS_WINDOW (ev_window));
+ GtkWidget *dialog;
+ gchar *text, *markup;
+ gint n_print_jobs;
+
+ n_print_jobs = ev_window->priv->print_queue ?
+ g_queue_get_length (ev_window->priv->print_queue) : 0;
+
+ if (n_print_jobs == 0) {
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+ return;
+ }
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ NULL);
+ if (n_print_jobs == 1) {
+ EvPrintOperation *op;
+ const gchar *job_name;
+
+ op = g_queue_peek_tail (ev_window->priv->print_queue);
+ job_name = ev_print_operation_get_job_name (op);
+
+ text = g_strdup_printf (_("Wait until print job “%s” finishes before closing?"),
+ job_name);
+ } else {
+ text = g_strdup_printf (_("There are %d print jobs active. "
+ "Wait until print finishes before closing?"),
+ n_print_jobs);
+ }
+
+ markup = g_strdup_printf ("<b>%s</b>", text);
+ g_free (text);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
+ g_free (markup);
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s",
+ _("If you close the window, pending print "
+ "jobs will not be printed."));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Cancel _print and Close"),
+ GTK_RESPONSE_NO,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ _("Close _after Printing"),
+ GTK_RESPONSE_YES,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_YES,
+ GTK_RESPONSE_NO,
+ GTK_RESPONSE_CANCEL,
+ -1);
- gtk_widget_destroy (GTK_WIDGET (ev_window));
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (print_jobs_confirmation_dialog_response),
+ ev_window);
+ gtk_widget_show (dialog);
}
static void
static void
ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
+ ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_FORWARD, FALSE);
}
static void
ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
+ ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_BACKWARD, FALSE);
}
static void
{
gboolean continuous;
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"continuous", continuous,
{
gboolean dual_page;
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"dual-page", dual_page,
static void
ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
{
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
static void
ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
static void
ev_window_run_fullscreen (EvWindow *window)
{
+ EvView *view = EV_VIEW (window->priv->view);
+ gboolean fullscreen_window = TRUE;
+
+ if (ev_view_get_fullscreen (view))
+ return;
+
if (!window->priv->fullscreen_toolbar) {
window->priv->fullscreen_toolbar =
gtk_ui_manager_get_widget (window->priv->ui_manager,
window->priv->fullscreen_toolbar, 1);
}
+ if (ev_view_get_presentation (view)) {
+ ev_window_stop_presentation (window, FALSE);
+ fullscreen_window = FALSE;
+ }
+
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
NULL);
- ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
+ ev_view_set_fullscreen (view, TRUE);
ev_window_update_fullscreen_action (window);
/* If the user doesn't have the main toolbar he/she won't probably want
update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR,
(window->priv->chrome & EV_CHROME_TOOLBAR) != 0);
update_chrome_visibility (window);
-
- gtk_window_fullscreen (GTK_WINDOW (window));
+
+ if (fullscreen_window)
+ gtk_window_fullscreen (GTK_WINDOW (window));
gtk_widget_grab_focus (window->priv->view);
if (!ev_window_is_empty (window))
}
static void
-ev_window_stop_fullscreen (EvWindow *window)
+ev_window_stop_fullscreen (EvWindow *window,
+ gboolean unfullscreen_window)
{
EvView *view = EV_VIEW (window->priv->view);
- if (!ev_view_get_fullscreen (EV_VIEW (view)))
+ if (!ev_view_get_fullscreen (view))
return;
g_object_set (G_OBJECT (window->priv->scrolled_window),
ev_window_update_fullscreen_action (window);
update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
update_chrome_visibility (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (unfullscreen_window)
+ gtk_window_unfullscreen (GTK_WINDOW (window));
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
{
gboolean fullscreen;
- g_return_if_fail (EV_IS_WINDOW (window));
- ev_window_stop_presentation (window);
-
fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (fullscreen) {
ev_window_run_fullscreen (window);
} else {
- ev_window_stop_fullscreen (window);
+ ev_window_stop_fullscreen (window, TRUE);
}
}
g_source_remove (window->priv->presentation_timeout_id);
}
-#if GLIB_CHECK_VERSION (2, 13, 0)
window->priv->presentation_timeout_id =
g_timeout_add_seconds (PRESENTATION_TIMEOUT,
(GSourceFunc)presentation_timeout_cb, window);
-#else
- window->priv->presentation_timeout_id =
- g_timeout_add (PRESENTATION_TIMEOUT * 1000,
- (GSourceFunc)presentation_timeout_cb, window);
-#endif
ev_view_show_cursor (EV_VIEW (window->priv->view));
}
static void
ev_window_run_presentation (EvWindow *window)
{
+ EvView *view = EV_VIEW (window->priv->view);
+ gboolean fullscreen_window = TRUE;
+
+ if (ev_view_get_presentation (view))
+ return;
+
+ if (ev_view_get_fullscreen (view)) {
+ ev_window_stop_fullscreen (window, FALSE);
+ fullscreen_window = FALSE;
+ }
+
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
NULL);
- ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
+ ev_view_set_presentation (view, TRUE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
gtk_widget_grab_focus (window->priv->view);
- gtk_window_fullscreen (GTK_WINDOW (window));
+ if (fullscreen_window)
+ gtk_window_fullscreen (GTK_WINDOW (window));
g_signal_connect (window->priv->view,
"motion-notify-event",
}
static void
-ev_window_stop_presentation (EvWindow *window)
+ev_window_stop_presentation (EvWindow *window,
+ gboolean unfullscreen_window)
{
- if (!ev_view_get_presentation (EV_VIEW (window->priv->view)))
+ EvView *view = EV_VIEW (window->priv->view);
+
+ if (!ev_view_get_presentation (view))
return;
g_object_set (G_OBJECT (window->priv->scrolled_window),
ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (unfullscreen_window)
+ gtk_window_unfullscreen (GTK_WINDOW (window));
g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) presentation_motion_notify_cb,
{
gboolean presentation;
- g_return_if_fail (EV_IS_WINDOW (window));
- ev_window_stop_fullscreen (window);
-
presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (presentation) {
ev_window_run_presentation (window);
- } else {
- ev_window_stop_presentation (window);
- }
-}
-
-static void
-ev_window_run_preview (EvWindow *window)
-{
- GtkAction *action;
-
- if (!window->priv->preview_toolbar) {
- window->priv->preview_toolbar =
- gtk_ui_manager_get_widget (window->priv->ui_manager,
- "/PreviewToolbar");
-
- gtk_box_pack_start (GTK_BOX (window->priv->main_box),
- window->priv->preview_toolbar,
- FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (window->priv->main_box),
- window->priv->preview_toolbar, 1);
}
-
- ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
-
- update_chrome_flag (window, EV_CHROME_TOOLBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
-
- update_chrome_flag (window, EV_CHROME_PREVIEW_TOOLBAR, TRUE);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "PreviewPrint");
-#if GTK_CHECK_VERSION (2, 11, 0)
- gtk_action_set_visible (action, TRUE);
-#else
- gtk_action_set_visible (action, FALSE);
-#endif
-
- update_chrome_visibility (window);
}
static void
}
}
+static gboolean
+ev_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event)
+{
+ EvWindow *window = EV_WINDOW (widget);
+ EvView *view = EV_VIEW (window->priv->view);
+
+ if (GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event) {
+ GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event (widget, event);
+ }
+
+ if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) == 0)
+ return FALSE;
+
+ if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
+ if (ev_view_get_fullscreen (view) || ev_view_get_presentation (view))
+ return FALSE;
+
+ ev_window_run_fullscreen (window);
+ } else {
+ if (ev_view_get_fullscreen (view))
+ ev_window_stop_fullscreen (window, FALSE);
+ else if (ev_view_get_presentation (view))
+ ev_window_stop_presentation (window, FALSE);
+ }
+
+ return FALSE;
+}
+
static void
ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode)
static void
ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
{
- gchar *uri;
+ ev_window_reload_document (ev_window);
+}
- uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri, NULL, 0, NULL, FALSE, NULL);
- g_free (uri);
+static void
+ev_window_cmd_view_autoscroll (GtkAction *action, EvWindow *ev_window)
+{
+ ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view));
}
+#if GTK_CHECK_VERSION (2, 14, 0)
+static void
+ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
+ "ghelp:evince",
+ GDK_CURRENT_TIME,
+ &error);
+ if (error) {
+ ev_window_error_message (ev_window, error,
+ "%s", _("There was an error displaying help"));
+ g_error_free (error);
+ }
+}
+#else /* !GTK_CHECK_VERSION (2, 14, 0) */
static void
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
}
command = g_strconcat ("gnome-help ghelp://", uri, NULL);
- g_free (uri);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (ev_window));
- gdk_spawn_command_line_on_screen (screen, command, &error);
- if (error != NULL) {
- g_warning (error->message);
- g_error_free (error);
- }
- g_free (command);
-}
-
-static void
-ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
-{
- ev_window_stop_fullscreen (window);
-}
-
-static void
-ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window)
-{
- ev_window_stop_fullscreen (window);
- ev_window_run_presentation (window);
-}
-
-#ifdef WITH_GTK_PRINT
-static void ev_window_do_preview_print (EvWindow *window);
-
-static gboolean
-ev_window_enumerate_printer_cb (GtkPrinter *printer,
- EvWindow *window)
-{
- EvWindowPrivate *priv = window->priv;
- const gchar *printer_name;
-
- printer_name = gtk_print_settings_get_printer (priv->print_settings);
- if ((printer_name
- && strcmp (printer_name, gtk_printer_get_name (printer)) == 0) ||
- (!printer_name && gtk_printer_is_default (printer))) {
- if (priv->printer)
- g_object_unref (priv->printer);
- priv->printer = g_object_ref (printer);
-
- /* Now that we have the printer, we'll start the print */
- ev_window_do_preview_print (window);
-
- return TRUE; /* we're done */
- }
-
- return FALSE; /* continue the enumeration */
-}
-
-static void
-ev_window_preview_print_finished (GtkPrintJob *print_job,
- EvWindow *window,
- GError *error)
-{
- if (error) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to print document"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ g_free (uri);
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (ev_window));
+ gdk_spawn_command_line_on_screen (screen, command, &error);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
-
- g_object_unref (print_job);
- gtk_widget_destroy (GTK_WIDGET (window));
+ g_free (command);
}
+#endif /* GTK_CHECK_VERSION (2, 14, 0) */
static void
-ev_window_do_preview_print (EvWindow *window)
+ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
{
- EvWindowPrivate *priv = window->priv;
- GtkPageSetup *page_setup;
- GtkPrintJob *job;
- gchar *filename;
- GError *error = NULL;
-
- g_assert (priv->print_settings != NULL);
- g_assert (priv->printer != NULL);
-
- page_setup = gtk_page_setup_new ();
-
- job = gtk_print_job_new ("evince-print",
- priv->printer,
- priv->print_settings,
- page_setup);
-
- g_object_unref (priv->print_settings);
- priv->print_settings = NULL;
- g_object_unref (priv->printer);
- priv->printer = NULL;
- g_object_unref (page_setup);
-
- filename = g_filename_from_uri (priv->local_uri ?
- priv->local_uri : priv->uri,
- NULL, NULL);
-
- if (gtk_print_job_set_source_file (job, filename, &error)) {
- gtk_print_job_send (job,
- (GtkPrintJobCompleteFunc)ev_window_preview_print_finished,
- window, NULL);
- } else {
- g_warning (error->message);
- g_error_free (error);
- }
-
- g_free (filename);
-
- gtk_widget_hide (GTK_WIDGET (window));
+ ev_window_stop_fullscreen (window, TRUE);
}
-#endif /* WITH_GTK_PRINT */
-
static void
-ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
+ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window)
{
-#ifdef WITH_GTK_PRINT
- EvWindowPrivate *priv = window->priv;
- GtkPrintSettings *print_settings = NULL;
-#if GTK_CHECK_VERSION (2, 11, 0)
- const gchar *print_settings_file = priv->print_settings_file;
-
- if (print_settings_file) {
- if (g_file_test (print_settings_file, G_FILE_TEST_IS_REGULAR)) {
- GError *error = NULL;
-
- print_settings = gtk_print_settings_new_from_file (print_settings_file,
- &error);
-
- if (error) {
- g_warning (error->message);
- g_error_free (error);
- print_settings = NULL;
- }
- }
- }
-#endif /* GTK 2.11.0 */
-
- if (!print_settings)
- print_settings = gtk_print_settings_new ();
-
- if (priv->print_settings)
- g_object_unref (priv->print_settings);
- priv->print_settings = print_settings;
-
- gtk_enumerate_printers ((GtkPrinterFunc) ev_window_enumerate_printer_cb,
- window, NULL, FALSE);
-#endif /* WITH_GTK_PRINT */
+ ev_window_run_presentation (window);
}
static void
{
GtkWidget *widget;
+ ev_view_autoscroll_stop (EV_VIEW (window->priv->view));
+
widget = gtk_window_get_focus (GTK_WINDOW (window));
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
update_chrome_flag (window, EV_CHROME_FINDBAR, FALSE);
NULL);
if (fullscreen) {
- ev_window_stop_fullscreen (window);
+ ev_window_stop_fullscreen (window, TRUE);
} else if (presentation) {
- ev_window_stop_presentation (window);
+ ev_window_stop_presentation (window, TRUE);
gtk_widget_grab_focus (window->priv->view);
} else {
gtk_widget_grab_focus (window->priv->view);
GEnumValue *enum_value;
mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
- enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
+ enum_value = g_enum_get_value (g_type_class_peek (EV_TYPE_SIZING_MODE), mode);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
enum_value->value_nick);
}
+static void
+ev_window_set_view_size (EvWindow *window)
+{
+ gint width, height;
+ GtkRequisition vsb_requisition;
+ GtkRequisition hsb_requisition;
+ gint scrollbar_spacing;
+ GtkWidget *scrolled_window = window->priv->scrolled_window;
+
+ if (!window->priv->view)
+ return;
+
+ /* Calculate the width available for the content */
+ width = scrolled_window->allocation.width;
+ height = scrolled_window->allocation.height;
+
+ if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window)) == GTK_SHADOW_IN) {
+ width -= 2 * window->priv->view->style->xthickness;
+ height -= 2 * window->priv->view->style->ythickness;
+ }
+
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (scrolled_window)->vscrollbar,
+ &vsb_requisition);
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (scrolled_window)->hscrollbar,
+ &hsb_requisition);
+ gtk_widget_style_get (scrolled_window,
+ "scrollbar_spacing",
+ &scrollbar_spacing,
+ NULL);
+
+ ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
+ MAX (1, width),
+ MAX (1, height),
+ vsb_requisition.width + scrollbar_spacing,
+ hsb_requisition.height + scrollbar_spacing);
+}
+
static void
ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
EvWindow *ev_window)
{
- GtkWidget *scrolled_window;
EvSizingMode sizing_mode;
g_object_get (ev_window->priv->view,
"sizing-mode", &sizing_mode,
NULL);
- scrolled_window = ev_window->priv->scrolled_window;
-
- g_signal_handlers_disconnect_by_func (ev_window->priv->view, ev_view_update_view_size, scrolled_window);
-
- if (sizing_mode != EV_SIZING_FREE)
- ev_view_update_view_size (EV_VIEW (ev_window->priv->view),
- GTK_SCROLLED_WINDOW (scrolled_window));
-
- switch (sizing_mode) {
- case EV_SIZING_BEST_FIT:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (ev_view_update_view_size),
- scrolled_window);
- break;
- case EV_SIZING_FIT_WIDTH:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (ev_view_update_view_size),
- scrolled_window);
- break;
- case EV_SIZING_FREE:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- break;
- }
+ g_object_set (ev_window->priv->scrolled_window,
+ "hscrollbar-policy",
+ sizing_mode == EV_SIZING_FREE ?
+ GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
update_sizing_buttons (ev_window);
save_sizing_mode (ev_window);
id = THUMBNAILS_SIDEBAR_ID;
} else if (current_page == ev_window->priv->sidebar_attachments) {
id = ATTACHMENTS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_layers) {
+ id = LAYERS_SIDEBAR_ID;
} else {
g_assert_not_reached();
}
}
static void
-view_find_status_changed_cb (EvView *view,
- GParamSpec *pspec,
- EvWindow *ev_window)
+ev_window_update_find_status_message (EvWindow *ev_window)
+{
+ gchar *message;
+
+ if (!ev_window->priv->find_job)
+ return;
+
+ if (ev_job_is_finished (ev_window->priv->find_job)) {
+ gint n_results;
+
+ n_results = ev_job_find_get_n_results (EV_JOB_FIND (ev_window->priv->find_job),
+ ev_page_cache_get_current_page (ev_window->priv->page_cache));
+ /* TRANS: Sometimes this could be better translated as
+ "%d hit(s) on this page". Therefore this string
+ contains plural cases. */
+ message = g_strdup_printf (ngettext ("%d found on this page",
+ "%d found on this page",
+ n_results),
+ n_results);
+ } else {
+ gdouble percent;
+
+ percent = ev_job_find_get_progress (EV_JOB_FIND (ev_window->priv->find_job));
+ message = g_strdup_printf (_("%3d%% remaining to search"),
+ (gint) ((1.0 - percent) * 100));
+ }
+
+ egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), message);
+ g_free (message);
+}
+
+static void
+ev_window_find_job_finished_cb (EvJobFind *job,
+ EvWindow *ev_window)
+{
+ ev_window_update_find_status_message (ev_window);
+}
+
+static void
+ev_window_find_job_updated_cb (EvJobFind *job,
+ gint page,
+ EvWindow *ev_window)
+{
+ ev_window_update_actions (ev_window);
+
+ ev_view_find_changed (EV_VIEW (ev_window->priv->view),
+ ev_job_find_get_results (job),
+ page);
+ ev_window_update_find_status_message (ev_window);
+}
+
+static void
+ev_window_clear_find_job (EvWindow *ev_window)
{
- const char *text;
+ if (ev_window->priv->find_job != NULL) {
+ if (!ev_job_is_finished (ev_window->priv->find_job))
+ ev_job_cancel (ev_window->priv->find_job);
- text = ev_view_get_find_status (view);
- egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
- text);
+ g_signal_handlers_disconnect_by_func (ev_window->priv->find_job,
+ ev_window_find_job_finished_cb,
+ ev_window);
+ g_signal_handlers_disconnect_by_func (ev_window->priv->find_job,
+ ev_window_find_job_updated_cb,
+ ev_window);
+ g_object_unref (ev_window->priv->find_job);
+ ev_window->priv->find_job = NULL;
+ }
}
static void
find_bar_close_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
+ ev_view_find_cancel (EV_VIEW (ev_window->priv->view));
+ ev_window_clear_find_job (ev_window);
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
update_chrome_visibility (ev_window);
}
gboolean case_sensitive;
const char *search_string;
+ if (!ev_window->priv->document || !EV_IS_DOCUMENT_FIND (ev_window->priv->document))
+ return;
+
/* Either the string or case sensitivity could have changed. */
-
case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
- ev_view_search_changed (EV_VIEW(ev_window->priv->view));
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
- if (ev_window->priv->document &&
- EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- if (search_string && search_string[0]) {
- ev_document_doc_mutex_lock ();
- ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
- ev_page_cache_get_current_page (ev_window->priv->page_cache),
- search_string,
- case_sensitive);
- ev_document_doc_mutex_unlock ();
- } else {
- ev_document_doc_mutex_lock ();
- ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
- ev_document_doc_mutex_unlock ();
-
- ev_window_update_actions (ev_window);
- egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
- NULL);
- gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
- }
+ ev_window_clear_find_job (ev_window);
+
+ if (search_string && search_string[0]) {
+ ev_window->priv->find_job = ev_job_find_new (ev_window->priv->document,
+ ev_page_cache_get_current_page (ev_window->priv->page_cache),
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache),
+ search_string,
+ case_sensitive);
+ g_signal_connect (ev_window->priv->find_job, "finished",
+ G_CALLBACK (ev_window_find_job_finished_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->find_job, "updated",
+ G_CALLBACK (ev_window_find_job_updated_cb),
+ ev_window);
+ ev_job_scheduler_push_job (ev_window->priv->find_job, EV_JOB_PRIORITY_NONE);
+ } else {
+ ev_window_update_actions (ev_window);
+ egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
+ NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
}
}
static void
find_bar_visibility_changed_cb (EggFindBar *find_bar,
- GParamSpec *param,
- EvWindow *ev_window)
+ GParamSpec *param,
+ EvWindow *ev_window)
{
gboolean visible;
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- ev_view_set_highlight_search (EV_VIEW(ev_window->priv->view), visible);
- ev_view_search_changed (EV_VIEW(ev_window->priv->view));
+ ev_view_find_set_highlight_search (EV_VIEW (ev_window->priv->view), visible);
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
ev_window_update_actions (ev_window);
- if (!visible)
+ if (visible)
+ find_bar_search_changed_cb (find_bar, NULL, ev_window);
+ else
egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), NULL);
}
}
static void
-find_bar_scroll(EggFindBar *find_bar, GtkScrollType scroll, EvWindow* ev_window)
+find_bar_scroll (EggFindBar *find_bar,
+ GtkScrollType scroll,
+ EvWindow *ev_window)
{
- ev_view_scroll(EV_VIEW(ev_window->priv->view), scroll, FALSE);
+ ev_view_scroll (EV_VIEW (ev_window->priv->view), scroll, FALSE);
}
static void
} else {
mode = EV_SIZING_FREE;
}
-
+
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
if (mode == EV_SIZING_FREE) {
}
}
+static void
+ev_window_drag_data_received (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time)
+
+{
+ EvWindow *window = EV_WINDOW (widget);
+ gchar **uris;
+ gint i = 0;
+ GSList *uri_list = NULL;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+ if (!uris) {
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ return;
+ }
+
+ for (i = 0; uris[i]; i++) {
+ uri_list = g_slist_prepend (uri_list, (gpointer) uris[i]);
+ }
+
+ ev_application_open_uri_list (EV_APP, uri_list,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ 0);
+ gtk_drag_finish (context, TRUE, FALSE, time);
+
+ g_strfreev (uris);
+ g_slist_free (uri_list);
+}
+
static void
ev_window_finalize (GObject *object)
{
{
EvWindow *window = EV_WINDOW (object);
EvWindowPrivate *priv = window->priv;
+ GObject *mpkeys = ev_application_get_media_keys (EV_APP);
+ if (mpkeys) {
+ g_signal_handlers_disconnect_by_func (mpkeys,
+ ev_window_media_player_key_pressed,
+ window);
+ }
+
+ if (priv->setup_document_idle > 0) {
+ g_source_remove (priv->setup_document_idle);
+ priv->setup_document_idle = 0;
+ }
+
+ if (priv->monitor) {
+ g_object_unref (priv->monitor);
+ priv->monitor = NULL;
+ }
+
if (priv->title) {
ev_window_title_free (priv->title);
priv->title = NULL;
ev_window_clear_load_job (window);
}
+ if (priv->reload_job) {
+ ev_window_clear_reload_job (window);
+ }
+
if (priv->save_job) {
ev_window_clear_save_job (window);
}
if (priv->thumbnail_job) {
ev_window_clear_thumbnail_job (window);
}
+
+ if (priv->find_job) {
+ ev_window_clear_find_job (window);
+ }
if (priv->local_uri) {
ev_window_clear_local_uri (window);
priv->local_uri = NULL;
}
-
- ev_window_close_dialogs (window);
-
-#ifdef WITH_GTK_PRINT
- ev_window_clear_print_job (window);
- if (window->priv->gtk_print_job) {
- g_object_unref (window->priv->gtk_print_job);
- window->priv->gtk_print_job = NULL;
+ ev_window_clear_progress_idle (window);
+ if (priv->progress_cancellable) {
+ g_object_unref (priv->progress_cancellable);
+ priv->progress_cancellable = NULL;
}
+ ev_window_close_dialogs (window);
+
if (window->priv->printer) {
g_object_unref (window->priv->printer);
window->priv->printer = NULL;
g_object_unref (window->priv->print_page_setup);
window->priv->print_page_setup = NULL;
}
-#endif
if (priv->link) {
g_object_unref (priv->link);
}
if (priv->uri) {
- if (priv->unlink_temp_file)
- ev_window_clear_temp_file (window);
+ /* Delete the uri if it's a temp symlink (open a copy) */
+ ev_window_clear_temp_symlink (window);
g_free (priv->uri);
priv->uri = NULL;
}
+ if (priv->search_string) {
+ g_free (priv->search_string);
+ priv->search_string = NULL;
+ }
+
if (priv->dest) {
g_object_unref (priv->dest);
priv->dest = NULL;
priv->history = NULL;
}
- if (priv->print_settings_file) {
- ev_window_clear_print_settings_file (window);
- priv->print_settings_file = NULL;
- }
-
if (priv->presentation_timeout_id > 0) {
g_source_remove (priv->presentation_timeout_id);
priv->presentation_timeout_id = 0;
}
+ if (priv->print_queue) {
+ g_queue_free (priv->print_queue);
+ priv->print_queue = NULL;
+ }
+
G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
}
g_object_class->finalize = ev_window_finalize;
widget_class->screen_changed = ev_window_screen_changed;
+ widget_class->window_state_event = ev_window_state_event;
+ widget_class->drag_data_received = ev_window_drag_data_received;
g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
}
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
- { "FileOpenCopy", NULL, N_("Op_en a Copy"), NULL,
+ { "FileOpenCopy", NULL, N_("Op_en a Copy"), "<control>N",
N_("Open a copy of the current document in a new window"),
G_CALLBACK (ev_window_cmd_file_open_copy) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
G_CALLBACK (ev_window_cmd_edit_find_previous) },
{ "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_toolbar) },
- { "EditRotateLeft", EV_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL, NULL,
+ { "EditRotateLeft", EV_STOCK_ROTATE_LEFT, N_("Rotate _Left"), "<control>Left", NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_left) },
- { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL, NULL,
+ { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "<control>Right", NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_right) },
/* View menu */
N_("Reload the document"),
G_CALLBACK (ev_window_cmd_view_reload) },
+ { "ViewAutoscroll", GTK_STOCK_MEDIA_PLAY, N_("Auto_scroll"), NULL, NULL,
+ G_CALLBACK (ev_window_cmd_view_autoscroll) },
+
/* Go menu */
- { "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",
+ { "GoPreviousPage", GTK_STOCK_GO_UP, N_("_Previous Page"), "<control>Page_Up",
N_("Go to the previous page"),
G_CALLBACK (ev_window_cmd_go_previous_page) },
- { "GoNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<control>Page_Down",
+ { "GoNextPage", GTK_STOCK_GO_DOWN, N_("_Next Page"), "<control>Page_Down",
N_("Go to the next page"),
G_CALLBACK (ev_window_cmd_go_next_page) },
- { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home",
+ { "GoFirstPage", GTK_STOCK_GOTO_TOP, N_("_First Page"), "<control>Home",
N_("Go to the first page"),
G_CALLBACK (ev_window_cmd_go_first_page) },
- { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End",
+ { "GoLastPage", GTK_STOCK_GOTO_BOTTOM, N_("_Last Page"), "<control>End",
N_("Go to the last page"),
G_CALLBACK (ev_window_cmd_go_last_page) },
{ "StartPresentation", EV_STOCK_RUN_PRESENTATION, N_("Start Presentation"), NULL,
N_("Start a presentation"),
G_CALLBACK (ev_window_cmd_start_presentation) },
- { "PreviewPrint", GTK_STOCK_PRINT, N_("Print"), NULL,
- N_("Print this document"),
- G_CALLBACK (ev_window_cmd_preview_print) },
/* Accellerators */
{ "Escape", NULL, "", "Escape", "",
G_CALLBACK (ev_window_cmd_view_zoom_in) },
{ "CtrlKpMinus", GTK_STOCK_ZOOM_OUT, NULL, "<control>KP_Subtract", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
+ { "CtrlInsert", GTK_STOCK_COPY, NULL, "<control>Insert", NULL,
+ G_CALLBACK (ev_window_cmd_edit_copy) },
};
/* Toggle items */
gtk_widget_grab_focus (window->priv->view);
}
+static void
+sidebar_layers_visibility_changed (EvSidebarLayers *layers,
+ EvWindow *window)
+{
+ ev_view_reload (EV_VIEW (window->priv->view));
+}
+
static void
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",
static gboolean
view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
{
+#ifdef ENABLE_DBUS
+ GObject *keys;
+
+ keys = ev_application_get_media_keys (EV_APP);
+ ev_media_player_keys_focused (EV_MEDIA_PLAYER_KEYS (keys));
+#endif /* ENABLE_DBUS */
+
update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE);
ev_window_set_action_sensitive (window, "ViewToolbar", TRUE);
launch_action (EvWindow *window, EvLinkAction *action)
{
const char *filename = ev_link_action_get_filename (action);
- char *uri = NULL;
+ GAppInfo *app_info;
+ GFile *file;
+ GList file_list = {NULL};
+ GAppLaunchContext *context = NULL;
+ GError *error = NULL;
+
+ if (filename == NULL)
+ return;
- if (filename && g_path_is_absolute (filename)) {
- uri = gnome_vfs_get_uri_from_local_path (filename);
+ if (g_path_is_absolute (filename)) {
+ file = g_file_new_for_path (filename);
} else {
- GnomeVFSURI *base_uri, *resolved_uri;
-
- base_uri = gnome_vfs_uri_new (window->priv->uri);
- if (base_uri && filename) {
- resolved_uri = gnome_vfs_uri_resolve_relative (base_uri, filename);
- if (resolved_uri) {
- uri = gnome_vfs_uri_to_string (resolved_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (resolved_uri);
- }
- gnome_vfs_uri_unref (base_uri);
- }
+ GFile *base_file;
+ gchar *dir;
+
+ dir = g_path_get_dirname (window->priv->uri);
+ base_file = g_file_new_for_uri (dir);
+ g_free (dir);
+
+ file = g_file_resolve_relative_path (base_file, filename);
+ g_object_unref (base_file);
}
- if (uri) {
- gnome_vfs_url_show (uri);
- } else {
- gnome_vfs_url_show (filename);
+ app_info = g_file_query_default_handler (file, NULL, &error);
+ if (!app_info) {
+ ev_window_error_message (window, error,
+ "%s",
+ _("Unable to launch external application."));
+ g_object_unref (file);
+ g_error_free (error);
+
+ return;
}
- g_free (uri);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
+ gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+#endif
+
+ file_list.data = file;
+ if (!g_app_info_launch (app_info, &file_list, context, &error)) {
+ ev_window_error_message (window, error,
+ "%s",
+ _("Unable to launch external application."));
+ g_error_free (error);
+ }
+
+ g_object_unref (app_info);
+ g_object_unref (file);
/* According to the PDF spec filename can be an executable. I'm not sure
allowing to launch executables is a good idea though. -- marco */
launch_external_uri (EvWindow *window, EvLinkAction *action)
{
const gchar *uri = ev_link_action_get_uri (action);
- GnomeVFSResult result = gnome_vfs_url_show (uri);
- GtkWidget *dialog;
- gchar* message = NULL;
+ GError *error = NULL;
+ gboolean ret;
+#if GTK_CHECK_VERSION (2, 14, 0)
+ GAppLaunchContext *context = NULL;
+#endif
- switch(result) {
- case GNOME_VFS_OK:
- break;
- case GNOME_VFS_ERROR_BAD_PARAMETERS:
- message = _("Invalid URI: “%s”");
- break;
- case GNOME_VFS_ERROR_NOT_SUPPORTED:
- message = _("Unsupported URI: “%s”");
- break;
- default:
- message = _("Unknown error");
- }
- if(message) {
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Unable to open external link"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- message, uri);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (dialog);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
+ gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+ GDK_CURRENT_TIME);
+#endif
+ if (!g_strstr_len (uri, strlen (uri), "://") &&
+ !g_str_has_prefix (uri, "mailto:")) {
+ gchar *http;
+
+ /* Not a valid uri, assuming it's http */
+ http = g_strdup_printf ("http://%s", uri);
+ ret = g_app_info_launch_default_for_uri (http, NULL, &error);
+ g_free (http);
+ } else {
+ ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
+ }
+
+ if (ret == FALSE) {
+ ev_window_error_message (window, error,
+ "%s", _("Unable to open external link"));
+ g_error_free (error);
}
- return;
}
static void
ev_link_action_get_dest (action),
0,
NULL,
- FALSE,
- NULL,
GDK_CURRENT_TIME);
g_free (uri);
static void
ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
{
- GtkClipboard *clipboard;
EvLinkAction *ev_action;
- const gchar *uri;
ev_action = ev_link_get_action (window->priv->link);
if (!ev_action)
return;
- uri = ev_link_action_get_uri (ev_action);
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
- GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_set_text (clipboard, uri, -1);
+ ev_view_copy_link_address (EV_VIEW (window->priv->view),
+ ev_action);
}
+
static void
image_save_dialog_response_cb (GtkWidget *fc,
gint response_id,
EvWindow *ev_window)
{
- GnomeVFSURI *target_uri;
- gchar *uri;
- gchar *filename;
- gboolean is_local;
- GError *error = NULL;
+ GFile *target_file;
+ gboolean is_native;
+ GError *error = NULL;
+ GdkPixbuf *pixbuf;
+ gchar *uri;
+ gchar **extensions;
+ gchar *filename;
+ gchar *file_format;
+ GdkPixbufFormat *format;
+ GtkFileFilter *filter;
if (response_id != GTK_RESPONSE_OK) {
gtk_widget_destroy (fc);
}
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
- target_uri = gnome_vfs_uri_new (uri);
- is_local = gnome_vfs_uri_is_local (target_uri);
+ filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (fc));
+ format = g_object_get_data (G_OBJECT (filter), "pixbuf-format");
- if (is_local) {
- filename = g_filename_from_uri (uri, NULL, NULL);
+ if (format == NULL) {
+ format = get_gdk_pixbuf_format_by_extension (uri);
+ }
+
+ if (format == NULL) {
+ ev_window_error_message (ev_window, NULL,
+ "%s",
+ _("Couldn't find appropriate format to save image"));
+ g_free (uri);
+ gtk_widget_destroy (fc);
+
+ return;
+ }
+
+ extensions = gdk_pixbuf_format_get_extensions (format);
+ if (!g_str_has_suffix (uri, extensions[0])) {
+ gchar *uri_extension;
+
+ uri_extension = g_strconcat (uri, ".", extensions[0], NULL);
+ target_file = g_file_new_for_uri (uri_extension);
+ g_free (uri_extension);
} else {
- filename = ev_tmp_filename ("saveimage");
+ target_file = g_file_new_for_uri (uri);
}
-
+ g_strfreev (extensions);
g_free (uri);
- /* FIXME: allow saving in other image formats than png */
- gdk_pixbuf_save (ev_image_get_pixbuf (ev_window->priv->image),
- filename, "png", &error, NULL);
+ is_native = g_file_is_native (target_file);
+ if (is_native) {
+ filename = g_file_get_path (target_file);
+ } else {
+ filename = ev_tmp_filename ("saveimage");
+ }
+
+ 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 ();
+
+ file_format = gdk_pixbuf_format_get_name (format);
+ gdk_pixbuf_save (pixbuf, filename, file_format, &error, NULL);
+ g_free (file_format);
+ g_object_unref (pixbuf);
if (error) {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("The image could not be saved."),
- error);
+ ev_window_error_message (ev_window, error,
+ "%s", _("The image could not be saved."));
g_error_free (error);
g_free (filename);
- gnome_vfs_uri_unref (target_uri);
+ g_object_unref (target_file);
gtk_widget_destroy (fc);
return;
}
- if (!is_local) {
- GnomeVFSURI *source_uri;
- gchar *local_uri;
-
- local_uri = g_filename_to_uri (filename, NULL, NULL);
- source_uri = gnome_vfs_uri_new (local_uri);
- g_free (local_uri);
- ev_window_save_remote (ev_window, source_uri, target_uri);
- gnome_vfs_uri_unref (source_uri);
+ if (!is_native) {
+ GFile *source_file;
+
+ source_file = g_file_new_for_path (filename);
+
+ ev_window_save_remote (ev_window, EV_SAVE_IMAGE,
+ source_file, target_file);
+ g_object_unref (source_file);
}
g_free (filename);
- gnome_vfs_uri_unref (target_uri);
+ g_object_unref (target_file);
gtk_widget_destroy (fc);
}
static void
ev_view_popup_cmd_save_image_as (GtkAction *action, EvWindow *window)
{
- GtkWidget *fc;
- GtkFileFilter *filter;
+ GtkWidget *fc;
if (!window->priv->image)
return;
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Images"));
- gtk_file_filter_add_pixbuf_formats (filter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), filter);
-
+
+ file_chooser_dialog_add_writable_pixbuf_formats (GTK_FILE_CHOOSER (fc));
+
g_signal_connect (fc, "response",
G_CALLBACK (image_save_dialog_response_cb),
window);
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
ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
{
- GList *l;
+ GList *l;
+ GdkScreen *screen;
if (!window->priv->attach_list)
return;
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+
for (l = window->priv->attach_list; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
GError *error = NULL;
attachment = (EvAttachment *) l->data;
- ev_attachment_open (attachment, &error);
+ ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (window),
- _("Unable to open attachment"),
- error);
+ ev_window_error_message (window, error,
+ "%s", _("Unable to open attachment"));
g_error_free (error);
}
}
gint response_id,
EvWindow *ev_window)
{
- GnomeVFSURI *target_uri;
+ GFile *target_file;
gchar *uri;
GList *l;
GtkFileChooserAction fc_action;
gboolean is_dir;
- gboolean is_local;
+ gboolean is_native;
if (response_id != GTK_RESPONSE_OK) {
gtk_widget_destroy (fc);
}
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
- target_uri = gnome_vfs_uri_new (uri);
+ target_file = g_file_new_for_uri (uri);
g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- is_local = gnome_vfs_uri_is_local (target_uri);
+ is_native = g_file_is_native (target_file);
for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
- gchar *filename;
+ GFile *save_to;
GError *error = NULL;
attachment = (EvAttachment *) l->data;
- if (is_local) {
+ if (is_native) {
if (is_dir) {
- filename = g_strjoin ("/", uri,
- ev_attachment_get_name (attachment),
- NULL);
+ save_to = g_file_get_child (target_file,
+ ev_attachment_get_name (attachment));
} else {
- filename = g_strdup (uri);
+ save_to = g_object_ref (target_file);
}
} else {
- filename = ev_tmp_filename ("saveattachment");
+ save_to = ev_tmp_file_get ("saveattachment");
}
- ev_attachment_save (attachment, filename, &error);
+ ev_attachment_save (attachment, save_to, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("The attachment could not be saved."),
- error);
+ ev_window_error_message (ev_window, error,
+ "%s", _("The attachment could not be saved."));
g_error_free (error);
- g_free (filename);
+ g_object_unref (save_to);
continue;
}
- if (!is_local) {
- GnomeVFSURI *src_uri;
- GnomeVFSURI *dest_uri;
- gchar *local_uri;
+ if (!is_native) {
+ GFile *dest_file;
if (is_dir) {
- const gchar *name = ev_attachment_get_name (attachment);
-
- dest_uri = gnome_vfs_uri_append_file_name (target_uri,
- name);
+ dest_file = g_file_get_child (target_file,
+ ev_attachment_get_name (attachment));
} else {
- dest_uri = gnome_vfs_uri_ref (target_uri);
+ dest_file = g_object_ref (target_file);
}
-
- local_uri = g_filename_to_uri (filename, NULL, NULL);
- src_uri = gnome_vfs_uri_new (local_uri);
- g_free (local_uri);
- ev_window_save_remote (ev_window, src_uri, dest_uri);
- gnome_vfs_uri_unref (src_uri);
- gnome_vfs_uri_unref (dest_uri);
+
+ ev_window_save_remote (ev_window, EV_SAVE_ATTACHMENT,
+ save_to, dest_file);
+
+ g_object_unref (dest_file);
}
- g_free (filename);
+ g_object_unref (save_to);
}
g_free (uri);
- gnome_vfs_uri_unref (target_uri);
+ g_object_unref (target_file);
gtk_widget_destroy (fc);
}
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
gtk_widget_show (fc);
}
+static void
+ev_window_media_player_key_pressed (EvWindow *window,
+ const gchar *key,
+ gpointer user_data)
+{
+ if (!gtk_window_is_active (GTK_WINDOW (window)))
+ return;
+
+ /* Note how Previous/Next only go to the
+ * next/previous page despite their icon telling you
+ * they should go to the beginning/end.
+ *
+ * There's very few keyboards with FFW/RWD though,
+ * so we stick the most useful keybinding on the most
+ * often seen keys
+ */
+ if (strcmp (key, "Play") == 0) {
+ ev_window_run_presentation (window);
+ } else if (strcmp (key, "Previous") == 0) {
+ ev_window_cmd_go_previous_page (NULL, window);
+ } else if (strcmp (key, "Next") == 0) {
+ ev_window_cmd_go_next_page (NULL, window);
+ } else if (strcmp (key, "FastForward") == 0) {
+ ev_window_cmd_go_last_page (NULL, window);
+ } else if (strcmp (key, "Rewind") == 0) {
+ ev_window_cmd_go_first_page (NULL, window);
+ }
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *sidebar_widget;
+ GObject *mpkeys;
g_signal_connect (ev_window, "configure_event",
G_CALLBACK (window_configure_event_cb), NULL);
g_error_free (error);
}
-#if GTK_CHECK_VERSION(2,11,4)
ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
-#else
- /* It's fine to just use the one of the default screen here */
- ev_window->priv->recent_manager = gtk_recent_manager_get_for_screen (
- gdk_screen_get_default ());
-#endif
ev_window->priv->recent_action_group = NULL;
ev_window->priv->recent_ui_id = 0;
g_signal_connect_swapped (ev_window->priv->recent_manager,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+ sidebar_widget = ev_sidebar_layers_new ();
+ ev_window->priv->sidebar_layers = sidebar_widget;
+ g_signal_connect (sidebar_widget,
+ "layers_visibility_changed",
+ G_CALLBACK (sidebar_layers_visibility_changed),
+ ev_window);
+ gtk_widget_show (sidebar_widget);
+ ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+ sidebar_widget);
+
ev_window->priv->view_box = gtk_vbox_new (FALSE, 0);
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
ev_window->priv->view = ev_view_new ();
ev_view_set_screen_dpi (EV_VIEW (ev_window->priv->view),
get_screen_dpi (GTK_WINDOW (ev_window)));
- ev_window->priv->password_view = ev_password_view_new ();
+ ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
g_signal_connect_swapped (ev_window->priv->password_view,
"unlock",
- G_CALLBACK (ev_window_popup_password_dialog),
+ G_CALLBACK (ev_window_password_view_unlock),
ev_window);
g_signal_connect_object (ev_window->priv->view, "focus_in_event",
G_CALLBACK (view_actions_focus_in_cb),
g_signal_connect_object (ev_window->priv->view, "handle-link",
G_CALLBACK (view_handle_link_cb),
ev_window, 0);
-
+ g_signal_connect_swapped (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (ev_window_set_view_size),
+ ev_window);
g_signal_connect_object (ev_window->priv->view,
"popup",
G_CALLBACK (view_menu_popup_cb),
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
- g_signal_connect (ev_window->priv->view,
- "notify::find-status",
- G_CALLBACK (view_find_status_changed_cb),
- ev_window);
g_signal_connect (ev_window->priv->view,
"notify::sizing-mode",
G_CALLBACK (ev_window_sizing_mode_changed_cb),
"/AttachmentPopup");
ev_window->priv->attach_list = NULL;
+ /* Media player keys */
+ mpkeys = ev_application_get_media_keys (EV_APP);
+ if (mpkeys) {
+ g_signal_connect_swapped (mpkeys, "key_pressed",
+ G_CALLBACK (ev_window_media_player_key_pressed),
+ ev_window);
+ }
+
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);
gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
setup_view_from_metadata (ev_window);
- setup_sidebar_from_metadata (ev_window, NULL);
+ setup_sidebar_from_metadata (ev_window);
ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
ev_window_setup_action_sensitivity (ev_window);
+
+ /* Drag and Drop */
+ gtk_drag_dest_set (GTK_WIDGET (ev_window),
+ GTK_DEST_DEFAULT_ALL,
+ NULL, 0,
+ GDK_ACTION_COPY);
+ gtk_drag_dest_add_uri_targets (GTK_WIDGET (ev_window));
}
/**