#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (2, 14, 0)
+#include <gtk/gtkunixprint.h>
+#else
#include <gtk/gtkprintunixdialog.h>
+#endif
#include <gconf/gconf-client.h>
#include "egg-editable-toolbar.h"
#include "ev-document-fonts.h"
#include "ev-document-images.h"
#include "ev-document-links.h"
-#include "ev-document-security.h"
#include "ev-document-thumbnails.h"
#include "ev-file-exporter.h"
#include "ev-file-helpers.h"
#include "ev-navigation-action.h"
#include "ev-open-recent-action.h"
#include "ev-page-action.h"
-#include "ev-password.h"
#include "ev-password-view.h"
#include "ev-properties-dialog.h"
#include "ev-sidebar-attachments.h"
#include "ev-sidebar-links.h"
#include "ev-sidebar-page.h"
#include "ev-sidebar-thumbnails.h"
+#include "ev-sidebar-layers.h"
#include "ev-stock-icons.h"
#include "ev-utils.h"
+#include "ev-keyring.h"
#include "ev-view.h"
#include "ev-window.h"
#include "ev-window-title.h"
GtkWidget *sidebar_thumbs;
GtkWidget *sidebar_links;
GtkWidget *sidebar_attachments;
+ GtkWidget *sidebar_layers;
/* Dialogs */
GtkWidget *properties;
GtkWidget *print_dialog;
- GtkWidget *password_dialog;
/* UI Builders */
GtkActionGroup *action_group;
/* Document */
char *uri;
+ glong uri_mtime;
char *local_uri;
EvLinkDest *dest;
gboolean unlink_temp_file;
gboolean in_reload;
EvFileMonitor *monitor;
+ guint setup_document_idle;
EvDocument *document;
EvHistory *history;
EvJob *thumbnail_job;
EvJob *save_job;
EvJob *print_job;
+ EvJob *find_job;
/* Printing */
gboolean print_preview;
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define ATTACHMENTS_SIDEBAR_ID "attachments"
+#define LAYERS_SIDEBAR_ID "layers"
static const gchar *document_print_settings[] = {
GTK_PRINT_SETTINGS_N_COPIES,
static void view_handle_link_cb (EvView *view,
EvLink *link,
EvWindow *window);
+static void ev_window_update_find_status_message (EvWindow *ev_window);
static void ev_window_cmd_edit_find (GtkAction *action,
EvWindow *ev_window);
static void find_bar_search_changed_cb (EggFindBar *find_bar,
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,
+ const gchar *key,
+ gpointer user_data);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
int n_pages = 0, page = -1;
gboolean has_pages = FALSE;
gboolean presentation_mode;
+ gboolean can_find_in_page = FALSE;
if (ev_window->priv->document && ev_window->priv->page_cache) {
page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
has_pages = n_pages > 0;
}
+ can_find_in_page = (ev_window->priv->find_job &&
+ ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
+
ev_window_set_action_sensitive (ev_window, "EditCopy",
has_pages &&
ev_view_get_has_selection (view));
ev_window_set_action_sensitive (ev_window, "EditFindNext",
- ev_view_can_find_next (view));
+ has_pages && can_find_in_page);
ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
- ev_view_can_find_previous (view));
+ has_pages && can_find_in_page);
presentation_mode = ev_view_get_presentation (view);
}
static void
-ev_window_error_message (GtkWindow *window, const gchar *msg, GError *error)
+ev_window_error_message (EvWindow *window,
+ GError *error,
+ const gchar *format,
+ ...)
{
GtkWidget *area;
+ va_list args;
+ gchar *msg = NULL;
- if (EV_WINDOW (window)->priv->message_area)
+ if (window->priv->message_area)
return;
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
area = ev_message_area_new (GTK_MESSAGE_ERROR,
msg,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CANCEL,
NULL);
+ g_free (msg);
+
if (error)
ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message);
g_signal_connect (area, "response",
G_CALLBACK (ev_window_message_area_response_cb),
window);
gtk_widget_show (area);
- ev_window_set_message_area (EV_WINDOW (window), area);
+ ev_window_set_message_area (window, area);
}
static void
-ev_window_warning_message (GtkWindow *window, const gchar *msg)
+ev_window_warning_message (EvWindow *window,
+ const gchar *format,
+ ...)
{
GtkWidget *area;
+ va_list args;
+ gchar *msg = NULL;
- if (EV_WINDOW (window)->priv->message_area)
+ if (window->priv->message_area)
return;
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
area = ev_message_area_new (GTK_MESSAGE_WARNING,
msg,
GTK_STOCK_CLOSE,
GTK_RESPONSE_CANCEL,
NULL);
+ g_free (msg);
g_signal_connect (area, "response",
G_CALLBACK (ev_window_message_area_response_cb),
window);
gtk_widget_show (area);
- ev_window_set_message_area (EV_WINDOW (window), area);
-}
-
-static void
-find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
-{
- ev_window_update_actions (ev_window);
+ ev_window_set_message_area (window, area);
}
static void
EvWindow *ev_window)
{
ev_window_update_actions (ev_window);
-
+
+ ev_window_update_find_status_message (ev_window);
+
if (!ev_window_is_empty (ev_window))
ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
}
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, };
g_value_unset(&sidebar_size);
}
- if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
+ if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, TRUE)) {
const char *page_id = g_value_get_string (&sidebar_page);
-
+
if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
- } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
- } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+ } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+ } else if (strcmp (page_id, LAYERS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
}
g_value_unset (&sidebar_page);
- } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
- ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (document) {
+ if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (layers), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), layers);
+ }
}
if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
EvDocument *document = ev_window->priv->document;
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
GtkAction *action;
-
- if (EV_IS_DOCUMENT_FIND (document)) {
- g_signal_connect_object (G_OBJECT (document),
- "find_changed",
- G_CALLBACK (find_changed_cb),
- ev_window, 0);
- }
+
+ ev_window->priv->setup_document_idle = 0;
ev_window_refresh_window_thumbnail (ev_window, 0);
if (ev_window->priv->properties) {
ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->uri,
ev_window->priv->document);
}
if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
ev_view_set_document (view, document);
} else {
- ev_window_warning_message (GTK_WINDOW (ev_window),
+ ev_window_warning_message (ev_window, "%s",
_("The document contains no pages"));
}
- g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
+ if (ev_window->priv->setup_document_idle > 0)
+ g_source_remove (ev_window->priv->setup_document_idle);
+ ev_window->priv->setup_document_idle = g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
}
static void
}
static void
-password_dialog_response (GtkWidget *password_dialog,
- gint response_id,
- EvWindow *ev_window)
+ev_window_password_view_unlock (EvWindow *ev_window)
{
- char *password;
+ const gchar *password;
- if (response_id == GTK_RESPONSE_OK) {
-
- password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog));
- if (password) {
- ev_document_doc_mutex_lock ();
- ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->load_job->document),
- password);
- ev_document_doc_mutex_unlock ();
- }
- g_free (password);
-
- ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
-
- ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
- ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
-
- gtk_widget_destroy (password_dialog);
-
- return;
- }
-
- gtk_widget_set_sensitive (ev_window->priv->password_view, TRUE);
- gtk_widget_destroy (password_dialog);
-}
-
-/* Called either by ev_window_load_job_cb or by the "unlock" callback on the
- * password_view page. It assumes that ev_window->priv->password_* has been set
- * correctly. These are cleared by password_dialog_response() */
-
-static void
-ev_window_popup_password_dialog (EvWindow *ev_window)
-{
g_assert (ev_window->priv->load_job);
- gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
-
- ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
- ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_PASSWORD);
-
- if (ev_window->priv->password_dialog == NULL) {
- ev_window->priv->password_dialog =
- g_object_new (EV_TYPE_PASSWORD_DIALOG, "uri", ev_window->priv->uri, NULL);
- gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->password_dialog), GTK_WINDOW (ev_window));
-
- g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
- (gpointer) &(ev_window->priv->password_dialog));
- g_signal_connect (ev_window->priv->password_dialog,
- "response",
- G_CALLBACK (password_dialog_response),
- ev_window);
- gtk_widget_show (ev_window->priv->password_dialog);
- } else {
- ev_password_dialog_set_bad_pass (EV_PASSWORD_DIALOG (ev_window->priv->password_dialog));
- }
+ password = ev_password_view_get_password (EV_PASSWORD_VIEW (ev_window->priv->password_view));
+ ev_job_load_set_password (EV_JOB_LOAD (ev_window->priv->load_job), password);
+ ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
}
static void
* function should _not_ necessarily expect those to exist after being
* called. */
static void
-ev_window_load_job_cb (EvJob *job,
- gpointer data)
+ev_window_load_job_cb (EvJob *job,
+ gpointer data)
{
EvWindow *ev_window = EV_WINDOW (data);
EvDocument *document = EV_JOB (job)->document;
ev_window_add_recent (ev_window, ev_window->priv->uri);
}
+ ev_window_title_set_type (ev_window->priv->title,
+ EV_WINDOW_TITLE_DOCUMENT);
+ if (job_load->password) {
+ GPasswordSave flags;
+
+ flags = ev_password_view_get_password_save_flags (
+ EV_PASSWORD_VIEW (ev_window->priv->password_view));
+ ev_keyring_save_password (ev_window->priv->uri,
+ job_load->password,
+ flags);
+ }
+
if (job_load->dest) {
EvLink *link;
EvLinkAction *link_action;
break;
}
- /* Restart the search after reloading */
- if (ev_window->priv->in_reload) {
- GtkWidget *widget;
-
- widget = gtk_window_get_focus (GTK_WINDOW (ev_window));
- if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
- find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
- NULL, ev_window);
- }
- } else if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) {
+ if (job_load->search_string && EV_IS_DOCUMENT_FIND (document)) {
ev_window_cmd_edit_find (NULL, ev_window);
egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar),
job_load->search_string);
}
/* Create a monitor for the document */
- ev_window->priv->monitor = ev_file_monitor_new (job_load->uri);
+ ev_window->priv->monitor = ev_file_monitor_new (ev_window->priv->uri);
g_signal_connect_swapped (G_OBJECT (ev_window->priv->monitor), "changed",
G_CALLBACK (ev_window_document_changed),
ev_window);
if (job->error->domain == EV_DOCUMENT_ERROR &&
job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
- GFile *file;
- gchar *base_name;
-
+ gchar *password;
+
setup_view_from_metadata (ev_window);
+
+ /* First look whether password is in keyring */
+ password = ev_keyring_lookup_password (ev_window->priv->uri);
+ if (password) {
+ if (job_load->password && strcmp (password, job_load->password) == 0) {
+ /* Password in kering is wrong */
+ ev_job_load_set_password (job_load, NULL);
+ /* FIXME: delete password from keyring? */
+ } else {
+ ev_job_load_set_password (job_load, password);
+ ev_job_scheduler_push_job (job, EV_JOB_PRIORITY_NONE);
+ g_free (password);
+ return;
+ }
+
+ g_free (password);
+ }
+
+ /* We need to ask the user for a password */
+ ev_window_title_set_uri (ev_window->priv->title,
+ ev_window->priv->uri);
+ ev_window_title_set_type (ev_window->priv->title,
+ EV_WINDOW_TITLE_PASSWORD);
+
+ ev_password_view_set_uri (EV_PASSWORD_VIEW (ev_window->priv->password_view),
+ job_load->uri);
- file = g_file_new_for_uri (job_load->uri);
- base_name = g_file_get_basename (file);
- ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
- base_name);
- g_object_unref (file);
- g_free (base_name);
ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
-
- ev_window_popup_password_dialog (ev_window);
+
+ ev_job_load_set_password (job_load, NULL);
+ ev_password_view_ask_password (EV_PASSWORD_VIEW (ev_window->priv->password_view));
} else {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("Unable to open document"),
- job->error);
+ ev_window_error_message (ev_window, job->error,
+ "%s", _("Unable to open document"));
ev_window_clear_load_job (ev_window);
}
}
ev_window->priv->in_reload = FALSE;
return;
}
-
+
ev_window_set_document (ev_window, job->document);
/* Restart the search after reloading */
find_bar_search_changed_cb (EGG_FIND_BAR (ev_window->priv->find_bar),
NULL, ev_window);
}
-
+
ev_window_clear_reload_job (ev_window);
ev_window->priv->in_reload = FALSE;
}
static void
ev_window_close_dialogs (EvWindow *ev_window)
{
- if (ev_window->priv->password_dialog)
- gtk_widget_destroy (ev_window->priv->password_dialog);
- ev_window->priv->password_dialog = NULL;
-
if (ev_window->priv->print_dialog)
gtk_widget_destroy (ev_window->priv->print_dialog);
ev_window->priv->print_dialog = NULL;
{
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
ev_window->priv->in_reload = FALSE;
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("Unable to open document"),
- error);
+ ev_window_error_message (ev_window, error,
+ "%s", _("Unable to open document"));
g_free (ev_window->priv->local_uri);
ev_window->priv->local_uri = NULL;
+ ev_window->priv->uri_mtime = 0;
+}
+
+static void
+set_uri_mtime (GFile *source,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GFileInfo *info;
+ GError *error = NULL;
+
+ info = g_file_query_info_finish (source, async_result, &error);
+
+ if (error) {
+ ev_window->priv->uri_mtime = 0;
+ g_error_free (error);
+ } else {
+ GTimeVal mtime;
+
+ g_file_info_get_modification_time (info, &mtime);
+ ev_window->priv->uri_mtime = mtime.tv_sec;
+ g_object_unref (info);
+ }
+
+ g_object_unref (source);
}
static void
g_file_copy_finish (source, async_result, &error);
if (!error) {
ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
- g_object_unref (source);
-
+ g_file_query_info_async (source,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ 0, G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback)set_uri_mtime,
+ ev_window);
return;
}
}
static void
-ev_window_reload_document (EvWindow *ev_window)
+ev_window_reload_local (EvWindow *ev_window)
{
const gchar *uri;
-
- ev_window_clear_reload_job (ev_window);
- ev_window->priv->in_reload = TRUE;
uri = ev_window->priv->local_uri ? ev_window->priv->local_uri : ev_window->priv->uri;
ev_window->priv->reload_job = ev_job_load_new (uri, NULL, 0, NULL);
ev_job_scheduler_push_job (ev_window->priv->reload_job, EV_JOB_PRIORITY_NONE);
}
+static void
+reload_remote_copy_ready_cb (GFile *remote,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ g_file_copy_finish (remote, async_result, NULL);
+ ev_window_reload_local (ev_window);
+ g_object_unref (remote);
+}
+
+static void
+query_remote_uri_mtime_cb (GFile *remote,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GFileInfo *info;
+ GTimeVal mtime;
+ GError *error = NULL;
+
+ info = g_file_query_info_finish (remote, async_result, &error);
+ if (error) {
+ g_error_free (error);
+ g_object_unref (remote);
+ ev_window_reload_local (ev_window);
+
+ return;
+ }
+
+ g_file_info_get_modification_time (info, &mtime);
+ if (ev_window->priv->uri_mtime != mtime.tv_sec) {
+ GFile *target_file;
+
+ /* Remote file has changed */
+ ev_window->priv->uri_mtime = mtime.tv_sec;
+ target_file = g_file_new_for_uri (ev_window->priv->local_uri);
+ g_file_copy_async (remote, target_file,
+ G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT, NULL,
+ NULL, NULL, /* no progress callback */
+ (GAsyncReadyCallback) reload_remote_copy_ready_cb,
+ ev_window);
+ g_object_unref (target_file);
+ } else {
+ g_object_unref (remote);
+ ev_window_reload_local (ev_window);
+ }
+
+ g_object_unref (info);
+}
+
+static void
+ev_window_reload_remote (EvWindow *ev_window)
+{
+ GFile *remote;
+
+ remote = g_file_new_for_uri (ev_window->priv->uri);
+ /* Reload the remote uri only if it has changed */
+ g_file_query_info_async (remote,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ 0, G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback)query_remote_uri_mtime_cb,
+ ev_window);
+}
+
+static void
+ev_window_reload_document (EvWindow *ev_window)
+{
+ ev_window_clear_reload_job (ev_window);
+ ev_window->priv->in_reload = TRUE;
+
+ if (ev_window->priv->local_uri) {
+ ev_window_reload_remote (ev_window);
+ } else {
+ ev_window_reload_local (ev_window);
+ }
+}
+
static void
file_open_dialog_response_cb (GtkWidget *chooser,
gint response_id,
new_filename = ev_window_create_tmp_symlink (old_filename, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (window),
- _("Cannot open a copy."),
- error);
-
+ ev_window_error_message (window, error,
+ "%s", _("Cannot open a copy."));
g_error_free (error);
g_free (old_filename);
g_free (new_filename);
GFile *dst)
{
EvWindow *window;
- GtkWidget *dialog;
gchar *name;
GError *error = NULL;
return;
}
- window = g_object_get_data (G_OBJECT (dst), "ev-window");
+ window = EV_WINDOW (g_object_get_data (G_OBJECT (dst), "ev-window"));
name = g_file_get_basename (dst);
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("The file could not be saved as “%s”."),
- name);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", error->message);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (dialog);
+ ev_window_error_message (window, error,
+ _("The file could not be saved as “%s”."),
+ name);
ev_tmp_file_unlink (src);
-
g_free (name);
g_error_free (error);
}
EvWindow *window)
{
if (ev_job_is_failed (job)) {
- gchar *msg;
-
- msg = g_strdup_printf (_("The file could not be saved as “%s”."),
- EV_JOB_SAVE (job)->uri);
- ev_window_error_message (GTK_WINDOW (window), msg, job->error);
- g_free (msg);
+ ev_window_error_message (window, job->error,
+ _("The file could not be saved as “%s”."),
+ EV_JOB_SAVE (job)->uri);
}
ev_window_clear_save_job (window);
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),
- "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ ev_window_error_message (window, error,
+ "%s", _("Failed to print document"));
} else {
/* If printed successfully, save print settings */
ev_application_set_print_settings (EV_APP,
ev_application_set_print_settings (EV_APP,
window->priv->print_settings);
-#if GTK_CHECK_VERSION (2, 11, 0)
print_settings_file = ev_tmp_filename ("print-settings");
gtk_print_settings_to_file (settings, print_settings_file, NULL);
-#endif
+
uri = g_filename_to_uri (filename, NULL, NULL);
ev_application_open_uri_at_dest (EV_APP,
uri,
GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
if (!gtk_printer_accepts_ps (window->priv->printer)) {
- GtkWidget *msgdialog;
-
- msgdialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Printing is not supported on this printer."));
-
- gtk_dialog_run (GTK_DIALOG (msgdialog));
- gtk_widget_destroy (msgdialog);
-
+ ev_window_error_message (window, NULL, "%s",
+ _("Printing is not supported on this printer."));
return FALSE;
}
if (ev_window->priv->properties == NULL) {
ev_window->priv->properties = ev_properties_dialog_new ();
ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
+ ev_window->priv->uri,
ev_window->priv->document);
g_object_add_weak_pointer (G_OBJECT (ev_window->priv->properties),
(gpointer) &(ev_window->priv->properties));
static void
ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
+ ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_FORWARD, FALSE);
}
static void
ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
+ ev_view_scroll (EV_VIEW (window->priv->view), GTK_SCROLL_PAGE_BACKWARD, FALSE);
}
static void
presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (presentation) {
ev_window_run_presentation (window);
- } else {
- ev_window_stop_presentation (window, TRUE);
}
}
action = gtk_action_group_get_action (window->priv->action_group,
"PreviewPrint");
-#if GTK_CHECK_VERSION (2, 11, 0)
gtk_action_set_visible (action, TRUE);
-#else
- gtk_action_set_visible (action, FALSE);
-#endif
update_chrome_visibility (window);
}
ev_view_previous_page (EV_VIEW (ev_window->priv->view));
}
-void
-ev_window_go_previous_page (EvWindow *ev_window)
-{
- ev_window_cmd_go_previous_page (NULL, ev_window);
-}
-
static void
ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
{
ev_view_next_page (EV_VIEW (ev_window->priv->view));
}
-void
-ev_window_go_next_page (EvWindow *ev_window)
-{
- ev_window_cmd_go_next_page (NULL, ev_window);
-}
-
static void
ev_window_cmd_go_first_page (GtkAction *action, EvWindow *ev_window)
{
ev_page_cache_set_current_page (ev_window->priv->page_cache, 0);
}
-void
-ev_window_go_first_page (EvWindow *ev_window)
-{
- ev_window_cmd_go_first_page (NULL, ev_window);
-}
-
static void
ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
{
ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
}
-void
-ev_window_go_last_page (EvWindow *ev_window)
-{
- ev_window_cmd_go_last_page (NULL, ev_window);
-}
-
static void
ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window)
{
ev_view_autoscroll_start (EV_VIEW (ev_window->priv->view));
}
+#if GTK_CHECK_VERSION (2, 14, 0)
+static void
+ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
+ "ghelp:evince",
+ GDK_CURRENT_TIME,
+ &error);
+ if (error) {
+ ev_window_error_message (ev_window, error,
+ "%s", _("There was an error displaying help"));
+ g_error_free (error);
+ }
+}
+#else /* !GTK_CHECK_VERSION (2, 14, 0) */
static void
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
}
g_free (command);
}
+#endif /* GTK_CHECK_VERSION (2, 14, 0) */
static void
ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
ev_window_run_presentation (window);
}
-void
-ev_window_start_presentation (EvWindow *ev_window)
-{
- ev_window_run_presentation (ev_window);
-}
-
static gboolean
ev_window_enumerate_printer_cb (GtkPrinter *printer,
EvWindow *window)
GError *error)
{
if (error) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Failed to print document"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ ev_window_error_message (window, error,
+ "%s", _("Failed to print document"));
}
g_object_unref (print_job);
{
EvWindowPrivate *priv = window->priv;
GtkPrintSettings *print_settings = NULL;
-#if GTK_CHECK_VERSION (2, 11, 0)
const gchar *print_settings_file = priv->print_settings_file;
if (print_settings_file) {
}
}
}
-#endif /* GTK 2.11.0 */
if (!print_settings)
print_settings = gtk_print_settings_new ();
id = THUMBNAILS_SIDEBAR_ID;
} else if (current_page == ev_window->priv->sidebar_attachments) {
id = ATTACHMENTS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_layers) {
+ id = LAYERS_SIDEBAR_ID;
} else {
g_assert_not_reached();
}
}
static void
-view_find_status_changed_cb (EvView *view,
- GParamSpec *pspec,
- EvWindow *ev_window)
+ev_window_update_find_status_message (EvWindow *ev_window)
+{
+ gchar *message;
+
+ if (!ev_window->priv->find_job)
+ return;
+
+ if (ev_job_is_finished (ev_window->priv->find_job)) {
+ gint n_results;
+
+ n_results = ev_job_find_get_n_results (EV_JOB_FIND (ev_window->priv->find_job),
+ ev_page_cache_get_current_page (ev_window->priv->page_cache));
+ /* TRANS: Sometimes this could be better translated as
+ "%d hit(s) on this page". Therefore this string
+ contains plural cases. */
+ message = g_strdup_printf (ngettext ("%d found on this page",
+ "%d found on this page",
+ n_results),
+ n_results);
+ } else {
+ gdouble percent;
+
+ percent = ev_job_find_get_progress (EV_JOB_FIND (ev_window->priv->find_job));
+ message = g_strdup_printf (_("%3d%% remaining to search"),
+ (gint) ((1.0 - percent) * 100));
+ }
+
+ egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), message);
+ g_free (message);
+}
+
+static void
+ev_window_find_job_finished_cb (EvJobFind *job,
+ EvWindow *ev_window)
+{
+ ev_window_update_find_status_message (ev_window);
+}
+
+static void
+ev_window_find_job_updated_cb (EvJobFind *job,
+ gint page,
+ EvWindow *ev_window)
+{
+ ev_window_update_actions (ev_window);
+
+ ev_view_find_changed (EV_VIEW (ev_window->priv->view),
+ ev_job_find_get_results (job),
+ page);
+ ev_window_update_find_status_message (ev_window);
+}
+
+static void
+ev_window_clear_find_job (EvWindow *ev_window)
{
- const char *text;
+ if (ev_window->priv->find_job != NULL) {
+ if (!ev_job_is_finished (ev_window->priv->find_job))
+ ev_job_cancel (ev_window->priv->find_job);
- text = ev_view_get_find_status (view);
- egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
- text);
+ g_signal_handlers_disconnect_by_func (ev_window->priv->find_job,
+ ev_window_find_job_finished_cb,
+ ev_window);
+ g_signal_handlers_disconnect_by_func (ev_window->priv->find_job,
+ ev_window_find_job_updated_cb,
+ ev_window);
+ g_object_unref (ev_window->priv->find_job);
+ ev_window->priv->find_job = NULL;
+ }
}
static void
EvWindow *ev_window)
{
ev_view_find_cancel (EV_VIEW (ev_window->priv->view));
+ ev_window_clear_find_job (ev_window);
update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
update_chrome_visibility (ev_window);
}
gboolean case_sensitive;
const char *search_string;
+ if (!ev_window->priv->document || !EV_IS_DOCUMENT_FIND (ev_window->priv->document))
+ return;
+
/* Either the string or case sensitivity could have changed. */
-
case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
- ev_view_search_changed (EV_VIEW(ev_window->priv->view));
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
- if (ev_window->priv->document &&
- EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- if (search_string && search_string[0]) {
- ev_document_doc_mutex_lock ();
- ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
- ev_page_cache_get_current_page (ev_window->priv->page_cache),
- search_string,
- case_sensitive);
- ev_document_doc_mutex_unlock ();
- } else {
- ev_document_doc_mutex_lock ();
- ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
- ev_document_doc_mutex_unlock ();
-
- ev_window_update_actions (ev_window);
- egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
- NULL);
- gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
- }
+ ev_window_clear_find_job (ev_window);
+
+ if (search_string && search_string[0]) {
+ ev_window->priv->find_job = ev_job_find_new (ev_window->priv->document,
+ ev_page_cache_get_current_page (ev_window->priv->page_cache),
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache),
+ search_string,
+ case_sensitive);
+ g_signal_connect (ev_window->priv->find_job, "finished",
+ G_CALLBACK (ev_window_find_job_finished_cb),
+ ev_window);
+ g_signal_connect (ev_window->priv->find_job, "updated",
+ G_CALLBACK (ev_window_find_job_updated_cb),
+ ev_window);
+ ev_job_scheduler_push_job (ev_window->priv->find_job, EV_JOB_PRIORITY_NONE);
+ } else {
+ ev_window_update_actions (ev_window);
+ egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
+ NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
}
}
static void
find_bar_visibility_changed_cb (EggFindBar *find_bar,
- GParamSpec *param,
- EvWindow *ev_window)
+ GParamSpec *param,
+ EvWindow *ev_window)
{
gboolean visible;
if (ev_window->priv->document &&
EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
- ev_view_set_highlight_search (EV_VIEW (ev_window->priv->view), visible);
- ev_view_search_changed (EV_VIEW (ev_window->priv->view));
+ ev_view_find_set_highlight_search (EV_VIEW (ev_window->priv->view), visible);
+ ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
ev_window_update_actions (ev_window);
if (visible)
}
static void
-find_bar_scroll(EggFindBar *find_bar, GtkScrollType scroll, EvWindow* ev_window)
+find_bar_scroll (EggFindBar *find_bar,
+ GtkScrollType scroll,
+ EvWindow *ev_window)
{
- ev_view_scroll(EV_VIEW(ev_window->priv->view), scroll, FALSE);
+ ev_view_scroll (EV_VIEW (ev_window->priv->view), scroll, FALSE);
}
static void
{
EvWindow *window = EV_WINDOW (object);
EvWindowPrivate *priv = window->priv;
-#ifdef ENABLE_DBUS
- GObject *keys;
+ GObject *mpkeys = ev_application_get_media_keys (EV_APP);
- keys = ev_application_get_media_keys (EV_APP);
- if (keys) {
- ev_media_player_keys_focused (EV_MEDIA_PLAYER_KEYS (keys), NULL);
- g_object_unref (keys);
+ if (mpkeys) {
+ g_signal_handlers_disconnect_by_func (mpkeys,
+ ev_window_media_player_key_pressed,
+ window);
}
-#endif /* ENABLE_DBUS */
-
+
+ if (priv->setup_document_idle > 0) {
+ g_source_remove (priv->setup_document_idle);
+ priv->setup_document_idle = 0;
+ }
+
if (priv->monitor) {
g_object_unref (priv->monitor);
priv->monitor = NULL;
if (priv->thumbnail_job) {
ev_window_clear_thumbnail_job (window);
}
+
+ if (priv->find_job) {
+ ev_window_clear_find_job (window);
+ }
if (priv->local_uri) {
ev_window_clear_local_uri (window);
priv->local_uri = NULL;
}
-
+
ev_window_close_dialogs (window);
ev_window_clear_print_job (window);
gtk_widget_grab_focus (window->priv->view);
}
+static void
+sidebar_layers_visibility_changed (EvSidebarLayers *layers,
+ EvWindow *window)
+{
+ ev_view_reload (EV_VIEW (window->priv->view));
+}
+
static void
register_custom_actions (EvWindow *window, GtkActionGroup *group)
{
GObject *keys;
keys = ev_application_get_media_keys (EV_APP);
- if (keys) {
- ev_media_player_keys_focused (EV_MEDIA_PLAYER_KEYS (keys), window);
- g_object_unref (keys);
- }
+ ev_media_player_keys_focused (EV_MEDIA_PLAYER_KEYS (keys));
#endif /* ENABLE_DBUS */
update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE);
launch_action (EvWindow *window, EvLinkAction *action)
{
const char *filename = ev_link_action_get_filename (action);
- const char *content_type;
GAppInfo *app_info;
- GFileInfo *file_info;
GFile *file;
- GList *file_list = NULL;
-
+ GList file_list = {NULL};
+ GAppLaunchContext *context = NULL;
+ GError *error = NULL;
+
if (filename == NULL)
return;
file = g_file_new_for_path (filename);
} else {
GFile *base_file;
+ gchar *dir;
+
+ dir = g_path_get_dirname (window->priv->uri);
+ base_file = g_file_new_for_uri (dir);
+ g_free (dir);
- base_file = g_file_new_for_uri (window->priv->uri);
- file = g_file_resolve_relative_path (base_file,
- filename);
-
+ file = g_file_resolve_relative_path (base_file, filename);
g_object_unref (base_file);
}
-
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- 0, NULL, NULL);
- if (file_info == NULL) {
+
+ app_info = g_file_query_default_handler (file, NULL, &error);
+ if (!app_info) {
+ ev_window_error_message (window, error,
+ "%s",
+ _("Unable to launch external application."));
g_object_unref (file);
+ g_error_free (error);
+
return;
}
-
- content_type = g_file_info_get_content_type (file_info);
- app_info = g_app_info_get_default_for_type (content_type, TRUE);
-
- file_list = g_list_append (file_list, file);
- /* FIXME: should we use a GAppLaunchContext? */
- g_app_info_launch (app_info, file_list,
- NULL, NULL);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
+ gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+#endif
+
+ file_list.data = file;
+ if (!g_app_info_launch (app_info, &file_list, context, &error)) {
+ ev_window_error_message (window, error,
+ "%s",
+ _("Unable to launch external application."));
+ g_error_free (error);
+ }
- g_list_free (file_list);
g_object_unref (app_info);
- g_object_unref (file_info);
g_object_unref (file);
/* According to the PDF spec filename can be an executable. I'm not sure
const gchar *uri = ev_link_action_get_uri (action);
GError *error = NULL;
gboolean ret;
+#if GTK_CHECK_VERSION (2, 14, 0)
+ GAppLaunchContext *context = NULL;
+#endif
+
+#if GTK_CHECK_VERSION (2, 14, 0)
+ context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
+ gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
+ gtk_window_get_screen (GTK_WINDOW (window)));
+ gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+ GDK_CURRENT_TIME);
+#endif
+
+ if (!g_strstr_len (uri, strlen (uri), "://") &&
+ !g_str_has_prefix (uri, "mailto:")) {
+ gchar *http;
+
+ /* Not a valid uri, assuming it's http */
+ http = g_strdup_printf ("http://%s", uri);
+ ret = g_app_info_launch_default_for_uri (http, NULL, &error);
+ g_free (http);
+ } else {
+ ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
+ }
- ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
if (ret == FALSE) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Unable to open external link"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message, uri);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gtk_widget_show (dialog);
- g_error_free(error);
+ ev_window_error_message (window, error,
+ "%s", _("Unable to open external link"));
+ g_error_free (error);
}
}
}
if (format == NULL) {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("Couldn't find appropriate format to save image"),
- NULL);
+ ev_window_error_message (ev_window, NULL,
+ "%s",
+ _("Couldn't find appropriate format to save image"));
g_free (uri);
gtk_widget_destroy (fc);
}
extensions = gdk_pixbuf_format_get_extensions (format);
- if (g_str_has_suffix(uri, extensions[0])) {
+ if (!g_str_has_suffix (uri, extensions[0])) {
gchar *uri_extension;
uri_extension = g_strconcat (uri, ".", extensions[0], NULL);
} else {
target_file = g_file_new_for_uri (uri);
}
- g_strfreev(extensions);
+ g_strfreev (extensions);
g_free (uri);
is_native = g_file_is_native (target_file);
g_object_unref (pixbuf);
if (error) {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("The image could not be saved."),
- error);
+ ev_window_error_message (ev_window, error,
+ "%s", _("The image could not be saved."));
g_error_free (error);
g_free (filename);
g_object_unref (target_file);
static void
ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
{
- GList *l;
+ GList *l;
+ GdkScreen *screen;
if (!window->priv->attach_list)
return;
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+
for (l = window->priv->attach_list; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
GError *error = NULL;
attachment = (EvAttachment *) l->data;
- ev_attachment_open (attachment, &error);
+ ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (window),
- _("Unable to open attachment"),
- error);
+ ev_window_error_message (window, error,
+ "%s", _("Unable to open attachment"));
g_error_free (error);
}
}
ev_attachment_save (attachment, save_to, &error);
if (error) {
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("The attachment could not be saved."),
- error);
+ ev_window_error_message (ev_window, error,
+ "%s", _("The attachment could not be saved."));
g_error_free (error);
g_object_unref (save_to);
gtk_widget_show (fc);
}
+static void
+ev_window_media_player_key_pressed (EvWindow *window,
+ const gchar *key,
+ gpointer user_data)
+{
+ if (!gtk_window_is_active (GTK_WINDOW (window)))
+ return;
+
+ /* Note how Previous/Next only go to the
+ * next/previous page despite their icon telling you
+ * they should go to the beginning/end.
+ *
+ * There's very few keyboards with FFW/RWD though,
+ * so we stick the most useful keybinding on the most
+ * often seen keys
+ */
+ if (strcmp (key, "Play") == 0) {
+ ev_window_run_presentation (window);
+ } else if (strcmp (key, "Previous") == 0) {
+ ev_window_cmd_go_previous_page (NULL, window);
+ } else if (strcmp (key, "Next") == 0) {
+ ev_window_cmd_go_next_page (NULL, window);
+ } else if (strcmp (key, "FastForward") == 0) {
+ ev_window_cmd_go_last_page (NULL, window);
+ } else if (strcmp (key, "Rewind") == 0) {
+ ev_window_cmd_go_first_page (NULL, window);
+ }
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *sidebar_widget;
+ GObject *mpkeys;
g_signal_connect (ev_window, "configure_event",
G_CALLBACK (window_configure_event_cb), NULL);
g_error_free (error);
}
-#if GTK_CHECK_VERSION(2,11,4)
ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
-#else
- /* It's fine to just use the one of the default screen here */
- ev_window->priv->recent_manager = gtk_recent_manager_get_for_screen (
- gdk_screen_get_default ());
-#endif
ev_window->priv->recent_action_group = NULL;
ev_window->priv->recent_ui_id = 0;
g_signal_connect_swapped (ev_window->priv->recent_manager,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+ sidebar_widget = ev_sidebar_layers_new ();
+ ev_window->priv->sidebar_layers = sidebar_widget;
+ g_signal_connect (sidebar_widget,
+ "layers_visibility_changed",
+ G_CALLBACK (sidebar_layers_visibility_changed),
+ ev_window);
+ gtk_widget_show (sidebar_widget);
+ ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+ sidebar_widget);
+
ev_window->priv->view_box = gtk_vbox_new (FALSE, 0);
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
ev_window->priv->view = ev_view_new ();
ev_view_set_screen_dpi (EV_VIEW (ev_window->priv->view),
get_screen_dpi (GTK_WINDOW (ev_window)));
- ev_window->priv->password_view = ev_password_view_new ();
+ ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window));
g_signal_connect_swapped (ev_window->priv->password_view,
"unlock",
- G_CALLBACK (ev_window_popup_password_dialog),
+ G_CALLBACK (ev_window_password_view_unlock),
ev_window);
g_signal_connect_object (ev_window->priv->view, "focus_in_event",
G_CALLBACK (view_actions_focus_in_cb),
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->view);
- g_signal_connect (ev_window->priv->view,
- "notify::find-status",
- G_CALLBACK (view_find_status_changed_cb),
- ev_window);
g_signal_connect (ev_window->priv->view,
"notify::sizing-mode",
G_CALLBACK (ev_window_sizing_mode_changed_cb),
"/AttachmentPopup");
ev_window->priv->attach_list = NULL;
+ /* Media player keys */
+ mpkeys = ev_application_get_media_keys (EV_APP);
+ if (mpkeys) {
+ g_signal_connect_swapped (mpkeys, "key_pressed",
+ G_CALLBACK (ev_window_media_player_key_pressed),
+ ev_window);
+ }
+
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);