#include "ev-page-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-print-job.h"
#include "ev-properties-dialog.h"
#include "ev-ps-exporter.h"
#include "ev-document-thumbnails.h"
#include "ev-document-fonts.h"
#include "ev-document-find.h"
#include "ev-document-security.h"
-#include "ev-document-types.h"
+#include "ev-document-factory.h"
#include "ev-job-queue.h"
#include "ev-jobs.h"
#include "ev-sidebar-page.h"
#include "ev-utils.h"
#include "ev-debug.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
+
#include <poppler.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gnome.h>
-#include <libgnomeprintui/gnome-print-dialog.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <gconf/gconf-client.h>
EV_CHROME_TOOLBAR = 1 << 1,
EV_CHROME_FINDBAR = 1 << 2,
EV_CHROME_RAISE_TOOLBAR = 1 << 3,
- EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR
+ EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4,
+ EV_CHROME_SIDEBAR = 1 << 5,
+ EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
} EvChrome;
struct _EvWindowPrivate {
GtkWidget *find_bar;
GtkWidget *scrolled_window;
GtkWidget *view;
- GtkWidget *page_view;
GtkWidget *password_view;
GtkWidget *sidebar_thumbs;
GtkWidget *sidebar_links;
-
- EvWindowTitle *title;
+ GtkWidget *sidebar_attachments;
/* Dialogs */
GtkWidget *properties;
+#ifdef WITH_PRINT
+ GtkWidget *print_dialog;
+#endif
+ GtkWidget *password_dialog;
/* UI Builders */
GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
+ GtkActionGroup *view_popup_action_group;
+ GtkActionGroup *attachment_popup_action_group;
+ GtkUIManager *ui_manager;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
GtkWidget *fullscreen_popup;
- GSource *fullscreen_timeout_source;
+ guint fullscreen_timeout_id;
+
+ /* Popup link */
+ GtkWidget *view_popup;
+ EvLink *link;
+
+ /* Popup attachment */
+ GtkWidget *attachment_popup;
+ GList *attach_list;
/* Document */
char *uri;
char *local_uri;
+ EvLinkDest *dest;
+
EvDocument *document;
- EvPageCache *page_cache;
+ EvPageCache *page_cache;
EvWindowPageMode page_mode;
+ EvWindowTitle *title;
+ EggRecentViewUIManager *recent_view;
- /* These members are used temporarily when in PAGE_MODE_PASSWORD */
- EvDocument *password_document;
- GtkWidget *password_dialog;
- char *password_uri;
-
- /* Job used to load document */
EvJob *xfer_job;
- EvJob *load_job;
+#ifdef WITH_GNOME_PRINT
+ GnomePrintJob *print_job;
+#endif
- EggRecentViewUIManager *recent_view;
+#ifdef WITH_GTK_PRINT
+ EvJob *print_job;
+ GtkPrintJob *gtk_print_job;
+ GtkPrinter *printer;
+ GtkPrintSettings *print_settings;
+ GtkPageSetup *print_page_setup;
+#endif
};
static const GtkTargetEntry ev_drop_types[] = {
#define PAGE_SELECTOR_ACTION "PageSelector"
#define ZOOM_CONTROL_ACTION "ViewZoom"
-#define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
#define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
#define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
+#define ATTACHMENTS_SIDEBAR_ID "attachments"
-#define PRINT_CONFIG_FILENAME "ev-print-config.xml"
-
+static void ev_window_update_actions (EvWindow *ev_window);
static void ev_window_update_fullscreen_popup (EvWindow *window);
static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
GParamSpec *pspec,
EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
-static void ev_window_load_job_cb (EvJobLoad *job,
- gpointer data);
-static void ev_window_xfer_job_cb (EvJobXfer *job,
- gpointer data);
+static void ev_window_xfer_job_cb (EvJobXfer *job,
+ gpointer data);
+static void ev_window_print_job_cb (EvJobPrint *job,
+ EvWindow *window);
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
EvWindow *ev_window);
static void ev_window_stop_presentation (EvWindow *window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
-static void show_fullscreen_popup (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_copy_link_address (GtkAction *action,
+ EvWindow *window);
+static void ev_attachment_popup_cmd_open_attachment (GtkAction *action,
+ EvWindow *window);
+static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action,
+ EvWindow *window);
+static void ev_window_cmd_view_best_fit (GtkAction *action,
+ EvWindow *ev_window);
+static void ev_window_cmd_view_page_width (GtkAction *action,
+ EvWindow *ev_window);
+static void fullscreen_set_timeout (EvWindow *window);
+static gboolean fullscreen_motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer user_data);
+static gboolean fullscreen_leave_notify_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer user_data);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
static void
-set_action_sensitive (EvWindow *ev_window,
- const char *name,
- gboolean sensitive)
+ev_window_set_action_sensitive (EvWindow *ev_window,
+ const char *name,
+ gboolean sensitive)
{
GtkAction *action = gtk_action_group_get_action (ev_window->priv->action_group,
name);
gtk_action_set_sensitive (action, sensitive);
}
+
static void
-update_action_sensitivity (EvWindow *ev_window)
+ev_window_setup_action_sensitivity (EvWindow *ev_window)
{
- EvView *view;
- EvDocument *document;
+ EvDocument *document = ev_window->priv->document;
const EvDocumentInfo *info = NULL;
- EvWindowPageMode page_mode;
- gboolean sensitive, has_pages = FALSE, has_document;
- int n_pages = 0, page = -1;
+
+ gboolean has_document = FALSE;
gboolean ok_to_print = TRUE;
gboolean ok_to_copy = TRUE;
gboolean has_properties = TRUE;
gboolean override_restrictions = FALSE;
- GConfClient *client;
+ gboolean can_get_text = FALSE;
+ gboolean has_pages = FALSE;
+ gboolean can_find = FALSE;
- view = EV_VIEW (ev_window->priv->view);
-
- document = ev_window->priv->document;
+ GConfClient *client;
- if (document)
+ if (document) {
+ has_document = TRUE;
info = ev_page_cache_get_info (ev_window->priv->page_cache);
-
- page_mode = ev_window->priv->page_mode;
- has_document = document != NULL;
+ }
if (has_document && ev_window->priv->page_cache) {
- page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
- n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
- has_pages = has_document && n_pages > 0;
+ has_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0;
+ }
+
+ if (!info || info->fields_mask == 0) {
+ has_properties = FALSE;
+ }
+
+ if (has_document && ev_document_can_get_text (document)) {
+ can_get_text = TRUE;
+ }
+
+ if (has_document && EV_IS_DOCUMENT_FIND (document)) {
+ can_find = TRUE;
}
client = gconf_client_get_default ();
if (has_document && !EV_IS_PS_EXPORTER(document))
ok_to_print = FALSE;
- if (!info || info->fields_mask == 0) {
- has_properties = FALSE;
- }
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);
+
/* File menu */
- /* "FileOpen": always sensitive */
- set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
- set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
- set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
- /* "FileCloseWindow": always sensitive */
+ ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
+ 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);
/* Edit menu */
- sensitive = has_pages && ev_document_can_get_text (document);
- set_action_sensitive (ev_window, "EditCopy", sensitive && ok_to_copy);
- set_action_sensitive (ev_window, "EditSelectAll", sensitive && ok_to_copy);
- set_action_sensitive (ev_window, "EditFind",
+ ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text);
+ ev_window_set_action_sensitive (ev_window, "EditFind",
has_pages && EV_IS_DOCUMENT_FIND (document));
- set_action_sensitive (ev_window, "Slash",
+ ev_window_set_action_sensitive (ev_window, "Slash",
has_pages && EV_IS_DOCUMENT_FIND (document));
- set_action_sensitive (ev_window, "EditFindNext",
- ev_view_can_find_next (view));
- set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
- set_action_sensitive (ev_window, "EditRotateRight", has_pages);
+ ev_window_set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
+ ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages);
/* View menu */
- set_action_sensitive (ev_window, "ViewContinuous", has_pages);
- set_action_sensitive (ev_window, "ViewDual", has_pages);
- set_action_sensitive (ev_window, "ViewZoomIn",
+ ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages);
+ 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);
+
+ /* 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_update_actions (ev_window);
+}
+
+static void
+ev_window_update_actions (EvWindow *ev_window)
+{
+ EvView *view = EV_VIEW (ev_window->priv->view);
+ int n_pages = 0, page = -1;
+ gboolean has_pages = FALSE;
+
+ if (ev_window->priv->document && ev_window->priv->page_cache) {
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+ n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+ has_pages = n_pages > 0;
+ }
+
+ 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));
+ ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
+ ev_view_can_find_previous (view));
+
+ ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
has_pages && ev_view_can_zoom_in (view));
- set_action_sensitive (ev_window, "ViewZoomOut",
+ ev_window_set_action_sensitive (ev_window, "ViewZoomOut",
has_pages && ev_view_can_zoom_out (view));
- set_action_sensitive (ev_window, "ViewBestFit", has_pages);
- set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
- set_action_sensitive (ev_window, "ViewReload", has_pages);
/* Go menu */
- if (document) {
- set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
- set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
- set_action_sensitive (ev_window, "GoFirstPage", page > 0);
- set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
+ if (has_pages) {
+ ev_window_set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
+ ev_window_set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
+ ev_window_set_action_sensitive (ev_window, "GoFirstPage", page > 0);
+ ev_window_set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
} else {
- set_action_sensitive (ev_window, "GoFirstPage", FALSE);
- set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
- set_action_sensitive (ev_window, "GoNextPage", FALSE);
- set_action_sensitive (ev_window, "GoLastPage", FALSE);
+ ev_window_set_action_sensitive (ev_window, "GoFirstPage", FALSE);
+ ev_window_set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
+ ev_window_set_action_sensitive (ev_window, "GoNextPage", FALSE);
+ ev_window_set_action_sensitive (ev_window, "GoLastPage", FALSE);
}
- /* Toolbar-specific actions: */
- set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
- set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
-
- if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ if (has_pages &&
+ ev_view_get_sizing_mode (view) != EV_SIZING_FIT_WIDTH &&
+ ev_view_get_sizing_mode (view) != EV_SIZING_BEST_FIT) {
GtkAction *action;
float zoom;
float real_zoom;
}
}
+static void
+ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive)
+{
+ if (window->priv->action_group) {
+ ev_window_set_action_sensitive (window, "PageDown", sensitive);
+ ev_window_set_action_sensitive (window, "PageUp", sensitive);
+ ev_window_set_action_sensitive (window, "Space", sensitive);
+ ev_window_set_action_sensitive (window, "ShiftSpace", sensitive);
+ ev_window_set_action_sensitive (window, "BackSpace", sensitive);
+ ev_window_set_action_sensitive (window, "ShiftBackSpace", sensitive);
+ ev_window_set_action_sensitive (window, "Return", sensitive);
+ ev_window_set_action_sensitive (window, "ShiftReturn", sensitive);
+ ev_window_set_action_sensitive (window, "Slash", sensitive);
+ ev_window_set_action_sensitive (window, "Plus", sensitive);
+ ev_window_set_action_sensitive (window, "Minus", sensitive);
+ ev_window_set_action_sensitive (window, "KpPlus", sensitive);
+ ev_window_set_action_sensitive (window, "KpMinus", sensitive);
+ ev_window_set_action_sensitive (window, "Equal", sensitive);
+ }
+}
+
static void
set_widget_visibility (GtkWidget *widget, gboolean visible)
{
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_assert (GTK_IS_WIDGET (widget));
if (visible)
gtk_widget_show (widget);
update_chrome_visibility (EvWindow *window)
{
EvWindowPrivate *priv = window->priv;
- gboolean menubar, toolbar, findbar, fullscreen_toolbar;
+ gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
presentation = ev_view_get_presentation (EV_VIEW (priv->view));
menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode;
- fullscreen_toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
- (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0);
+ fullscreen_toolbar = ((priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
+ (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
- set_widget_visibility (priv->menubar, menubar);
-
+ set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar_dock, toolbar);
- set_action_sensitive (window, "EditToolbar", toolbar);
-
set_widget_visibility (priv->find_bar, findbar);
+ set_widget_visibility (priv->sidebar, sidebar);
- if (priv->fullscreen_popup != NULL) {
- if (fullscreen)
- show_fullscreen_popup (window);
- else
- set_widget_visibility (priv->fullscreen_popup, FALSE);
+ ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
+ gtk_widget_set_sensitive (priv->menubar, menubar);
+ if (priv->fullscreen_popup != NULL) {
set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
+ set_widget_visibility (priv->fullscreen_popup, fullscreen_toolbar);
}
}
static void
-update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
+update_chrome_flag (EvWindow *window, EvChrome flag, gboolean active)
{
EvWindowPrivate *priv = window->priv;
- GConfClient *client;
if (active) {
priv->chrome |= flag;
- }
- else {
+ } else {
priv->chrome &= ~flag;
}
- if (pref != NULL) {
- client = gconf_client_get_default ();
- gconf_client_set_bool (client, pref, active, NULL);
- g_object_unref (client);
- }
-
update_chrome_visibility (window);
}
-static void
-ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
-{
- GtkAction *action;
-
- update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, NULL, TRUE);
- set_action_sensitive (window, "ViewToolbar", FALSE);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- PAGE_SELECTOR_ACTION);
- ev_page_action_grab_focus (EV_PAGE_ACTION (action));
-}
-
-static void
-ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
-{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD);
-}
-
-static void
-ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
-{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD);
-}
-
-static void
-ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
-{
- gboolean continuous;
-
- ev_window_stop_presentation (ev_window);
- continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- g_object_set (G_OBJECT (ev_window->priv->view),
- "continuous", continuous,
- NULL);
- update_action_sensitivity (ev_window);
-}
-
-static void
-ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
-{
- gboolean dual_page;
-
- ev_window_stop_presentation (ev_window);
- dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- g_object_set (G_OBJECT (ev_window->priv->view),
- "dual-page", dual_page,
- NULL);
- update_action_sensitivity (ev_window);
-}
-
-static void
-ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
-{
- ev_window_stop_presentation (ev_window);
-
- 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);
- } else {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
- }
- update_action_sensitivity (ev_window);
-}
-
-static void
-ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
-{
- ev_window_stop_presentation (ev_window);
-
- 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);
- } else {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
- }
- update_action_sensitivity (ev_window);
-}
-
static void
update_sizing_buttons (EvWindow *window)
{
NULL);
switch (sizing_mode) {
- case EV_SIZING_BEST_FIT:
- best_fit = TRUE;
- page_width = FALSE;
- break;
- case EV_SIZING_FIT_WIDTH:
- best_fit = FALSE;
- page_width = TRUE;
- break;
-
- default:
- best_fit = page_width = FALSE;
- break;
+ case EV_SIZING_BEST_FIT:
+ best_fit = TRUE;
+ page_width = FALSE;
+ break;
+ case EV_SIZING_FIT_WIDTH:
+ best_fit = FALSE;
+ page_width = TRUE;
+ break;
+ default:
+ best_fit = page_width = FALSE;
+ break;
}
action = gtk_action_group_get_action (action_group, "ViewBestFit");
}
}
-void
-ev_window_open_page_label (EvWindow *ev_window,
- const char *label)
-{
- if (ev_window->priv->page_cache) {
- ev_page_cache_set_page_label (ev_window->priv->page_cache,
- label);
- }
-}
-
gboolean
ev_window_is_empty (const EvWindow *ev_window)
{
g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
return (ev_window->priv->document == NULL) &&
- (ev_window->priv->load_job == NULL) &&
(ev_window->priv->xfer_job == NULL);
}
static void
-unable_to_load_dialog_response_cb (GtkWidget *dialog,
+ev_window_error_dialog_response_cb (GtkWidget *dialog,
gint response_id,
EvWindow *ev_window)
{
}
static void
-unable_to_load (EvWindow *ev_window,
- const char *error_message)
+ev_window_error_dialog (GtkWindow *window, const gchar *msg, GError *error)
{
GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
- _("Unable to open document"));
+ msg);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", error_message);
+ "%s", error->message);
g_signal_connect (dialog, "response",
- G_CALLBACK (unable_to_load_dialog_response_cb),
- ev_window);
+ G_CALLBACK (ev_window_error_dialog_response_cb),
+ window);
gtk_widget_show (dialog);
}
static void
find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
{
- update_action_sensitivity (ev_window);
+ ev_window_update_actions (ev_window);
}
static void
gint page,
EvWindow *ev_window)
{
- update_action_sensitivity (ev_window);
+ ev_window_update_actions (ev_window);
- if (ev_window->priv->uri) {
+ if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
- }
}
static void
}
static void
-update_sidebar_visibility (EvWindow *window)
+setup_document_from_metadata (EvWindow *window)
{
char *uri = window->priv->uri;
- GValue sidebar_visibility = { 0, };
+ GValue page = { 0, };
+ gint new_page;
- if (uri && ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility)) {
- set_widget_visibility (window->priv->sidebar,
- g_value_get_boolean (&sidebar_visibility));
+ if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
+ new_page = CLAMP (g_value_get_int (&page), 0, ev_page_cache_get_n_pages (window->priv->page_cache) - 1);
+ ev_page_cache_set_current_page (window->priv->page_cache,
+ new_page);
+ g_value_unset (&page);
}
}
static void
-setup_document_from_metadata (EvWindow *window)
+setup_chrome_from_metadata (EvWindow *window)
{
- char *uri = window->priv->uri;
- GValue page = { 0, };
+ EvChrome chrome = EV_CHROME_NORMAL;
+ GValue show_toolbar = { 0, };
- /* Page */
- if (uri && ev_metadata_manager_get (uri, "page", &page)) {
- ev_page_cache_set_current_page (window->priv->page_cache,
- g_value_get_int (&page));
+ if (ev_metadata_manager_get (NULL, "show_toolbar", &show_toolbar, FALSE)) {
+ if (!g_value_get_boolean (&show_toolbar))
+ chrome &= ~EV_CHROME_TOOLBAR;
+ g_value_unset (&show_toolbar);
}
+ window->priv->chrome = chrome;
}
static void
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, };
- if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size)) {
+ if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
g_value_get_int (&sidebar_size));
+ g_value_unset(&sidebar_size);
}
-
- if (ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page)) {
+
+ if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
const char *page_id = g_value_get_string (&sidebar_page);
-
- if (strcmp (page_id, "links") == 0) {
+
+ 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")) {
+ } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && 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 (links), document)) {
- ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
- } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
}
+ 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);
}
- update_sidebar_visibility (window);
+ if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, g_value_get_boolean (&sidebar_visibility));
+ g_value_unset (&sidebar_visibility);
+ }
}
static void
-ev_window_setup_document (EvWindow *ev_window)
+setup_view_from_metadata (EvWindow *window)
{
- const EvDocumentInfo *info;
- EvDocument *document;
- EvView *view = EV_VIEW (ev_window->priv->view);
- EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
- GtkAction *action;
+ EvView *view = EV_VIEW (window->priv->view);
+ char *uri = window->priv->uri;
+ GEnumValue *enum_value;
+ GValue width = { 0, };
+ GValue height = { 0, };
+ GValue maximized = { 0, };
+ GValue x = { 0, };
+ GValue y = { 0, };
+ GValue sizing_mode = { 0, };
+ GValue zoom = { 0, };
+ GValue continuous = { 0, };
+ GValue dual_page = { 0, };
+ GValue presentation = { 0, };
+ GValue fullscreen = { 0, };
+ GValue rotation = { 0, };
+ gboolean restore_size = TRUE;
- document = ev_window->priv->document;
- ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
- g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
+ /* Window size */
- if (EV_IS_DOCUMENT_FIND (document)) {
- g_signal_connect_object (G_OBJECT (document),
- "find_changed",
- G_CALLBACK (find_changed_cb),
- ev_window, 0);
+ if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
+ if (g_value_get_boolean (&maximized)) {
+ gtk_window_maximize (GTK_WINDOW (window));
+ restore_size = FALSE;
+ } else {
+ gtk_window_unmaximize (GTK_WINDOW (window));
+ }
+ g_value_unset (&maximized);
}
- ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
-
- ev_sidebar_set_document (sidebar, document);
-
- if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
- ev_view_set_document (view, document);
+ if (restore_size &&
+ 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);
+ }
+ if (restore_size &&
+ 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);
}
- ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
- ev_window_title_set_document (ev_window->priv->title, document);
- action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
- ev_page_action_set_document (EV_PAGE_ACTION (action), document);
- update_action_sensitivity (ev_window);
+ /* 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_value_unset (&sizing_mode);
+ ev_view_set_sizing_mode (view, enum_value->value);
+ }
- info = ev_page_cache_get_info (ev_window->priv->page_cache);
- update_document_mode (ev_window, info->mode);
+ /* Zoom */
+ if (ev_metadata_manager_get (uri, "zoom", &zoom, FALSE) &&
+ ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
+ g_value_unset (&zoom);
+ }
- if (ev_window->priv->properties) {
- ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
- ev_window->priv->document);
+ /* Continuous */
+ if (ev_metadata_manager_get (uri, "continuous", &continuous, FALSE)) {
+ ev_view_set_continuous (view, g_value_get_boolean (&continuous));
+ g_value_unset (&continuous);
}
- setup_document_from_metadata (ev_window);
+ /* Dual page */
+ if (ev_metadata_manager_get (uri, "dual-page", &dual_page, FALSE)) {
+ ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
+ g_value_unset (&dual_page);
+ }
+
+ /* Presentation */
+ if (ev_metadata_manager_get (uri, "presentation", &presentation, FALSE)) {
+ if (g_value_get_boolean (&presentation) && uri) {
+ ev_window_run_presentation (window);
+ }
+ g_value_unset (&presentation);
+ }
+
+ /* Fullscreen */
+ if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen, FALSE)) {
+ if (g_value_get_boolean (&fullscreen) && uri) {
+ ev_window_run_fullscreen (window);
+ }
+ g_value_unset (&fullscreen);
+ }
+
+ /* Rotation */
+ if (ev_metadata_manager_get (uri, "rotation", &rotation, TRUE)) {
+ if (g_value_get_int (&rotation)) {
+ switch (g_value_get_int (&rotation)) {
+ case 90:
+ ev_view_set_rotation (view, 90);
+ break;
+ case 180:
+ ev_view_set_rotation (view, 180);
+ break;
+ case 270:
+ ev_view_set_rotation (view, 270);
+ break;
+ default:
+ break;
+ }
+ }
+ g_value_unset (&rotation);
+ }
+}
+
+static void
+ev_window_setup_document (EvWindow *ev_window)
+{
+ const EvDocumentInfo *info;
+ EvDocument *document;
+ EvView *view = EV_VIEW (ev_window->priv->view);
+ EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
+ GtkAction *action;
+
+ document = ev_window->priv->document;
+ ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
+ g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
+
+ if (EV_IS_DOCUMENT_FIND (document)) {
+ g_signal_connect_object (G_OBJECT (document),
+ "find_changed",
+ G_CALLBACK (find_changed_cb),
+ ev_window, 0);
+ }
+
+ ev_sidebar_set_document (sidebar, document);
+
+ if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
+ ev_view_set_document (view, document);
+ }
+ ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
+
+ ev_window_title_set_document (ev_window->priv->title, document);
+ ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
+ ev_page_action_set_document (EV_PAGE_ACTION (action), document);
+ ev_window_setup_action_sensitivity (ev_window);
+
+ if (ev_window->priv->properties) {
+ ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->document);
+ }
+
+ setup_document_from_metadata (ev_window);
setup_sidebar_from_metadata (ev_window, document);
+
+ info = ev_page_cache_get_info (ev_window->priv->page_cache);
+ update_document_mode (ev_window, info->mode);
}
static void
char *password;
if (response_id == GTK_RESPONSE_OK) {
- EvDocument *document;
- gchar *uri;
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->password_document),
+ ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->xfer_job->document),
password);
ev_document_doc_mutex_unlock ();
}
ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
- document = ev_window->priv->password_document;
- uri = ev_window->priv->password_uri;
-
- ev_window->priv->password_document = NULL;
- ev_window->priv->password_uri = NULL;
-
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);
+ ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
gtk_widget_destroy (password_dialog);
- g_object_unref (document);
- g_free (uri);
-
return;
}
gtk_widget_destroy (password_dialog);
}
-/* Called either by ev_window_load_job_cb or by the "unlock" callback on the
+/* Called either by ev_window_xfer_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)
{
- g_assert (ev_window->priv->password_document);
- g_assert (ev_window->priv->password_uri);
+ g_assert (ev_window->priv->xfer_job);
gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
- ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->password_uri);
+ 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->password_uri, NULL);
+ 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),
}
}
-
static void
-ev_window_clear_jobs (EvWindow *ev_window)
+ev_window_clear_xfer_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);
-
- 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);
- ev_window->priv->load_job = NULL;
- }
-
if (ev_window->priv->xfer_job != NULL) {
if (!ev_window->priv->xfer_job->finished)
* function should _not_ necessarily expect those to exist after being
* called. */
static void
-ev_window_load_job_cb (EvJobLoad *job,
+ev_window_xfer_job_cb (EvJobXfer *job,
gpointer data)
{
EvWindow *ev_window = EV_WINDOW (data);
EvDocument *document = EV_JOB (job)->document;
- g_assert (document);
- g_assert (document != ev_window->priv->document);
g_assert (job->uri);
-
- if (ev_window->priv->password_document) {
- g_object_unref (ev_window->priv->password_document);
- ev_window->priv->password_document = NULL;
- }
- if (ev_window->priv->password_uri) {
- g_free (ev_window->priv->password_uri);
- ev_window->priv->password_uri = NULL;
- }
+
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
/* Success! */
if (job->error == NULL) {
+
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = g_strdup (job->uri);
+ setup_view_from_metadata (ev_window);
+
+ if (job->local_uri) {
+ ev_window->priv->local_uri = g_strdup (job->local_uri);
+ } else {
+ ev_window->priv->local_uri = NULL;
+ }
+
if (ev_window->priv->document)
g_object_unref (ev_window->priv->document);
ev_window->priv->document = g_object_ref (document);
- ev_window_setup_document (ev_window);
-
- ev_window_add_recent (ev_window, ev_window->priv->uri);
- ev_window_clear_jobs (ev_window);
+ ev_window_setup_document (ev_window);
+ ev_window_add_recent (ev_window, ev_window->priv->uri);
+
+ if (job->dest)
+ ev_window_goto_dest (ev_window, job->dest);
+
+ switch (job->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;
+ }
+
+ ev_window_clear_xfer_job (ev_window);
return;
}
job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
gchar *base_name, *file_name;
- ev_window->priv->password_document = g_object_ref (document);
- ev_window->priv->password_uri = g_strdup (job->uri);
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = g_strdup (job->uri);
+ setup_view_from_metadata (ev_window);
+
file_name = gnome_vfs_format_uri_for_display (job->uri);
base_name = g_path_get_basename (file_name);
ev_window_popup_password_dialog (ev_window);
} else {
- unable_to_load (ev_window, job->error->message);
+ ev_window_error_dialog (GTK_WINDOW (ev_window),
+ _("Unable to open document"),
+ job->error);
+ ev_window_clear_xfer_job (ev_window);
}
return;
}
-static void
-ev_window_xfer_job_cb (EvJobXfer *job,
- gpointer data)
+const char *
+ev_window_get_uri (EvWindow *ev_window)
{
- EvWindow *ev_window = EV_WINDOW (data);
-
-
-
- if (job->error != NULL) {
- unable_to_load (ev_window, job->error->message);
- ev_window_clear_jobs (ev_window);
- } else {
- char *uri;
-
- EvDocument *document = g_object_ref (EV_JOB (job)->document);
-
- if (job->local_uri) {
- ev_window->priv->local_uri = g_strdup (job->local_uri);
- uri = ev_window->priv->local_uri;
- } else {
- ev_window->priv->local_uri = NULL;
- uri = ev_window->priv->uri;
- }
-
- ev_window_clear_jobs (ev_window);
-
- ev_window->priv->load_job = ev_job_load_new (document, uri);
- g_signal_connect (ev_window->priv->load_job,
- "finished",
- G_CALLBACK (ev_window_load_job_cb),
- ev_window);
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
- g_object_unref (document);
- }
+ return ev_window->priv->uri;
}
static void
-setup_view_from_metadata (EvWindow *window)
+ev_window_close_dialogs (EvWindow *ev_window)
{
- EvView *view = EV_VIEW (window->priv->view);
- char *uri = window->priv->uri;
- GEnumValue *enum_value;
- GValue width = { 0, };
- GValue height = { 0, };
- GValue maximized = { 0, };
- GValue x = { 0, };
- GValue y = { 0, };
- GValue sizing_mode = { 0, };
- GValue zoom = { 0, };
- GValue continuous = { 0, };
- GValue dual_page = { 0, };
- GValue presentation = { 0, };
- GValue fullscreen = { 0, };
- GValue rotation = { 0, };
-
- if (window->priv->uri == NULL) {
- return;
- }
-
- /* Window size */
- if (!GTK_WIDGET_VISIBLE (window)) {
- gboolean restore_size = TRUE;
-
- if (ev_metadata_manager_get (uri, "window_maximized", &maximized)) {
- if (g_value_get_boolean (&maximized)) {
- gtk_window_maximize (GTK_WINDOW (window));
- restore_size = FALSE;
- }
- }
-
- if (restore_size &&
- ev_metadata_manager_get (uri, "window_x", &x) &&
- ev_metadata_manager_get (uri, "window_y", &y) &&
- ev_metadata_manager_get (uri, "window_width", &width) &&
- ev_metadata_manager_get (uri, "window_height", &height)) {
- gtk_window_set_default_size (GTK_WINDOW (window),
- g_value_get_int (&width),
- g_value_get_int (&height));
- gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
- g_value_get_int (&y));
- }
- }
-
- /* Sizing mode */
- if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode)) {
- enum_value = g_enum_get_value_by_nick
- (EV_SIZING_MODE_CLASS, g_value_get_string (&sizing_mode));
- g_value_unset (&sizing_mode);
- ev_view_set_sizing_mode (view, enum_value->value);
- }
-
- /* Zoom */
- if (ev_metadata_manager_get (uri, "zoom", &zoom) &&
- ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
- ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
- }
-
- /* Continuous */
- if (ev_metadata_manager_get (uri, "continuous", &continuous)) {
- ev_view_set_continuous (view, g_value_get_boolean (&continuous));
- }
-
- /* Dual page */
- if (ev_metadata_manager_get (uri, "dual-page", &dual_page)) {
- ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
- }
-
- /* Presentation */
- if (ev_metadata_manager_get (uri, "presentation", &presentation)) {
- if (g_value_get_boolean (&presentation)) {
- ev_window_run_presentation (window);
- }
- }
-
- /* Fullscreen */
- if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen)) {
- if (g_value_get_boolean (&fullscreen)) {
- ev_window_run_fullscreen (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
- /* Rotation */
- if (ev_metadata_manager_get (uri, "rotation", &rotation)) {
- if (g_value_get_int (&rotation)) {
- switch (g_value_get_int (&rotation)) {
- case 90:
- ev_view_set_rotation (view, 90);
- break;
- case 180:
- ev_view_set_rotation (view, 180);
- break;
- case 270:
- ev_view_set_rotation (view, 270);
- break;
- default:
- break;
- }
- }
- }
+#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;
}
void
-ev_window_open_uri (EvWindow *ev_window, const char *uri)
+ev_window_open_uri (EvWindow *ev_window,
+ const char *uri,
+ EvLinkDest *dest,
+ EvWindowRunMode mode)
{
- if (ev_window->priv->password_dialog)
- gtk_widget_destroy (ev_window->priv->password_dialog);
-
- g_free (ev_window->priv->uri);
- ev_window->priv->uri = g_strdup (uri);
-
- setup_view_from_metadata (ev_window);
-
- ev_window_clear_jobs (ev_window);
+ ev_window_close_dialogs (ev_window);
+ ev_window_clear_xfer_job (ev_window);
ev_window_clear_local_uri (ev_window);
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
- ev_window->priv->xfer_job = ev_job_xfer_new (uri);
+ ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest, mode);
g_signal_connect (ev_window->priv->xfer_job,
"finished",
G_CALLBACK (ev_window_xfer_job_cb),
ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
}
+void
+ev_window_goto_dest (EvWindow *ev_window, EvLinkDest *dest)
+{
+ ev_view_goto_dest (EV_VIEW (ev_window->priv->view), dest);
+}
+
static void
file_open_dialog_response_cb (GtkWidget *chooser,
gint response_id,
g_slist_foreach (uris, (GFunc)g_free, NULL);
g_slist_free (uris);
}
+ ev_application_set_chooser_uri (EV_APP,
+ gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)));
gtk_widget_destroy (chooser);
}
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
NULL);
- ev_document_types_add_filters (chooser, NULL);
+ ev_document_factory_add_filters (chooser, NULL);
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
-
+ if (ev_application_get_chooser_uri (EV_APP) != NULL)
+ gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser),
+ ev_application_get_chooser_uri (EV_APP));
+
g_signal_connect (chooser, "response",
G_CALLBACK (file_open_dialog_response_cb),
window);
G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
}
-/* FIXME
-static gboolean
-overwrite_existing_file (GtkWindow *window, const gchar *file_name)
-{
- GtkWidget *msgbox;
- gchar *utf8_file_name;
- AtkObject *obj;
- gint ret;
-
- utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
- msgbox = gtk_message_dialog_new (
- window,
- (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("A file named \"%s\" already exists."),
- utf8_file_name);
- g_free (utf8_file_name);
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (msgbox),
- _("Do you want to replace it with the one you are saving?"));
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (msgbox),
- _("_Replace"), GTK_RESPONSE_YES);
-
- gtk_dialog_set_default_response (GTK_DIALOG (msgbox),
- GTK_RESPONSE_CANCEL);
-
- obj = gtk_widget_get_accessible (msgbox);
-
- if (GTK_IS_ACCESSIBLE (obj))
- atk_object_set_name (obj, _("Question"));
-
- ret = gtk_dialog_run (GTK_DIALOG (msgbox));
- gtk_widget_destroy (msgbox);
-
- return (ret == GTK_RESPONSE_YES);
-}
-*/
-
-static void
-save_error_dialog (GtkWindow *window, const gchar *file_name)
-{
- GtkWidget *error_dialog;
-
- error_dialog = gtk_message_dialog_new (
- window,
- (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("The file could not be saved as \"%s\"."),
- file_name);
-
- /* Easy way to make the text bold while keeping the string
- * above free from pango markup (FIXME ?) */
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (error_dialog), " ");
-
- gtk_dialog_run (GTK_DIALOG (error_dialog));
- gtk_widget_destroy (error_dialog);
-}
-
static void
file_save_dialog_response_cb (GtkWidget *fc,
gint response_id,
gboolean success;
if (response_id == GTK_RESPONSE_OK) {
- const char *uri;
+ gchar *uri;
+ GError *err = NULL;
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
ev_document_doc_mutex_lock ();
- success = ev_document_save (ev_window->priv->document, uri, NULL);
+ success = ev_document_save (ev_window->priv->document, uri, &err);
ev_document_doc_mutex_unlock ();
- if (!success) {
- save_error_dialog (GTK_WINDOW (fc), uri);
+ if (err) {
+ gchar *msg;
+ msg = g_strdup_printf (_("The file could not be saved as “%s”."), uri);
+ ev_window_error_dialog (GTK_WINDOW (fc), msg, err);
+ g_free (msg);
}
+
+ g_free (uri);
}
gtk_widget_destroy (fc);
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
- ev_document_types_add_filters (fc, ev_window->priv->document);
+ ev_document_factory_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
-
+
+ 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_current_name (GTK_FILE_CHOOSER (fc), base_name);
gtk_widget_show (fc);
}
-static gboolean
-using_pdf_printer (GnomePrintConfig *config)
+#ifdef WITH_GTK_PRINT
+static void
+ev_window_clear_print_job (EvWindow *window)
{
- const guchar *driver;
+ if (window->priv->print_job) {
+ if (!window->priv->print_job->finished)
+ ev_job_queue_remove_job (window->priv->print_job);
- driver = gnome_print_config_get (
- config, (const guchar *)"Settings.Engine.Backend.Driver");
-
- if (driver) {
- if (!strcmp ((const gchar *)driver, "gnome-print-pdf"))
- return TRUE;
- else
- return FALSE;
+ 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;
}
-
- return FALSE;
}
-static gboolean
-using_postscript_printer (GnomePrintConfig *config)
+static void
+ev_window_print_finished (GtkPrintJob *print_job,
+ EvWindow *window,
+ GError *error)
{
- const guchar *driver;
- const guchar *transport;
+ 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);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+}
- driver = gnome_print_config_get (
- config, (const guchar *)"Settings.Engine.Backend.Driver");
+static void
+ev_window_print_send (EvWindow *window,
+ const gchar *filename)
+{
+ GtkPrintJob *job;
+ GError *error = NULL;
+
+ if (window->priv->gtk_print_job)
+ g_object_unref (window->priv->gtk_print_job);
+
+ job = gtk_print_job_new ("evince-print",
+ window->priv->printer,
+ window->priv->print_settings,
+ window->priv->print_page_setup);
+
+ window->priv->gtk_print_job = job;
- transport = gnome_print_config_get (
- config, (const guchar *)"Settings.Transport.Backend");
+ 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);
+ }
+}
- if (driver) {
- if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
- return TRUE;
- else
- return FALSE;
- } else if (transport) { /* these transports default to PostScript */
- if (!strcmp ((const gchar *)transport, "CUPS"))
- return TRUE;
- else if (!strcmp ((const gchar *)transport, "LPD"))
- return TRUE;
+static void
+ev_window_print_job_cb (EvJobPrint *job,
+ EvWindow *window)
+{
+ if (job->error) {
+ g_warning (job->error->message);
+ ev_window_clear_print_job (window);
+ return;
}
- return FALSE;
+ g_assert (job->temp_file != NULL);
+
+ ev_window_print_send (window, job->temp_file);
}
-static GnomePrintConfig *
-load_print_config_from_file (void)
+static gboolean
+ev_window_print_dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ EvWindow *window)
{
- GnomePrintConfig *print_config = NULL;
- char *file_name, *contents = NULL;
+ EvBackend document_type;
+ gboolean export_to_ps = TRUE;
+ GtkPrintPages print_pages;
+
+ if (response != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ window->priv->print_dialog = NULL;
- file_name = g_build_filename (ev_dot_dir (), PRINT_CONFIG_FILENAME,
- NULL);
+ return FALSE;
+ }
+
+ 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)));
+
+ document_type = ev_document_factory_get_backend (window->priv->document);
+ print_pages = gtk_print_settings_get_print_pages (window->priv->print_settings);
+
+ if (print_pages == GTK_PRINT_PAGES_ALL) {
+ switch (document_type) {
+ case EV_BACKEND_PDF:
+ /* Export to ps when printing to file */
+ if (gtk_print_settings_has_key (window->priv->print_settings,
+ GTK_PRINT_SETTINGS_OUTPUT_URI)) {
+ export_to_ps = TRUE;
+ } else {
+ export_to_ps = !gtk_printer_accepts_pdf (window->priv->printer);
+ }
- if (g_file_get_contents (file_name, &contents, NULL, NULL)) {
- print_config = gnome_print_config_from_string (contents, 0);
- g_free (contents);
+ break;
+ case EV_BACKEND_PS:
+ export_to_ps = FALSE;
+ break;
+ default:
+ export_to_ps = TRUE;
+ break;
+ }
}
- if (print_config == NULL) {
- print_config = gnome_print_config_default ();
+ if ((export_to_ps || document_type == EV_BACKEND_PS) &&
+ !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);
+
+ return FALSE;
}
- g_free (file_name);
+ if (export_to_ps) {
+ EvPrintRange *ranges = NULL;
+ EvPageCache *page_cache;
+ gint n_ranges = 0;
+ gint current_page;
+ gint width;
+ gint height;
+
+ ev_window_clear_print_job (window);
+
+ current_page =
+ gtk_print_unix_dialog_get_current_page (GTK_PRINT_UNIX_DIALOG (dialog));
+
+ switch (print_pages) {
+ case GTK_PRINT_PAGES_CURRENT:
+ ranges = g_new0 (EvPrintRange, 1);
+
+ ranges->start = current_page;
+ ranges->end = current_page;
+ n_ranges = 1;
+
+ break;
+ case GTK_PRINT_PAGES_RANGES: {
+ GtkPageRange *page_range;
+
+ 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));
+ }
+ break;
+ default:
+ break;
+ }
+
+ page_cache = ev_page_cache_get (window->priv->document);
+ ev_page_cache_get_size (page_cache,
+ current_page,
+ 0, 1.0,
+ &width, &height);
+
+ window->priv->print_job =
+ ev_job_print_new (window->priv->document,
+ ranges, n_ranges,
+ (gdouble)width,
+ (gdouble)height);
+
+ 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);
+ } else {
+ gchar *filename;
+
+ filename = g_filename_from_uri (window->priv->uri, NULL, NULL);
+ ev_window_print_send (window, filename);
+ g_free (filename);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ window->priv->print_dialog = NULL;
- return print_config;
+ return TRUE;
}
-static void
-save_print_config_to_file (GnomePrintConfig *config)
+void
+ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
{
- char *file_name, *str;
+ GtkWidget *dialog;
+ EvPageCache *page_cache;
+ gint current_page;
+ gint document_last_page;
- g_return_if_fail (config != NULL);
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+ g_return_if_fail (ev_window->priv->document != NULL);
- str = gnome_print_config_to_string (config, 0);
- if (str == NULL) return;
+ if (ev_window->priv->print_dialog) {
+ gtk_window_present (GTK_WINDOW (ev_window->priv->print_dialog));
+ return;
+ }
+
+ 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);
- file_name = g_build_filename (ev_dot_dir (),
- PRINT_CONFIG_FILENAME,
- NULL);
+ if (!ev_window->priv->print_settings)
+ ev_window->priv->print_settings = gtk_print_settings_new ();
-#ifdef HAVE_G_FILE_SET_CONTENTS
- g_file_set_contents (file_name, str, -1, NULL);
-#else
- ev_file_set_contents (file_name, str, -1, NULL);
-#endif
+ if (first_page != 1 || last_page != document_last_page) {
+ GtkPageRange range;
- g_free (file_name);
- g_free (str);
+ /* Ranges in GtkPrint are 0 - N */
+ range.start = first_page - 1;
+ range.end = last_page - 1;
+
+ gtk_print_settings_set_print_pages (ev_window->priv->print_settings,
+ GTK_PRINT_PAGES_RANGES);
+ gtk_print_settings_set_page_ranges (ev_window->priv->print_settings,
+ &range, 1);
+ }
+
+ dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
+ ev_window->priv->print_dialog = dialog;
+ gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
+ GTK_PRINT_CAPABILITY_PAGE_SET |
+ GTK_PRINT_CAPABILITY_COPIES |
+ GTK_PRINT_CAPABILITY_COLLATE |
+ GTK_PRINT_CAPABILITY_REVERSE |
+ GTK_PRINT_CAPABILITY_SCALE |
+ GTK_PRINT_CAPABILITY_GENERATE_PS);
+ 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);
+
+ 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 */
-static void
-ev_window_print (EvWindow *window)
+#ifdef WITH_GNOME_PRINT
+static gboolean
+ev_window_print_dialog_response_cb (GtkDialog *print_dialog,
+ gint response,
+ EvWindow *ev_window)
{
- EvPageCache *page_cache;
- int last_page;
+ 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);
+ }
- page_cache = ev_page_cache_get (window->priv->document);
- last_page = ev_page_cache_get_n_pages (page_cache);
+ g_object_unref (config);
- ev_window_print_range (window, 1, -1);
-}
+ 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;
-const char *
-ev_window_get_uri (EvWindow *ev_window)
-{
- return ev_window->priv->uri;
+ return FALSE;
}
void
ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
{
GnomePrintConfig *config;
- GnomePrintJob *job;
- GtkWidget *print_dialog;
gchar *pages_label;
- EvPrintJob *print_job = NULL;
- EvPageCache *page_cache;
g_return_if_fail (EV_IS_WINDOW (ev_window));
g_return_if_fail (ev_window->priv->document != NULL);
- page_cache = ev_page_cache_get (ev_window->priv->document);
- if (last_page == -1) {
- last_page = ev_page_cache_get_n_pages (page_cache);
- }
-
config = load_print_config_from_file ();
- job = gnome_print_job_new (config);
- print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
- (GNOME_PRINT_DIALOG_RANGE |
- GNOME_PRINT_DIALOG_COPIES));
+ 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 (print_dialog),
+ 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 (print_dialog),
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (ev_window->priv->print_dialog),
GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
FALSE);
- while (TRUE) {
- int response;
- response = gtk_dialog_run (GTK_DIALOG (print_dialog));
-
- if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
- break;
-
- /* 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);
-
- continue;
- } 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);
-
- continue;
- }
-
- save_print_config_to_file (config);
-
- print_job = g_object_new (EV_TYPE_PRINT_JOB,
- "gnome_print_job", job,
- "document", ev_window->priv->document,
- "print_dialog", print_dialog,
- NULL);
- break;
- }
-
- g_object_unref (job);
+ 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);
+}
+#endif /* WITH_GNOME_PRINT */
- gtk_widget_destroy (print_dialog);
+static void
+ev_window_print (EvWindow *window)
+{
+ EvPageCache *page_cache;
+ gint last_page;
- if (print_job != NULL) {
- ev_print_job_print (print_job, GTK_WINDOW (ev_window));
- g_object_unref (print_job);
- }
+ page_cache = ev_page_cache_get (window->priv->document);
+ last_page = ev_page_cache_get_n_pages (page_cache);
- g_object_unref (config);
+#ifdef WITH_PRINT
+ ev_window_print_range (window, 1, last_page);
+#endif
}
static void
}
static void
-find_not_supported_dialog (EvWindow *ev_window)
+ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
{
- GtkWidget *dialog;
+ GtkAction *action;
+
+ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
+ ev_window_set_action_sensitive (window, "ViewToolbar", FALSE);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ PAGE_SELECTOR_ACTION);
+ ev_page_action_grab_focus (EV_PAGE_ACTION (action));
+}
- /* If you change this so it isn't modal, be sure you don't
- * allow multiple copies of the dialog...
- */
+static void
+ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
+}
- dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("The \"Find\" feature will not work with this document"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Searching for text is only supported for PDF documents."));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+static void
+ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
+}
+
+static void
+ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean continuous;
+
+ ev_window_stop_presentation (ev_window);
+ continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "continuous", continuous,
+ NULL);
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean dual_page;
+
+ ev_window_stop_presentation (ev_window);
+ dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "dual-page", dual_page,
+ NULL);
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ 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);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ 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);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ ev_window_update_actions (ev_window);
}
+
static void
ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
{
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
- if (ev_window->priv->document == NULL) {
- g_printerr ("We should have set the Find menu item insensitive since there's no document\n");
- } else if (!EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- find_not_supported_dialog (ev_window);
- } else {
- update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
+ if (ev_window->priv->document == NULL || !EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
+ g_error ("Find action should be insensitive since document doesn't support find");
+ return;
+ }
- gtk_widget_grab_focus (ev_window->priv->find_bar);
- }
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
+ gtk_widget_grab_focus (ev_window->priv->find_bar);
}
static void
ev_view_find_next (EV_VIEW (ev_window->priv->view));
}
+static void
+ev_window_cmd_edit_find_previous (GtkAction *action, EvWindow *ev_window)
+{
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
if (GTK_WIDGET (window)->window == NULL)
return;
- toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
+ toolbar = (window->priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
(window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0;
popup_width = popup->requisition.width;
popup_height = popup->requisition.height;
ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
EvWindow *ev_window)
{
- if (ev_window->priv->uri) {
+ if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_int (ev_window->priv->uri, "sidebar_size",
gtk_paned_get_position (GTK_PANED (object)));
- }
}
static void
fullscreen_timeout_cb (gpointer data)
{
EvWindow *window = EV_WINDOW (data);
-
- g_object_set (window->priv->fullscreen_popup, "visible", FALSE, NULL);
+
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
ev_view_hide_cursor (EV_VIEW (window->priv->view));
- g_source_unref (window->priv->fullscreen_timeout_source);
- window->priv->fullscreen_timeout_source = NULL;
+ window->priv->fullscreen_timeout_id = 0;
return FALSE;
}
static void
fullscreen_set_timeout (EvWindow *window)
{
- GSource *source;
-
- if (window->priv->fullscreen_timeout_source != NULL) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
+ if (window->priv->fullscreen_timeout_id != 0) {
+ g_source_remove (window->priv->fullscreen_timeout_id);
}
+
+ window->priv->fullscreen_timeout_id =
+ g_timeout_add (FULLSCREEN_TIMEOUT, fullscreen_timeout_cb, window);
- source = g_timeout_source_new (FULLSCREEN_TIMEOUT);
- g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
- g_source_attach (source, NULL);
- window->priv->fullscreen_timeout_source = source;
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, TRUE);
+ update_chrome_visibility (window);
+ ev_view_show_cursor (EV_VIEW (window->priv->view));
}
static void
fullscreen_clear_timeout (EvWindow *window)
{
- if (window->priv->fullscreen_timeout_source != NULL) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
+ if (window->priv->fullscreen_timeout_id != 0) {
+ g_source_remove (window->priv->fullscreen_timeout_id);
}
-
- window->priv->fullscreen_timeout_source = NULL;
+
+ window->priv->fullscreen_timeout_id = 0;
+ update_chrome_visibility (window);
ev_view_show_cursor (EV_VIEW (window->priv->view));
}
-static void
-show_fullscreen_popup (EvWindow *window)
-{
- if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
- g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
- ev_view_show_cursor (EV_VIEW (window->priv->view));
- }
-
- fullscreen_set_timeout (window);
-}
-
static gboolean
fullscreen_motion_notify_cb (GtkWidget *widget,
GdkEventMotion *event,
{
EvWindow *window = EV_WINDOW (user_data);
- show_fullscreen_popup (window);
+ fullscreen_set_timeout (window);
return FALSE;
}
GdkScreen *screen;
window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model
- (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
+ (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
popup = gtk_window_new (GTK_WINDOW_POPUP);
hbox = gtk_hbox_new (FALSE, 0);
static void
ev_window_run_fullscreen (EvWindow *window)
{
- ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
if (window->priv->fullscreen_popup == NULL)
window->priv->fullscreen_popup
= ev_window_create_fullscreen_popup (window);
- update_chrome_visibility (window);
- gtk_widget_hide (window->priv->sidebar);
-
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_window_update_fullscreen_action (window);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ gtk_widget_grab_focus (window->priv->view);
+ ev_window_update_fullscreen_popup (window);
+
g_signal_connect (window->priv->view,
"motion-notify-event",
G_CALLBACK (fullscreen_motion_notify_cb),
window);
fullscreen_set_timeout (window);
- gtk_widget_grab_focus (window->priv->view);
- ev_window_update_fullscreen_action (window);
- gtk_window_fullscreen (GTK_WINDOW (window));
- ev_window_update_fullscreen_popup (window);
-
- if (window->priv->uri) {
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
- }
}
static void
if (!ev_view_get_fullscreen (EV_VIEW (view)))
return;
- ev_view_set_fullscreen (view, FALSE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
- fullscreen_clear_timeout (window);
+ ev_view_set_fullscreen (view, FALSE);
+ ev_window_update_fullscreen_action (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
- g_signal_handlers_disconnect_by_func (view,
+ g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) fullscreen_motion_notify_cb,
window);
- g_signal_handlers_disconnect_by_func (view,
+ g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) fullscreen_leave_notify_cb,
window);
- ev_window_update_fullscreen_action (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
- update_chrome_visibility (window);
- update_sidebar_visibility (window);
+ fullscreen_clear_timeout (window);
- if (window->priv->uri) {
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
- }
}
static void
"shadow-type", GTK_SHADOW_NONE,
NULL);
- gtk_widget_grab_focus (window->priv->view);
ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
- gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
- update_chrome_visibility (window);
- gtk_widget_hide (window->priv->sidebar);
- if (window->priv->uri) {
+ gtk_widget_grab_focus (window->priv->view);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+
+ g_signal_connect (window->priv->view,
+ "motion-notify-event",
+ G_CALLBACK (fullscreen_motion_notify_cb),
+ window);
+ g_signal_connect (window->priv->view,
+ "leave-notify-event",
+ G_CALLBACK (fullscreen_leave_notify_cb),
+ window);
+ fullscreen_set_timeout (window);
+
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
- }
}
static void
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
+
ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
- gtk_window_unfullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
- update_chrome_visibility (window);
- update_sidebar_visibility (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
+
+ g_signal_handlers_disconnect_by_func (window->priv->view,
+ (gpointer) fullscreen_motion_notify_cb,
+ window);
+ g_signal_handlers_disconnect_by_func (window->priv->view,
+ (gpointer) fullscreen_leave_notify_cb,
+ window);
+ fullscreen_clear_timeout (window);
- if (window->priv->uri) {
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
- }
}
static void
}
}
+static void
+ev_window_run_preview (EvWindow *window)
+{
+ EggToolbarsModel *model;
+ EggTbModelFlags flags;
+
+ model = egg_toolbars_model_new ();
+
+ egg_toolbars_model_load_toolbars (model,
+ DATADIR"/evince-toolbar.xml");
+
+ flags = egg_toolbars_model_get_flags (model, 1);
+ egg_toolbars_model_set_flags (model, 1, flags &= ~(EGG_TB_MODEL_HIDDEN));
+
+ egg_editable_toolbar_set_model (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ model);
+
+ egg_editable_toolbar_hide (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "DefaultToolBar");
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "PreviewToolBar");
+
+ ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
+
+ update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
+ update_chrome_visibility (window);
+}
+
static gboolean
ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
- gboolean fullscreen;
-
- g_object_get (priv->view,
- "fullscreen", &fullscreen,
- NULL);
- if (fullscreen)
- show_fullscreen_popup (window);
+ if (ev_view_get_fullscreen (EV_VIEW (priv->view)))
+ fullscreen_set_timeout (window);
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
}
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
- gboolean fullscreen;
- g_object_get (priv->view,
- "fullscreen", &fullscreen,
- NULL);
-
- if (fullscreen)
+ if (ev_view_get_fullscreen (EV_VIEW (priv->view))) {
+ fullscreen_set_timeout (window);
gtk_widget_hide (priv->fullscreen_popup);
+ }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
}
window->priv->page_mode = page_mode;
switch (page_mode) {
- case PAGE_MODE_DOCUMENT:
- child = window->priv->view;
- break;
- case PAGE_MODE_PASSWORD:
- child = window->priv->password_view;
- break;
- default:
- g_assert_not_reached ();
+ case PAGE_MODE_DOCUMENT:
+ child = window->priv->view;
+ break;
+ case PAGE_MODE_PASSWORD:
+ child = window->priv->password_view;
+ break;
+ default:
+ g_assert_not_reached ();
}
real_child = gtk_bin_get_child (GTK_BIN (window->priv->scrolled_window));
gtk_container_add (GTK_CONTAINER (window->priv->scrolled_window),
child);
}
- update_action_sensitivity (window);
+ ev_window_update_actions (window);
}
-static void
-ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
-{
- EvWindow *ev_window = EV_WINDOW (data);
- egg_editable_toolbar_set_edit_mode
- (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
- ev_application_save_toolbars_model (EV_APP);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
static void
ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
}
+static void
+ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
+{
+ EvWindow *ev_window = EV_WINDOW (data);
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
+ ev_application_save_toolbars_model (EV_APP);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
static void
ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
{
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
- egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
- DATADIR "/evince-toolbar.xml");
egg_editable_toolbar_set_edit_mode
(EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
{
char *uri;
- int page;
g_return_if_fail (EV_IS_WINDOW (ev_window));
- page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri);
-
- /* In case the number of pages in the document has changed. */
- page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache));
-
- ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ ev_window_open_uri (ev_window, uri, NULL, 0);
g_free (uri);
}
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, NULL, FALSE);
+ update_chrome_flag (window, EV_CHROME_FINDBAR, FALSE);
gtk_widget_grab_focus (window->priv->view);
} else {
gboolean fullscreen;
EvSizingMode mode;
GEnumValue *enum_value;
- if (window->priv->uri) {
- mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
- enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
+ mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
+ enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
enum_value->value_nick);
- }
}
static void
update_view_size (NULL, ev_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 (update_view_size),
- ev_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 (update_view_size),
- ev_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;
+ 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 (update_view_size),
+ ev_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 (update_view_size),
+ ev_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;
}
update_sizing_buttons (ev_window);
static void
ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
{
- update_action_sensitivity (ev_window);
+ ev_window_update_actions (ev_window);
- if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+ if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE && !ev_window_is_empty (ev_window)) {
ev_metadata_manager_set_double (ev_window->priv->uri, "zoom",
ev_view_get_zoom (view));
}
{
ev_window_update_continuous_action (ev_window);
- if (ev_window->priv->uri) {
+ if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_boolean (ev_window->priv->uri, "continuous",
ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
- }
}
static void
rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
- if (window->priv->uri) {
+ if (!ev_window_is_empty (window))
ev_metadata_manager_set_int (window->priv->uri, "rotation",
rotation);
- }
ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
rotation);
}
+static void
+ev_window_has_selection_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
+{
+ ev_window_update_actions (window);
+}
+
static void
ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
{
ev_window_update_dual_page_action (ev_window);
- if (ev_window->priv->uri) {
+ if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_boolean (ev_window->priv->uri, "dual-page",
ev_view_get_dual_page (EV_VIEW (ev_window->priv->view)));
- }
}
static char *
"Marco Pesenti Gritti <marco@gnome.org>",
"Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
"Bryan Clark <clarkbw@gnome.org>",
+ "Carlos Garcia Campos <carlosgc@gnome.org>",
NULL
};
};
const char *license[] = {
- N_("Evince is free software; you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as published by\n"
- "the Free Software Foundation; either version 2 of the License, or\n"
+ N_("Evince is free software; you can redistribute it and/or modify "
+ "it under the terms of the GNU General Public License as published by "
+ "the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n"),
- N_("Evince is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ N_("Evince is distributed in the hope that it will be useful, "
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n"),
- N_("You should have received a copy of the GNU General Public License\n"
- "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
+ N_("You should have received a copy of the GNU General Public License "
+ "along with Evince; if not, write to the Free Software Foundation, Inc., "
"59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
};
"authors", authors,
"documenters", documenters,
"translator-credits", _("translator-credits"),
+ "logo-icon-name", "evince",
+ "wrap-license", TRUE,
NULL);
g_free (comments);
static void
ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_TOOLBAR,
- GCONF_CHROME_TOOLBAR,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ gboolean active;
+
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ update_chrome_flag (ev_window, EV_CHROME_TOOLBAR, active);
+ ev_metadata_manager_set_boolean (NULL, "show_toolbar", active);
}
static void
ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
- set_widget_visibility (ev_window->priv->sidebar,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
+ gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
static void
id = LINKS_SIDEBAR_ID;
} else if (current_page == ev_window->priv->sidebar_thumbs) {
id = THUMBNAILS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_attachments) {
+ id = ATTACHMENTS_SIDEBAR_ID;
} else {
g_assert_not_reached();
}
g_object_unref (current_page);
- if (ev_window->priv->uri) {
+ if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_string (ev_window->priv->uri, "sidebar_page", id);
- }
}
static void
-ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
+ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
+ GParamSpec *pspec,
EvWindow *ev_window)
{
EvView *view = EV_VIEW (ev_window->priv->view);
GtkAction *action;
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
-
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
GTK_WIDGET_VISIBLE (ev_sidebar));
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
- if (!ev_view_get_presentation (view) && !ev_view_get_fullscreen (view)) {
+ if (!ev_view_get_presentation (view) &&
+ !ev_view_get_fullscreen (view)) {
ev_metadata_manager_set_boolean (ev_window->priv->uri, "sidebar_visibility",
GTK_WIDGET_VISIBLE (ev_sidebar));
}
}
+static gboolean
+view_menu_popup_cb (EvView *view,
+ EvLink *link,
+ EvWindow *ev_window)
+{
+ GtkWidget *popup;
+ gboolean show_external = FALSE;
+ gboolean show_internal = FALSE;
+ GtkAction *action;
+
+ if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
+ return FALSE;
+
+ if (ev_window->priv->link)
+ g_object_unref (ev_window->priv->link);
+
+ if (link)
+ ev_window->priv->link = g_object_ref (link);
+ else
+ ev_window->priv->link = NULL;
+
+ popup = ev_window->priv->view_popup;
+
+ if (ev_window->priv->link) {
+ EvLinkAction *ev_action;
+
+ ev_action = ev_link_get_action (link);
+ if (!ev_action)
+ return FALSE;
+
+ switch (ev_link_action_get_action_type (ev_action)) {
+ case EV_LINK_ACTION_TYPE_GOTO_DEST:
+ case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
+ show_internal = TRUE;
+ break;
+ case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+ case EV_LINK_ACTION_TYPE_LAUNCH:
+ show_external = TRUE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
+ "OpenLink");
+ gtk_action_set_visible (action, show_external);
+
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
+ "CopyLinkAddress");
+ gtk_action_set_visible (action, show_external);
+
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
+ "GoLink");
+ gtk_action_set_visible (action, show_internal);
+
+ gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
+ NULL, NULL,
+ 3, gtk_get_current_event_time ());
+ return TRUE;
+}
+
+static gboolean
+attachment_bar_menu_popup_cb (EvSidebarAttachments *attachbar,
+ GList *attach_list,
+ EvWindow *ev_window)
+{
+ GtkWidget *popup;
+
+ g_assert (attach_list != NULL);
+
+ if (ev_window->priv->attach_list) {
+ g_list_foreach (ev_window->priv->attach_list,
+ (GFunc) g_object_unref, NULL);
+ g_list_free (ev_window->priv->attach_list);
+ }
+
+ ev_window->priv->attach_list = attach_list;
+
+ popup = ev_window->priv->attachment_popup;
+
+ gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
+ NULL, NULL,
+ 3, gtk_get_current_event_time ());
+
+ return TRUE;
+}
+
static void
view_find_status_changed_cb (EvView *view,
GParamSpec *pspec,
find_bar_close_cb (EggFindBar *find_bar,
EvWindow *ev_window)
{
- update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, FALSE);
+ update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
}
static void
visible = GTK_WIDGET_VISIBLE (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
-#if 0
- g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)");
-#endif
+ ev_view_search_changed (EV_VIEW(ev_window->priv->view));
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
ev_document_doc_mutex_unlock ();
- update_action_sensitivity (ev_window);
+ 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_scroll(EggFindBar *find_bar, GtkScrollType scroll, EvWindow* ev_window)
+{
+ ev_view_scroll(EV_VIEW(ev_window->priv->view), scroll, FALSE);
+}
+
static void
zoom_control_changed_cb (EphyZoomAction *action,
float zoom,
g_list_free (windows);
}
- g_list_free (windows);
G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
}
priv->action_group = NULL;
}
+ if (priv->view_popup_action_group) {
+ g_object_unref (priv->view_popup_action_group);
+ priv->view_popup_action_group = NULL;
+ }
+
+ if (priv->attachment_popup_action_group) {
+ g_object_unref (priv->attachment_popup_action_group);
+ priv->attachment_popup_action_group = NULL;
+ }
+
if (priv->page_cache) {
g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
priv->page_cache = NULL;
priv->view = NULL;
}
- if (priv->page_view) {
- g_object_unref (priv->page_view);
- priv->page_view = NULL;
- }
-
- if (priv->load_job || priv->xfer_job) {
- ev_window_clear_jobs (window);
+ if (priv->xfer_job) {
+ ev_window_clear_xfer_job (window);
}
if (priv->local_uri) {
ev_window_clear_local_uri (window);
}
+
+ ev_window_close_dialogs (window);
+
+#ifdef WITH_GTK_PRINT
+ ev_window_clear_print_job (window);
- if (priv->password_document) {
- g_object_unref (priv->password_document);
- priv->password_document = NULL;
+ if (window->priv->gtk_print_job) {
+ g_object_unref (window->priv->gtk_print_job);
+ window->priv->gtk_print_job = NULL;
}
- if (priv->password_uri) {
- g_free (priv->password_uri);
- priv->password_uri = NULL;
+ if (window->priv->printer) {
+ g_object_unref (window->priv->printer);
+ window->priv->printer = NULL;
}
- if (priv->password_dialog) {
- gtk_widget_destroy (priv->password_dialog);
+ if (window->priv->print_settings) {
+ g_object_unref (window->priv->print_settings);
+ window->priv->print_settings = NULL;
+ }
+
+ if (window->priv->print_page_setup) {
+ g_object_unref (window->priv->print_page_setup);
+ window->priv->print_page_setup = NULL;
+ }
+#endif
+
+ if (priv->link) {
+ g_object_unref (priv->link);
+ priv->link = NULL;
+ }
+
+ if (priv->attach_list) {
+ g_list_foreach (priv->attach_list,
+ (GFunc) g_object_unref,
+ NULL);
+ g_list_free (priv->attach_list);
+ priv->attach_list = NULL;
}
if (priv->find_bar) {
priv->uri = NULL;
}
- if (window->priv->fullscreen_timeout_source) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
- window->priv->fullscreen_timeout_source = NULL;
+ if (priv->dest) {
+ g_object_unref (priv->dest);
+ priv->dest = NULL;
+ }
+
+ if (priv->fullscreen_timeout_id) {
+ g_source_remove (priv->fullscreen_timeout_id);
+ priv->fullscreen_timeout_id = 0;
}
destroy_fullscreen_popup (window);
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
- { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL, NULL,
+ { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
+ N_("Save a copy of the current document"),
G_CALLBACK (ev_window_cmd_save_as) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
N_("Print this document"),
G_CALLBACK (ev_window_cmd_edit_copy) },
{ "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
G_CALLBACK (ev_window_cmd_edit_select_all) },
- { "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
+ { "EditFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F",
N_("Find a word or phrase in the document"),
G_CALLBACK (ev_window_cmd_edit_find) },
{ "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL,
G_CALLBACK (ev_window_cmd_edit_find_next) },
+ { "EditFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
+ G_CALLBACK (ev_window_cmd_edit_find_previous) },
{ "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_toolbar) },
{ "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL,
G_CALLBACK (ev_window_cmd_scroll_backward) },
{ "ShiftBackSpace", NULL, "", "<shift>BackSpace", NULL,
G_CALLBACK (ev_window_cmd_scroll_forward) },
+ { "Return", NULL, "", "Return", NULL,
+ G_CALLBACK (ev_window_cmd_scroll_forward) },
+ { "ShiftReturn", NULL, "", "<shift>Return", NULL,
+ G_CALLBACK (ev_window_cmd_scroll_backward) },
{ "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_in) },
{ "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_in) },
+ { "Equal", GTK_STOCK_ZOOM_IN, NULL, "equal", NULL,
+ G_CALLBACK (ev_window_cmd_view_zoom_in) },
{ "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
{ "FocusPageSelector", NULL, "", "<control>l", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_in) },
{ "KpMinus", GTK_STOCK_ZOOM_OUT, NULL, "KP_Subtract", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
+ { "CtrlKpPlus", GTK_STOCK_ZOOM_IN, NULL, "<control>KP_Add", NULL,
+ 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) },
};
/* Toggle items */
{ "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
N_("Show or hide the toolbar"),
G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
- { "ViewSidebar", NULL, N_("Side _Pane"), "F9",
+ { "ViewSidebar", GTK_STOCK_INDEX, N_("Side _Pane"), "F9",
N_("Show or hide the side pane"),
G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
{ "ViewContinuous", EV_STOCK_VIEW_CONTINUOUS, N_("_Continuous"), NULL,
G_CALLBACK (ev_window_cmd_view_page_width) },
};
+/* Popups specific items */
+static const GtkActionEntry view_popup_entries [] = {
+ /* Links */
+ { "OpenLink", GTK_STOCK_OPEN, N_("_Open Link"), NULL,
+ NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
+ { "GoLink", GTK_STOCK_GO_FORWARD, N_("_Go To"), NULL,
+ NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
+ { "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
+ NULL,
+ G_CALLBACK (ev_view_popup_cmd_copy_link_address) },
+};
+
+static const GtkActionEntry attachment_popup_entries [] = {
+ { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open..."), NULL,
+ NULL, G_CALLBACK (ev_attachment_popup_cmd_open_attachment) },
+ { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
+ NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
+};
+
static void
drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, GtkSelectionData *selection_data,
ev_application_open_uri_list (EV_APP, uris, 0);
g_slist_free (uris);
-
- gtk_drag_finish (context, TRUE, FALSE, time);
}
}
static void
activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
{
- g_return_if_fail (EV_IS_WINDOW (window));
-
- ev_view_goto_link (EV_VIEW (window->priv->view), link);
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
gtk_widget_grab_focus (window->priv->view);
}
(action, G_CALLBACK (ev_window_view_toolbar_cb), window);
}
-static EvChrome
-load_chrome (void)
-{
- EvChrome chrome = EV_CHROME_NORMAL;
- GConfClient *client;
- GConfValue *value;
-
- client = gconf_client_get_default ();
-
- value = gconf_client_get (client, GCONF_CHROME_TOOLBAR, NULL);
- if (value != NULL) {
- if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
- chrome &= ~EV_CHROME_TOOLBAR;
- }
- gconf_value_free (value);
- }
-
- g_object_unref (client);
-
- return chrome;
-}
-
static void
sidebar_widget_model_set (EvSidebarLinks *ev_sidebar_links,
GParamSpec *pspec,
g_object_unref (model);
}
-
-static void
-ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive)
-{
- if (window->priv->action_group) {
- set_action_sensitive (window, "PageDown", sensitive);
- set_action_sensitive (window, "PageUp", sensitive);
- set_action_sensitive (window, "Space", sensitive);
- set_action_sensitive (window, "ShiftSpace", sensitive);
- set_action_sensitive (window, "BackSpace", sensitive);
- set_action_sensitive (window, "ShiftBackSpace", sensitive);
- set_action_sensitive (window, "Slash", sensitive);
- set_action_sensitive (window, "Plus", sensitive);
- set_action_sensitive (window, "Minus", sensitive);
- set_action_sensitive (window, "KpPlus", sensitive);
- set_action_sensitive (window, "KpMinus", sensitive);
- }
-}
-
static gboolean
view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
{
- update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, NULL, FALSE);
- set_action_sensitive (window, "ViewToolbar", TRUE);
+ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE);
+ ev_window_set_action_sensitive (window, "ViewToolbar", TRUE);
ev_window_set_view_accels_sensitivity (window, TRUE);
static gboolean
window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
{
- char *uri = window->priv->uri;
-
- if (uri && !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
+ if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
gboolean maximized;
maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
- ev_metadata_manager_set_boolean (uri, "window_maximized", maximized);
+ if (!ev_window_is_empty (window))
+ ev_metadata_manager_set_boolean (window->priv->uri, "window_maximized", maximized);
}
return FALSE;
state = gdk_window_get_state (GTK_WIDGET (window)->window);
- if (uri && !(state & GDK_WINDOW_STATE_FULLSCREEN)) {
+ if (!(state & GDK_WINDOW_STATE_FULLSCREEN)) {
gtk_window_get_position (GTK_WINDOW (window), &x, &y);
gtk_window_get_size (GTK_WINDOW (window), &width, &height);
- ev_metadata_manager_set_int (uri, "window_x", x);
- ev_metadata_manager_set_int (uri, "window_y", y);
- ev_metadata_manager_set_int (uri, "window_width", width);
- ev_metadata_manager_set_int (uri, "window_height", height);
+ if (!ev_window_is_empty (window)) {
+ ev_metadata_manager_set_int (uri, "window_x", x);
+ ev_metadata_manager_set_int (uri, "window_y", y);
+ ev_metadata_manager_set_int (uri, "window_width", width);
+ ev_metadata_manager_set_int (uri, "window_height", height);
+ }
}
return FALSE;
static void
sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
{
- ev_view_goto_link (EV_VIEW (window->priv->view), link);
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
+}
+
+static void
+launch_action (EvWindow *window, EvLinkAction *action)
+{
+ const char *filename = ev_link_action_get_filename (action);
+ char *uri = NULL;
+
+ if (filename && g_path_is_absolute (filename)) {
+ uri = gnome_vfs_get_uri_from_local_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);
+ }
+ }
+
+ if (uri) {
+ gnome_vfs_url_show (uri);
+ } else {
+ gnome_vfs_url_show (filename);
+ }
+
+ g_free (uri);
+
+ /* According to the PDF spec filename can be an executable. I'm not sure
+ allowing to launch executables is a good idea though. -- marco */
+}
+
+static void
+launch_external_uri (EvWindow *window, EvLinkAction *action)
+{
+ const char *uri;
+ char *escaped;
+
+ uri = ev_link_action_get_uri (action);
+ escaped = gnome_vfs_escape_host_and_path_string (uri);
+
+ gnome_vfs_url_show (escaped);
+ g_free (escaped);
+}
+
+static void
+open_remote_link (EvWindow *window, EvLinkAction *action)
+{
+ gchar *uri;
+ gchar *dir;
+
+ dir = g_path_get_dirname (window->priv->uri);
+
+ uri = g_build_filename (dir, ev_link_action_get_filename (action),
+ NULL);
+ g_free (dir);
+
+ ev_application_open_uri_at_dest (EV_APP, uri,
+ ev_link_action_get_dest (action),
+ 0,
+ GDK_CURRENT_TIME);
+
+ g_free (uri);
+}
+
+static void
+do_action_named (EvWindow *window, EvLinkAction *action)
+{
+ const gchar *name = ev_link_action_get_name (action);
+
+ if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
+ ev_window_cmd_go_first_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
+ ev_window_cmd_go_previous_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
+ ev_window_cmd_go_next_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
+ ev_window_cmd_go_last_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
+ ev_window_cmd_focus_page_selector (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "Find") == 0) {
+ ev_window_cmd_edit_find (NULL, window);
+ } else {
+ g_warning ("Unimplemented named action: %s, please post a "
+ "bug report in Evince bugzilla "
+ "(http://bugzilla.gnome.org) with a testcase.",
+ name);
+ }
+}
+
+static void
+view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
+{
+ switch (ev_link_action_get_action_type (action)) {
+ case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+ launch_external_uri (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_LAUNCH:
+ launch_action (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
+ open_remote_link (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_NAMED:
+ do_action_named (window, action);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+ev_view_popup_cmd_open_link (GtkAction *action, EvWindow *window)
+{
+ ev_view_handle_link (EV_VIEW (window->priv->view), window->priv->link);
+}
+
+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);
+}
+
+static void
+ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
+{
+ GList *l;
+
+ if (!window->priv->attach_list)
+ return;
+
+ 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);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (window),
+ _("Unable to open attachment"),
+ error);
+ g_error_free (error);
+ }
+ }
+}
+
+static void
+attachment_save_dialog_response_cb (GtkWidget *fc,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ gchar *uri;
+ GList *l;
+ GtkFileChooserAction fc_action;
+ gboolean is_dir;
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (fc);
+ return;
+ }
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+
+ g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
+ is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
+ EvAttachment *attachment;
+ gchar *filename;
+ GError *error = NULL;
+
+ attachment = (EvAttachment *) l->data;
+
+ if (is_dir) {
+ filename = g_strjoin ("/", uri,
+ ev_attachment_get_name (attachment),
+ NULL);
+ } else {
+ filename = g_strdup (uri);
+ }
+
+ ev_attachment_save (attachment, filename, &error);
+ g_free (filename);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (fc),
+ _("The attachment could not be saved."),
+ error);
+ g_error_free (error);
+ }
+ }
+
+ g_free (uri);
+
+ gtk_widget_destroy (fc);
+}
+
+static void
+ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, EvWindow *window)
+{
+ GtkWidget *fc;
+ EvAttachment *attachment = NULL;
+
+ if (!window->priv->attach_list)
+ return;
+
+ if (g_list_length (window->priv->attach_list) == 1)
+ attachment = (EvAttachment *) window->priv->attach_list->data;
+
+ fc = gtk_file_chooser_dialog_new (
+ _("Save a Copy"),
+ GTK_WINDOW (window),
+ attachment ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
+
+ if (attachment)
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc),
+ ev_attachment_get_name (attachment));
+
+ g_signal_connect (fc, "response",
+ G_CALLBACK (attachment_save_dialog_response_cb),
+ window);
+
+ gtk_widget_show (fc);
}
static void
ev_window_set_view_accels_sensitivity (ev_window, FALSE);
+ action_group = gtk_action_group_new ("ViewPopupActions");
+ ev_window->priv->view_popup_action_group = action_group;
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, view_popup_entries,
+ G_N_ELEMENTS (view_popup_entries),
+ ev_window);
+ gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+ action_group, 0);
+
+ action_group = gtk_action_group_new ("AttachmentPopupActions");
+ ev_window->priv->attachment_popup_action_group = action_group;
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, attachment_popup_entries,
+ G_N_ELEMENTS (attachment_popup_entries),
+ ev_window);
+ gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+ action_group, 0);
+
if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
DATADIR"/evince-ui.xml",
&error)) {
gtk_widget_show (toolbar_dock);
ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
- (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
+ (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
"DefaultToolBar");
gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
gtk_widget_show (ev_window->priv->sidebar);
/* Stub sidebar, for now */
+
sidebar_widget = ev_sidebar_links_new ();
ev_window->priv->sidebar_links = sidebar_widget;
g_signal_connect (sidebar_widget,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+ sidebar_widget = ev_sidebar_attachments_new ();
+ ev_window->priv->sidebar_attachments = sidebar_widget;
+ g_signal_connect_object (sidebar_widget,
+ "popup",
+ G_CALLBACK (attachment_bar_menu_popup_cb),
+ ev_window, 0);
+ gtk_widget_show (sidebar_widget);
+ ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+ sidebar_widget);
+
sidebar_widget = ev_sidebar_thumbnails_new ();
ev_window->priv->sidebar_thumbs = sidebar_widget;
g_signal_connect (sidebar_widget,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
-
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"shadow-type", GTK_SHADOW_IN,
g_signal_connect_object (ev_window->priv->view, "focus_out_event",
G_CALLBACK (view_actions_focus_out_cb),
ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "external-link",
+ G_CALLBACK (view_external_link_cb),
+ ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view,
+ "popup",
+ G_CALLBACK (view_menu_popup_cb),
+ ev_window, 0);
gtk_widget_show (ev_window->priv->view);
gtk_widget_show (ev_window->priv->password_view);
+ /* Find Bar */
+ ev_window->priv->find_bar = egg_find_bar_new ();
+ gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
+ ev_window->priv->find_bar,
+ FALSE, TRUE, 0);
/* We own a ref on these widgets, as we can swap them in and out */
g_object_ref (ev_window->priv->view);
- //g_object_ref (ev_window->priv->page_view);
g_object_ref (ev_window->priv->password_view);
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
"notify::rotation",
G_CALLBACK (ev_window_rotation_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->view,
+ "notify::has-selection",
+ G_CALLBACK (ev_window_has_selection_changed_cb),
+ ev_window);
- ev_window->priv->find_bar = egg_find_bar_new ();
- gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
- ev_window->priv->find_bar,
- FALSE, TRUE, 0);
-
- ev_window_setup_recent (ev_window);
- ev_window->priv->chrome = load_chrome ();
- set_chrome_actions (ev_window);
- update_chrome_visibility (ev_window);
-
- /* Connect sidebar signals */
+ /* Connect sidebar signals */
g_signal_connect (ev_window->priv->sidebar,
"notify::visible",
G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
"notify::visible",
G_CALLBACK (find_bar_search_changed_cb),
ev_window);
+ g_signal_connect (ev_window->priv->find_bar,
+ "scroll",
+ G_CALLBACK (find_bar_scroll),
+ ev_window);
+
+ /* Popups */
+ ev_window->priv->view_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/DocumentPopup");
+ ev_window->priv->link = NULL;
+
+ ev_window->priv->attachment_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/AttachmentPopup");
+ ev_window->priv->attach_list = NULL;
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);
/* Drag and Drop */
- gtk_drag_dest_unset (GTK_WIDGET (ev_window));
- gtk_drag_dest_set (GTK_WIDGET (ev_window), GTK_DEST_DEFAULT_ALL, ev_drop_types,
+ gtk_drag_dest_unset (GTK_WIDGET (ev_window->priv->view));
+ gtk_drag_dest_set (GTK_WIDGET (ev_window->priv->view),
+ GTK_DEST_DEFAULT_ALL,
+ ev_drop_types,
sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
GDK_ACTION_COPY);
- g_signal_connect (G_OBJECT (ev_window), "drag_data_received",
- G_CALLBACK (drag_data_received_cb), NULL);
+ g_signal_connect_swapped (G_OBJECT (ev_window->priv->view), "drag-data-received",
+ G_CALLBACK (drag_data_received_cb),
+ ev_window);
+
+ /* Set it user interface params */
+
+ ev_window_setup_recent (ev_window);
+
+ setup_chrome_from_metadata (ev_window);
+ set_chrome_actions (ev_window);
+ update_chrome_visibility (ev_window);
- /* Set it to something random to force a change */
+ gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
+
+ setup_view_from_metadata (ev_window);
+ setup_sidebar_from_metadata (ev_window, NULL);
ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
- update_action_sensitivity (ev_window);
+ ev_window_setup_action_sensitivity (ev_window);
}
GtkWidget *
ev_window = GTK_WIDGET (g_object_new (EV_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
- "default-width", 600,
- "default-height", 600,
NULL));
return ev_window;