#include "ev-page-action.h"
#include "ev-sidebar.h"
#include "ev-sidebar-links.h"
+#include "ev-sidebar-attachments.h"
#include "ev-sidebar-thumbnails.h"
#include "ev-view.h"
#include "ev-password.h"
#include <libgnomeprintui/gnome-print-dialog.h>
#endif
+#ifdef WITH_GTK_PRINT
+#include <gtk/gtkprintunixdialog.h>
+#endif
+
#include <poppler.h>
#include <glib/gi18n.h>
EV_CHROME_TOOLBAR = 1 << 1,
EV_CHROME_FINDBAR = 1 << 2,
EV_CHROME_RAISE_TOOLBAR = 1 << 3,
- EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR
+ EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4,
+ EV_CHROME_SIDEBAR = 1 << 5,
+ EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
} EvChrome;
struct _EvWindowPrivate {
GtkWidget *password_view;
GtkWidget *sidebar_thumbs;
GtkWidget *sidebar_links;
+ GtkWidget *sidebar_attachments;
/* Dialogs */
GtkWidget *properties;
-#ifdef WITH_GNOME_PRINT
+#ifdef WITH_PRINT
GtkWidget *print_dialog;
#endif
GtkWidget *password_dialog;
/* UI Builders */
GtkActionGroup *action_group;
- GtkActionGroup *popups_action_group;
+ GtkActionGroup *view_popup_action_group;
+ GtkActionGroup *attachment_popup_action_group;
GtkUIManager *ui_manager;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
GtkWidget *fullscreen_popup;
- GSource *fullscreen_timeout_source;
+ guint fullscreen_timeout_id;
/* Popup link */
- GtkWidget *popup;
+ GtkWidget *view_popup;
EvLink *link;
+ /* Popup attachment */
+ GtkWidget *attachment_popup;
+ GList *attach_list;
+
/* Document */
char *uri;
char *local_uri;
+ EvLinkDest *dest;
EvDocument *document;
- EvDocument *password_document;
+
EvPageCache *page_cache;
EvWindowPageMode page_mode;
EvWindowTitle *title;
#ifdef WITH_GNOME_PRINT
GnomePrintJob *print_job;
#endif
+
+#ifdef WITH_GTK_PRINT
+ EvJob *print_job;
+ GtkPrintJob *gtk_print_job;
+ GtkPrinter *printer;
+ GtkPrintSettings *print_settings;
+ GtkPageSetup *print_page_setup;
+#endif
};
static const GtkTargetEntry ev_drop_types[] = {
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
+#define ATTACHMENTS_SIDEBAR_ID "attachments"
static void ev_window_update_actions (EvWindow *ev_window);
static void ev_window_update_fullscreen_popup (EvWindow *window);
EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
-static void ev_window_xfer_job_cb (EvJobXfer *job,
- gpointer data);
+static void ev_window_xfer_job_cb (EvJobXfer *job,
+ gpointer data);
+static void ev_window_print_job_cb (EvJobPrint *job,
+ EvWindow *window);
static void ev_window_sizing_mode_changed_cb (EvView *view,
GParamSpec *pspec,
EvWindow *ev_window);
static void ev_window_stop_presentation (EvWindow *window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
-static void show_fullscreen_popup (EvWindow *window);
-static void ev_popup_cmd_open_link (GtkAction *action,
+static void ev_window_run_preview (EvWindow *window);
+static void ev_view_popup_cmd_open_link (GtkAction *action,
EvWindow *window);
-static void ev_popup_cmd_copy_link_address (GtkAction *action,
+static void ev_view_popup_cmd_copy_link_address (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,
+ EvWindow *window);
static void ev_window_cmd_view_best_fit (GtkAction *action,
EvWindow *ev_window);
static void ev_window_cmd_view_page_width (GtkAction *action,
EvWindow *ev_window);
+static void fullscreen_set_timeout (EvWindow *window);
+static gboolean fullscreen_motion_notify_cb (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer user_data);
+static gboolean fullscreen_leave_notify_cb (GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer user_data);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
ok_to_print = FALSE;
}
-#ifndef WITH_GNOME_PRINT
+#ifndef WITH_PRINT
ok_to_print = FALSE;
#endif
g_object_unref (client);
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));
+ ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
+ ev_view_can_find_previous (view));
ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
has_pages && ev_view_can_zoom_in (view));
static void
set_widget_visibility (GtkWidget *widget, gboolean visible)
{
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_assert (GTK_IS_WIDGET (widget));
if (visible)
gtk_widget_show (widget);
update_chrome_visibility (EvWindow *window)
{
EvWindowPrivate *priv = window->priv;
- gboolean menubar, toolbar, findbar, fullscreen_toolbar;
+ gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
presentation = ev_view_get_presentation (EV_VIEW (priv->view));
menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
(priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode;
- fullscreen_toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
- (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0);
+ fullscreen_toolbar = ((priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
+ (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->toolbar_dock, toolbar);
set_widget_visibility (priv->find_bar, findbar);
+ set_widget_visibility (priv->sidebar, sidebar);
ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
gtk_widget_set_sensitive (priv->menubar, menubar);
if (priv->fullscreen_popup != NULL) {
- if (fullscreen)
- show_fullscreen_popup (window);
- else
- set_widget_visibility (priv->fullscreen_popup, FALSE);
-
set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
+ set_widget_visibility (priv->fullscreen_popup, fullscreen_toolbar);
}
}
NULL);
switch (sizing_mode) {
- case EV_SIZING_BEST_FIT:
- best_fit = TRUE;
- page_width = FALSE;
- break;
- case EV_SIZING_FIT_WIDTH:
- best_fit = FALSE;
- page_width = TRUE;
- break;
-
- default:
- best_fit = page_width = FALSE;
- break;
+ case EV_SIZING_BEST_FIT:
+ best_fit = TRUE;
+ page_width = FALSE;
+ break;
+ case EV_SIZING_FIT_WIDTH:
+ best_fit = FALSE;
+ page_width = TRUE;
+ break;
+ default:
+ best_fit = page_width = FALSE;
+ break;
}
action = gtk_action_group_get_action (action_group, "ViewBestFit");
}
}
-void
-ev_window_open_page_label (EvWindow *ev_window,
- const char *label)
-{
- if (ev_window->priv->page_cache) {
- ev_page_cache_set_page_label (ev_window->priv->page_cache,
- label);
- }
-}
-
gboolean
ev_window_is_empty (const EvWindow *ev_window)
{
}
static void
-unable_to_load_dialog_response_cb (GtkWidget *dialog,
+ev_window_error_dialog_response_cb (GtkWidget *dialog,
gint response_id,
EvWindow *ev_window)
{
}
static void
-unable_to_load (EvWindow *ev_window,
- const char *error_message)
+ev_window_error_dialog (GtkWindow *window, const gchar *msg, GError *error)
{
GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
- _("Unable to open document"));
+ msg);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", error_message);
+ "%s", error->message);
g_signal_connect (dialog, "response",
- G_CALLBACK (unable_to_load_dialog_response_cb),
- ev_window);
+ G_CALLBACK (ev_window_error_dialog_response_cb),
+ window);
gtk_widget_show (dialog);
}
}
}
-static void
-update_sidebar_visibility (EvWindow *window)
-{
- char *uri = window->priv->uri;
- GValue sidebar_visibility = { 0, };
-
- if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
- set_widget_visibility (window->priv->sidebar,
- g_value_get_boolean (&sidebar_visibility));
- }
-}
-
static void
setup_document_from_metadata (EvWindow *window)
{
new_page = CLAMP (g_value_get_int (&page), 0, ev_page_cache_get_n_pages (window->priv->page_cache) - 1);
ev_page_cache_set_current_page (window->priv->page_cache,
new_page);
+ g_value_unset (&page);
}
}
if (ev_metadata_manager_get (NULL, "show_toolbar", &show_toolbar, FALSE)) {
if (!g_value_get_boolean (&show_toolbar))
chrome &= ~EV_CHROME_TOOLBAR;
+ g_value_unset (&show_toolbar);
}
window->priv->chrome = chrome;
}
-
static void
setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
{
GtkWidget *sidebar = window->priv->sidebar;
GtkWidget *links = window->priv->sidebar_links;
GtkWidget *thumbs = window->priv->sidebar_thumbs;
+ GtkWidget *attachments = window->priv->sidebar_attachments;
GValue sidebar_size = { 0, };
GValue sidebar_page = { 0, };
+ GValue sidebar_visibility = { 0, };
if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
g_value_get_int (&sidebar_size));
+ g_value_unset(&sidebar_size);
}
-
- if (ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
+
+ if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
const char *page_id = g_value_get_string (&sidebar_page);
-
- if (strcmp (page_id, "links") == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
+
+ 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") && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
+ } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && 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)) {
ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
}
- } else {
- if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
- ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
- }
+ 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);
}
- update_sidebar_visibility (window);
+ if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, g_value_get_boolean (&sidebar_visibility));
+ g_value_unset (&sidebar_visibility);
+ }
}
static void
} else {
gtk_window_unmaximize (GTK_WINDOW (window));
}
+ g_value_unset (&maximized);
}
if (restore_size &&
gtk_window_resize (GTK_WINDOW (window),
g_value_get_int (&width),
g_value_get_int (&height));
+ g_value_unset (&width);
+ g_value_unset (&height);
}
if (restore_size &&
ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
g_value_get_int (&y));
+ g_value_unset (&x);
+ g_value_unset (&y);
}
/* Sizing mode */
if (ev_metadata_manager_get (uri, "zoom", &zoom, FALSE) &&
ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
+ g_value_unset (&zoom);
}
/* Continuous */
if (ev_metadata_manager_get (uri, "continuous", &continuous, FALSE)) {
ev_view_set_continuous (view, g_value_get_boolean (&continuous));
+ g_value_unset (&continuous);
}
/* Dual page */
if (ev_metadata_manager_get (uri, "dual-page", &dual_page, FALSE)) {
ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
+ g_value_unset (&dual_page);
}
/* Presentation */
if (g_value_get_boolean (&presentation) && uri) {
ev_window_run_presentation (window);
}
+ g_value_unset (&presentation);
}
/* Fullscreen */
if (g_value_get_boolean (&fullscreen) && uri) {
ev_window_run_fullscreen (window);
}
+ g_value_unset (&fullscreen);
}
/* Rotation */
if (ev_metadata_manager_get (uri, "rotation", &rotation, TRUE)) {
if (g_value_get_int (&rotation)) {
switch (g_value_get_int (&rotation)) {
- case 90:
- ev_view_set_rotation (view, 90);
- break;
- case 180:
- ev_view_set_rotation (view, 180);
- break;
- case 270:
- ev_view_set_rotation (view, 270);
- break;
- default:
- break;
+ case 90:
+ ev_view_set_rotation (view, 90);
+ break;
+ case 180:
+ ev_view_set_rotation (view, 180);
+ break;
+ case 270:
+ ev_view_set_rotation (view, 270);
+ break;
+ default:
+ break;
}
}
+ g_value_unset (&rotation);
}
}
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->password_document),
+ ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->xfer_job->document),
password);
ev_document_doc_mutex_unlock ();
}
ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
- g_object_unref (ev_window->priv->password_document);
- ev_window->priv->password_document = NULL;
-
ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
static void
ev_window_popup_password_dialog (EvWindow *ev_window)
{
- g_assert (ev_window->priv->password_document);
+ g_assert (ev_window->priv->xfer_job);
gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
- if (ev_window->priv->password_document) {
- g_object_unref (ev_window->priv->password_document);
- ev_window->priv->password_document = NULL;
- }
-
/* Success! */
if (job->error == NULL) {
ev_window_setup_document (ev_window);
ev_window_add_recent (ev_window, ev_window->priv->uri);
- ev_window_clear_xfer_job (ev_window);
-
+
+ if (job->dest)
+ ev_window_goto_dest (ev_window, job->dest);
+
+ switch (job->mode) {
+ case EV_WINDOW_MODE_FULLSCREEN:
+ ev_window_run_fullscreen (ev_window);
+ break;
+ case EV_WINDOW_MODE_PRESENTATION:
+ ev_window_run_presentation (ev_window);
+ break;
+ case EV_WINDOW_MODE_PREVIEW:
+ ev_window_run_preview (ev_window);
+ break;
+ default:
+ break;
+ }
+
+ ev_window_clear_xfer_job (ev_window);
return;
}
ev_window->priv->uri = g_strdup (job->uri);
setup_view_from_metadata (ev_window);
- ev_window->priv->password_document = g_object_ref (document);
file_name = gnome_vfs_format_uri_for_display (job->uri);
base_name = g_path_get_basename (file_name);
ev_window_popup_password_dialog (ev_window);
} else {
- unable_to_load (ev_window, job->error->message);
+ ev_window_error_dialog (GTK_WINDOW (ev_window),
+ _("Unable to open document"),
+ job->error);
ev_window_clear_xfer_job (ev_window);
}
if (ev_window->priv->password_dialog)
gtk_widget_destroy (ev_window->priv->password_dialog);
ev_window->priv->password_dialog = NULL;
+
+#ifdef WITH_PRINT
+ if (ev_window->priv->print_dialog)
+ gtk_widget_destroy (ev_window->priv->print_dialog);
+ ev_window->priv->print_dialog = NULL;
+#endif
#ifdef WITH_GNOME_PRINT
- if (ev_window->priv->print_dialog) {
- gtk_widget_destroy (ev_window->priv->print_dialog);
+ if (ev_window->priv->print_job)
g_object_unref (ev_window->priv->print_job);
- }
- ev_window->priv->print_dialog = NULL;
ev_window->priv->print_job = NULL;
#endif
-
+
if (ev_window->priv->properties)
gtk_widget_destroy (ev_window->priv->properties);
ev_window->priv->properties = NULL;
}
void
-ev_window_open_uri (EvWindow *ev_window, const char *uri)
+ev_window_open_uri (EvWindow *ev_window,
+ const char *uri,
+ EvLinkDest *dest,
+ EvWindowRunMode mode)
{
- g_free (ev_window->priv->uri);
- ev_window->priv->uri = NULL;
-
ev_window_close_dialogs (ev_window);
ev_window_clear_xfer_job (ev_window);
ev_window_clear_local_uri (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
- ev_window->priv->xfer_job = ev_job_xfer_new (uri);
+ ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest, mode);
g_signal_connect (ev_window->priv->xfer_job,
"finished",
G_CALLBACK (ev_window_xfer_job_cb),
ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
}
+void
+ev_window_goto_dest (EvWindow *ev_window, EvLinkDest *dest)
+{
+ ev_view_goto_dest (EV_VIEW (ev_window->priv->view), dest);
+}
+
static void
file_open_dialog_response_cb (GtkWidget *chooser,
gint response_id,
G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
}
-static void
-save_error_dialog (GtkWindow *window, const gchar *file_name)
-{
- GtkWidget *error_dialog;
-
- error_dialog = gtk_message_dialog_new (
- window,
- (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("The file could not be saved as \"%s\"."),
- file_name);
-
- /* Easy way to make the text bold while keeping the string
- * above free from pango markup (FIXME ?) */
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (error_dialog), " ");
-
- gtk_dialog_run (GTK_DIALOG (error_dialog));
- gtk_widget_destroy (error_dialog);
-}
-
static void
file_save_dialog_response_cb (GtkWidget *fc,
gint response_id,
gboolean success;
if (response_id == GTK_RESPONSE_OK) {
- const char *uri;
+ gchar *uri;
+ GError *err = NULL;
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
ev_document_doc_mutex_lock ();
- success = ev_document_save (ev_window->priv->document, uri, NULL);
+ success = ev_document_save (ev_window->priv->document, uri, &err);
ev_document_doc_mutex_unlock ();
- if (!success) {
- save_error_dialog (GTK_WINDOW (fc), uri);
+ if (err) {
+ gchar *msg;
+ msg = g_strdup_printf (_("The file could not be saved as “%s”."), uri);
+ ev_window_error_dialog (GTK_WINDOW (fc), msg, err);
+ g_free (msg);
}
+
+ g_free (uri);
}
gtk_widget_destroy (fc);
ev_document_factory_add_filters (fc, ev_window->priv->document);
gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
-#ifdef HAVE_GTK_FILE_CHOOSER_SET_DO_OVERWRITE_CONFIRMATION
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (fc), TRUE);
-#endif
file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri);
base_name = g_path_get_basename (file_name);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
gtk_widget_show (fc);
}
+#ifdef WITH_GTK_PRINT
static void
-ev_window_print (EvWindow *window)
+ev_window_clear_print_job (EvWindow *window)
{
- EvPageCache *page_cache;
- int last_page;
+ if (window->priv->print_job) {
+ if (!window->priv->print_job->finished)
+ ev_job_queue_remove_job (window->priv->print_job);
- page_cache = ev_page_cache_get (window->priv->document);
- last_page = ev_page_cache_get_n_pages (page_cache);
+ g_signal_handlers_disconnect_by_func (window->priv->print_job,
+ ev_window_print_job_cb,
+ window);
+ g_object_unref (window->priv->print_job);
+ window->priv->print_job = NULL;
+ }
+}
-#ifdef WITH_GNOME_PRINT
- ev_window_print_range (window, 1, last_page);
-#endif
+static void
+ev_window_print_finished (GtkPrintJob *print_job,
+ EvWindow *window,
+ GError *error)
+{
+ 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),
+ error->message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
}
+static void
+ev_window_print_send (EvWindow *window,
+ const gchar *filename)
+{
+ GtkPrintJob *job;
+ GError *error = NULL;
+
+ if (window->priv->gtk_print_job)
+ g_object_unref (window->priv->gtk_print_job);
+
+ job = gtk_print_job_new ("evince-print",
+ window->priv->printer,
+ window->priv->print_settings,
+ window->priv->print_page_setup);
+
+ window->priv->gtk_print_job = job;
+
+ if (gtk_print_job_set_source_file (job, filename, &error)) {
+ gtk_print_job_send (job,
+ (GtkPrintJobCompleteFunc)ev_window_print_finished,
+ window, NULL);
+ } else {
+ ev_window_clear_print_job (window);
+ g_warning (error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+ev_window_print_job_cb (EvJobPrint *job,
+ EvWindow *window)
+{
+ if (job->error) {
+ g_warning (job->error->message);
+ ev_window_clear_print_job (window);
+ return;
+ }
+
+ g_assert (job->temp_file != NULL);
+
+ ev_window_print_send (window, job->temp_file);
+}
+
+static gboolean
+ev_window_print_dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ EvWindow *window)
+{
+ EvBackend document_type;
+ gboolean export_to_ps = TRUE;
+ GtkPrintPages print_pages;
+
+ if (response != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ window->priv->print_dialog = NULL;
+
+ return FALSE;
+ }
+
+ if (window->priv->printer)
+ g_object_unref (window->priv->printer);
+ if (window->priv->print_settings)
+ g_object_unref (window->priv->print_settings);
+ if (window->priv->print_page_setup)
+ g_object_unref (window->priv->print_page_setup);
+
+ window->priv->printer = g_object_ref (
+ gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (dialog)));
+ window->priv->print_settings = g_object_ref (
+ gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (dialog)));
+ window->priv->print_page_setup = g_object_ref (
+ gtk_print_unix_dialog_get_page_setup (GTK_PRINT_UNIX_DIALOG (dialog)));
+
+ document_type = ev_document_factory_get_backend (window->priv->document);
+ print_pages = gtk_print_settings_get_print_pages (window->priv->print_settings);
+
+ if (print_pages == GTK_PRINT_PAGES_ALL) {
+ switch (document_type) {
+ case EV_BACKEND_PDF:
+ /* Export to ps when printing to file */
+ if (gtk_print_settings_has_key (window->priv->print_settings,
+ GTK_PRINT_SETTINGS_OUTPUT_URI)) {
+ export_to_ps = TRUE;
+ } else {
+ export_to_ps = !gtk_printer_accepts_pdf (window->priv->printer);
+ }
+
+ break;
+ case EV_BACKEND_PS:
+ export_to_ps = FALSE;
+ break;
+ default:
+ export_to_ps = TRUE;
+ break;
+ }
+ }
+
+ if ((export_to_ps || document_type == EV_BACKEND_PS) &&
+ !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);
+
+ return FALSE;
+ }
+
+ if (export_to_ps) {
+ EvPrintRange *ranges = NULL;
+ EvPageCache *page_cache;
+ gint n_ranges = 0;
+ gint current_page;
+ gint width;
+ gint height;
+
+ ev_window_clear_print_job (window);
+
+ current_page =
+ gtk_print_unix_dialog_get_current_page (GTK_PRINT_UNIX_DIALOG (dialog));
+
+ switch (print_pages) {
+ case GTK_PRINT_PAGES_CURRENT:
+ ranges = g_new0 (EvPrintRange, 1);
+
+ ranges->start = current_page;
+ ranges->end = current_page;
+ n_ranges = 1;
+
+ break;
+ case GTK_PRINT_PAGES_RANGES: {
+ GtkPageRange *page_range;
+
+ page_range = gtk_print_settings_get_page_ranges (window->priv->print_settings,
+ &n_ranges);
+ if (n_ranges > 0)
+ ranges = g_memdup (page_range, n_ranges * sizeof (GtkPageRange));
+ }
+ break;
+ default:
+ break;
+ }
+
+ page_cache = ev_page_cache_get (window->priv->document);
+ ev_page_cache_get_size (page_cache,
+ current_page,
+ 0, 1.0,
+ &width, &height);
+
+ window->priv->print_job =
+ ev_job_print_new (window->priv->document,
+ ranges, n_ranges,
+ (gdouble)width,
+ (gdouble)height);
+
+ g_signal_connect (window->priv->print_job, "finished",
+ G_CALLBACK (ev_window_print_job_cb),
+ window);
+ /* The priority doesn't matter for this job */
+ ev_job_queue_add_job (window->priv->print_job, EV_JOB_PRIORITY_LOW);
+ } else {
+ gchar *filename;
+
+ filename = g_filename_from_uri (window->priv->uri, NULL, NULL);
+ ev_window_print_send (window, filename);
+ g_free (filename);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ window->priv->print_dialog = NULL;
+
+ return TRUE;
+}
+
+void
+ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
+{
+ GtkWidget *dialog;
+ EvPageCache *page_cache;
+ gint current_page;
+ gint document_last_page;
+
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+ g_return_if_fail (ev_window->priv->document != NULL);
+
+ if (ev_window->priv->print_dialog) {
+ gtk_window_present (GTK_WINDOW (ev_window->priv->print_dialog));
+ return;
+ }
+
+ page_cache = ev_page_cache_get (ev_window->priv->document);
+ current_page = ev_page_cache_get_current_page (page_cache);
+ document_last_page = ev_page_cache_get_n_pages (page_cache);
+
+ if (!ev_window->priv->print_settings)
+ ev_window->priv->print_settings = gtk_print_settings_new ();
+
+ if (first_page != 1 || last_page != document_last_page) {
+ GtkPageRange range;
+
+ /* Ranges in GtkPrint are 0 - N */
+ range.start = first_page - 1;
+ range.end = last_page - 1;
+
+ gtk_print_settings_set_print_pages (ev_window->priv->print_settings,
+ GTK_PRINT_PAGES_RANGES);
+ gtk_print_settings_set_page_ranges (ev_window->priv->print_settings,
+ &range, 1);
+ }
+
+ dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
+ ev_window->priv->print_dialog = dialog;
+ gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
+ GTK_PRINT_CAPABILITY_PAGE_SET |
+ GTK_PRINT_CAPABILITY_COPIES |
+ GTK_PRINT_CAPABILITY_COLLATE |
+ GTK_PRINT_CAPABILITY_REVERSE |
+ GTK_PRINT_CAPABILITY_SCALE |
+ GTK_PRINT_CAPABILITY_GENERATE_PS);
+ gtk_print_unix_dialog_set_current_page (GTK_PRINT_UNIX_DIALOG (dialog),
+ current_page);
+
+ gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG (dialog),
+ ev_window->priv->print_settings);
+
+ if (ev_window->priv->print_page_setup)
+ gtk_print_unix_dialog_set_page_setup (GTK_PRINT_UNIX_DIALOG (dialog),
+ ev_window->priv->print_page_setup);
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (ev_window_print_dialog_response_cb),
+ ev_window);
+
+ gtk_widget_show (dialog);
+}
+#endif /* WITH_GTK_PRINT */
#ifdef WITH_GNOME_PRINT
static gboolean
-ev_window_print_dialog_response_cb (GtkDialog *print_dialog, gint response, gpointer data)
+ev_window_print_dialog_response_cb (GtkDialog *print_dialog,
+ gint response,
+ EvWindow *ev_window)
{
- EvWindow *ev_window = EV_WINDOW (data);
- EvPrintJob *print_job;
- GnomePrintConfig *config;
+ EvPrintJob *print_job;
+ GnomePrintConfig *config;
- if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) {
- gtk_widget_destroy (GTK_WIDGET (print_dialog));
- ev_window->priv->print_dialog = NULL;
- g_object_unref (ev_window->priv->print_job);
- ev_window->priv->print_job = NULL;
- return FALSE;
- }
+ if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) {
+ gtk_widget_destroy (GTK_WIDGET (print_dialog));
+ ev_window->priv->print_dialog = NULL;
+ g_object_unref (ev_window->priv->print_job);
+ ev_window->priv->print_job = NULL;
+
+ return FALSE;
+ }
- config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (print_dialog));
-
- /* FIXME: Change this when we have the first backend
- * that can print more than postscript
- */
- if (using_pdf_printer (config)) {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Generating PDF is not supported"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return FALSE;
- } else if (!using_postscript_printer (config)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- _("Printing is not supported on this printer."));
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
- gnome_print_config_get (config, (guchar *)"Settings.Engine.Backend.Driver"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return FALSE;
- }
+ config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (print_dialog));
- save_print_config_to_file (config);
-
- print_job = g_object_new (EV_TYPE_PRINT_JOB,
- "gnome_print_job", ev_window->priv->print_job,
- "document", ev_window->priv->document,
- "print_dialog", print_dialog,
- NULL);
+ /* FIXME: Change this when we have the first backend
+ * that can print more than postscript
+ */
+ if (using_pdf_printer (config)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Generating PDF is not supported"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return FALSE;
+ } else if (!using_postscript_printer (config)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Printing is not supported on this printer."));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("You were trying to print to a printer using the “%s” driver. "
+ "This program requires a PostScript printer driver."),
+ gnome_print_config_get (config, (guchar *)"Settings.Engine.Backend.Driver"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return FALSE;
+ }
- if (print_job != NULL) {
- ev_print_job_print (print_job, GTK_WINDOW (ev_window));
- g_object_unref (print_job);
- }
+ save_print_config_to_file (config);
+
+ print_job = g_object_new (EV_TYPE_PRINT_JOB,
+ "gnome_print_job", ev_window->priv->print_job,
+ "document", ev_window->priv->document,
+ "print_dialog", print_dialog,
+ NULL);
+
+ if (print_job != NULL) {
+ ev_print_job_print (print_job, GTK_WINDOW (ev_window));
+ g_object_unref (print_job);
+ }
- g_object_unref (config);
+ g_object_unref (config);
- gtk_widget_destroy (GTK_WIDGET (print_dialog));
- ev_window->priv->print_dialog = NULL;
- g_object_unref (ev_window->priv->print_job);
- ev_window->priv->print_job = NULL;
+ gtk_widget_destroy (GTK_WIDGET (print_dialog));
+ ev_window->priv->print_dialog = NULL;
+ g_object_unref (ev_window->priv->print_job);
+ ev_window->priv->print_job = NULL;
- return FALSE;
+ return FALSE;
}
void
if (ev_window->priv->print_job == NULL)
ev_window->priv->print_job = gnome_print_job_new (config);
- if (ev_window->priv->print_dialog == NULL)
- ev_window->priv->print_dialog = gnome_print_dialog_new (ev_window->priv->print_job, (guchar *) _("Print"),
- (GNOME_PRINT_DIALOG_RANGE |
- GNOME_PRINT_DIALOG_COPIES));
- gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->print_dialog), GTK_WINDOW (ev_window));
+ if (ev_window->priv->print_dialog == NULL) {
+ ev_window->priv->print_dialog =
+ gnome_print_dialog_new (ev_window->priv->print_job,
+ (guchar *) _("Print"),
+ (GNOME_PRINT_DIALOG_RANGE |
+ GNOME_PRINT_DIALOG_COPIES));
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->print_dialog),
+ GTK_WINDOW (ev_window));
g_object_unref (config);
pages_label = g_strconcat (_("Pages"), " ", NULL);
GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
FALSE);
- g_signal_connect (G_OBJECT (ev_window->priv->print_dialog), "response", G_CALLBACK (ev_window_print_dialog_response_cb), ev_window);
+ g_signal_connect (G_OBJECT (ev_window->priv->print_dialog), "response",
+ G_CALLBACK (ev_window_print_dialog_response_cb),
+ ev_window);
gtk_widget_show (ev_window->priv->print_dialog);
- return;
}
#endif /* WITH_GNOME_PRINT */
-
+
+static void
+ev_window_print (EvWindow *window)
+{
+ EvPageCache *page_cache;
+ gint last_page;
+
+ page_cache = ev_page_cache_get (window->priv->document);
+ last_page = ev_page_cache_get_n_pages (page_cache);
+
+#ifdef WITH_PRINT
+ ev_window_print_range (window, 1, last_page);
+#endif
+}
+
static void
ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
{
ev_view_find_next (EV_VIEW (ev_window->priv->view));
}
+static void
+ev_window_cmd_edit_find_previous (GtkAction *action, EvWindow *ev_window)
+{
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ ev_view_find_previous (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
{
if (GTK_WIDGET (window)->window == NULL)
return;
- toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
+ toolbar = (window->priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
(window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0;
popup_width = popup->requisition.width;
popup_height = popup->requisition.height;
fullscreen_timeout_cb (gpointer data)
{
EvWindow *window = EV_WINDOW (data);
-
- g_object_set (window->priv->fullscreen_popup, "visible", FALSE, NULL);
+
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
ev_view_hide_cursor (EV_VIEW (window->priv->view));
- g_source_unref (window->priv->fullscreen_timeout_source);
- window->priv->fullscreen_timeout_source = NULL;
+ window->priv->fullscreen_timeout_id = 0;
return FALSE;
}
static void
fullscreen_set_timeout (EvWindow *window)
{
- GSource *source;
-
- if (window->priv->fullscreen_timeout_source != NULL) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
+ if (window->priv->fullscreen_timeout_id != 0) {
+ g_source_remove (window->priv->fullscreen_timeout_id);
}
+
+ window->priv->fullscreen_timeout_id =
+ g_timeout_add (FULLSCREEN_TIMEOUT, fullscreen_timeout_cb, window);
- source = g_timeout_source_new (FULLSCREEN_TIMEOUT);
- g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
- g_source_attach (source, NULL);
- window->priv->fullscreen_timeout_source = source;
+ update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, TRUE);
+ update_chrome_visibility (window);
+ ev_view_show_cursor (EV_VIEW (window->priv->view));
}
static void
fullscreen_clear_timeout (EvWindow *window)
{
- if (window->priv->fullscreen_timeout_source != NULL) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
+ if (window->priv->fullscreen_timeout_id != 0) {
+ g_source_remove (window->priv->fullscreen_timeout_id);
}
-
- window->priv->fullscreen_timeout_source = NULL;
+
+ window->priv->fullscreen_timeout_id = 0;
+ update_chrome_visibility (window);
ev_view_show_cursor (EV_VIEW (window->priv->view));
}
-static void
-show_fullscreen_popup (EvWindow *window)
-{
- if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
- g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
- ev_view_show_cursor (EV_VIEW (window->priv->view));
- }
-
- fullscreen_set_timeout (window);
-}
-
static gboolean
fullscreen_motion_notify_cb (GtkWidget *widget,
GdkEventMotion *event,
{
EvWindow *window = EV_WINDOW (user_data);
- show_fullscreen_popup (window);
+ fullscreen_set_timeout (window);
return FALSE;
}
GdkScreen *screen;
window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model
- (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
+ (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
popup = gtk_window_new (GTK_WINDOW_POPUP);
hbox = gtk_hbox_new (FALSE, 0);
static void
ev_window_run_fullscreen (EvWindow *window)
{
- ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
if (window->priv->fullscreen_popup == NULL)
window->priv->fullscreen_popup
= ev_window_create_fullscreen_popup (window);
- update_chrome_visibility (window);
- gtk_widget_hide (window->priv->sidebar);
-
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
NULL);
+
+ ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
+ ev_window_update_fullscreen_action (window);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ gtk_widget_grab_focus (window->priv->view);
+ ev_window_update_fullscreen_popup (window);
+
g_signal_connect (window->priv->view,
"motion-notify-event",
G_CALLBACK (fullscreen_motion_notify_cb),
window);
fullscreen_set_timeout (window);
- gtk_widget_grab_focus (window->priv->view);
- ev_window_update_fullscreen_action (window);
- gtk_window_fullscreen (GTK_WINDOW (window));
- ev_window_update_fullscreen_popup (window);
-
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
}
if (!ev_view_get_fullscreen (EV_VIEW (view)))
return;
- ev_view_set_fullscreen (view, FALSE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
- fullscreen_clear_timeout (window);
+ ev_view_set_fullscreen (view, FALSE);
+ ev_window_update_fullscreen_action (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
- g_signal_handlers_disconnect_by_func (view,
+ g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) fullscreen_motion_notify_cb,
window);
- g_signal_handlers_disconnect_by_func (view,
+ g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) fullscreen_leave_notify_cb,
window);
- ev_window_update_fullscreen_action (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
- update_chrome_visibility (window);
- update_sidebar_visibility (window);
+ fullscreen_clear_timeout (window);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
"shadow-type", GTK_SHADOW_NONE,
NULL);
- gtk_widget_grab_focus (window->priv->view);
ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
- gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
- update_chrome_visibility (window);
- gtk_widget_hide (window->priv->sidebar);
+
+ gtk_widget_grab_focus (window->priv->view);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+
+ g_signal_connect (window->priv->view,
+ "motion-notify-event",
+ G_CALLBACK (fullscreen_motion_notify_cb),
+ window);
+ g_signal_connect (window->priv->view,
+ "leave-notify-event",
+ G_CALLBACK (fullscreen_leave_notify_cb),
+ window);
+ fullscreen_set_timeout (window);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
+
ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
- gtk_window_unfullscreen (GTK_WINDOW (window));
ev_window_update_presentation_action (window);
- update_chrome_visibility (window);
- update_sidebar_visibility (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
+
+ g_signal_handlers_disconnect_by_func (window->priv->view,
+ (gpointer) fullscreen_motion_notify_cb,
+ window);
+ g_signal_handlers_disconnect_by_func (window->priv->view,
+ (gpointer) fullscreen_leave_notify_cb,
+ window);
+ fullscreen_clear_timeout (window);
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
}
}
+static void
+ev_window_run_preview (EvWindow *window)
+{
+ EggToolbarsModel *model;
+ EggTbModelFlags flags;
+
+ model = egg_toolbars_model_new ();
+
+ egg_toolbars_model_load_toolbars (model,
+ DATADIR"/evince-toolbar.xml");
+
+ flags = egg_toolbars_model_get_flags (model, 1);
+ egg_toolbars_model_set_flags (model, 1, flags &= ~(EGG_TB_MODEL_HIDDEN));
+
+ egg_editable_toolbar_set_model (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ model);
+
+ egg_editable_toolbar_hide (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "DefaultToolBar");
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
+ "PreviewToolBar");
+
+ ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
+
+ update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
+ update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
+ update_chrome_visibility (window);
+}
+
static gboolean
ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
- gboolean fullscreen;
-
- g_object_get (priv->view,
- "fullscreen", &fullscreen,
- NULL);
- if (fullscreen)
- show_fullscreen_popup (window);
+ if (ev_view_get_fullscreen (EV_VIEW (priv->view)))
+ fullscreen_set_timeout (window);
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
}
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
- gboolean fullscreen;
-
- g_object_get (priv->view,
- "fullscreen", &fullscreen,
- NULL);
- if (fullscreen)
+ if (ev_view_get_fullscreen (EV_VIEW (priv->view))) {
+ fullscreen_set_timeout (window);
gtk_widget_hide (priv->fullscreen_popup);
+ }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
}
window->priv->page_mode = page_mode;
switch (page_mode) {
- case PAGE_MODE_DOCUMENT:
- child = window->priv->view;
- break;
- case PAGE_MODE_PASSWORD:
- child = window->priv->password_view;
- break;
- default:
- g_assert_not_reached ();
+ case PAGE_MODE_DOCUMENT:
+ child = window->priv->view;
+ break;
+ case PAGE_MODE_PASSWORD:
+ child = window->priv->password_view;
+ break;
+ default:
+ g_assert_not_reached ();
}
real_child = gtk_bin_get_child (GTK_BIN (window->priv->scrolled_window));
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
- egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
- DATADIR "/evince-toolbar.xml");
egg_editable_toolbar_set_edit_mode
(EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
{
char *uri;
- int page;
g_return_if_fail (EV_IS_WINDOW (ev_window));
- page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
uri = g_strdup (ev_window->priv->uri);
- ev_window_open_uri (ev_window, uri);
-
- /* In case the number of pages in the document has changed. */
- page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache) - 1);
-
- ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
+ ev_window_open_uri (ev_window, uri, NULL, 0);
g_free (uri);
}
update_view_size (NULL, ev_window);
switch (sizing_mode) {
- case EV_SIZING_BEST_FIT:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (update_view_size),
- ev_window);
- break;
- case EV_SIZING_FIT_WIDTH:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_NEVER,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- g_signal_connect (ev_window->priv->view, "zoom_invalid",
- G_CALLBACK (update_view_size),
- ev_window);
- break;
- case EV_SIZING_FREE:
- g_object_set (G_OBJECT (scrolled_window),
- "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
- break;
+ case EV_SIZING_BEST_FIT:
+ g_object_set (G_OBJECT (scrolled_window),
+ "hscrollbar-policy", GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
+ g_signal_connect (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (update_view_size),
+ ev_window);
+ break;
+ case EV_SIZING_FIT_WIDTH:
+ g_object_set (G_OBJECT (scrolled_window),
+ "hscrollbar-policy", GTK_POLICY_NEVER,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
+ g_signal_connect (ev_window->priv->view, "zoom_invalid",
+ G_CALLBACK (update_view_size),
+ ev_window);
+ break;
+ case EV_SIZING_FREE:
+ g_object_set (G_OBJECT (scrolled_window),
+ "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
+ break;
}
update_sizing_buttons (ev_window);
"Marco Pesenti Gritti <marco@gnome.org>",
"Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
"Bryan Clark <clarkbw@gnome.org>",
+ "Carlos Garcia Campos <carlosgc@gnome.org>",
NULL
};
};
const char *license[] = {
- N_("Evince is free software; you can redistribute it and/or modify\n"
- "it under the terms of the GNU General Public License as published by\n"
- "the Free Software Foundation; either version 2 of the License, or\n"
+ N_("Evince is free software; you can redistribute it and/or modify "
+ "it under the terms of the GNU General Public License as published by "
+ "the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n"),
- N_("Evince is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ N_("Evince is distributed in the hope that it will be useful, "
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n"),
- N_("You should have received a copy of the GNU General Public License\n"
- "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
+ N_("You should have received a copy of the GNU General Public License "
+ "along with Evince; if not, write to the Free Software Foundation, Inc., "
"59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
};
"authors", authors,
"documenters", documenters,
"translator-credits", _("translator-credits"),
+ "logo-icon-name", "evince",
+ "wrap-license", TRUE,
NULL);
g_free (comments);
static void
ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
- set_widget_visibility (ev_window->priv->sidebar,
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
+ gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
static void
id = LINKS_SIDEBAR_ID;
} else if (current_page == ev_window->priv->sidebar_thumbs) {
id = THUMBNAILS_SIDEBAR_ID;
+ } else if (current_page == ev_window->priv->sidebar_attachments) {
+ id = ATTACHMENTS_SIDEBAR_ID;
} else {
g_assert_not_reached();
}
}
static void
-ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
+ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_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");
-
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
GTK_WIDGET_VISIBLE (ev_sidebar));
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
if (!ev_view_get_presentation (view) &&
- !ev_view_get_fullscreen (view) &&
- !ev_window_is_empty (ev_window)) {
+ !ev_view_get_fullscreen (view)) {
ev_metadata_manager_set_boolean (ev_window->priv->uri, "sidebar_visibility",
GTK_WIDGET_VISIBLE (ev_sidebar));
}
}
static gboolean
-view_menu_popup_cb (EvView *view,
- EvLink *link,
- EvWindow *ev_window)
+view_menu_popup_cb (EvView *view,
+ EvLink *link,
+ EvWindow *ev_window)
{
GtkWidget *popup;
gboolean show_external = FALSE;
if (ev_window->priv->link)
g_object_unref (ev_window->priv->link);
+
if (link)
ev_window->priv->link = g_object_ref (link);
else
ev_window->priv->link = NULL;
- popup = ev_window->priv->popup;
+ popup = ev_window->priv->view_popup;
+
+ if (ev_window->priv->link) {
+ EvLinkAction *ev_action;
- if (ev_window->priv->link)
- switch (ev_link_get_link_type (ev_window->priv->link)) {
- case EV_LINK_TYPE_PAGE:
- case EV_LINK_TYPE_PAGE_FIT:
- case EV_LINK_TYPE_PAGE_FITH:
- case EV_LINK_TYPE_PAGE_FITV:
- case EV_LINK_TYPE_PAGE_FITR:
- case EV_LINK_TYPE_PAGE_XYZ:
+ ev_action = ev_link_get_action (link);
+ if (!ev_action)
+ return FALSE;
+
+ switch (ev_link_action_get_action_type (ev_action)) {
+ case EV_LINK_ACTION_TYPE_GOTO_DEST:
+ case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
show_internal = TRUE;
break;
- case EV_LINK_TYPE_EXTERNAL_URI:
- case EV_LINK_TYPE_LAUNCH:
+ case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+ case EV_LINK_ACTION_TYPE_LAUNCH:
show_external = TRUE;
break;
- default:
+ default:
break;
}
+ }
- action = gtk_action_group_get_action (ev_window->priv->popups_action_group,
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
"OpenLink");
gtk_action_set_visible (action, show_external);
- action = gtk_action_group_get_action (ev_window->priv->popups_action_group,
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
"CopyLinkAddress");
gtk_action_set_visible (action, show_external);
- action = gtk_action_group_get_action (ev_window->priv->popups_action_group,
+ action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
"GoLink");
gtk_action_set_visible (action, show_internal);
gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
NULL, NULL,
3, gtk_get_current_event_time ());
- return FALSE;
+ return TRUE;
+}
+
+static gboolean
+attachment_bar_menu_popup_cb (EvSidebarAttachments *attachbar,
+ GList *attach_list,
+ EvWindow *ev_window)
+{
+ GtkWidget *popup;
+
+ g_assert (attach_list != NULL);
+
+ 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 = attach_list;
+
+ popup = ev_window->priv->attachment_popup;
+
+ gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
+ NULL, NULL,
+ 3, gtk_get_current_event_time ());
+
+ return TRUE;
}
static void
priv->action_group = NULL;
}
- if (priv->popups_action_group) {
- g_object_unref (priv->popups_action_group);
- priv->popups_action_group = NULL;
+ if (priv->view_popup_action_group) {
+ g_object_unref (priv->view_popup_action_group);
+ priv->view_popup_action_group = NULL;
+ }
+
+ if (priv->attachment_popup_action_group) {
+ g_object_unref (priv->attachment_popup_action_group);
+ priv->attachment_popup_action_group = NULL;
}
if (priv->page_cache) {
if (priv->local_uri) {
ev_window_clear_local_uri (window);
}
+
+ ev_window_close_dialogs (window);
- if (priv->password_document) {
- g_object_unref (priv->password_document);
- priv->password_document = NULL;
+#ifdef WITH_GTK_PRINT
+ ev_window_clear_print_job (window);
+
+ if (window->priv->gtk_print_job) {
+ g_object_unref (window->priv->gtk_print_job);
+ window->priv->gtk_print_job = NULL;
}
- ev_window_close_dialogs (window);
+ if (window->priv->printer) {
+ g_object_unref (window->priv->printer);
+ window->priv->printer = NULL;
+ }
+
+ if (window->priv->print_settings) {
+ g_object_unref (window->priv->print_settings);
+ window->priv->print_settings = NULL;
+ }
+
+ if (window->priv->print_page_setup) {
+ g_object_unref (window->priv->print_page_setup);
+ window->priv->print_page_setup = NULL;
+ }
+#endif
if (priv->link) {
g_object_unref (priv->link);
priv->link = NULL;
}
+ if (priv->attach_list) {
+ g_list_foreach (priv->attach_list,
+ (GFunc) g_object_unref,
+ NULL);
+ g_list_free (priv->attach_list);
+ priv->attach_list = NULL;
+ }
+
if (priv->find_bar) {
g_signal_handlers_disconnect_by_func
(window->priv->find_bar,
priv->uri = NULL;
}
- if (window->priv->fullscreen_timeout_source) {
- g_source_unref (window->priv->fullscreen_timeout_source);
- g_source_destroy (window->priv->fullscreen_timeout_source);
- window->priv->fullscreen_timeout_source = NULL;
+ if (priv->dest) {
+ g_object_unref (priv->dest);
+ priv->dest = NULL;
+ }
+
+ if (priv->fullscreen_timeout_id) {
+ g_source_remove (priv->fullscreen_timeout_id);
+ priv->fullscreen_timeout_id = 0;
}
destroy_fullscreen_popup (window);
G_CALLBACK (ev_window_cmd_edit_copy) },
{ "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
G_CALLBACK (ev_window_cmd_edit_select_all) },
- { "EditFind", GTK_STOCK_FIND, NULL, "<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,
G_CALLBACK (ev_window_cmd_edit_find_next) },
+ { "EditFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
+ G_CALLBACK (ev_window_cmd_edit_find_previous) },
{ "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
G_CALLBACK (ev_window_cmd_edit_toolbar) },
{ "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL,
};
/* Popups specific items */
-static const GtkActionEntry popups_entries [] = {
+static const GtkActionEntry view_popup_entries [] = {
/* Links */
{ "OpenLink", GTK_STOCK_OPEN, N_("_Open Link"), NULL,
- NULL, G_CALLBACK (ev_popup_cmd_open_link) },
+ NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
{ "GoLink", GTK_STOCK_GO_FORWARD, N_("_Go To"), NULL,
- NULL, G_CALLBACK (ev_popup_cmd_open_link) },
+ NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
{ "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
NULL,
- G_CALLBACK (ev_popup_cmd_copy_link_address) },
+ G_CALLBACK (ev_view_popup_cmd_copy_link_address) },
+};
+
+static const GtkActionEntry attachment_popup_entries [] = {
+ { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open..."), NULL,
+ NULL, G_CALLBACK (ev_attachment_popup_cmd_open_attachment) },
+ { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
+ NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
};
static void
ev_application_open_uri_list (EV_APP, uris, 0);
g_slist_free (uris);
-
- gtk_drag_finish (context, TRUE, FALSE, time);
}
}
static void
activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
{
- g_return_if_fail (EV_IS_WINDOW (window));
-
- ev_view_goto_link (EV_VIEW (window->priv->view), link);
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
gtk_widget_grab_focus (window->priv->view);
}
static void
sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
{
- ev_view_goto_link (EV_VIEW (window->priv->view), link);
+ ev_view_handle_link (EV_VIEW (window->priv->view), link);
}
static void
-launch_link (EvWindow *window, EvLink *link)
+launch_action (EvWindow *window, EvLinkAction *action)
{
- const char *filename = ev_link_get_filename (link);
+ const char *filename = ev_link_action_get_filename (action);
char *uri = NULL;
if (filename && g_path_is_absolute (filename)) {
}
static void
-launch_external_uri (EvWindow *window, EvLink *link)
+launch_external_uri (EvWindow *window, EvLinkAction *action)
{
const char *uri;
char *escaped;
- uri = ev_link_get_uri (link);
+ uri = ev_link_action_get_uri (action);
escaped = gnome_vfs_escape_host_and_path_string (uri);
gnome_vfs_url_show (escaped);
}
static void
-view_external_link_cb (EvView *view, EvLink *link, EvWindow *window)
+open_remote_link (EvWindow *window, EvLinkAction *action)
+{
+ gchar *uri;
+ gchar *dir;
+
+ dir = g_path_get_dirname (window->priv->uri);
+
+ uri = g_build_filename (dir, ev_link_action_get_filename (action),
+ NULL);
+ g_free (dir);
+
+ ev_application_open_uri_at_dest (EV_APP, uri,
+ ev_link_action_get_dest (action),
+ 0,
+ GDK_CURRENT_TIME);
+
+ g_free (uri);
+}
+
+static void
+do_action_named (EvWindow *window, EvLinkAction *action)
+{
+ const gchar *name = ev_link_action_get_name (action);
+
+ if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
+ ev_window_cmd_go_first_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
+ ev_window_cmd_go_previous_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
+ ev_window_cmd_go_next_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
+ ev_window_cmd_go_last_page (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
+ ev_window_cmd_focus_page_selector (NULL, window);
+ } else if (g_ascii_strcasecmp (name, "Find") == 0) {
+ ev_window_cmd_edit_find (NULL, window);
+ } else {
+ g_warning ("Unimplemented named action: %s, please post a "
+ "bug report in Evince bugzilla "
+ "(http://bugzilla.gnome.org) with a testcase.",
+ name);
+ }
+}
+
+static void
+view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
{
- switch (ev_link_get_link_type (link)) {
- case EV_LINK_TYPE_EXTERNAL_URI:
- launch_external_uri (window, link);
- break;
- case EV_LINK_TYPE_LAUNCH:
- launch_link (window, link);
- break;
- default:
- g_assert_not_reached ();
+ switch (ev_link_action_get_action_type (action)) {
+ case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+ launch_external_uri (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_LAUNCH:
+ launch_action (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
+ open_remote_link (window, action);
+ break;
+ case EV_LINK_ACTION_TYPE_NAMED:
+ do_action_named (window, action);
+ break;
+ default:
+ g_assert_not_reached ();
}
}
static void
-ev_popup_cmd_open_link (GtkAction *action, EvWindow *window)
+ev_view_popup_cmd_open_link (GtkAction *action, EvWindow *window)
{
- ev_view_goto_link (EV_VIEW (window->priv->view), window->priv->link);
+ ev_view_handle_link (EV_VIEW (window->priv->view), window->priv->link);
}
static void
-ev_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
+ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
{
GtkClipboard *clipboard;
+ EvLinkAction *ev_action;
const gchar *uri;
- uri = ev_link_get_uri (window->priv->link);
+ ev_action = ev_link_get_action (window->priv->link);
+ if (!ev_action)
+ return;
+
+ uri = ev_link_action_get_uri (ev_action);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, uri, -1);
}
+static void
+ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
+{
+ GList *l;
+
+ if (!window->priv->attach_list)
+ return;
+
+ 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);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (window),
+ _("Unable to open attachment"),
+ error);
+ g_error_free (error);
+ }
+ }
+}
+
+static void
+attachment_save_dialog_response_cb (GtkWidget *fc,
+ gint response_id,
+ EvWindow *ev_window)
+{
+ gchar *uri;
+ GList *l;
+ GtkFileChooserAction fc_action;
+ gboolean is_dir;
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (fc);
+ return;
+ }
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
+
+ g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
+ is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
+ EvAttachment *attachment;
+ gchar *filename;
+ GError *error = NULL;
+
+ attachment = (EvAttachment *) l->data;
+
+ if (is_dir) {
+ filename = g_strjoin ("/", uri,
+ ev_attachment_get_name (attachment),
+ NULL);
+ } else {
+ filename = g_strdup (uri);
+ }
+
+ ev_attachment_save (attachment, filename, &error);
+ g_free (filename);
+
+ if (error) {
+ ev_window_error_dialog (GTK_WINDOW (fc),
+ _("The attachment could not be saved."),
+ error);
+ g_error_free (error);
+ }
+ }
+
+ g_free (uri);
+
+ gtk_widget_destroy (fc);
+}
+
+static void
+ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, EvWindow *window)
+{
+ GtkWidget *fc;
+ EvAttachment *attachment = NULL;
+
+ if (!window->priv->attach_list)
+ return;
+
+ if (g_list_length (window->priv->attach_list) == 1)
+ attachment = (EvAttachment *) window->priv->attach_list->data;
+
+ fc = gtk_file_chooser_dialog_new (
+ _("Save a Copy"),
+ GTK_WINDOW (window),
+ attachment ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
+
+ if (attachment)
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc),
+ ev_attachment_get_name (attachment));
+
+ g_signal_connect (fc, "response",
+ G_CALLBACK (attachment_save_dialog_response_cb),
+ window);
+
+ gtk_widget_show (fc);
+}
+
static void
ev_window_init (EvWindow *ev_window)
{
ev_window_set_view_accels_sensitivity (ev_window, FALSE);
- action_group = gtk_action_group_new ("PopupsActions");
- ev_window->priv->popups_action_group = action_group;
+ action_group = gtk_action_group_new ("ViewPopupActions");
+ ev_window->priv->view_popup_action_group = action_group;
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, view_popup_entries,
+ G_N_ELEMENTS (view_popup_entries),
+ ev_window);
+ gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+ action_group, 0);
+
+ action_group = gtk_action_group_new ("AttachmentPopupActions");
+ ev_window->priv->attachment_popup_action_group = action_group;
gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group, popups_entries,
- G_N_ELEMENTS (popups_entries), ev_window);
+ gtk_action_group_add_actions (action_group, attachment_popup_entries,
+ G_N_ELEMENTS (attachment_popup_entries),
+ ev_window);
gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
action_group, 0);
gtk_widget_show (toolbar_dock);
ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
- (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
+ (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
"DefaultToolBar");
gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
gtk_widget_show (ev_window->priv->sidebar);
/* Stub sidebar, for now */
+
sidebar_widget = ev_sidebar_links_new ();
ev_window->priv->sidebar_links = sidebar_widget;
g_signal_connect (sidebar_widget,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
+ sidebar_widget = ev_sidebar_attachments_new ();
+ ev_window->priv->sidebar_attachments = sidebar_widget;
+ g_signal_connect_object (sidebar_widget,
+ "popup",
+ G_CALLBACK (attachment_bar_menu_popup_cb),
+ ev_window, 0);
+ gtk_widget_show (sidebar_widget);
+ ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+ sidebar_widget);
+
sidebar_widget = ev_sidebar_thumbnails_new ();
ev_window->priv->sidebar_thumbs = sidebar_widget;
g_signal_connect (sidebar_widget,
ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
sidebar_widget);
-
ev_window->priv->scrolled_window =
GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"shadow-type", GTK_SHADOW_IN,
gtk_widget_show (ev_window->priv->view);
gtk_widget_show (ev_window->priv->password_view);
+ /* Find Bar */
ev_window->priv->find_bar = egg_find_bar_new ();
gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
ev_window->priv->find_bar,
ev_window);
/* Popups */
- ev_window->priv->popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
- "/DocumentPopup");
+ ev_window->priv->view_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/DocumentPopup");
ev_window->priv->link = NULL;
+ ev_window->priv->attachment_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/AttachmentPopup");
+ ev_window->priv->attach_list = NULL;
+
/* Give focus to the document view */
gtk_widget_grab_focus (ev_window->priv->view);
/* Drag and Drop */
- gtk_drag_dest_unset (GTK_WIDGET (ev_window));
- gtk_drag_dest_set (GTK_WIDGET (ev_window), GTK_DEST_DEFAULT_ALL, ev_drop_types,
+ gtk_drag_dest_unset (GTK_WIDGET (ev_window->priv->view));
+ gtk_drag_dest_set (GTK_WIDGET (ev_window->priv->view),
+ GTK_DEST_DEFAULT_ALL,
+ ev_drop_types,
sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
GDK_ACTION_COPY);
- g_signal_connect (G_OBJECT (ev_window), "drag_data_received",
- G_CALLBACK (drag_data_received_cb), NULL);
-
+ g_signal_connect_swapped (G_OBJECT (ev_window->priv->view), "drag-data-received",
+ G_CALLBACK (drag_data_received_cb),
+ ev_window);
+
/* Set it user interface params */
ev_window_setup_recent (ev_window);
+
setup_chrome_from_metadata (ev_window);
set_chrome_actions (ev_window);
update_chrome_visibility (ev_window);
- update_sidebar_visibility (ev_window);
- gtk_window_set_default_size (GTK_WINDOW (ev_window),
- 600, 600);
+ gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
+
setup_view_from_metadata (ev_window);
+ setup_sidebar_from_metadata (ev_window, NULL);
ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
ev_window_setup_action_sensitivity (ev_window);