#include "ev-history.h"
#include "ev-image.h"
#include "ev-message-area.h"
+#include "ev-mount-operation.h"
#include <gtk/gtkprintunixdialog.h>
static void ev_window_add_recent (EvWindow *window,
const char *filename);
static void ev_window_run_fullscreen (EvWindow *window);
-static void ev_window_stop_fullscreen (EvWindow *window);
+static void ev_window_stop_fullscreen (EvWindow *window,
+ gboolean unfullscreen_window);
static void ev_window_cmd_view_fullscreen (GtkAction *action,
EvWindow *window);
static void ev_window_run_presentation (EvWindow *window);
-static void ev_window_stop_presentation (EvWindow *window);
+static void ev_window_stop_presentation (EvWindow *window,
+ gboolean unfullscreen_window);
static void ev_window_cmd_view_presentation (GtkAction *action,
EvWindow *window);
static void ev_window_run_preview (EvWindow *window);
GParamSpec *param,
EvWindow *ev_window);
static void ev_window_do_preview_print (EvWindow *window);
+static void ev_window_load_file_remote (EvWindow *ev_window,
+ GFile *source_file);
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
static void
ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
{
-
- EvRenderContext *rc;
gint page_width, page_height;
gdouble scale;
EvDocument *document = ev_window->priv->document;
&page_width, &page_height);
scale = (gdouble)128 / (gdouble)page_width;
- rc = ev_render_context_new (rotation, 0, scale);
-
- ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+ ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
G_CALLBACK (ev_window_set_icon_from_thumbnail),
ev_window);
ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
- g_object_unref (rc);
}
static gboolean
ev_window->priv->properties = NULL;
}
+static void
+ev_window_load_remote_failed (EvWindow *ev_window,
+ GError *error)
+{
+ ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+ ev_window->priv->in_reload = FALSE;
+ ev_window_error_message (GTK_WINDOW (ev_window),
+ _("Unable to open document"),
+ error);
+ g_free (ev_window->priv->local_uri);
+ ev_window->priv->local_uri = NULL;
+}
+
+static void
+mount_volume_ready_cb (GFile *source,
+ GAsyncResult *async_result,
+ EvWindow *ev_window)
+{
+ GError *error = NULL;
+
+ g_file_mount_enclosing_volume_finish (source, async_result, &error);
+
+ if (error) {
+ ev_window_load_remote_failed (ev_window, error);
+ g_object_unref (source);
+ g_error_free (error);
+ } else {
+ /* Volume successfully mounted,
+ try opening the file again */
+ ev_window_load_file_remote (ev_window, source);
+ }
+}
+
static void
window_open_file_copy_ready_cb (GFile *source,
GAsyncResult *async_result,
if (error->domain == G_IO_ERROR &&
error->code == G_IO_ERROR_NOT_MOUNTED) {
- /* TODO: try to mount */
+ GMountOperation *operation;
+
+ operation = ev_mount_operation_new (GTK_WINDOW (ev_window));
+ g_file_mount_enclosing_volume (source,
+ G_MOUNT_MOUNT_NONE,
+ operation, NULL,
+ (GAsyncReadyCallback)mount_volume_ready_cb,
+ ev_window);
+ g_object_unref (operation);
+ } else {
+ ev_window_load_remote_failed (ev_window, error);
+ g_object_unref (source);
}
-
- ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
- ev_window->priv->in_reload = FALSE;
- ev_window_error_message (GTK_WINDOW (ev_window),
- _("Unable to open document"),
- error);
- g_free (ev_window->priv->local_uri);
- ev_window->priv->local_uri = NULL;
g_error_free (error);
- g_object_unref (source);
}
static void
_("The file could not be saved as ā%sā."),
name);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message);
+ "%s", error->message);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
GTK_BUTTONS_OK,
_("Failed to print document"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message);
+ "%s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
GtkPrintJob *job;
GError *error = NULL;
- job = gtk_print_job_new ("evince-print",
+ job = gtk_print_job_new (gtk_window_get_title (GTK_WINDOW (window)),
window->priv->printer,
settings,
window->priv->print_page_setup);
window, NULL);
} else {
ev_window_clear_print_job (window);
- g_warning (error->message);
+ g_warning ("%s", error->message);
g_error_free (error);
}
}
EvWindow *window)
{
if (job->error) {
- g_warning (job->error->message);
+ g_warning ("%s", job->error->message);
ev_window_clear_print_job (window);
return;
}
{
gboolean continuous;
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"continuous", continuous,
{
gboolean dual_page;
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"dual-page", dual_page,
static void
ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
{
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
static void
ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
- ev_window_stop_presentation (ev_window);
+ ev_window_stop_presentation (ev_window, TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
static void
ev_window_run_fullscreen (EvWindow *window)
{
+ EvView *view = EV_VIEW (window->priv->view);
+ gboolean fullscreen_window = TRUE;
+
+ if (ev_view_get_fullscreen (view))
+ return;
+
if (!window->priv->fullscreen_toolbar) {
window->priv->fullscreen_toolbar =
gtk_ui_manager_get_widget (window->priv->ui_manager,
window->priv->fullscreen_toolbar, 1);
}
+ if (ev_view_get_presentation (view)) {
+ ev_window_stop_presentation (window, FALSE);
+ fullscreen_window = FALSE;
+ }
+
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_view_set_fullscreen (view, TRUE);
ev_window_update_fullscreen_action (window);
/* If the user doesn't have the main toolbar he/she won't probably want
update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR,
(window->priv->chrome & EV_CHROME_TOOLBAR) != 0);
update_chrome_visibility (window);
-
- gtk_window_fullscreen (GTK_WINDOW (window));
+
+ if (fullscreen_window)
+ gtk_window_fullscreen (GTK_WINDOW (window));
gtk_widget_grab_focus (window->priv->view);
if (!ev_window_is_empty (window))
}
static void
-ev_window_stop_fullscreen (EvWindow *window)
+ev_window_stop_fullscreen (EvWindow *window,
+ gboolean unfullscreen_window)
{
EvView *view = EV_VIEW (window->priv->view);
- if (!ev_view_get_fullscreen (EV_VIEW (view)))
+ if (!ev_view_get_fullscreen (view))
return;
g_object_set (G_OBJECT (window->priv->scrolled_window),
ev_window_update_fullscreen_action (window);
update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
update_chrome_visibility (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (unfullscreen_window)
+ gtk_window_unfullscreen (GTK_WINDOW (window));
if (!ev_window_is_empty (window))
ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
{
gboolean fullscreen;
- g_return_if_fail (EV_IS_WINDOW (window));
- ev_window_stop_presentation (window);
-
fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (fullscreen) {
ev_window_run_fullscreen (window);
} else {
- ev_window_stop_fullscreen (window);
+ ev_window_stop_fullscreen (window, TRUE);
}
}
static void
ev_window_run_presentation (EvWindow *window)
{
+ EvView *view = EV_VIEW (window->priv->view);
+ gboolean fullscreen_window = TRUE;
+
+ if (ev_view_get_presentation (view))
+ return;
+
+ if (ev_view_get_fullscreen (view)) {
+ ev_window_stop_fullscreen (window, FALSE);
+ fullscreen_window = FALSE;
+ }
+
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_NONE,
NULL);
- ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
+ ev_view_set_presentation (view, TRUE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
gtk_widget_grab_focus (window->priv->view);
- gtk_window_fullscreen (GTK_WINDOW (window));
+ if (fullscreen_window)
+ gtk_window_fullscreen (GTK_WINDOW (window));
g_signal_connect (window->priv->view,
"motion-notify-event",
}
static void
-ev_window_stop_presentation (EvWindow *window)
+ev_window_stop_presentation (EvWindow *window,
+ gboolean unfullscreen_window)
{
- if (!ev_view_get_presentation (EV_VIEW (window->priv->view)))
+ EvView *view = EV_VIEW (window->priv->view);
+
+ if (!ev_view_get_presentation (view))
return;
g_object_set (G_OBJECT (window->priv->scrolled_window),
ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (unfullscreen_window)
+ gtk_window_unfullscreen (GTK_WINDOW (window));
g_signal_handlers_disconnect_by_func (window->priv->view,
(gpointer) presentation_motion_notify_cb,
{
gboolean presentation;
- g_return_if_fail (EV_IS_WINDOW (window));
- ev_window_stop_fullscreen (window);
-
presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (presentation) {
ev_window_run_presentation (window);
} else {
- ev_window_stop_presentation (window);
+ ev_window_stop_presentation (window, TRUE);
}
}
screen = gtk_widget_get_screen (GTK_WIDGET (ev_window));
gdk_spawn_command_line_on_screen (screen, command, &error);
if (error != NULL) {
- g_warning (error->message);
+ g_warning ("%s", error->message);
g_error_free (error);
}
g_free (command);
static void
ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
{
- ev_window_stop_fullscreen (window);
+ ev_window_stop_fullscreen (window, TRUE);
}
static void
ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window)
{
- ev_window_stop_fullscreen (window);
ev_window_run_presentation (window);
}
GTK_BUTTONS_OK,
_("Failed to print document"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- error->message);
+ "%s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
page_setup = gtk_page_setup_new ();
- job = gtk_print_job_new ("evince-print",
+ job = gtk_print_job_new (gtk_window_get_title (GTK_WINDOW (window)),
priv->printer,
priv->print_settings,
page_setup);
(GtkPrintJobCompleteFunc)ev_window_preview_print_finished,
window, NULL);
} else {
- g_warning (error->message);
+ g_warning ("%s", error->message);
g_error_free (error);
}
&error);
if (error) {
- g_warning (error->message);
+ g_warning ("%s", error->message);
g_error_free (error);
print_settings = NULL;
}
NULL);
if (fullscreen) {
- ev_window_stop_fullscreen (window);
+ ev_window_stop_fullscreen (window, TRUE);
} else if (presentation) {
- ev_window_stop_presentation (window);
+ ev_window_stop_presentation (window, TRUE);
gtk_widget_grab_focus (window->priv->view);
} else {
gtk_widget_grab_focus (window->priv->view);
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
N_("Open an existing document"),
G_CALLBACK (ev_window_cmd_file_open) },
- { "FileOpenCopy", NULL, N_("Op_en a Copy"), NULL,
+ { "FileOpenCopy", NULL, N_("Op_en a Copy"), "<control>N",
N_("Open a copy of the current document in a new window"),
G_CALLBACK (ev_window_cmd_file_open_copy) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
G_CALLBACK (ev_window_cmd_view_zoom_in) },
{ "CtrlKpMinus", GTK_STOCK_ZOOM_OUT, NULL, "<control>KP_Subtract", NULL,
G_CALLBACK (ev_window_cmd_view_zoom_out) },
+ { "CtrlInsert", GTK_STOCK_COPY, NULL, "<control>Insert", NULL,
+ G_CALLBACK (ev_window_cmd_edit_copy) },
};
/* Toggle items */
static void
ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
{
- GtkClipboard *clipboard;
EvLinkAction *ev_action;
- const gchar *uri;
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);
+ ev_view_copy_link_address (EV_VIEW (window->priv->view),
+ ev_action);
}