#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;
#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"
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,
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;
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;
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);
}
}
}
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;
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) {
#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;
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)
{
}
}
+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,
"<arg type='s' name='source_file' direction='out'/>"
"<arg type='(ii)' name='source_point' direction='out'/>"
"</signal>"
+ "<signal name='Closed'/>"
"</interface>"
"</node>";
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,
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),
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
+}