#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <math.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "ev-page-action.h"
#include "ev-password-view.h"
#include "ev-properties-dialog.h"
+#include "ev-sidebar-annotations.h"
#include "ev-sidebar-attachments.h"
#include "ev-sidebar.h"
#include "ev-sidebar-links.h"
#include "ev-window-title.h"
#include "ev-print-operation.h"
#include "ev-progress-message-area.h"
+#include "ev-annotation-properties-dialog.h"
#ifdef ENABLE_DBUS
#include "ev-media-player-keys.h"
GtkWidget *sidebar_links;
GtkWidget *sidebar_attachments;
GtkWidget *sidebar_layers;
+ GtkWidget *sidebar_annots;
/* Settings */
GSettings *settings;
GtkWidget *fullscreen_toolbar;
/* Popup view */
- GtkWidget *view_popup;
- EvLink *link;
- EvImage *image;
+ GtkWidget *view_popup;
+ EvLink *link;
+ EvImage *image;
+ EvAnnotation *annot;
/* Popup attachment */
GtkWidget *attachment_popup;
#ifdef WITH_GCONF
GConfClient *gconf_client;
#endif
+#ifdef ENABLE_DBUS
+ /* DBus */
+ guint dbus_object_id;
+ gchar *dbus_object_path;
+#endif
};
#define EV_WINDOW_GET_PRIVATE(object) \
#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 GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
+#ifdef ENABLE_DBUS
+#define EV_WINDOW_DBUS_OBJECT_PATH "/org/gnome/evince/Window/%d"
+#define EV_WINDOW_DBUS_INTERFACE "org.gnome.evince.Window"
+#endif
+
#define GS_SCHEMA_NAME "org.gnome.Evince"
-#define GS_OVERRIDE_RESTRICTIONS "override_restrictions"
+#define GS_OVERRIDE_RESTRICTIONS "override-restrictions"
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
#define ATTACHMENTS_SIDEBAR_ID "attachments"
#define LAYERS_SIDEBAR_ID "layers"
+#define ANNOTS_SIDEBAR_ID "annotations"
#define EV_PRINT_SETTINGS_FILE "print-settings"
#define EV_PRINT_SETTINGS_GROUP "Print Settings"
#define EV_TOOLBARS_FILENAME "evince-toolbar.xml"
#define MIN_SCALE 0.05409
-#define MAX_SCALE 4.0
+#define PAGE_CACHE_SIZE 52428800 /* 50MB */
#define MAX_RECENT_ITEM_LEN (40)
EvWindow *window);
static void ev_view_popup_cmd_copy_image (GtkAction *action,
EvWindow *window);
+static void ev_view_popup_cmd_annot_properties (GtkAction *action,
+ EvWindow *window);
static void ev_attachment_popup_cmd_open_attachment (GtkAction *action,
EvWindow *window);
static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action,
static void ev_window_media_player_key_pressed (EvWindow *window,
const gchar *key,
gpointer user_data);
+static void ev_window_update_max_min_scale (EvWindow *window);
+#ifdef ENABLE_DBUS
+static void ev_window_emit_closed (EvWindow *window);
+#endif
static guint ev_window_n_copies = 0;
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;
gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT, NULL)) {
ok_to_print = FALSE;
}
-
- 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 */
GtkWidget *links = window->priv->sidebar_links;
GtkWidget *thumbs = window->priv->sidebar_thumbs;
GtkWidget *attachments = window->priv->sidebar_attachments;
+ GtkWidget *annots = window->priv->sidebar_annots;
GtkWidget *layers = window->priv->sidebar_layers;
gchar *page_id;
gint sidebar_size;
gboolean sidebar_visibility;
+ if (document) {
+ if (!window->priv->metadata ||
+ !ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility)) {
+ sidebar_visibility = g_settings_get_boolean (window->priv->last_settings, "show-sidebar");
+ }
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, sidebar_visibility);
+ update_chrome_visibility (window);
+ }
+
if (!window->priv->metadata)
return;
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);
+ } else if (strcmp (page_id, ANNOTS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (annots), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), annots);
}
} else if (document) {
if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), 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);
+ } else if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (annots), document)) {
+ ev_sidebar_set_page (EV_SIDEBAR (sidebar), annots);
}
}
-
- if (!ev_metadata_get_boolean (window->priv->metadata, "sidebar_visibility", &sidebar_visibility))
- sidebar_visibility = g_settings_get_boolean (window->priv->last_settings, "show-sidebar");
-
- update_chrome_flag (window, EV_CHROME_SIDEBAR, sidebar_visibility);
- update_chrome_visibility (window);
}
static void
gdouble width_ratio;
gdouble height_ratio;
- if (!window->priv->metadata)
- return;
-
- /* 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. */
- page = ev_document_model_get_page (window->priv->model);
- n_pages = ev_document_get_n_pages (window->priv->document);
- if (page == n_pages - 1)
- ev_document_model_set_page (window->priv->model, 0);
+ if (window->priv->metadata) {
+ /* 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. */
+ page = ev_document_model_get_page (window->priv->model);
+ n_pages = ev_document_get_n_pages (window->priv->document);
+ if (page == n_pages - 1)
+ ev_document_model_set_page (window->priv->model, 0);
- setup_sidebar_from_metadata (window);
+ setup_sidebar_from_metadata (window);
- if (ev_metadata_get_int (window->priv->metadata, "window_width", &width) &&
- ev_metadata_get_int (window->priv->metadata, "window_height", &height))
- return; /* size was already set in setup_size_from_metadata */
+ if (ev_metadata_get_int (window->priv->metadata, "window_width", &width) &&
+ ev_metadata_get_int (window->priv->metadata, "window_height", &height))
+ return; /* size was already set in setup_size_from_metadata */
+ }
g_settings_get (window->priv->last_settings, "window-ratio", "(dd)", &width_ratio, &height_ratio);
if (width_ratio > 0. && height_ratio > 0.) {
screen = gtk_window_get_screen (GTK_WINDOW (window));
if (screen) {
request_width = MIN (request_width, gdk_screen_get_width (screen));
- request_height = MIN (request_width, gdk_screen_get_height (screen));
+ request_height = MIN (request_height, gdk_screen_get_height (screen));
}
if (request_width > 0 && request_height > 0) {
GtkAction *action;
ev_window->priv->setup_document_idle = 0;
-
+
ev_window_refresh_window_thumbnail (ev_window);
ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
g_object_unref (ev_window->priv->document);
ev_window->priv->document = g_object_ref (document);
+ ev_window_update_max_min_scale (ev_window);
+
ev_window_set_message_area (ev_window, NULL);
if (ev_document_get_n_pages (document) <= 0) {
_("The document contains only empty pages"));
}
+ if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+ gtk_widget_destroy (ev_window->priv->presentation_view);
+ ev_window->priv->presentation_view = NULL;
+ ev_window_run_presentation (ev_window);
+ }
+
if (ev_window->priv->setup_document_idle > 0)
g_source_remove (ev_window->priv->setup_document_idle);
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
- ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
ev_window->priv->window_mode = mode;
g_object_unref (ev_window->priv->metadata);
source_file = g_file_new_for_uri (uri);
- if (ev_is_metadata_supported_for_file (source_file))
+ if (!ev_file_is_temp (source_file) &&
+ ev_is_metadata_supported_for_file (source_file))
ev_window->priv->metadata = ev_metadata_new (source_file);
else
ev_window->priv->metadata = NULL;
if (!g_file_is_native (source_file) && !ev_window->priv->local_uri) {
ev_window_load_file_remote (ev_window, source_file);
} else {
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
g_object_unref (source_file);
ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
}
ev_window_error_message (window, job->error,
_("The file could not be saved as “%s”."),
EV_JOB_SAVE (job)->uri);
+ } else {
+ ev_window_add_recent (window, EV_JOB_SAVE (job)->uri);
}
ev_window_clear_save_job (window);
key_file = get_print_settings_file ();
gtk_print_settings_to_key_file (print_settings, key_file, EV_PRINT_SETTINGS_GROUP);
- save_print_setting_file (key_file);
- g_key_file_free (key_file);
-
- if (!window->priv->metadata)
- return;
/* Save print settings that are specific to the document */
for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) {
- const gchar *value;
+ /* Remove it from global settings */
+ g_key_file_remove_key (key_file, EV_PRINT_SETTINGS_GROUP,
+ document_print_settings[i], NULL);
- value = gtk_print_settings_get (print_settings,
- document_print_settings[i]);
- ev_metadata_set_string (window->priv->metadata,
- document_print_settings[i], value);
+ if (window->priv->metadata) {
+ const gchar *value;
+
+ value = gtk_print_settings_get (print_settings,
+ document_print_settings[i]);
+ ev_metadata_set_string (window->priv->metadata,
+ document_print_settings[i], value);
+ }
}
+
+ save_print_setting_file (key_file);
+ g_key_file_free (key_file);
}
static void
key_file = get_print_settings_file ();
gtk_page_setup_to_key_file (page_setup, key_file, EV_PAGE_SETUP_GROUP);
+
+ /* Do not save document settings in global file */
+ g_key_file_remove_key (key_file, EV_PAGE_SETUP_GROUP,
+ "page-setup-orientation", NULL);
+ g_key_file_remove_key (key_file, EV_PAGE_SETUP_GROUP,
+ "page-setup-margin-top", NULL);
+ g_key_file_remove_key (key_file, EV_PAGE_SETUP_GROUP,
+ "page-setup-margin-bottom", NULL);
+ g_key_file_remove_key (key_file, EV_PAGE_SETUP_GROUP,
+ "page-setup-margin-left", NULL);
+ g_key_file_remove_key (key_file, EV_PAGE_SETUP_GROUP,
+ "page-setup-margin-right", NULL);
+
save_print_setting_file (key_file);
g_key_file_free (key_file);
ev_document_model_set_page (ev_window->priv->model, current_page);
}
+ /* TODO: warn about form fields, and annots not saved */
+
n_print_jobs = ev_window->priv->print_queue ?
g_queue_get_length (ev_window->priv->print_queue) : 0;
g_free (menubar_accel_accel);
}
+static void
+ev_window_update_max_min_scale (EvWindow *window)
+{
+ gdouble dpi;
+ GtkAction *action;
+ gdouble min_width, min_height;
+ gdouble width, height;
+ gdouble max_scale;
+ gint rotation = ev_document_model_get_rotation (window->priv->model);
+
+ if (!window->priv->document)
+ return;
+
+ dpi = get_screen_dpi (window) / 72.0;
+
+ ev_document_get_min_page_size (window->priv->document, &min_width, &min_height);
+ width = (rotation == 0 || rotation == 180) ? min_width : min_height;
+ height = (rotation == 0 || rotation == 180) ? min_height : min_width;
+ max_scale = sqrt (PAGE_CACHE_SIZE / (width * dpi * 4 * height * dpi));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ ZOOM_CONTROL_ACTION);
+ ephy_zoom_action_set_max_zoom_level (EPHY_ZOOM_ACTION (action), max_scale * dpi);
+
+ ev_document_model_set_min_scale (window->priv->model, MIN_SCALE * dpi);
+ ev_document_model_set_max_scale (window->priv->model, max_scale * dpi);
+}
+
static void
ev_window_screen_changed (GtkWidget *widget,
GdkScreen *old_screen)
{
EvWindow *window = EV_WINDOW (widget);
- EvWindowPrivate *priv = window->priv;
GdkScreen *screen;
- gdouble dpi;
screen = gtk_widget_get_screen (widget);
if (screen == old_screen)
return;
ev_window_setup_gtk_settings (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);
+ ev_window_update_max_min_scale (window);
if (GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed) {
GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed (widget, old_screen);
ev_metadata_set_int (window->priv->metadata, "rotation",
rotation);
+ ev_window_update_max_min_scale (window);
ev_window_refresh_window_thumbnail (window);
}
id = ATTACHMENTS_SIDEBAR_ID;
} else if (current_page == ev_window->priv->sidebar_layers) {
id = LAYERS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_annots) {
+ id = ANNOTS_SIDEBAR_ID;
} else {
g_assert_not_reached();
}
GtkAction *action;
gboolean show_annot = FALSE;
+ if (ev_window->priv->annot)
+ g_object_unref (ev_window->priv->annot);
+ ev_window->priv->annot = (annot) ? g_object_ref (annot) : NULL;
+
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
+ "AnnotProperties");
+ gtk_action_set_visible (action, (annot != NULL && EV_IS_ANNOTATION_MARKUP (annot)));
+
if (annot && EV_IS_ANNOTATION_ATTACHMENT (annot)) {
- EvAttachment *attachment = EV_ANNOTATION_ATTACHMENT (annot)->attachment;
+ EvAttachment *attachment;
+ attachment = ev_annotation_attachment_get_attachment (EV_ANNOTATION_ATTACHMENT (annot));
if (attachment) {
show_annot = TRUE;
if (ev_window->priv->attach_list) {
window);
}
+#ifdef ENABLE_DBUS
+ if (priv->dbus_object_id > 0) {
+ ev_window_emit_closed (window);
+ g_dbus_connection_unregister_object (ev_application_get_dbus_connection (EV_APP),
+ priv->dbus_object_id);
+ priv->dbus_object_id = 0;
+ }
+
+ if (priv->dbus_object_path) {
+ g_free (priv->dbus_object_path);
+ priv->dbus_object_path = NULL;
+ }
+#endif /* ENABLE_DBUS */
+
if (priv->metadata) {
g_object_unref (priv->metadata);
priv->metadata = NULL;
}
if (priv->last_settings) {
+ g_settings_apply (priv->last_settings);
g_object_unref (priv->last_settings);
priv->last_settings = NULL;
}
priv->image = NULL;
}
+ if (priv->annot) {
+ g_object_unref (priv->annot);
+ priv->annot = NULL;
+ }
+
if (priv->attach_list) {
g_list_foreach (priv->attach_list,
(GFunc) g_object_unref,
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) },
+ { "AnnotProperties", NULL, N_("Annotation Properties…"), NULL,
+ NULL, G_CALLBACK (ev_view_popup_cmd_annot_properties) }
};
static const GtkActionEntry attachment_popup_entries [] = {
ev_view_reload (EV_VIEW (window->priv->view));
}
+static void
+sidebar_annots_annot_activated_cb (EvSidebarAnnotations *sidebar_annots,
+ EvMapping *annot_mapping,
+ EvWindow *window)
+{
+ ev_view_focus_annotation (EV_VIEW (window->priv->view), annot_mapping);
+}
+
+static void
+sidebar_annots_begin_annot_add (EvSidebarAnnotations *sidebar_annots,
+ EvAnnotationType annot_type,
+ EvWindow *window)
+{
+ ev_view_begin_add_annotation (EV_VIEW (window->priv->view), annot_type);
+}
+
+static void
+view_annot_added (EvView *view,
+ EvAnnotation *annot,
+ EvWindow *window)
+{
+ ev_sidebar_annotations_annot_added (EV_SIDEBAR_ANNOTATIONS (window->priv->sidebar_annots),
+ annot);
+}
+
+static void
+sidebar_annots_annot_add_cancelled (EvSidebarAnnotations *sidebar_annots,
+ EvWindow *window)
+{
+ ev_view_cancel_add_annotation (EV_VIEW (window->priv->view));
+}
+
static void
register_custom_actions (EvWindow *window, GtkActionGroup *group)
{
g_object_unref (pixbuf);
}
+static void
+ev_view_popup_cmd_annot_properties (GtkAction *action,
+ EvWindow *window)
+{
+ const gchar *author;
+ GdkColor color;
+ gdouble opacity;
+ gboolean popup_is_open;
+ EvAnnotationPropertiesDialog *dialog;
+ EvAnnotation *annot = window->priv->annot;
+ EvAnnotationsSaveMask mask = EV_ANNOTATIONS_SAVE_NONE;
+
+ if (!annot)
+ return;
+
+ dialog = EV_ANNOTATION_PROPERTIES_DIALOG (ev_annotation_properties_dialog_new_with_annotation (window->priv->annot));
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_APPLY) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ return;
+ }
+
+ /* Set annotations changes */
+ author = ev_annotation_properties_dialog_get_author (dialog);
+ if (ev_annotation_markup_set_label (EV_ANNOTATION_MARKUP (annot), author))
+ mask |= EV_ANNOTATIONS_SAVE_LABEL;
+
+ ev_annotation_properties_dialog_get_color (dialog, &color);
+ if (ev_annotation_set_color (annot, &color))
+ mask |= EV_ANNOTATIONS_SAVE_COLOR;
+
+ opacity = ev_annotation_properties_dialog_get_opacity (dialog);
+ if (ev_annotation_markup_set_opacity (EV_ANNOTATION_MARKUP (annot), opacity))
+ mask |= EV_ANNOTATIONS_SAVE_OPACITY;
+
+ popup_is_open = ev_annotation_properties_dialog_get_popup_is_open (dialog);
+ if (ev_annotation_markup_set_popup_is_open (EV_ANNOTATION_MARKUP (annot), popup_is_open))
+ mask |= EV_ANNOTATIONS_SAVE_POPUP_IS_OPEN;
+
+ if (EV_IS_ANNOTATION_TEXT (annot)) {
+ EvAnnotationTextIcon icon;
+
+ icon = ev_annotation_properties_dialog_get_text_icon (dialog);
+ if (ev_annotation_text_set_icon (EV_ANNOTATION_TEXT (annot), icon))
+ mask |= EV_ANNOTATIONS_SAVE_TEXT_ICON;
+ }
+
+ if (mask != EV_ANNOTATIONS_SAVE_NONE) {
+ ev_document_doc_mutex_lock ();
+ ev_document_annotations_save_annotation (EV_DOCUMENT_ANNOTATIONS (window->priv->document),
+ window->priv->annot,
+ mask);
+ ev_document_doc_mutex_unlock ();
+
+ /* FIXME: update annot region only */
+ ev_view_reload (EV_VIEW (window->priv->view));
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
static void
ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
{
return toolbars_model;
}
+#ifdef ENABLE_DBUS
+static void
+ev_window_sync_source (EvWindow *window,
+ EvSourceLink *link)
+{
+ GDBusConnection *connection;
+ GError *error = NULL;
+
+ if (window->priv->dbus_object_id <= 0)
+ return;
+
+ connection = ev_application_get_dbus_connection (EV_APP);
+ if (!connection)
+ return;
+
+ g_dbus_connection_emit_signal (connection,
+ NULL,
+ window->priv->dbus_object_path,
+ EV_WINDOW_DBUS_INTERFACE,
+ "SyncSource",
+ g_variant_new ("(s(ii))",
+ link->filename,
+ link->line,
+ link->col),
+ &error);
+ if (error) {
+ g_printerr ("Failed to emit DBus signal SyncSource: %s\n",
+ error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+ev_window_emit_closed (EvWindow *window)
+{
+ GDBusConnection *connection;
+ GError *error = NULL;
+
+ if (window->priv->dbus_object_id <= 0)
+ return;
+
+ connection = ev_application_get_dbus_connection (EV_APP);
+ if (!connection)
+ return;
+
+ g_dbus_connection_emit_signal (connection,
+ NULL,
+ window->priv->dbus_object_path,
+ EV_WINDOW_DBUS_INTERFACE,
+ "Closed",
+ NULL,
+ &error);
+ if (error) {
+ g_printerr ("Failed to emit DBus signal Closed: %s\n",
+ error->message);
+ g_error_free (error);
+
+ return;
+ }
+
+ /* If this is the last window call g_dbus_connection_flush_sync()
+ * to make sure the signal is emitted.
+ */
+ if (ev_application_get_n_windows (EV_APP) == 1)
+ g_dbus_connection_flush_sync (connection, NULL, NULL);
+}
+
+static void
+method_call_cb (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ EvWindow *window = EV_WINDOW (user_data);
+
+ if (g_strcmp0 (method_name, "SyncView") != 0)
+ return;
+
+ if (window->priv->document && ev_document_has_synctex (window->priv->document)) {
+ EvSourceLink link;
+
+ g_variant_get (parameters, "(&s(ii))", &link.filename, &link.line, &link.col);
+ ev_view_highlight_forward_search (EV_VIEW (window->priv->view), &link);
+ gtk_window_present (GTK_WINDOW (window));
+ }
+
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
+}
+
+static const char introspection_xml[] =
+ "<node>"
+ "<interface name='org.gnome.evince.Window'>"
+ "<method name='SyncView'>"
+ "<arg type='s' name='source_file' direction='in'/>"
+ "<arg type='(ii)' name='source_point' direction='in'/>"
+ "</method>"
+ "<signal name='SyncSource'>"
+ "<arg type='s' name='source_file' direction='out'/>"
+ "<arg type='(ii)' name='source_point' direction='out'/>"
+ "</signal>"
+ "<signal name='Closed'/>"
+ "</interface>"
+ "</node>";
+
+static const GDBusInterfaceVTable interface_vtable = {
+ method_call_cb,
+ NULL,
+ NULL
+};
+
+static GDBusNodeInfo *introspection_data;
+#endif /* ENABLE_DBUS */
+
static void
ev_window_init (EvWindow *ev_window)
{
EggToolbarsModel *toolbars_model;
GObject *mpkeys;
gchar *ui_path;
- gdouble dpi;
+#ifdef ENABLE_DBUS
+ GDBusConnection *connection;
+ static gint window_id = 0;
+#endif
g_signal_connect (ev_window, "configure_event",
G_CALLBACK (window_configure_event_cb), NULL);
ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
+#ifdef ENABLE_DBUS
+ connection = ev_application_get_dbus_connection (EV_APP);
+ if (connection) {
+ if (!introspection_data) {
+ introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error);
+ if (error) g_warning ("%s\n", error->message);
+ }
+ g_assert (introspection_data != NULL);
+
+ ev_window->priv->dbus_object_path = g_strdup_printf (EV_WINDOW_DBUS_OBJECT_PATH, window_id++);
+ ev_window->priv->dbus_object_id =
+ g_dbus_connection_register_object (connection,
+ ev_window->priv->dbus_object_path,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ ev_window, NULL,
+ &error);
+ if (ev_window->priv->dbus_object_id == 0) {
+ g_printerr ("Failed to register bus object %s: %s\n",
+ ev_window->priv->dbus_object_path, error->message);
+ g_error_free (error);
+ g_free (ev_window->priv->dbus_object_path);
+ ev_window->priv->dbus_object_path = NULL;
+ error = NULL;
+ }
+ }
+
+#endif /* ENABLE_DBUS */
+
ev_window->priv->model = ev_document_model_new ();
ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+ sidebar_widget = ev_sidebar_annotations_new ();
+ ev_window->priv->sidebar_annots = sidebar_widget;
+ g_signal_connect (sidebar_widget,
+ "annot_activated",
+ G_CALLBACK (sidebar_annots_annot_activated_cb),
+ ev_window);
+ g_signal_connect (sidebar_widget,
+ "begin_annot_add",
+ G_CALLBACK (sidebar_annots_begin_annot_add),
+ ev_window);
+ g_signal_connect (sidebar_widget,
+ "annot_add_cancelled",
+ G_CALLBACK (sidebar_annots_annot_add_cancelled),
+ 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,
gtk_widget_show (ev_window->priv->view_box);
ev_window->priv->view = ev_view_new ();
+ ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), PAGE_CACHE_SIZE);
ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model);
- 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_swapped (ev_window->priv->password_view,
"unlock",
g_signal_connect_object (ev_window->priv->view, "selection-changed",
G_CALLBACK (view_selection_changed_cb),
ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "annot-added",
+ G_CALLBACK (view_annot_added),
+ ev_window, 0);
+#ifdef ENABLE_DBUS
+ g_signal_connect_swapped (ev_window->priv->view, "sync-source",
+ G_CALLBACK (ev_window_sync_source),
+ ev_window);
+#endif
gtk_widget_show (ev_window->priv->view);
gtk_widget_show (ev_window->priv->password_view);
gtk_widget_grab_focus (ev_window->priv->view);
ev_window->priv->last_settings = g_settings_new (GS_SCHEMA_NAME".Default");
+ g_settings_delay (ev_window->priv->last_settings);
/* Set it user interface params */
ev_window_setup_recent (ev_window);
return ev_window;
}
+
+const gchar *
+ev_window_get_dbus_object_path (EvWindow *ev_window)
+{
+#ifdef ENABLE_DBUS
+ return ev_window->priv->dbus_object_path;
+#else
+ return NULL;
+#endif
+}