#else
#include <gtk/gtkprintunixdialog.h>
#endif
+#ifdef WITH_GCONF
#include <gconf/gconf-client.h>
+#endif
#include "egg-editable-toolbar.h"
#include "egg-toolbar-editor.h"
#include "ev-document-images.h"
#include "ev-document-links.h"
#include "ev-document-thumbnails.h"
+#include "ev-document-type-builtins.h"
#include "ev-file-exporter.h"
#include "ev-file-helpers.h"
#include "ev-file-monitor.h"
#include "ev-utils.h"
#include "ev-keyring.h"
#include "ev-view.h"
+#include "ev-view-type-builtins.h"
#include "ev-window.h"
#include "ev-window-title.h"
#include "ev-print-operation.h"
EV_CHROME_RAISE_TOOLBAR = 1 << 3,
EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4,
EV_CHROME_SIDEBAR = 1 << 5,
- EV_CHROME_PREVIEW_TOOLBAR = 1 << 6,
EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
} EvChrome;
/* Presentation mode */
guint presentation_timeout_id;
- /* Preview mode */
- GtkWidget *preview_toolbar;
- gchar *print_settings_file;
-
/* Popup view */
GtkWidget *view_popup;
EvLink *link;
char *uri;
glong uri_mtime;
char *local_uri;
- gboolean unlink_temp_file;
gboolean in_reload;
EvFileMonitor *monitor;
guint setup_document_idle;
gboolean unfullscreen_window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
-static void ev_window_run_preview (EvWindow *window);
static void ev_view_popup_cmd_open_link (GtkAction *action,
EvWindow *window);
static void ev_view_popup_cmd_open_link_new_window (GtkAction *action,
static void find_bar_search_changed_cb (EggFindBar *find_bar,
GParamSpec *param,
EvWindow *ev_window);
-static void ev_window_do_preview_print (EvWindow *window);
static void ev_window_load_file_remote (EvWindow *ev_window,
GFile *source_file);
static void ev_window_media_player_key_pressed (EvWindow *window,
gboolean can_get_text = FALSE;
gboolean has_pages = FALSE;
gboolean can_find = FALSE;
-
+#ifdef WITH_GCONF
GConfClient *client;
+#endif
if (document) {
has_document = TRUE;
can_find = TRUE;
}
+#ifdef WITH_GCONF
client = gconf_client_get_default ();
override_restrictions = gconf_client_get_bool (client,
GCONF_OVERRIDE_RESTRICTIONS,
NULL);
+#endif
if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
if (has_document && !EV_IS_FILE_EXPORTER(document))
ok_to_print = FALSE;
-
+#ifdef WITH_GCONF
if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
ok_to_copy = FALSE;
}
}
g_object_unref (client);
+#endif
/* File menu */
ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
- ev_window_set_action_sensitive (ev_window, "PreviewPrint", has_pages && ok_to_print);
ev_window_update_actions (ev_window);
}
EvWindowPrivate *priv = window->priv;
gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
- gboolean preview_toolbar;
presentation = ev_view_get_presentation (EV_VIEW (priv->view));
fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !presentation;
- preview_toolbar = (priv->chrome& EV_CHROME_PREVIEW_TOOLBAR);
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar, toolbar);
set_widget_visibility (priv->find_bar, findbar);
set_widget_visibility (priv->sidebar, sidebar);
- if (priv->preview_toolbar)
- set_widget_visibility (priv->preview_toolbar, preview_toolbar);
-
ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
gtk_widget_set_sensitive (priv->menubar, menubar);
}
}
-static void
-setup_document_from_metadata (EvWindow *window)
-{
- char *uri = window->priv->uri;
- GValue page = { 0, };
- gint n_pages;
- gint new_page;
-
- /* View the previously shown page, but make sure to not open a document on
- * the last page, since closing it on the last page most likely means the
- * user was finished reading the document. In that case, reopening should
- * show the first page. */
- if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
- n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
- new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
- if (!window->priv->in_reload && new_page == n_pages - 1)
- new_page = 0;
- ev_page_cache_set_current_page (window->priv->page_cache,
- new_page);
- g_value_unset (&page);
- }
-}
-
static void
setup_chrome_from_metadata (EvWindow *window)
{
}
static void
-setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
+setup_sidebar_from_metadata (EvWindow *window)
{
- char *uri = window->priv->uri;
- GtkWidget *sidebar = window->priv->sidebar;
- GtkWidget *links = window->priv->sidebar_links;
- GtkWidget *thumbs = window->priv->sidebar_thumbs;
- GtkWidget *attachments = window->priv->sidebar_attachments;
- GtkWidget *layers = window->priv->sidebar_layers;
- GValue sidebar_size = { 0, };
- GValue sidebar_page = { 0, };
- GValue sidebar_visibility = { 0, };
+ gchar *uri = window->priv->uri;
+ EvDocument *document = window->priv->document;
+ GtkWidget *sidebar = window->priv->sidebar;
+ GtkWidget *links = window->priv->sidebar_links;
+ GtkWidget *thumbs = window->priv->sidebar_thumbs;
+ GtkWidget *attachments = window->priv->sidebar_attachments;
+ GtkWidget *layers = window->priv->sidebar_layers;
+ GValue sidebar_size = { 0, };
+ GValue sidebar_page = { 0, };
+ GValue sidebar_visibility = { 0, };
if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
}
static void
-setup_size_from_metadata (EvWindow *window)
+setup_document_from_metadata (EvWindow *window)
{
- char *uri = window->priv->uri;
+ gchar *uri = window->priv->uri;
+ GValue page = { 0, };
GValue width = { 0, };
GValue height = { 0, };
GValue width_ratio = { 0, };
GValue height_ratio = { 0, };
- GValue maximized = { 0, };
- GValue x = { 0, };
- GValue y = { 0, };
- if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
- if (g_value_get_boolean (&maximized)) {
- gtk_window_maximize (GTK_WINDOW (window));
- g_value_unset (&maximized);
- return;
- } else {
- gtk_window_unmaximize (GTK_WINDOW (window));
- }
- g_value_unset (&maximized);
+ /* View the previously shown page, but make sure to not open a document on
+ * the last page, since closing it on the last page most likely means the
+ * user was finished reading the document. In that case, reopening should
+ * show the first page. */
+ if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
+ gint n_pages;
+ gint new_page;
+
+ n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
+ new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
+ ev_page_cache_set_current_page (window->priv->page_cache,
+ new_page);
+ g_value_unset (&page);
}
- if (ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
- ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
- gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
- g_value_get_int (&y));
- g_value_unset (&x);
- g_value_unset (&y);
- }
+ setup_sidebar_from_metadata (window);
- if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
- ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
- gtk_window_resize (GTK_WINDOW (window),
- g_value_get_int (&width),
- g_value_get_int (&height));
- g_value_unset (&width);
- g_value_unset (&height);
- return;
- }
+ if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
+ ev_metadata_manager_get (uri, "window_height", &height, TRUE))
+ return; /* size was already set in setup_size_from_metadata */
- if (window->priv->page_cache &&
- ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
+ if (ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
ev_metadata_manager_get (uri, "window_height_ratio", &height_ratio, FALSE)) {
-
- gint document_width;
- gint document_height;
-
+ gint document_width;
+ gint document_height;
GdkScreen *screen;
-
- gint request_width;
- gint request_height;
+ gint request_width;
+ gint request_height;
ev_page_cache_get_max_width (window->priv->page_cache,
0, 1.0,
}
static void
-setup_view_from_metadata (EvWindow *window)
+setup_size_from_metadata (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
char *uri = window->priv->uri;
- GEnumValue *enum_value;
- GValue sizing_mode = { 0, };
- GValue zoom = { 0, };
- GValue continuous = { 0, };
- GValue dual_page = { 0, };
- GValue presentation = { 0, };
- GValue fullscreen = { 0, };
- GValue rotation = { 0, };
+ GValue width = { 0, };
+ GValue height = { 0, };
GValue maximized = { 0, };
+ GValue x = { 0, };
+ GValue y = { 0, };
- /* Maximized */
if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
if (g_value_get_boolean (&maximized)) {
gtk_window_maximize (GTK_WINDOW (window));
+ g_value_unset (&maximized);
+ return;
} else {
gtk_window_unmaximize (GTK_WINDOW (window));
}
g_value_unset (&maximized);
}
+ if (ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
+ ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
+ gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
+ g_value_get_int (&y));
+ g_value_unset (&x);
+ g_value_unset (&y);
+ }
+
+ if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
+ ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
+ gtk_window_resize (GTK_WINDOW (window),
+ g_value_get_int (&width),
+ g_value_get_int (&height));
+ g_value_unset (&width);
+ g_value_unset (&height);
+ }
+}
+
+static void
+setup_view_from_metadata (EvWindow *window)
+{
+ EvView *view = EV_VIEW (window->priv->view);
+ gchar *uri = window->priv->uri;
+ GEnumValue *enum_value;
+ GValue sizing_mode = { 0, };
+ GValue zoom = { 0, };
+ GValue continuous = { 0, };
+ GValue dual_page = { 0, };
+ GValue presentation = { 0, };
+ GValue fullscreen = { 0, };
+ GValue rotation = { 0, };
+
/* Sizing mode */
if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode, FALSE)) {
enum_value = g_enum_get_value_by_nick
- (EV_SIZING_MODE_CLASS, g_value_get_string (&sizing_mode));
+ (g_type_class_peek (EV_TYPE_SIZING_MODE), g_value_get_string (&sizing_mode));
g_value_unset (&sizing_mode);
ev_view_set_sizing_mode (view, enum_value->value);
}
g_signal_connect (ev_window->priv->page_cache, "history-changed",
G_CALLBACK (history_changed_cb), ev_window);
- setup_size_from_metadata (ev_window);
- setup_sidebar_from_metadata (ev_window, document);
- setup_document_from_metadata (ev_window);
+ if (ev_window->priv->in_reload && ev_window->priv->dest) {
+ gint page;
+
+ /* Restart the current page */
+ page = CLAMP (ev_link_dest_get_page (ev_window->priv->dest),
+ 0,
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache) - 1);
+ ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = NULL;
+ }
if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
ev_view_set_document (view, document);
}
static void
-ev_window_clear_print_settings_file (EvWindow *ev_window)
-{
- if (ev_window->priv->print_settings_file) {
- g_unlink (ev_window->priv->print_settings_file);
- g_free (ev_window->priv->print_settings_file);
- ev_window->priv->print_settings_file = NULL;
- }
-}
-
-static void
-ev_window_clear_temp_file (EvWindow *ev_window)
+ev_window_clear_temp_symlink (EvWindow *ev_window)
{
GFile *file, *tempdir;
return;
file = g_file_new_for_uri (ev_window->priv->uri);
- tempdir = g_file_new_for_path (g_get_tmp_dir ());
+ tempdir = g_file_new_for_path (ev_tmp_dir ());
if (g_file_has_prefix (file, tempdir)) {
- g_file_delete (file, NULL, NULL);
+ GFileInfo *file_info;
+ GError *error = NULL;
+
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, &error);
+ if (file_info) {
+ if (g_file_info_get_is_symlink (file_info))
+ g_file_delete (file, NULL, NULL);
+ g_object_unref (file_info);
+ } else {
+ g_warning ("Error deleting temp symlink: %s\n", error->message);
+ g_error_free (error);
+ }
}
g_object_unref (file);
/* Success! */
if (!ev_job_is_failed (job)) {
ev_window_set_document (ev_window, document);
-
- if (ev_window->priv->window_mode != EV_WINDOW_MODE_PREVIEW) {
- setup_view_from_metadata (ev_window);
- }
- if (!ev_window->priv->unlink_temp_file) {
- ev_window_add_recent (ev_window, ev_window->priv->uri);
- }
+ setup_document_from_metadata (ev_window);
+ setup_view_from_metadata (ev_window);
+
+ ev_window_add_recent (ev_window, ev_window->priv->uri);
ev_window_title_set_type (ev_window->priv->title,
EV_WINDOW_TITLE_DOCUMENT);
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;
}
/* Create a monitor for the document */
ev_window->priv->monitor = ev_file_monitor_new (ev_window->priv->uri);
- g_signal_connect_swapped (G_OBJECT (ev_window->priv->monitor), "changed",
+ g_signal_connect_swapped (ev_window->priv->monitor, "changed",
G_CALLBACK (ev_window_document_changed),
ev_window);
return;
}
- if (job->error->domain == EV_DOCUMENT_ERROR &&
- job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+ if (g_error_matches (job->error, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_ENCRYPTED)) {
gchar *password;
setup_view_from_metadata (ev_window);
if (ev_job_is_failed (job)) {
ev_window_clear_reload_job (ev_window);
ev_window->priv->in_reload = FALSE;
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = NULL;
+
return;
}
ev_window_set_document (ev_window, job->document);
-
+
/* Restart the search after reloading */
widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
error->code == G_IO_ERROR_CANCELLED) {
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
- ev_window_clear_print_settings_file (ev_window);
g_free (ev_window->priv->uri);
ev_window->priv->uri = NULL;
g_object_unref (source);
const char *uri,
EvLinkDest *dest,
EvWindowRunMode mode,
- const gchar *search_string,
- gboolean unlink_temp_file,
- const gchar *print_settings)
+ const gchar *search_string)
{
GFile *source_file;
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
- ev_window_clear_print_settings_file (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
- ev_window->priv->unlink_temp_file = unlink_temp_file;
ev_window->priv->window_mode = mode;
- if (mode == EV_WINDOW_MODE_PREVIEW) {
- ev_window->priv->print_settings_file = print_settings ?
- g_strdup (print_settings) : NULL;
- }
-
if (ev_window->priv->uri)
g_free (ev_window->priv->uri);
ev_window->priv->uri = g_strdup (uri);
ev_window->priv->dest = dest ? g_object_ref (dest) : NULL;
setup_size_from_metadata (ev_window);
-
+
ev_window->priv->load_job = ev_job_load_new (uri);
g_signal_connect (ev_window->priv->load_job,
"finished",
static void
ev_window_reload_document (EvWindow *ev_window)
{
+ gint page;
+
+
ev_window_clear_reload_job (ev_window);
ev_window->priv->in_reload = TRUE;
+ page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+
+ if (ev_window->priv->dest)
+ g_object_unref (ev_window->priv->dest);
+ /* FIXME: save the scroll position too (xyz dest) */
+ ev_window->priv->dest = ev_link_dest_new_page (page);
+
if (ev_window->priv->local_uri) {
ev_window_reload_remote (ev_window);
} else {
dest,
0,
NULL,
- TRUE,
- NULL,
GDK_CURRENT_TIME);
g_free (symlink_uri);
}
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, FALSE, NULL,
- GDK_CURRENT_TIME);
+ NULL, 0, NULL, GDK_CURRENT_TIME);
}
static void
{
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, FALSE, NULL,
- GDK_CURRENT_TIME);
+ NULL, 0, NULL, GDK_CURRENT_TIME);
}
static void
gtk_recent_info_ref (info),
(GDestroyNotify) gtk_recent_info_unref);
- g_signal_connect (G_OBJECT (action), "activate",
+ g_signal_connect (action, "activate",
G_CALLBACK (ev_window_cmd_recent_file_activate),
(gpointer) ev_window);
ev_document_factory_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
ev_window->priv->print_queue = g_queue_new ();
op = ev_print_operation_new (ev_window->priv->document);
- g_signal_connect (G_OBJECT (op), "begin_print",
+ g_signal_connect (op, "begin_print",
G_CALLBACK (ev_window_print_operation_begin_print),
(gpointer)ev_window);
- g_signal_connect (G_OBJECT (op), "status_changed",
+ g_signal_connect (op, "status_changed",
G_CALLBACK (ev_window_print_operation_status_changed),
(gpointer)ev_window);
- g_signal_connect (G_OBJECT (op), "done",
+ g_signal_connect (op, "done",
G_CALLBACK (ev_window_print_operation_done),
(gpointer)ev_window);
GTK_RESPONSE_YES,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_YES,
+ GTK_RESPONSE_NO,
+ GTK_RESPONSE_CANCEL,
+ -1);
g_signal_connect (dialog, "response",
G_CALLBACK (print_jobs_confirmation_dialog_response),
}
}
-static void
-ev_window_run_preview (EvWindow *window)
-{
- GtkAction *action;
-
- if (!window->priv->preview_toolbar) {
- window->priv->preview_toolbar =
- gtk_ui_manager_get_widget (window->priv->ui_manager,
- "/PreviewToolbar");
-
- gtk_box_pack_start (GTK_BOX (window->priv->main_box),
- window->priv->preview_toolbar,
- FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (window->priv->main_box),
- window->priv->preview_toolbar, 1);
- }
-
- ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
-
- update_chrome_flag (window, EV_CHROME_TOOLBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
- update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
-
- update_chrome_flag (window, EV_CHROME_PREVIEW_TOOLBAR, TRUE);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "PreviewPrint");
- gtk_action_set_visible (action, TRUE);
-
- update_chrome_visibility (window);
-}
-
static void
ev_window_screen_changed (GtkWidget *widget,
GdkScreen *old_screen)
ev_window_run_presentation (window);
}
-static gboolean
-ev_window_enumerate_printer_cb (GtkPrinter *printer,
- EvWindow *window)
-{
- EvWindowPrivate *priv = window->priv;
- const gchar *printer_name;
-
- printer_name = gtk_print_settings_get_printer (priv->print_settings);
- if ((printer_name
- && strcmp (printer_name, gtk_printer_get_name (printer)) == 0) ||
- (!printer_name && gtk_printer_is_default (printer))) {
- if (priv->printer)
- g_object_unref (priv->printer);
- priv->printer = g_object_ref (printer);
-
- /* Now that we have the printer, we'll start the print */
- ev_window_do_preview_print (window);
-
- return TRUE; /* we're done */
- }
-
- return FALSE; /* continue the enumeration */
-}
-
-static void
-ev_window_preview_print_finished (GtkPrintJob *print_job,
- EvWindow *window,
- GError *error)
-{
- if (error) {
- ev_window_error_message (window, error,
- "%s", _("Failed to print document"));
- }
-
- g_object_unref (print_job);
- gtk_widget_destroy (GTK_WIDGET (window));
-}
-
-static void
-ev_window_do_preview_print (EvWindow *window)
-{
- EvWindowPrivate *priv = window->priv;
- GtkPrintJob *job;
- gchar *filename;
- GError *error = NULL;
-
- g_assert (priv->print_settings != NULL);
- g_assert (priv->printer != NULL);
-
- job = gtk_print_job_new (gtk_window_get_title (GTK_WINDOW (window)),
- priv->printer,
- priv->print_settings,
- priv->print_page_setup);
-
- g_object_unref (priv->print_settings);
- priv->print_settings = NULL;
- g_object_unref (priv->print_page_setup);
- priv->print_page_setup = NULL;
- g_object_unref (priv->printer);
- priv->printer = NULL;
-
- filename = g_filename_from_uri (priv->local_uri ?
- priv->local_uri : priv->uri,
- NULL, NULL);
-
- if (gtk_print_job_set_source_file (job, filename, &error)) {
- gtk_print_job_send (job,
- (GtkPrintJobCompleteFunc)ev_window_preview_print_finished,
- window, NULL);
- } else {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_free (filename);
-
- gtk_widget_hide (GTK_WIDGET (window));
-}
-
-static void
-ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
-{
- EvWindowPrivate *priv = window->priv;
- GtkPrintSettings *print_settings;
- GtkPageSetup *page_setup;
- const gchar *print_settings_file = priv->print_settings_file;
-
- if (print_settings_file && g_file_test (print_settings_file, G_FILE_TEST_IS_REGULAR)) {
- GKeyFile *key_file;
- GError *error = NULL;
-
- key_file = g_key_file_new ();
- g_key_file_load_from_file (key_file,
- print_settings_file,
- G_KEY_FILE_KEEP_COMMENTS |
- G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
- if (!error) {
- print_settings =
- gtk_print_settings_new_from_key_file (key_file,
- "Print Settings",
- NULL);
- print_settings = print_settings ? print_settings : gtk_print_settings_new ();
-
- page_setup = gtk_page_setup_new_from_key_file (key_file,
- "Page Setup",
- NULL);
- page_setup = page_setup ? page_setup : gtk_page_setup_new ();
- } else {
- print_settings = gtk_print_settings_new ();
- page_setup = gtk_page_setup_new ();
- g_error_free (error);
- }
-
- g_key_file_free (key_file);
- } else {
- print_settings = gtk_print_settings_new ();
- page_setup = gtk_page_setup_new ();
- }
-
- if (priv->print_settings)
- g_object_unref (priv->print_settings);
- priv->print_settings = print_settings;
- if (priv->print_page_setup)
- g_object_unref (priv->print_page_setup);
- priv->print_page_setup = page_setup;
-
- gtk_enumerate_printers ((GtkPrinterFunc) ev_window_enumerate_printer_cb,
- window, NULL, FALSE);
-}
-
static void
ev_window_cmd_escape (GtkAction *action, EvWindow *window)
{
GEnumValue *enum_value;
mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
- enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
+ enum_value = g_enum_get_value (g_type_class_peek (EV_TYPE_SIZING_MODE), mode);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
enum_value->value_nick);
}
+static void
+ev_window_set_view_size (EvWindow *window)
+{
+ gint width, height;
+ GtkRequisition vsb_requisition;
+ GtkRequisition hsb_requisition;
+ gint scrollbar_spacing;
+ GtkWidget *scrolled_window = window->priv->scrolled_window;
+
+ if (!window->priv->view)
+ return;
+
+ /* Calculate the width available for the content */
+ width = scrolled_window->allocation.width;
+ height = scrolled_window->allocation.height;
+
+ if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window)) == GTK_SHADOW_IN) {
+ width -= 2 * window->priv->view->style->xthickness;
+ height -= 2 * window->priv->view->style->ythickness;
+ }
+
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (scrolled_window)->vscrollbar,
+ &vsb_requisition);
+ gtk_widget_size_request (GTK_SCROLLED_WINDOW (scrolled_window)->hscrollbar,
+ &hsb_requisition);
+ gtk_widget_style_get (scrolled_window,
+ "scrollbar_spacing",
+ &scrollbar_spacing,
+ NULL);
+
+ ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
+ MAX (1, width),
+ MAX (1, height),
+ vsb_requisition.width + scrollbar_spacing,
+ hsb_requisition.height + scrollbar_spacing);
+}
+
static void
ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
EvWindow *ev_window)
{
- GtkWidget *scrolled_window;
EvSizingMode sizing_mode;
g_object_get (ev_window->priv->view,
"sizing-mode", &sizing_mode,
NULL);
- scrolled_window = ev_window->priv->scrolled_window;
-
- g_signal_handlers_disconnect_by_func (ev_window->priv->view, ev_view_update_view_size, scrolled_window);
-
- if (sizing_mode != EV_SIZING_FREE)
- ev_view_update_view_size (EV_VIEW (ev_window->priv->view),
- GTK_SCROLLED_WINDOW (scrolled_window));
-
- switch (sizing_mode) {
- case EV_SIZING_BEST_FIT:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (ev_view_update_view_size),
- scrolled_window);
- break;
- case EV_SIZING_FIT_WIDTH:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (ev_view_update_view_size),
- scrolled_window);
- break;
- case EV_SIZING_FREE:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- break;
- }
+ g_object_set (ev_window->priv->scrolled_window,
+ "hscrollbar-policy",
+ sizing_mode == EV_SIZING_FREE ?
+ GTK_POLICY_AUTOMATIC : GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
update_sizing_buttons (ev_window);
save_sizing_mode (ev_window);
} else {
mode = EV_SIZING_FREE;
}
-
+
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
if (mode == EV_SIZING_FREE) {
}
if (priv->uri) {
- if (priv->unlink_temp_file)
- ev_window_clear_temp_file (window);
+ /* Delete the uri if it's a temp symlink (open a copy) */
+ ev_window_clear_temp_symlink (window);
g_free (priv->uri);
priv->uri = NULL;
}
priv->history = NULL;
}
- if (priv->print_settings_file) {
- ev_window_clear_print_settings_file (window);
- priv->print_settings_file = NULL;
- }
-
if (priv->presentation_timeout_id > 0) {
g_source_remove (priv->presentation_timeout_id);
priv->presentation_timeout_id = 0;
G_CALLBACK (ev_window_cmd_edit_find_previous) },
{ "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_toolbar) },
- { "EditRotateLeft", EV_STOCK_ROTATE_LEFT, N_("Rotate _Left"), "<alt>Left", NULL,
+ { "EditRotateLeft", EV_STOCK_ROTATE_LEFT, N_("Rotate _Left"), "<control>Left", NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_left) },
- { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "<alt>Right", NULL,
+ { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "<control>Right", NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_right) },
/* View menu */
{ "StartPresentation", EV_STOCK_RUN_PRESENTATION, N_("Start Presentation"), NULL,
N_("Start a presentation"),
G_CALLBACK (ev_window_cmd_start_presentation) },
- { "PreviewPrint", GTK_STOCK_PRINT, N_("Print"), NULL,
- N_("Print this document"),
- G_CALLBACK (ev_window_cmd_preview_print) },
/* Accellerators */
{ "Escape", NULL, "", "Escape", "",
ev_link_action_get_dest (action),
0,
NULL,
- FALSE,
- NULL,
GDK_CURRENT_TIME);
g_free (uri);
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (fc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (fc), FALSE);
g_signal_connect_object (ev_window->priv->view, "handle-link",
G_CALLBACK (view_handle_link_cb),
ev_window, 0);
-
+ g_signal_connect_swapped (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (ev_window_set_view_size),
+ ev_window);
g_signal_connect_object (ev_window->priv->view,
"popup",
G_CALLBACK (view_menu_popup_cb),
gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
setup_view_from_metadata (ev_window);
- setup_sidebar_from_metadata (ev_window, NULL);
+ setup_sidebar_from_metadata (ev_window);
ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
ev_window_setup_action_sensitivity (ev_window);