/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
/* this file is part of evince, a gnome document viewer
*
+ * Copyright (C) 2009 Juanjo Marín <juanj.marin@juntadeandalucia.es>
* Copyright (C) 2008 Carlos Garcia Campos
* Copyright (C) 2004 Martin Kretzschmar
* Copyright (C) 2004 Red Hat, Inc.
#include "ev-document-images.h"
#include "ev-document-links.h"
#include "ev-document-thumbnails.h"
+#include "ev-document-annotations.h"
#include "ev-document-type-builtins.h"
+#include "ev-document-misc.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-presentation.h"
#include "ev-view-type-builtins.h"
#include "ev-window.h"
#include "ev-window-title.h"
#include "ev-media-player-keys.h"
#endif /* ENABLE_DBUS */
-#ifdef ENABLE_PDF
-#include <poppler.h>
-#endif
-
typedef enum {
PAGE_MODE_DOCUMENT,
PAGE_MODE_PASSWORD
GtkWidget *find_bar;
GtkWidget *scrolled_window;
GtkWidget *view;
+ GtkWidget *presentation_view;
GtkWidget *message_area;
GtkWidget *password_view;
GtkWidget *sidebar_thumbs;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
- /* Presentation mode */
- guint presentation_timeout_id;
-
/* Popup view */
GtkWidget *view_popup;
EvLink *link;
GtkPrintSettings *print_settings;
GtkPageSetup *print_page_setup;
gboolean close_after_print;
+#ifdef WITH_GCONF
+ GConfClient *gconf_client;
+#endif
};
#define EV_WINDOW_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
+#define EV_WINDOW_IS_PRESENTATION(w) (w->priv->presentation_view != NULL)
+
#define PAGE_SELECTOR_ACTION "PageSelector"
#define ZOOM_CONTROL_ACTION "ViewZoom"
#define NAVIGATION_ACTION "Navigation"
+#define GCONF_LOCKDOWN_DIR "/desktop/gnome/lockdown"
#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 PRESENTATION_TIMEOUT 5
+#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define EV_PRINT_SETTINGS_GROUP "Print Settings"
#define EV_PAGE_SETUP_GROUP "Page Setup"
+#define EV_TOOLBARS_FILENAME "evince-toolbar.xml"
+
#define MIN_SCALE 0.05409
#define MAX_SCALE 4.0
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
+static gdouble
+get_screen_dpi (EvWindow *window)
+{
+ GdkScreen *screen;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ return ev_document_misc_get_screen_dpi (screen);
+}
+
static void
ev_window_set_action_sensitive (EvWindow *ev_window,
const char *name,
{
EvDocument *document = ev_window->priv->document;
const EvDocumentInfo *info = NULL;
-
gboolean has_document = FALSE;
gboolean ok_to_print = TRUE;
+ gboolean ok_to_print_setup = TRUE;
gboolean ok_to_copy = TRUE;
gboolean has_properties = TRUE;
gboolean override_restrictions = TRUE;
gboolean can_get_text = FALSE;
gboolean has_pages = FALSE;
gboolean can_find = FALSE;
-#ifdef WITH_GCONF
- GConfClient *client;
-#endif
if (document) {
has_document = TRUE;
}
#ifdef WITH_GCONF
- client = gconf_client_get_default ();
- override_restrictions = gconf_client_get_bool (client,
- GCONF_OVERRIDE_RESTRICTIONS,
- NULL);
+ if (has_document)
+ override_restrictions = gconf_client_get_bool (ev_window->priv->gconf_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_print = FALSE;
#ifdef WITH_GCONF
- if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
+ if (has_document &&
+ gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_SAVE, NULL)) {
ok_to_copy = FALSE;
}
- if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
+ if (has_document &&
+ gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT, NULL)) {
ok_to_print = FALSE;
}
- g_object_unref (client);
+ if (has_document &&
+ gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT_SETUP, NULL)) {
+ ok_to_print_setup = FALSE;
+ }
#endif
/* File menu */
ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
- ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print);
+#if !GTK_CHECK_VERSION (2, 17, 4)
+ ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print && ok_to_print_setup);
+#endif
ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewInvertedColors", has_pages);
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION, FALSE);
+ /* Help menu */
+#ifdef G_OS_WIN32
+ ev_window_set_action_sensitive (ev_window, "HelpContents", FALSE);
+#endif
+
ev_window_update_actions (ev_window);
}
ev_window_set_action_sensitive (ev_window, "F3",
has_pages && can_find_in_page);
- presentation_mode = ev_view_get_presentation (view);
+ presentation_mode = EV_WINDOW_IS_PRESENTATION (ev_window);
ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
has_pages &&
ZOOM_CONTROL_ACTION);
real_zoom = ev_document_model_get_scale (ev_window->priv->model);
- real_zoom *= 72.0 / get_screen_dpi (GTK_WINDOW (ev_window));
+ real_zoom *= 72.0 / get_screen_dpi (ev_window);
zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
ev_window_set_action_sensitive (window, "KpPlus", sensitive);
ev_window_set_action_sensitive (window, "KpMinus", sensitive);
ev_window_set_action_sensitive (window, "Equal", sensitive);
+ ev_window_set_action_sensitive (window, "p", sensitive);
+ ev_window_set_action_sensitive (window, "n", sensitive);
ev_window_set_action_sensitive (window, "Slash", sensitive && can_find);
}
gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
- presentation = ev_view_get_presentation (EV_VIEW (priv->view));
+ presentation = EV_WINDOW_IS_PRESENTATION (window);
fullscreen = ev_document_model_get_fullscreen (priv->model);
fullscreen_mode = fullscreen || presentation;
if (link) {
action = g_object_ref (ev_link_get_action (link));
dest = ev_link_action_get_dest (action);
- page = ev_link_dest_get_page (dest);
- page_label = ev_view_page_label_from_dest (EV_VIEW (window->priv->view), dest);
+ page_label = ev_document_links_get_dest_page_label (EV_DOCUMENT_LINKS (window->priv->document), dest);
} else {
dest = ev_link_dest_new_page (page);
action = ev_link_action_new_dest (dest);
}
if (find_task.chapter)
- link_title = g_strdup_printf (_("Page %s - %s"), page_label, find_task.chapter);
+ link_title = g_strdup_printf (_("Page %s — %s"), page_label, find_task.chapter);
else
link_title = g_strdup_printf (_("Page %s"), page_label);
ev_window_add_history (window, current_page, NULL);
}
+static void
+view_selection_changed_cb (EvView *view,
+ EvWindow *window)
+{
+ ev_window_set_action_sensitive (window, "EditCopy",
+ ev_view_get_has_selection (view));
+}
+
static void
ev_window_page_changed_cb (EvWindow *ev_window,
gint old_page,
gchar *sizing_mode;
gdouble zoom;
gint rotation;
- gboolean continuous = { 0, };
- gboolean dual_page = { 0, };
- gboolean fullscreen = { 0, };
+ gboolean inverted_colors = FALSE;
+ gboolean continuous = FALSE;
+ gboolean dual_page = FALSE;
+ gboolean fullscreen = FALSE;
if (!window->priv->metadata)
return;
/* Zoom */
if (ev_document_model_get_sizing_mode (window->priv->model) == EV_SIZING_FREE &&
ev_metadata_get_double (window->priv->metadata, "zoom", &zoom)) {
- zoom *= get_screen_dpi (GTK_WINDOW (window)) / 72.0;
+ zoom *= get_screen_dpi (window) / 72.0;
ev_document_model_set_scale (window->priv->model, zoom);
}
ev_document_model_set_rotation (window->priv->model, rotation);
}
+ /* Inverted Colors */
+ if (ev_metadata_get_boolean (window->priv->metadata, "inverted-colors", &inverted_colors))
+ ev_document_model_set_inverted_colors (window->priv->model, inverted_colors);
+
/* Continuous */
if (ev_metadata_get_boolean (window->priv->metadata, "continuous", &continuous)) {
ev_document_model_set_continuous (window->priv->model, continuous);
EvWindow *ev_window)
{
if (job->thumbnail) {
+ if (ev_document_model_get_inverted_colors (ev_window->priv->model))
+ ev_document_misc_invert_pixbuf (job->thumbnail);
gtk_window_set_icon (GTK_WINDOW (ev_window),
job->thumbnail);
}
}
static void
-ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
+ev_window_refresh_window_thumbnail (EvWindow *ev_window)
{
gdouble page_width;
gdouble scale;
+ gint rotation;
EvDocument *document = ev_window->priv->document;
if (!EV_IS_DOCUMENT_THUMBNAILS (document) ||
ev_document_get_page_size (document, 0, &page_width, NULL);
scale = 128. / page_width;
+ rotation = ev_document_model_get_rotation (ev_window->priv->model);
ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
}
+#ifdef WITH_GCONF
+static void
+lockdown_changed (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ EvWindow *ev_window)
+{
+ ev_window_setup_action_sensitivity (ev_window);
+}
+#endif /* WITH_GCONF */
+
static gboolean
ev_window_setup_document (EvWindow *ev_window)
{
ev_window->priv->setup_document_idle = 0;
- ev_window_refresh_window_thumbnail (ev_window, 0);
+ ev_window_refresh_window_thumbnail (ev_window);
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);
+#ifdef WITH_GCONF
+ if (!ev_window->priv->gconf_client)
+ ev_window->priv->gconf_client = gconf_client_get_default ();
+ gconf_client_add_dir (ev_window->priv->gconf_client,
+ GCONF_LOCKDOWN_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
+ gconf_client_add_dir (ev_window->priv->gconf_client,
+ GCONF_OVERRIDE_RESTRICTIONS,
+ GCONF_CLIENT_PRELOAD_NONE,
+ NULL);
+ gconf_client_notify_add (ev_window->priv->gconf_client,
+ GCONF_LOCKDOWN_DIR,
+ (GConfClientNotifyFunc)lockdown_changed,
+ ev_window, NULL, NULL);
+ gconf_client_notify_add (ev_window->priv->gconf_client,
+ GCONF_OVERRIDE_RESTRICTIONS,
+ (GConfClientNotifyFunc)lockdown_changed,
+ ev_window, NULL, NULL);
+#endif /* WITH_GCONF */
+
ev_window_setup_action_sensitivity (ev_window);
if (ev_window->priv->history)
info = ev_document_get_info (document);
update_document_mode (ev_window, info->mode);
- gtk_widget_grab_focus (ev_window->priv->view);
+ if (EV_WINDOW_IS_PRESENTATION (ev_window))
+ gtk_widget_grab_focus (ev_window->priv->presentation_view);
+ else
+ gtk_widget_grab_focus (ev_window->priv->view);
return FALSE;
}
ev_window_set_message_area (ev_window, NULL);
- 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_document_get_n_pages (document) - 1);
- ev_document_model_set_page (ev_window->priv->model, page);
- g_object_unref (ev_window->priv->dest);
- ev_window->priv->dest = NULL;
- }
-
if (ev_document_get_n_pages (document) <= 0) {
ev_window_warning_message (ev_window, "%s",
_("The document contains no pages"));
EvWindow *ev_window)
{
GtkWidget *widget;
- EvLinkDest *dest = NULL;
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;
-
+ if (ev_window->priv->dest) {
+ g_object_unref (ev_window->priv->dest);
+ ev_window->priv->dest = NULL;
+ }
+
return;
}
- if (ev_window->priv->dest) {
- dest = g_object_ref (ev_window->priv->dest);
- }
ev_document_model_set_document (ev_window->priv->model,
job->document);
- ev_window_handle_link (ev_window, dest);
+ if (ev_window->priv->dest) {
+ ev_window_handle_link (ev_window, ev_window->priv->dest);
+ /* Already unrefed by ev_link_action
+ * FIXME: link action should inc dest ref counting
+ * or not unref it at all
+ */
+ ev_window->priv->dest = NULL;
+ }
/* Restart the search after reloading */
widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
GFile *target_file;
if (!ev_window->priv->local_uri) {
- gchar *tmp_name;
- gchar *base_name;
+ char *base_name, *template;
+ GFile *tmp_file;
+ GError *err = NULL;
/* We'd like to keep extension of source uri since
- * it helps to resolve some mime types, say cbz */
- tmp_name = ev_tmp_filename (NULL);
+ * it helps to resolve some mime types, say cbz.
+ */
base_name = g_file_get_basename (source_file);
- ev_window->priv->local_uri = g_strconcat ("file:", tmp_name, "-",
- base_name, NULL);
+ template = g_strdup_printf ("document.XXXXXX-%s", base_name);
+ g_free (base_name);
+
+ tmp_file = ev_mkstemp_file (template, &err);
+ g_free (template);
+ if (tmp_file == NULL) {
+ ev_window_error_message (ev_window, err,
+ "%s", _("Failed to load remote file."));
+ g_error_free (err);
+ return;
+ }
+
+ ev_window->priv->local_uri = g_file_get_uri (tmp_file);
+ g_object_unref (tmp_file);
+
ev_job_load_set_uri (EV_JOB_LOAD (ev_window->priv->load_job),
ev_window->priv->local_uri);
- g_free (base_name);
- g_free (tmp_name);
}
ev_window_reset_progress_cancellable (ev_window);
target_file = g_file_new_for_uri (ev_window->priv->local_uri);
g_file_copy_async (source_file, target_file,
- 0, G_PRIORITY_DEFAULT,
+ G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT,
ev_window->priv->progress_cancellable,
(GFileProgressCallback)window_open_file_copy_progress_cb,
ev_window,
if (ev_window->priv->dest)
g_object_unref (ev_window->priv->dest);
- /* FIXME: save the scroll position too (xyz dest) */
- ev_window->priv->dest = dest ? g_object_ref (dest) : ev_link_dest_new_page (page);
+ ev_window->priv->dest = dest ? g_object_ref (dest) : NULL;
if (ev_window->priv->local_uri) {
ev_window_reload_remote (ev_window);
ev_application_open_uri_list (EV_APP, uris,
gtk_window_get_screen (GTK_WINDOW (ev_window)),
- GDK_CURRENT_TIME);
+ gtk_get_current_event_time ());
g_slist_foreach (uris, (GFunc)g_free, NULL);
g_slist_free (uris);
ev_window_open_document (new_window,
window->priv->document,
dest, 0, NULL);
- gtk_widget_show (GTK_WIDGET (new_window));
+ gtk_window_present (GTK_WINDOW (new_window));
}
static void
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, GDK_CURRENT_TIME);
+ NULL, 0, NULL, gtk_get_current_event_time ());
}
static void
{
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, GDK_CURRENT_TIME);
+ NULL, 0, NULL, gtk_get_current_event_time ());
}
static void
{
GKeyFile *print_settings_file;
gchar *filename;
+ GError *error = NULL;
print_settings_file = g_key_file_new ();
- filename = g_build_filename (ev_application_get_dot_dir (EV_APP),
- EV_PRINT_SETTINGS_FILE, NULL);
- if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
- GError *error = NULL;
-
- g_key_file_load_from_file (print_settings_file,
- filename,
- G_KEY_FILE_KEEP_COMMENTS |
- G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
- if (error) {
+ filename = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE),
+ EV_PRINT_SETTINGS_FILE, NULL);
+ if (!g_key_file_load_from_file (print_settings_file,
+ filename,
+ G_KEY_FILE_KEEP_COMMENTS |
+ G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error)) {
+
+ /* Don't warn if the file simply doesn't exist */
+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
g_warning ("%s", error->message);
- g_error_free (error);
- }
+
+ g_error_free (error);
}
+
g_free (filename);
return print_settings_file;
{
gchar *filename;
gchar *data;
- gssize data_length;
+ gsize data_length;
GError *error = NULL;
- filename = g_build_filename (ev_application_get_dot_dir (EV_APP),
+ filename = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE),
EV_PRINT_SETTINGS_FILE, NULL);
- data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL);
+ data = g_key_file_to_data (key_file, &data_length, NULL);
g_file_set_contents (filename, data, data_length, &error);
if (error) {
- g_warning ("%s", error->message);
+ g_warning ("Failed to save print settings: %s", error->message);
g_error_free (error);
}
g_free (data);
print_settings = ev_print_operation_get_print_settings (op);
ev_window_save_print_settings (ev_window, print_settings);
+
+ if (ev_print_operation_get_embed_page_setup (op)) {
+ GtkPageSetup *page_setup;
+
+ page_setup = ev_print_operation_get_default_page_setup (op);
+ ev_window_save_print_page_setup (ev_window, page_setup);
+ }
}
break;
ev_print_operation_set_current_page (op, current_page);
ev_print_operation_set_print_settings (op, print_settings);
ev_print_operation_set_default_page_setup (op, print_page_setup);
+#ifdef WITH_GCONF
+ ev_print_operation_set_embed_page_setup (op, !gconf_client_get_bool (ev_window->priv->gconf_client,
+ GCONF_LOCKDOWN_PRINT_SETUP,
+ NULL));
+#else
+ ev_print_operation_set_embed_page_setup (op, TRUE);
+#endif
g_object_unref (print_settings);
g_object_unref (print_page_setup);
static void
ev_window_run_fullscreen (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
gboolean fullscreen_window = TRUE;
if (ev_document_model_get_fullscreen (window->priv->model))
window->priv->fullscreen_toolbar, 1);
}
- if (ev_view_get_presentation (view)) {
+ if (EV_WINDOW_IS_PRESENTATION (window)) {
ev_window_stop_presentation (window, FALSE);
fullscreen_window = FALSE;
}
}
}
-static gboolean
-presentation_timeout_cb (EvWindow *window)
-{
- EvView *view = EV_VIEW (window->priv->view);
-
- if (!view || !ev_view_get_presentation (EV_VIEW (view)))
- return FALSE;
-
- ev_view_hide_cursor (EV_VIEW (window->priv->view));
- window->priv->presentation_timeout_id = 0;
-
- return FALSE;
-}
-
-static void
-presentation_set_timeout (EvWindow *window)
-{
- if (window->priv->presentation_timeout_id > 0) {
- g_source_remove (window->priv->presentation_timeout_id);
- }
-
- window->priv->presentation_timeout_id =
- g_timeout_add_seconds (PRESENTATION_TIMEOUT,
- (GSourceFunc)presentation_timeout_cb, window);
-
- ev_view_show_cursor (EV_VIEW (window->priv->view));
-}
-
-static void
-presentation_clear_timeout (EvWindow *window)
-{
- if (window->priv->presentation_timeout_id > 0) {
- g_source_remove (window->priv->presentation_timeout_id);
- }
-
- window->priv->presentation_timeout_id = 0;
-
- ev_view_show_cursor (EV_VIEW (window->priv->view));
-}
-
-static gboolean
-presentation_motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- presentation_set_timeout (window);
-
- return FALSE;
-}
-
-static gboolean
-presentation_leave_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- presentation_clear_timeout (window);
-
- return FALSE;
-}
-
static void
ev_window_update_presentation_action (EvWindow *window)
{
g_signal_handlers_block_by_func
(action, G_CALLBACK (ev_window_cmd_view_presentation), window);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- ev_view_get_presentation (EV_VIEW (window->priv->view)));
+ EV_WINDOW_IS_PRESENTATION (window));
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_cmd_view_presentation), window);
}
+static void
+ev_window_view_presentation_finished (EvWindow *window)
+{
+ ev_window_stop_presentation (window, TRUE);
+}
+
static void
ev_window_run_presentation (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
gboolean fullscreen_window = TRUE;
+ guint current_page;
+ guint rotation;
- if (ev_view_get_presentation (view))
+ if (EV_WINDOW_IS_PRESENTATION (window))
return;
if (ev_document_model_get_fullscreen (window->priv->model)) {
ev_window_stop_fullscreen (window, FALSE);
fullscreen_window = FALSE;
}
-
- g_object_set (G_OBJECT (window->priv->scrolled_window),
- "shadow-type", GTK_SHADOW_NONE,
- NULL);
- ev_view_set_presentation (view, TRUE);
- ev_window_update_presentation_action (window);
+ current_page = ev_document_model_get_page (window->priv->model);
+ rotation = ev_document_model_get_rotation (window->priv->model);
+ window->priv->presentation_view =
+ ev_view_presentation_new (window->priv->document, current_page, rotation);
+ g_signal_connect_swapped (window->priv->presentation_view, "finished",
+ G_CALLBACK (ev_window_view_presentation_finished),
+ window);
+ gtk_box_pack_start (GTK_BOX (window->priv->main_box),
+ window->priv->presentation_view,
+ FALSE, FALSE, 0);
+ gtk_widget_show (window->priv->presentation_view);
+
+ ev_window_update_presentation_action (window);
update_chrome_visibility (window);
-
- gtk_widget_grab_focus (window->priv->view);
+
+ gtk_widget_grab_focus (window->priv->presentation_view);
if (fullscreen_window)
gtk_window_fullscreen (GTK_WINDOW (window));
- g_signal_connect (window->priv->view,
- "motion-notify-event",
- G_CALLBACK (presentation_motion_notify_cb),
- window);
- g_signal_connect (window->priv->view,
- "leave-notify-event",
- G_CALLBACK (presentation_leave_notify_cb),
- window);
- presentation_set_timeout (window);
-
ev_application_screensaver_disable (EV_APP);
-
+
if (window->priv->metadata && !ev_window_is_empty (window))
ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE);
}
ev_window_stop_presentation (EvWindow *window,
gboolean unfullscreen_window)
{
- EvView *view = EV_VIEW (window->priv->view);
-
- if (!ev_view_get_presentation (view))
+ guint current_page;
+
+ if (!EV_WINDOW_IS_PRESENTATION (window))
return;
- g_object_set (G_OBJECT (window->priv->scrolled_window),
- "shadow-type", GTK_SHADOW_IN,
- NULL);
+ current_page = ev_view_presentation_get_current_page (EV_VIEW_PRESENTATION (window->priv->presentation_view));
+ ev_document_model_set_page (window->priv->model, current_page);
+
+ gtk_container_remove (GTK_CONTAINER (window->priv->main_box),
+ window->priv->presentation_view);
+ window->priv->presentation_view = NULL;
- ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
if (unfullscreen_window)
gtk_window_unfullscreen (GTK_WINDOW (window));
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) presentation_motion_notify_cb,
- window);
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) presentation_leave_notify_cb,
- window);
- presentation_clear_timeout (window);
+ gtk_widget_grab_focus (window->priv->view);
ev_application_screensaver_enable (EV_APP);
return;
ev_window_setup_gtk_settings (window);
- dpi = get_screen_dpi (GTK_WINDOW (window));
+ dpi = get_screen_dpi (window);
ev_document_model_set_min_scale (priv->model, MIN_SCALE * dpi / 72.0);
ev_document_model_set_max_scale (priv->model, MAX_SCALE * dpi / 72.0);
GdkEventWindowState *event)
{
EvWindow *window = EV_WINDOW (widget);
- EvView *view = EV_VIEW (window->priv->view);
if (GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event) {
GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event (widget, event);
return FALSE;
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
- if (ev_document_model_get_fullscreen (window->priv->model) || ev_view_get_presentation (view))
+ if (ev_document_model_get_fullscreen (window->priv->model) || EV_WINDOW_IS_PRESENTATION (window))
return FALSE;
ev_window_run_fullscreen (window);
} else {
if (ev_document_model_get_fullscreen (window->priv->model))
ev_window_stop_fullscreen (window, FALSE);
- else if (ev_view_get_presentation (view))
+ else if (EV_WINDOW_IS_PRESENTATION (window))
ev_window_stop_presentation (window, FALSE);
}
}
static void
-ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
+ev_window_cmd_view_inverted_colors (GtkAction *action, EvWindow *ev_window)
{
- 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);
+ gboolean inverted_colors = ev_document_model_get_inverted_colors (ev_window->priv->model);
+
+ ev_document_model_set_inverted_colors (ev_window->priv->model, !inverted_colors);
+}
+
+static void
+ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog,
+ gint response,
+ EvWindow *ev_window)
+{
+ EggEditableToolbar *toolbar;
+ gchar *toolbars_file;
+
+ toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
+ egg_editable_toolbar_set_edit_mode (toolbar, FALSE);
+
+ toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE),
+ "evince_toolbar.xml", NULL);
+ egg_toolbars_model_save_toolbars (egg_editable_toolbar_get_model (toolbar),
+ toolbars_file, "1.0");
+ g_free (toolbars_file);
+
gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
{
- GtkWidget *dialog;
- GtkWidget *editor;
+ GtkWidget *dialog;
+ GtkWidget *editor;
+ EggEditableToolbar *toolbar;
dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
- GTK_WINDOW (ev_window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_WINDOW (ev_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
+ GTK_RESPONSE_CLOSE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
-
+
+ toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar);
editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
- ev_application_get_toolbars_model (EV_APP));
+ egg_editable_toolbar_get_model (toolbar));
+
gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
-
+
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
- egg_editable_toolbar_set_edit_mode
- (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
+ egg_editable_toolbar_set_edit_mode (toolbar, TRUE);
g_signal_connect (dialog, "response",
G_CALLBACK (ev_window_cmd_edit_toolbar_cb),
gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
"ghelp:evince",
- GDK_CURRENT_TIME,
+ gtk_get_current_event_time (),
&error);
if (error) {
ev_window_error_message (ev_window, error,
gtk_widget_grab_focus (window->priv->view);
} else {
gboolean fullscreen;
- gboolean presentation;
fullscreen = ev_document_model_get_fullscreen (window->priv->model);
- g_object_get (window->priv->view,
- "presentation", &presentation,
- NULL);
if (fullscreen) {
ev_window_stop_fullscreen (window, TRUE);
- } else if (presentation) {
+ } else if (EV_WINDOW_IS_PRESENTATION (window)) {
ev_window_stop_presentation (window, TRUE);
gtk_widget_grab_focus (window->priv->view);
} else {
gtk_widget_grab_focus (window->priv->view);
}
- if (fullscreen && presentation)
+ if (fullscreen && EV_WINDOW_IS_PRESENTATION (window))
g_warning ("Both fullscreen and presentation set somehow");
}
}
gdouble zoom;
zoom = ev_document_model_get_scale (model);
- zoom *= 72.0 / get_screen_dpi (GTK_WINDOW (ev_window));
+ zoom *= 72.0 / get_screen_dpi (ev_window);
ev_metadata_set_double (ev_window->priv->metadata, "zoom", zoom);
}
}
ev_metadata_set_int (window->priv->metadata, "rotation",
rotation);
- ev_window_refresh_window_thumbnail (window, rotation);
+ ev_window_refresh_window_thumbnail (window);
}
static void
-ev_window_has_selection_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
+ev_window_update_inverted_colors_action (EvWindow *window)
{
- ev_window_update_actions (window);
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewInvertedColors");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_document_model_get_inverted_colors (window->priv->model));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_inverted_colors), window);
+}
+
+static void
+ev_window_inverted_colors_changed_cb (EvDocumentModel *model,
+ GParamSpec *pspec,
+ EvWindow *window)
+{
+ gboolean inverted_colors = ev_document_model_get_inverted_colors (model);
+
+ ev_window_update_inverted_colors_action (window);
+
+ if (window->priv->metadata && !ev_window_is_empty (window))
+ ev_metadata_set_boolean (window->priv->metadata, "inverted-colors",
+ inverted_colors);
+
+ ev_window_refresh_window_thumbnail (window);
}
static void
}
static char *
-build_comments_string (void)
-{
-#ifdef ENABLE_PDF
- PopplerBackend backend;
- const char *backend_name;
- const char *version;
-
- backend = poppler_get_backend ();
- version = poppler_get_version ();
- switch (backend) {
- case POPPLER_BACKEND_CAIRO:
- backend_name = "cairo";
- break;
- case POPPLER_BACKEND_SPLASH:
- backend_name = "splash";
- break;
- default:
- backend_name = "unknown";
- break;
+build_comments_string (EvDocument *document)
+{
+ gchar *comments = NULL;
+ EvDocumentBackendInfo info;
+
+ if (document && ev_document_get_backend_info (document, &info)) {
+ comments = g_strdup_printf (
+ _("Document Viewer\nUsing %s (%s)"),
+ info.name, info.version);
+ } else {
+ comments = g_strdup_printf (
+ _("Document Viewer"));
}
- return g_strdup_printf (_("Document Viewer.\n"
- "Using poppler %s (%s)"),
- version, backend_name);
-#else
- return g_strdup_printf (_("Document Viewer"));
-#endif
+ return comments;
}
static void
license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
_(license[2]), "\n", NULL);
- comments = build_comments_string ();
+
+ comments = build_comments_string (ev_window->priv->document);
gtk_show_about_dialog (
GTK_WINDOW (ev_window),
static void
ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
- if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
+ if (EV_WINDOW_IS_PRESENTATION (ev_window))
return;
update_chrome_flag (ev_window, EV_CHROME_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");
- if (!ev_view_get_presentation (view)) {
+ if (!EV_WINDOW_IS_PRESENTATION (ev_window)) {
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
GTK_WIDGET_VISIBLE (ev_sidebar));
gtk_action_set_visible (action, show_image);
}
+static void
+view_menu_annot_popup (EvWindow *ev_window,
+ EvAnnotation *annot)
+{
+ GtkAction *action;
+ gboolean show_annot = FALSE;
+
+ if (annot && EV_IS_ANNOTATION_ATTACHMENT (annot)) {
+ EvAttachment *attachment = EV_ANNOTATION_ATTACHMENT (annot)->attachment;
+
+ if (attachment) {
+ show_annot = TRUE;
+ 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 = NULL;
+ }
+ ev_window->priv->attach_list =
+ g_list_prepend (ev_window->priv->attach_list,
+ g_object_ref (attachment));
+ }
+ }
+
+ action = gtk_action_group_get_action (ev_window->priv->attachment_popup_action_group,
+ "OpenAttachment");
+ gtk_action_set_visible (action, show_annot);
+
+ action = gtk_action_group_get_action (ev_window->priv->attachment_popup_action_group,
+ "SaveAttachmentAs");
+ gtk_action_set_visible (action, show_annot);
+}
+
static gboolean
view_menu_popup_cb (EvView *view,
- GObject *object,
+ GList *items,
EvWindow *ev_window)
{
- if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
- return FALSE;
+ GList *l;
+ gboolean has_link = FALSE;
+ gboolean has_image = FALSE;
+ gboolean has_annot = FALSE;
+
+ for (l = items; l; l = g_list_next (l)) {
+ if (EV_IS_LINK (l->data)) {
+ view_menu_link_popup (ev_window, EV_LINK (l->data));
+ has_link = TRUE;
+ } else if (EV_IS_IMAGE (l->data)) {
+ view_menu_image_popup (ev_window, EV_IMAGE (l->data));
+ has_image = TRUE;
+ } else if (EV_IS_ANNOTATION (l->data)) {
+ view_menu_annot_popup (ev_window, EV_ANNOTATION (l->data));
+ has_annot = TRUE;
+ }
+ }
+
+ if (!has_link)
+ view_menu_link_popup (ev_window, NULL);
+ if (!has_image)
+ view_menu_image_popup (ev_window, NULL);
+ if (!has_annot)
+ view_menu_annot_popup (ev_window, NULL);
- view_menu_link_popup (ev_window,
- EV_IS_LINK (object) ? EV_LINK (object) : NULL);
- view_menu_image_popup (ev_window,
- EV_IS_IMAGE (object) ? EV_IMAGE (object) : NULL);
-
gtk_menu_popup (GTK_MENU (ev_window->priv->view_popup),
NULL, NULL, NULL, NULL,
3, gtk_get_current_event_time ());
if (mode == EV_SIZING_FREE) {
ev_document_model_set_scale (ev_window->priv->model,
- zoom * get_screen_dpi (GTK_WINDOW (ev_window)) / 72.0);
+ zoom * get_screen_dpi (ev_window) / 72.0);
}
}
static void
ev_window_finalize (GObject *object)
{
+ G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
+
if (ev_window_n_copies == 0) {
ev_application_shutdown (EV_APP);
} else {
ev_window_n_copies--;
}
-
- G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
}
static void
g_source_remove (priv->setup_document_idle);
priv->setup_document_idle = 0;
}
-
+
+#ifdef WITH_GCONF
+ if (priv->gconf_client) {
+ g_object_unref (priv->gconf_client);
+ priv->gconf_client = NULL;
+ }
+#endif
+
if (priv->monitor) {
g_object_unref (priv->monitor);
priv->monitor = NULL;
priv->history = NULL;
}
- if (priv->presentation_timeout_id > 0) {
- g_source_remove (priv->presentation_timeout_id);
- priv->presentation_timeout_id = 0;
- }
-
if (priv->print_queue) {
g_queue_free (priv->print_queue);
priv->print_queue = NULL;
g_object_unref (priv->view);
}
- if (!handled && !ev_view_get_presentation (EV_VIEW (priv->view))) {
+ if (!handled && !EV_WINDOW_IS_PRESENTATION (ev_window)) {
guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
if (priv->menubar_accel_keyval != 0 &&
{ "Help", NULL, N_("_Help") },
/* File menu */
- { "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
+ { "FileOpen", GTK_STOCK_OPEN, N_("_Open…"), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
{ "FileOpenCopy", NULL, N_("Op_en a Copy"), "<control>N",
N_("Open a copy of the current document in a new window"),
G_CALLBACK (ev_window_cmd_file_open_copy) },
- { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
+ { "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) },
- { "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Set_up..."), NULL,
- N_("Setup the page settings for printing"),
+ { "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Set_up…"), NULL,
+ N_("Set up the page settings for printing"),
G_CALLBACK (ev_window_cmd_file_print_setup) },
- { "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
+ { "FilePrint", GTK_STOCK_PRINT, N_("_Print…"), "<control>P",
N_("Print this document"),
G_CALLBACK (ev_window_cmd_file_print) },
{ "FileProperties", GTK_STOCK_PROPERTIES, N_("P_roperties"), "<alt>Return", NULL,
G_CALLBACK (ev_window_cmd_edit_copy) },
{ "EditSelectAll", GTK_STOCK_SELECT_ALL, N_("Select _All"), "<control>A", NULL,
G_CALLBACK (ev_window_cmd_edit_select_all) },
- { "EditFind", GTK_STOCK_FIND, N_("_Find..."), "<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,
{ "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), "<control>Right", NULL,
G_CALLBACK (ev_window_cmd_edit_rotate_right) },
+
/* View menu */
{ "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
N_("Enlarge the document"),
G_CALLBACK (ev_window_cmd_scroll_forward) },
{ "ShiftReturn", NULL, "", "<shift>Return", NULL,
G_CALLBACK (ev_window_cmd_scroll_backward) },
+ { "p", GTK_STOCK_GO_UP, "", "p", NULL,
+ G_CALLBACK (ev_window_cmd_go_previous_page) },
+ { "n", GTK_STOCK_GO_DOWN, "", "n", NULL,
+ G_CALLBACK (ev_window_cmd_go_next_page) },
{ "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,
{ "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL,
N_("Make the current document fill the window width"),
G_CALLBACK (ev_window_cmd_view_page_width) },
+ { "ViewInvertedColors", EV_STOCK_INVERTED_COLORS, N_("_Inverted Colors"), "<control>I",
+ N_("Show page contents with the colors inverted"),
+ G_CALLBACK (ev_window_cmd_view_inverted_colors) },
+
};
/* Popups specific items */
NULL, G_CALLBACK (ev_view_popup_cmd_open_link_new_window) },
{ "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
NULL, G_CALLBACK (ev_view_popup_cmd_copy_link_address) },
- { "SaveImageAs", NULL, N_("_Save Image As..."), NULL,
+ { "SaveImageAs", NULL, N_("_Save Image As…"), NULL,
NULL, G_CALLBACK (ev_view_popup_cmd_save_image_as) },
{ "CopyImage", NULL, N_("Copy _Image"), NULL,
NULL, G_CALLBACK (ev_view_popup_cmd_copy_image) },
};
static const GtkActionEntry attachment_popup_entries [] = {
- { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open..."), NULL,
+ { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open Attachment"), NULL,
NULL, G_CALLBACK (ev_attachment_popup_cmd_open_attachment) },
- { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
+ { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save Attachment As…"), NULL,
NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
};
action = g_object_new (EV_TYPE_OPEN_RECENT_ACTION,
"name", "FileOpenRecent",
- "label", _("_Open..."),
+ "label", _("_Open…"),
"tooltip", _("Open an existing document"),
"stock_id", GTK_STOCK_OPEN,
NULL);
context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
gtk_window_get_screen (GTK_WINDOW (window)));
- gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+ gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+ gtk_get_current_event_time ());
file_list.data = file;
if (!g_app_info_launch (app_info, &file_list, context, &error)) {
g_object_unref (app_info);
g_object_unref (file);
+ /* FIXMEchpe: unref launch context? */
/* According to the PDF spec filename can be an executable. I'm not sure
allowing to launch executables is a good idea though. -- marco */
gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
gtk_window_get_screen (GTK_WINDOW (window)));
gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
- GDK_CURRENT_TIME);
+ gtk_get_current_event_time ());
if (!g_strstr_len (uri, strlen (uri), "://") &&
!g_str_has_prefix (uri, "mailto:")) {
- gchar *http;
-
- /* Not a valid uri, assuming it's http */
- http = g_strdup_printf ("http://%s", uri);
- ret = g_app_info_launch_default_for_uri (http, NULL, &error);
- g_free (http);
+ gchar *new_uri;
+
+ /* Not a valid uri, assume http if it starts with www */
+ if (g_str_has_prefix (uri, "www.")) {
+ new_uri = g_strdup_printf ("http://%s", uri);
+ } else {
+ GFile *file, *parent;
+
+ file = g_file_new_for_uri (window->priv->uri);
+ parent = g_file_get_parent (file);
+ g_object_unref (file);
+ if (parent) {
+ gchar *parent_uri = g_file_get_uri (parent);
+
+ new_uri = g_build_filename (parent_uri, uri, NULL);
+ g_free (parent_uri);
+ g_object_unref (parent);
+ } else {
+ new_uri = g_strdup_printf ("file:///%s", uri);
+ }
+ }
+ ret = g_app_info_launch_default_for_uri (new_uri, context, &error);
+ g_free (new_uri);
} else {
- ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
+ ret = g_app_info_launch_default_for_uri (uri, context, &error);
}
-
+
if (ret == FALSE) {
- ev_window_error_message (window, error,
+ ev_window_error_message (window, error,
"%s", _("Unable to open external link"));
g_error_free (error);
}
+
+ /* FIXMEchpe: unref launch context? */
}
static void
ev_link_action_get_dest (action),
0,
NULL,
- GDK_CURRENT_TIME);
+ gtk_get_current_event_time ());
g_free (uri);
}
if (is_native) {
filename = g_file_get_path (target_file);
} else {
- filename = ev_tmp_filename ("saveimage");
+ /* Create a temporary local file to save to */
+ if (ev_mkstemp ("saveimage.XXXXXX", &filename, &error) == -1)
+ goto has_error;
}
ev_document_doc_mutex_lock ();
g_free (file_format);
g_object_unref (pixbuf);
+ has_error:
if (error) {
ev_window_error_message (ev_window, error,
"%s", _("The image could not be saved."));
attachment = (EvAttachment *) l->data;
- ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
+ ev_attachment_open (attachment, screen, gtk_get_current_event_time (), &error);
if (error) {
ev_window_error_message (window, error,
for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
- GFile *save_to;
+ GFile *save_to = NULL;
GError *error = NULL;
attachment = (EvAttachment *) l->data;
if (is_native) {
if (is_dir) {
save_to = g_file_get_child (target_file,
+ /* FIXMEchpe: file name encoding! */
ev_attachment_get_name (attachment));
} else {
save_to = g_object_ref (target_file);
}
} else {
- save_to = ev_tmp_file_get ("saveattachment");
+ save_to = ev_mkstemp_file ("saveattachment.XXXXXX", &error);
}
- ev_attachment_save (attachment, save_to, &error);
+ if (save_to)
+ ev_attachment_save (attachment, save_to, &error);
if (error) {
ev_window_error_message (ev_window, error,
}
}
+static EggToolbarsModel *
+get_toolbars_model (void)
+{
+ EggToolbarsModel *toolbars_model;
+ gchar *toolbars_file;
+ gchar *toolbars_path;
+ gint i;
+
+ toolbars_model = egg_toolbars_model_new ();
+
+ toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE),
+ "evince_toolbar.xml", NULL);
+ toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP),
+ "evince-toolbar.xml", NULL);
+ egg_toolbars_model_load_names (toolbars_model, toolbars_path);
+
+ if (!egg_toolbars_model_load_toolbars (toolbars_model, toolbars_file)) {
+ egg_toolbars_model_load_toolbars (toolbars_model, toolbars_path);
+ goto skip_conversion;
+ }
+
+ /* Open item doesn't exist anymore,
+ * convert it to OpenRecent for compatibility
+ */
+ for (i = 0; i < egg_toolbars_model_n_items (toolbars_model, 0); i++) {
+ const gchar *item;
+
+ item = egg_toolbars_model_item_nth (toolbars_model, 0, i);
+ if (g_ascii_strcasecmp (item, "FileOpen") == 0) {
+ egg_toolbars_model_remove_item (toolbars_model, 0, i);
+ egg_toolbars_model_add_item (toolbars_model, 0, i,
+ "FileOpenRecent");
+ egg_toolbars_model_save_toolbars (toolbars_model, toolbars_file, "1.0");
+ break;
+ }
+ }
+
+ skip_conversion:
+ g_free (toolbars_file);
+ g_free (toolbars_path);
+
+ egg_toolbars_model_set_flags (toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE);
+
+ return toolbars_model;
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *sidebar_widget;
+ GtkWidget *menuitem;
+ EggToolbarsModel *toolbars_model;
GObject *mpkeys;
gchar *ui_path;
gdouble dpi;
g_error_free (error);
}
g_free (ui_path);
-
+
+#if GTK_CHECK_VERSION (2, 17, 4)
+ {
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (ev_window->priv->action_group,
+ "FilePageSetup");
+ g_object_set (action, "visible", FALSE, "sensitive", FALSE, NULL);
+ }
+#endif
+
ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
ev_window->priv->recent_action_group = NULL;
ev_window->priv->recent_ui_id = 0;
gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
ev_window->priv->menubar,
FALSE, FALSE, 0);
-
- ev_window->priv->toolbar = GTK_WIDGET
- (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", ev_window->priv->ui_manager,
- "popup-path", "/ToolbarPopup",
- "model", ev_application_get_toolbars_model (EV_APP),
- NULL));
+ menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/MainMenu/EditMenu/EditRotateLeftMenu");
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
+ menuitem = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/MainMenu/EditMenu/EditRotateRightMenu");
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
+
+ toolbars_model = get_toolbars_model ();
+ ev_window->priv->toolbar = GTK_WIDGET
+ (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
+ "ui-manager", ev_window->priv->ui_manager,
+ "popup-path", "/ToolbarPopup",
+ "model", toolbars_model,
+ NULL));
+ g_object_unref (toolbars_model);
egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
"DefaultToolBar");
ev_window->priv->view = ev_view_new ();
ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model);
- dpi = get_screen_dpi (GTK_WINDOW (ev_window));
+ dpi = get_screen_dpi (ev_window);
ev_document_model_set_min_scale (ev_window->priv->model, MIN_SCALE * dpi / 72.0);
ev_document_model_set_max_scale (ev_window->priv->model, MAX_SCALE * dpi / 72.0);
ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
g_signal_connect_object (ev_window->priv->view, "handle-link",
G_CALLBACK (view_handle_link_cb),
ev_window, 0);
- g_signal_connect_object (ev_window->priv->view,
- "popup",
+ g_signal_connect_object (ev_window->priv->view, "popup",
G_CALLBACK (view_menu_popup_cb),
ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb),
+ ev_window, 0);
gtk_widget_show (ev_window->priv->view);
gtk_widget_show (ev_window->priv->password_view);
"notify::dual-page",
G_CALLBACK (ev_window_dual_mode_changed_cb),
ev_window);
-
- /* Connect to view signals */
- g_signal_connect (ev_window->priv->view,
- "notify::has-selection",
- G_CALLBACK (ev_window_has_selection_changed_cb),
+ g_signal_connect (ev_window->priv->model,
+ "notify::inverted-colors",
+ G_CALLBACK (ev_window_inverted_colors_changed_cb),
ev_window);
/* Connect sidebar signals */