1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
4 * Copyright (C) 2004 Martin Kretzschmar
5 * Copyright (C) 2004 Red Hat, Inc.
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
7 * Copyright (C) 2003, 2004, 2005 Christian Persch
10 * Martin Kretzschmar <martink@gnome.org>
12 * Evince is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * Evince is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
31 #include "ev-window.h"
32 #include "ev-window-title.h"
33 #include "ev-page-action.h"
34 #include "ev-sidebar.h"
35 #include "ev-sidebar-links.h"
36 #include "ev-sidebar-attachments.h"
37 #include "ev-sidebar-thumbnails.h"
39 #include "ev-password.h"
40 #include "ev-password-view.h"
41 #include "ev-properties-dialog.h"
42 #include "ev-ps-exporter.h"
43 #include "ev-document-thumbnails.h"
44 #include "ev-document-links.h"
45 #include "ev-document-fonts.h"
46 #include "ev-document-find.h"
47 #include "ev-document-security.h"
48 #include "ev-document-factory.h"
49 #include "ev-job-queue.h"
51 #include "ev-sidebar-page.h"
52 #include "eggfindbar.h"
54 #ifndef HAVE_GTK_RECENT
55 #include "egg-recent-view-uimanager.h"
56 #include "egg-recent-view.h"
57 #include "egg-recent-model.h"
60 #include "egg-toolbar-editor.h"
61 #include "egg-editable-toolbar.h"
62 #include "egg-toolbars-model.h"
63 #include "ephy-zoom.h"
64 #include "ephy-zoom-action.h"
65 #include "ev-application.h"
66 #include "ev-stock-icons.h"
67 #include "ev-metadata-manager.h"
68 #include "ev-file-helpers.h"
72 #ifdef WITH_GNOME_PRINT
73 #include "ev-print-job.h"
74 #include <libgnomeprintui/gnome-print-dialog.h>
78 #include <gtk/gtkprintunixdialog.h>
83 #include <glib/gi18n.h>
86 #include <libgnomevfs/gnome-vfs-utils.h>
87 #include <gconf/gconf-client.h>
97 EV_CHROME_MENUBAR = 1 << 0,
98 EV_CHROME_TOOLBAR = 1 << 1,
99 EV_CHROME_FINDBAR = 1 << 2,
100 EV_CHROME_RAISE_TOOLBAR = 1 << 3,
101 EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4,
102 EV_CHROME_SIDEBAR = 1 << 5,
103 EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
106 struct _EvWindowPrivate {
112 GtkWidget *toolbar_dock;
117 GtkWidget *scrolled_window;
119 GtkWidget *password_view;
120 GtkWidget *sidebar_thumbs;
121 GtkWidget *sidebar_links;
122 GtkWidget *sidebar_attachments;
125 GtkWidget *properties;
127 GtkWidget *print_dialog;
129 GtkWidget *password_dialog;
132 GtkActionGroup *action_group;
133 GtkActionGroup *view_popup_action_group;
134 GtkActionGroup *attachment_popup_action_group;
135 #ifdef HAVE_GTK_RECENT
136 GtkRecentManager *recent_manager;
137 GtkActionGroup *recent_action_group;
140 GtkUIManager *ui_manager;
142 /* Fullscreen mode */
143 GtkWidget *fullscreen_toolbar;
144 GtkWidget *fullscreen_popup;
145 guint fullscreen_timeout_id;
148 GtkWidget *view_popup;
151 /* Popup attachment */
152 GtkWidget *attachment_popup;
160 EvDocument *document;
162 EvPageCache *page_cache;
163 EvWindowPageMode page_mode;
164 EvWindowTitle *title;
165 #ifndef HAVE_GTK_RECENT
166 EggRecentViewUIManager *recent_view;
170 #ifdef WITH_GNOME_PRINT
171 GnomePrintJob *print_job;
174 #ifdef WITH_GTK_PRINT
176 GtkPrintJob *gtk_print_job;
178 GtkPrintSettings *print_settings;
179 GtkPageSetup *print_page_setup;
183 static const GtkTargetEntry ev_drop_types[] = {
184 { "text/uri-list", 0, 0 }
188 #define EV_WINDOW_GET_PRIVATE(object) \
189 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
191 #define PAGE_SELECTOR_ACTION "PageSelector"
192 #define ZOOM_CONTROL_ACTION "ViewZoom"
194 #define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
195 #define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
196 #define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
198 #define FULLSCREEN_TIMEOUT 5 * 1000
200 #define SIDEBAR_DEFAULT_SIZE 132
201 #define LINKS_SIDEBAR_ID "links"
202 #define THUMBNAILS_SIDEBAR_ID "thumbnails"
203 #define ATTACHMENTS_SIDEBAR_ID "attachments"
205 static void ev_window_update_actions (EvWindow *ev_window);
206 static void ev_window_update_fullscreen_popup (EvWindow *window);
207 static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
209 EvWindow *ev_window);
210 static void ev_window_set_page_mode (EvWindow *window,
211 EvWindowPageMode page_mode);
212 static void ev_window_xfer_job_cb (EvJobXfer *job,
214 #ifdef WITH_GTK_PRINT
215 static void ev_window_print_job_cb (EvJobPrint *job,
218 static void ev_window_sizing_mode_changed_cb (EvView *view,
220 EvWindow *ev_window);
221 static void ev_window_zoom_changed_cb (EvView *view,
223 EvWindow *ev_window);
224 static void ev_window_add_recent (EvWindow *window,
225 const char *filename);
226 static void ev_window_run_fullscreen (EvWindow *window);
227 static void ev_window_stop_fullscreen (EvWindow *window);
228 static void ev_window_cmd_view_fullscreen (GtkAction *action,
230 static void ev_window_run_presentation (EvWindow *window);
231 static void ev_window_stop_presentation (EvWindow *window);
232 static void ev_window_cmd_view_presentation (GtkAction *action,
234 static void ev_window_run_preview (EvWindow *window);
235 static void ev_view_popup_cmd_open_link (GtkAction *action,
237 static void ev_view_popup_cmd_copy_link_address (GtkAction *action,
239 static void ev_attachment_popup_cmd_open_attachment (GtkAction *action,
241 static void ev_attachment_popup_cmd_save_attachment_as (GtkAction *action,
243 static void ev_window_cmd_view_best_fit (GtkAction *action,
244 EvWindow *ev_window);
245 static void ev_window_cmd_view_page_width (GtkAction *action,
246 EvWindow *ev_window);
247 static void fullscreen_set_timeout (EvWindow *window);
248 static gboolean fullscreen_motion_notify_cb (GtkWidget *widget,
249 GdkEventMotion *event,
251 static gboolean fullscreen_leave_notify_cb (GtkWidget *widget,
252 GdkEventCrossing *event,
255 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
258 ev_window_set_action_sensitive (EvWindow *ev_window,
262 GtkAction *action = gtk_action_group_get_action (ev_window->priv->action_group,
264 gtk_action_set_sensitive (action, sensitive);
269 ev_window_setup_action_sensitivity (EvWindow *ev_window)
271 EvDocument *document = ev_window->priv->document;
272 const EvDocumentInfo *info = NULL;
274 gboolean has_document = FALSE;
275 gboolean ok_to_print = TRUE;
276 gboolean ok_to_copy = TRUE;
277 gboolean has_properties = TRUE;
278 gboolean override_restrictions = FALSE;
279 gboolean can_get_text = FALSE;
280 gboolean has_pages = FALSE;
281 gboolean can_find = FALSE;
287 info = ev_page_cache_get_info (ev_window->priv->page_cache);
290 if (has_document && ev_window->priv->page_cache) {
291 has_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0;
294 if (!info || info->fields_mask == 0) {
295 has_properties = FALSE;
298 if (has_document && ev_document_can_get_text (document)) {
302 if (has_pages && EV_IS_DOCUMENT_FIND (document)) {
306 client = gconf_client_get_default ();
307 override_restrictions = gconf_client_get_bool (client,
308 GCONF_OVERRIDE_RESTRICTIONS,
310 if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
311 ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
312 ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
315 if (has_document && !EV_IS_PS_EXPORTER(document))
319 if (gconf_client_get_bool (client, GCONF_LOCKDOWN_SAVE, NULL)) {
323 if (gconf_client_get_bool (client, GCONF_LOCKDOWN_PRINT, NULL)) {
329 g_object_unref (client);
333 ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
334 ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
335 ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
338 ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text);
339 ev_window_set_action_sensitive (ev_window, "EditFind", can_find);
340 ev_window_set_action_sensitive (ev_window, "Slash", can_find);
341 ev_window_set_action_sensitive (ev_window, "EditRotateLeft", has_pages);
342 ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages);
345 ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages);
346 ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages);
347 ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages);
348 ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
349 ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
351 /* Toolbar-specific actions: */
352 ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
353 ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
355 ev_window_update_actions (ev_window);
359 ev_window_update_actions (EvWindow *ev_window)
361 EvView *view = EV_VIEW (ev_window->priv->view);
362 int n_pages = 0, page = -1;
363 gboolean has_pages = FALSE;
365 if (ev_window->priv->document && ev_window->priv->page_cache) {
366 page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
367 n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
368 has_pages = n_pages > 0;
371 ev_window_set_action_sensitive (ev_window, "EditCopy", has_pages && ev_view_get_has_selection (view));
372 ev_window_set_action_sensitive (ev_window, "EditFindNext",
373 ev_view_can_find_next (view));
374 ev_window_set_action_sensitive (ev_window, "EditFindPrevious",
375 ev_view_can_find_previous (view));
377 ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
378 has_pages && ev_view_can_zoom_in (view));
379 ev_window_set_action_sensitive (ev_window, "ViewZoomOut",
380 has_pages && ev_view_can_zoom_out (view));
384 ev_window_set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
385 ev_window_set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
386 ev_window_set_action_sensitive (ev_window, "GoFirstPage", page > 0);
387 ev_window_set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
389 ev_window_set_action_sensitive (ev_window, "GoFirstPage", FALSE);
390 ev_window_set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
391 ev_window_set_action_sensitive (ev_window, "GoNextPage", FALSE);
392 ev_window_set_action_sensitive (ev_window, "GoLastPage", FALSE);
396 ev_view_get_sizing_mode (view) != EV_SIZING_FIT_WIDTH &&
397 ev_view_get_sizing_mode (view) != EV_SIZING_BEST_FIT) {
402 action = gtk_action_group_get_action (ev_window->priv->action_group,
403 ZOOM_CONTROL_ACTION);
405 real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
406 zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
408 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
413 ev_window_set_view_accels_sensitivity (EvWindow *window, gboolean sensitive)
417 can_find = window->priv->document &&
418 EV_IS_DOCUMENT_FIND (window->priv->document);
420 if (window->priv->action_group) {
421 ev_window_set_action_sensitive (window, "PageDown", sensitive);
422 ev_window_set_action_sensitive (window, "PageUp", sensitive);
423 ev_window_set_action_sensitive (window, "Space", sensitive);
424 ev_window_set_action_sensitive (window, "ShiftSpace", sensitive);
425 ev_window_set_action_sensitive (window, "BackSpace", sensitive);
426 ev_window_set_action_sensitive (window, "ShiftBackSpace", sensitive);
427 ev_window_set_action_sensitive (window, "Return", sensitive);
428 ev_window_set_action_sensitive (window, "ShiftReturn", sensitive);
429 ev_window_set_action_sensitive (window, "Plus", sensitive);
430 ev_window_set_action_sensitive (window, "Minus", sensitive);
431 ev_window_set_action_sensitive (window, "KpPlus", sensitive);
432 ev_window_set_action_sensitive (window, "KpMinus", sensitive);
433 ev_window_set_action_sensitive (window, "Equal", sensitive);
435 ev_window_set_action_sensitive (window, "Slash", sensitive && can_find);
440 set_widget_visibility (GtkWidget *widget, gboolean visible)
442 g_assert (GTK_IS_WIDGET (widget));
445 gtk_widget_show (widget);
447 gtk_widget_hide (widget);
451 update_chrome_visibility (EvWindow *window)
453 EvWindowPrivate *priv = window->priv;
454 gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
455 gboolean fullscreen_mode, presentation, fullscreen;
457 presentation = ev_view_get_presentation (EV_VIEW (priv->view));
458 fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
459 fullscreen_mode = fullscreen || presentation;
461 menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
462 toolbar = ((priv->chrome & EV_CHROME_TOOLBAR) != 0 ||
463 (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && !fullscreen_mode;
464 fullscreen_toolbar = ((priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
465 (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
466 findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
467 sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
469 set_widget_visibility (priv->menubar, menubar);
470 set_widget_visibility (priv->toolbar_dock, toolbar);
471 set_widget_visibility (priv->find_bar, findbar);
472 set_widget_visibility (priv->sidebar, sidebar);
474 ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
475 gtk_widget_set_sensitive (priv->menubar, menubar);
477 if (priv->fullscreen_popup != NULL) {
478 set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
479 set_widget_visibility (priv->fullscreen_popup, fullscreen_toolbar);
484 update_chrome_flag (EvWindow *window, EvChrome flag, gboolean active)
486 EvWindowPrivate *priv = window->priv;
489 priv->chrome |= flag;
491 priv->chrome &= ~flag;
494 update_chrome_visibility (window);
498 update_sizing_buttons (EvWindow *window)
500 GtkActionGroup *action_group = window->priv->action_group;
502 gboolean best_fit, page_width;
503 EvSizingMode sizing_mode;
505 if (window->priv->view == NULL)
508 g_object_get (window->priv->view,
509 "sizing_mode", &sizing_mode,
512 switch (sizing_mode) {
513 case EV_SIZING_BEST_FIT:
517 case EV_SIZING_FIT_WIDTH:
522 best_fit = page_width = FALSE;
526 action = gtk_action_group_get_action (action_group, "ViewBestFit");
527 g_signal_handlers_block_by_func
528 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
529 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), best_fit);
530 g_signal_handlers_unblock_by_func
531 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
533 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
534 g_signal_handlers_block_by_func
535 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
536 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
537 g_signal_handlers_unblock_by_func
538 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
540 action = gtk_action_group_get_action (window->priv->action_group,
541 ZOOM_CONTROL_ACTION);
543 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
545 } else if (page_width) {
546 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
547 EPHY_ZOOM_FIT_WIDTH);
552 ev_window_is_empty (const EvWindow *ev_window)
554 g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
556 return (ev_window->priv->document == NULL) &&
557 (ev_window->priv->xfer_job == NULL);
561 ev_window_error_dialog_response_cb (GtkWidget *dialog,
565 gtk_widget_destroy (dialog);
569 ev_window_error_dialog (GtkWindow *window, const gchar *msg, GError *error)
573 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
574 GTK_DIALOG_DESTROY_WITH_PARENT,
578 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
579 "%s", error->message);
580 g_signal_connect (dialog, "response",
581 G_CALLBACK (ev_window_error_dialog_response_cb),
583 gtk_widget_show (dialog);
587 find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
589 ev_window_update_actions (ev_window);
593 page_changed_cb (EvPageCache *page_cache,
597 ev_window_update_actions (ev_window);
599 if (!ev_window_is_empty (ev_window))
600 ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
604 update_document_mode (EvWindow *window, EvDocumentMode mode)
606 if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
607 ev_window_run_presentation (window);
609 else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
610 ev_window_run_fullscreen (window);
615 setup_document_from_metadata (EvWindow *window)
617 char *uri = window->priv->uri;
618 GValue page = { 0, };
621 if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
622 new_page = CLAMP (g_value_get_int (&page), 0, ev_page_cache_get_n_pages (window->priv->page_cache) - 1);
623 ev_page_cache_set_current_page (window->priv->page_cache,
625 g_value_unset (&page);
630 setup_chrome_from_metadata (EvWindow *window)
632 EvChrome chrome = EV_CHROME_NORMAL;
633 GValue show_toolbar = { 0, };
635 if (ev_metadata_manager_get (NULL, "show_toolbar", &show_toolbar, FALSE)) {
636 if (!g_value_get_boolean (&show_toolbar))
637 chrome &= ~EV_CHROME_TOOLBAR;
638 g_value_unset (&show_toolbar);
640 window->priv->chrome = chrome;
644 setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
646 char *uri = window->priv->uri;
647 GtkWidget *sidebar = window->priv->sidebar;
648 GtkWidget *links = window->priv->sidebar_links;
649 GtkWidget *thumbs = window->priv->sidebar_thumbs;
650 GtkWidget *attachments = window->priv->sidebar_attachments;
651 GValue sidebar_size = { 0, };
652 GValue sidebar_page = { 0, };
653 GValue sidebar_visibility = { 0, };
655 if (ev_metadata_manager_get (uri, "sidebar_size", &sidebar_size, FALSE)) {
656 gtk_paned_set_position (GTK_PANED (window->priv->hpaned),
657 g_value_get_int (&sidebar_size));
658 g_value_unset(&sidebar_size);
661 if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) {
662 const char *page_id = g_value_get_string (&sidebar_page);
664 if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
665 ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
666 } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
667 ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
668 } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
669 ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
671 g_value_unset (&sidebar_page);
672 } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
673 ev_sidebar_set_page (EV_SIDEBAR (sidebar), links);
676 if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) {
677 update_chrome_flag (window, EV_CHROME_SIDEBAR, g_value_get_boolean (&sidebar_visibility));
678 g_value_unset (&sidebar_visibility);
683 setup_size_from_metadata (EvWindow *window)
685 char *uri = window->priv->uri;
686 GValue width = { 0, };
687 GValue height = { 0, };
688 GValue width_ratio = { 0, };
689 GValue height_ratio = { 0, };
690 GValue maximized = { 0, };
694 if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
695 if (g_value_get_boolean (&maximized)) {
696 gtk_window_maximize (GTK_WINDOW (window));
699 gtk_window_unmaximize (GTK_WINDOW (window));
701 g_value_unset (&maximized);
704 if (ev_metadata_manager_get (uri, "window_x", &x, TRUE) &&
705 ev_metadata_manager_get (uri, "window_y", &y, TRUE)) {
706 gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
707 g_value_get_int (&y));
712 if (ev_metadata_manager_get (uri, "window_width", &width, TRUE) &&
713 ev_metadata_manager_get (uri, "window_height", &height, TRUE)) {
714 gtk_window_resize (GTK_WINDOW (window),
715 g_value_get_int (&width),
716 g_value_get_int (&height));
717 g_value_unset (&width);
718 g_value_unset (&height);
722 if (window->priv->page_cache &&
723 ev_metadata_manager_get (uri, "window_width_ratio", &width_ratio, FALSE) &&
724 ev_metadata_manager_get (uri, "window_height_ratio", &height_ratio, FALSE)) {
726 gint document_height;
728 ev_page_cache_get_max_width (window->priv->page_cache,
731 ev_page_cache_get_max_height (window->priv->page_cache,
735 gtk_window_resize (GTK_WINDOW (window),
736 g_value_get_double (&width_ratio) * document_width,
737 g_value_get_double (&height_ratio) * document_height);
738 g_value_unset (&width_ratio);
739 g_value_unset (&height_ratio);
745 setup_view_from_metadata (EvWindow *window)
747 EvView *view = EV_VIEW (window->priv->view);
748 char *uri = window->priv->uri;
749 GEnumValue *enum_value;
750 GValue sizing_mode = { 0, };
751 GValue zoom = { 0, };
752 GValue continuous = { 0, };
753 GValue dual_page = { 0, };
754 GValue presentation = { 0, };
755 GValue fullscreen = { 0, };
756 GValue rotation = { 0, };
757 GValue maximized = { 0, };
760 if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) {
761 if (g_value_get_boolean (&maximized)) {
762 gtk_window_maximize (GTK_WINDOW (window));
764 gtk_window_unmaximize (GTK_WINDOW (window));
766 g_value_unset (&maximized);
770 if (ev_metadata_manager_get (uri, "sizing_mode", &sizing_mode, FALSE)) {
771 enum_value = g_enum_get_value_by_nick
772 (EV_SIZING_MODE_CLASS, g_value_get_string (&sizing_mode));
773 g_value_unset (&sizing_mode);
774 ev_view_set_sizing_mode (view, enum_value->value);
778 if (ev_metadata_manager_get (uri, "zoom", &zoom, FALSE) &&
779 ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
780 ev_view_set_zoom (view, g_value_get_double (&zoom), FALSE);
781 g_value_unset (&zoom);
785 if (ev_metadata_manager_get (uri, "continuous", &continuous, FALSE)) {
786 ev_view_set_continuous (view, g_value_get_boolean (&continuous));
787 g_value_unset (&continuous);
791 if (ev_metadata_manager_get (uri, "dual-page", &dual_page, FALSE)) {
792 ev_view_set_dual_page (view, g_value_get_boolean (&dual_page));
793 g_value_unset (&dual_page);
797 if (ev_metadata_manager_get (uri, "presentation", &presentation, FALSE)) {
798 if (g_value_get_boolean (&presentation) && uri) {
799 ev_window_run_presentation (window);
801 g_value_unset (&presentation);
805 if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen, FALSE)) {
806 if (g_value_get_boolean (&fullscreen) && uri) {
807 ev_window_run_fullscreen (window);
809 g_value_unset (&fullscreen);
813 if (ev_metadata_manager_get (uri, "rotation", &rotation, TRUE)) {
814 if (g_value_get_int (&rotation)) {
815 switch (g_value_get_int (&rotation)) {
817 ev_view_set_rotation (view, 90);
820 ev_view_set_rotation (view, 180);
823 ev_view_set_rotation (view, 270);
829 g_value_unset (&rotation);
834 ev_window_setup_document (EvWindow *ev_window)
836 const EvDocumentInfo *info;
837 EvDocument *document;
838 EvView *view = EV_VIEW (ev_window->priv->view);
839 EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
842 document = ev_window->priv->document;
843 ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
844 g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
846 if (EV_IS_DOCUMENT_FIND (document)) {
847 g_signal_connect_object (G_OBJECT (document),
849 G_CALLBACK (find_changed_cb),
853 ev_sidebar_set_document (sidebar, document);
855 if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
856 ev_view_set_document (view, document);
858 ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
860 ev_window_title_set_document (ev_window->priv->title, document);
861 ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
863 action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
864 ev_page_action_set_document (EV_PAGE_ACTION (action), document);
865 ev_window_setup_action_sensitivity (ev_window);
867 if (ev_window->priv->properties) {
868 ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
869 ev_window->priv->document);
872 setup_size_from_metadata (ev_window);
873 setup_document_from_metadata (ev_window);
874 setup_sidebar_from_metadata (ev_window, document);
876 info = ev_page_cache_get_info (ev_window->priv->page_cache);
877 update_document_mode (ev_window, info->mode);
881 password_dialog_response (GtkWidget *password_dialog,
887 if (response_id == GTK_RESPONSE_OK) {
889 password = ev_password_dialog_get_password (EV_PASSWORD_DIALOG (password_dialog));
891 ev_document_doc_mutex_lock ();
892 ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->xfer_job->document),
894 ev_document_doc_mutex_unlock ();
898 ev_password_dialog_save_password (EV_PASSWORD_DIALOG (password_dialog));
900 ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
901 ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
903 gtk_widget_destroy (password_dialog);
908 gtk_widget_set_sensitive (ev_window->priv->password_view, TRUE);
909 gtk_widget_destroy (password_dialog);
912 /* Called either by ev_window_xfer_job_cb or by the "unlock" callback on the
913 * password_view page. It assumes that ev_window->priv->password_* has been set
914 * correctly. These are cleared by password_dialog_response() */
917 ev_window_popup_password_dialog (EvWindow *ev_window)
919 g_assert (ev_window->priv->xfer_job);
921 gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
923 ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
924 ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_PASSWORD);
926 if (ev_window->priv->password_dialog == NULL) {
927 ev_window->priv->password_dialog =
928 g_object_new (EV_TYPE_PASSWORD_DIALOG, "uri", ev_window->priv->uri, NULL);
929 gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->password_dialog), GTK_WINDOW (ev_window));
931 g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
932 (gpointer *) &(ev_window->priv->password_dialog));
933 g_signal_connect (ev_window->priv->password_dialog,
935 G_CALLBACK (password_dialog_response),
937 gtk_widget_show (ev_window->priv->password_dialog);
939 ev_password_dialog_set_bad_pass (EV_PASSWORD_DIALOG (ev_window->priv->password_dialog));
944 ev_window_clear_xfer_job (EvWindow *ev_window)
946 if (ev_window->priv->xfer_job != NULL) {
948 if (!ev_window->priv->xfer_job->finished)
949 ev_job_queue_remove_job (ev_window->priv->xfer_job);
951 g_signal_handlers_disconnect_by_func (ev_window->priv->xfer_job, ev_window_xfer_job_cb, ev_window);
952 g_object_unref (ev_window->priv->xfer_job);
953 ev_window->priv->xfer_job = NULL;
958 ev_window_clear_local_uri (EvWindow *ev_window)
962 if (ev_window->priv->local_uri) {
963 filename = g_filename_from_uri (ev_window->priv->local_uri, NULL, NULL);
964 if (filename != NULL) {
968 g_free (ev_window->priv->local_uri);
969 ev_window->priv->local_uri = NULL;
973 /* This callback will executed when load job will be finished.
975 * Since the flow of the error dialog is very confusing, we assume that both
976 * document and uri will go away after this function is called, and thus we need
977 * to ref/dup them. Additionally, it needs to clear
978 * ev_window->priv->password_{uri,document}, and thus people who call this
979 * function should _not_ necessarily expect those to exist after being
982 ev_window_xfer_job_cb (EvJobXfer *job,
985 EvWindow *ev_window = EV_WINDOW (data);
986 EvDocument *document = EV_JOB (job)->document;
990 ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
993 if (job->error == NULL) {
995 if (ev_window->priv->uri)
996 g_free (ev_window->priv->uri);
997 ev_window->priv->uri = g_strdup (job->uri);
999 if (ev_window->priv->local_uri)
1000 g_free (ev_window->priv->local_uri);
1001 ev_window->priv->local_uri =
1002 job->local_uri ? g_strdup (job->local_uri) : NULL;
1004 if (ev_window->priv->document)
1005 g_object_unref (ev_window->priv->document);
1006 ev_window->priv->document = g_object_ref (document);
1008 setup_view_from_metadata (ev_window);
1009 ev_window_setup_document (ev_window);
1010 ev_window_add_recent (ev_window, ev_window->priv->uri);
1013 ev_window_goto_dest (ev_window, job->dest);
1015 switch (job->mode) {
1016 case EV_WINDOW_MODE_FULLSCREEN:
1017 ev_window_run_fullscreen (ev_window);
1019 case EV_WINDOW_MODE_PRESENTATION:
1020 ev_window_run_presentation (ev_window);
1022 case EV_WINDOW_MODE_PREVIEW:
1023 ev_window_run_preview (ev_window);
1029 ev_window_clear_xfer_job (ev_window);
1033 if (job->error->domain == EV_DOCUMENT_ERROR &&
1034 job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
1035 gchar *base_name, *file_name;
1037 g_free (ev_window->priv->uri);
1038 ev_window->priv->uri = g_strdup (job->uri);
1039 setup_view_from_metadata (ev_window);
1041 file_name = gnome_vfs_format_uri_for_display (job->uri);
1042 base_name = g_path_get_basename (file_name);
1043 ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
1047 ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
1049 ev_window_popup_password_dialog (ev_window);
1051 ev_window_error_dialog (GTK_WINDOW (ev_window),
1052 _("Unable to open document"),
1054 ev_window_clear_xfer_job (ev_window);
1061 ev_window_get_uri (EvWindow *ev_window)
1063 return ev_window->priv->uri;
1067 ev_window_close_dialogs (EvWindow *ev_window)
1069 if (ev_window->priv->password_dialog)
1070 gtk_widget_destroy (ev_window->priv->password_dialog);
1071 ev_window->priv->password_dialog = NULL;
1074 if (ev_window->priv->print_dialog)
1075 gtk_widget_destroy (ev_window->priv->print_dialog);
1076 ev_window->priv->print_dialog = NULL;
1079 #ifdef WITH_GNOME_PRINT
1080 if (ev_window->priv->print_job)
1081 g_object_unref (ev_window->priv->print_job);
1082 ev_window->priv->print_job = NULL;
1085 if (ev_window->priv->properties)
1086 gtk_widget_destroy (ev_window->priv->properties);
1087 ev_window->priv->properties = NULL;
1091 ev_window_open_uri (EvWindow *ev_window,
1094 EvWindowRunMode mode)
1096 ev_window_close_dialogs (ev_window);
1097 ev_window_clear_xfer_job (ev_window);
1098 ev_window_clear_local_uri (ev_window);
1099 ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
1101 ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest, mode);
1102 g_signal_connect (ev_window->priv->xfer_job,
1104 G_CALLBACK (ev_window_xfer_job_cb),
1106 ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
1110 ev_window_goto_dest (EvWindow *ev_window, EvLinkDest *dest)
1112 ev_view_goto_dest (EV_VIEW (ev_window->priv->view), dest);
1116 file_open_dialog_response_cb (GtkWidget *chooser,
1118 EvWindow *ev_window)
1120 if (response_id == GTK_RESPONSE_OK) {
1123 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
1125 ev_application_open_uri_list (EV_APP, uris, GDK_CURRENT_TIME);
1127 g_slist_foreach (uris, (GFunc)g_free, NULL);
1128 g_slist_free (uris);
1130 ev_application_set_chooser_uri (EV_APP,
1131 gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)));
1133 gtk_widget_destroy (chooser);
1137 ev_window_cmd_file_open (GtkAction *action, EvWindow *window)
1141 chooser = gtk_file_chooser_dialog_new (_("Open Document"),
1142 GTK_WINDOW (window),
1143 GTK_FILE_CHOOSER_ACTION_OPEN,
1145 GTK_RESPONSE_CANCEL,
1146 GTK_STOCK_OPEN, GTK_RESPONSE_OK,
1149 ev_document_factory_add_filters (chooser, NULL);
1150 gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE);
1151 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
1152 if (ev_application_get_chooser_uri (EV_APP) != NULL) {
1153 gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser),
1154 ev_application_get_chooser_uri (EV_APP));
1155 } else if (window->priv->uri != NULL) {
1156 gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (chooser),
1160 g_signal_connect (chooser, "response",
1161 G_CALLBACK (file_open_dialog_response_cb),
1164 gtk_widget_show (chooser);
1167 #ifdef HAVE_GTK_RECENT
1169 ev_window_cmd_recent_file_activate (GtkAction *action,
1170 GtkRecentInfo *info)
1174 uri = gtk_recent_info_get_uri (info);
1176 ev_application_open_uri (EV_APP, uri, NULL,
1177 GDK_CURRENT_TIME, NULL);
1181 ev_window_cmd_recent_file_activate (GtkAction *action,
1182 EvWindow *ev_window)
1185 EggRecentItem *item;
1187 item = egg_recent_view_uimanager_get_item (ev_window->priv->recent_view,
1190 uri = egg_recent_item_get_uri (item);
1192 ev_application_open_uri (EV_APP, uri, NULL,
1193 GDK_CURRENT_TIME, NULL);
1197 #endif /* HAVE_GTK_RECENT */
1200 ev_window_add_recent (EvWindow *window, const char *filename)
1202 #ifdef HAVE_GTK_RECENT
1203 gtk_recent_manager_add_item (window->priv->recent_manager, filename);
1205 EggRecentItem *item;
1207 item = egg_recent_item_new_from_uri (filename);
1208 egg_recent_item_add_group (item, "Evince");
1209 egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
1210 #endif /* HAVE_GTK_RECENT */
1213 #ifdef HAVE_GTK_RECENT
1215 compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
1217 gboolean has_ev_a, has_ev_b;
1218 const gchar *evince = g_get_application_name ();
1220 has_ev_a = gtk_recent_info_has_application (a, evince);
1221 has_ev_b = gtk_recent_info_has_application (b, evince);
1223 if (has_ev_a && has_ev_b) {
1224 time_t time_a, time_b;
1226 time_a = gtk_recent_info_get_modified (a);
1227 time_b = gtk_recent_info_get_modified (b);
1229 return (time_b - time_a);
1230 } else if (has_ev_a) {
1232 } else if (has_ev_b) {
1238 #endif /* HAVE_GTK_RECENT */
1241 * Doubles underscore to avoid spurious menu accels.
1244 ev_window_get_recent_file_label (gint index, const gchar *filename)
1251 g_return_val_if_fail (filename != NULL, NULL);
1253 length = strlen (filename);
1254 str = g_string_sized_new (length + 10);
1255 g_string_printf (str, "_%d. ", index);
1258 end = filename + length;
1263 next = g_utf8_next_char (p);
1268 g_string_append (str, "__");
1271 g_string_append_len (str, p, next - p);
1278 return g_string_free (str, FALSE);
1282 ev_window_setup_recent (EvWindow *ev_window)
1284 #ifdef HAVE_GTK_RECENT
1287 const gchar *evince = g_get_application_name ();
1290 if (ev_window->priv->recent_ui_id > 0) {
1291 gtk_ui_manager_remove_ui (ev_window->priv->ui_manager,
1292 ev_window->priv->recent_ui_id);
1293 gtk_ui_manager_ensure_update (ev_window->priv->ui_manager);
1295 ev_window->priv->recent_ui_id = gtk_ui_manager_new_merge_id (ev_window->priv->ui_manager);
1297 if (ev_window->priv->recent_action_group) {
1298 gtk_ui_manager_remove_action_group (ev_window->priv->ui_manager,
1299 ev_window->priv->recent_action_group);
1300 g_object_unref (ev_window->priv->recent_action_group);
1302 ev_window->priv->recent_action_group = gtk_action_group_new ("RecentFilesActions");
1303 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
1304 ev_window->priv->recent_action_group, 0);
1306 items = gtk_recent_manager_get_items (ev_window->priv->recent_manager);
1307 items = g_list_sort (items, (GCompareFunc) compare_recent_items);
1309 for (l = items; l && l->data; l = g_list_next (l)) {
1310 GtkRecentInfo *info;
1315 info = (GtkRecentInfo *) l->data;
1317 if (!gtk_recent_info_has_application (info, evince))
1320 action_name = g_strdup_printf ("RecentFile%u", i++);
1321 label = ev_window_get_recent_file_label (
1322 n_items + 1, gtk_recent_info_get_display_name (info));
1324 action = g_object_new (GTK_TYPE_ACTION,
1325 "name", action_name,
1329 g_object_weak_ref (G_OBJECT (action),
1330 (GWeakNotify) gtk_recent_info_unref,
1331 gtk_recent_info_ref (info));
1332 g_signal_connect (G_OBJECT (action), "activate",
1333 G_CALLBACK (ev_window_cmd_recent_file_activate),
1336 gtk_action_group_add_action (ev_window->priv->recent_action_group,
1338 g_object_unref (action);
1340 gtk_ui_manager_add_ui (ev_window->priv->ui_manager,
1341 ev_window->priv->recent_ui_id,
1342 "/MainMenu/FileMenu/RecentFilesMenu",
1345 GTK_UI_MANAGER_MENUITEM,
1347 g_free (action_name);
1354 g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
1355 g_list_free (items);
1356 #else /* HAVE_GTK_RECENT */
1357 ev_window->priv->recent_view = egg_recent_view_uimanager_new (ev_window->priv->ui_manager,
1358 "/MainMenu/FileMenu/RecentFilesMenu",
1359 G_CALLBACK (ev_window_cmd_recent_file_activate),
1362 egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
1364 egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
1365 ev_application_get_recent_model (EV_APP));
1367 egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
1369 g_signal_connect (ev_window->priv->recent_view, "activate",
1370 G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
1371 #endif /* HAVE_GTK_RECENT */
1375 file_save_dialog_response_cb (GtkWidget *fc,
1377 EvWindow *ev_window)
1381 if (response_id == GTK_RESPONSE_OK) {
1385 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
1387 ev_document_doc_mutex_lock ();
1388 success = ev_document_save (ev_window->priv->document, uri, &err);
1389 ev_document_doc_mutex_unlock ();
1393 msg = g_strdup_printf (_("The file could not be saved as “%s”."), uri);
1394 ev_window_error_dialog (GTK_WINDOW (fc), msg, err);
1401 gtk_widget_destroy (fc);
1405 ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
1411 fc = gtk_file_chooser_dialog_new (
1413 GTK_WINDOW (ev_window), GTK_FILE_CHOOSER_ACTION_SAVE,
1414 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1415 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
1418 ev_document_factory_add_filters (fc, ev_window->priv->document);
1419 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
1421 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (fc), TRUE);
1422 file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri);
1423 base_name = g_path_get_basename (file_name);
1424 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name);
1428 g_signal_connect (fc, "response",
1429 G_CALLBACK (file_save_dialog_response_cb),
1432 gtk_widget_show (fc);
1435 #ifdef WITH_GTK_PRINT
1437 ev_window_clear_print_job (EvWindow *window)
1439 if (window->priv->print_job) {
1440 if (!window->priv->print_job->finished)
1441 ev_job_queue_remove_job (window->priv->print_job);
1443 g_signal_handlers_disconnect_by_func (window->priv->print_job,
1444 ev_window_print_job_cb,
1446 g_object_unref (window->priv->print_job);
1447 window->priv->print_job = NULL;
1452 ev_window_print_finished (GtkPrintJob *print_job,
1456 ev_window_clear_print_job (window);
1461 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1465 _("Failed to print document"));
1466 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
1469 gtk_dialog_run (GTK_DIALOG (dialog));
1470 gtk_widget_destroy (dialog);
1475 ev_window_print_send (EvWindow *window,
1476 const gchar *filename)
1479 GError *error = NULL;
1481 if (window->priv->gtk_print_job)
1482 g_object_unref (window->priv->gtk_print_job);
1484 job = gtk_print_job_new ("evince-print",
1485 window->priv->printer,
1486 window->priv->print_settings,
1487 window->priv->print_page_setup);
1489 window->priv->gtk_print_job = job;
1491 if (gtk_print_job_set_source_file (job, filename, &error)) {
1492 gtk_print_job_send (job,
1493 (GtkPrintJobCompleteFunc)ev_window_print_finished,
1496 ev_window_clear_print_job (window);
1497 g_warning (error->message);
1498 g_error_free (error);
1503 ev_window_print_job_cb (EvJobPrint *job,
1507 g_warning (job->error->message);
1508 ev_window_clear_print_job (window);
1512 g_assert (job->temp_file != NULL);
1514 ev_window_print_send (window, job->temp_file);
1518 ev_window_print_dialog_response_cb (GtkDialog *dialog,
1522 EvPrintRange *ranges = NULL;
1523 EvPageCache *page_cache;
1532 GtkPrintPages print_pages;
1534 if (response != GTK_RESPONSE_OK) {
1535 gtk_widget_destroy (GTK_WIDGET (dialog));
1536 window->priv->print_dialog = NULL;
1541 if (window->priv->printer)
1542 g_object_unref (window->priv->printer);
1543 if (window->priv->print_settings)
1544 g_object_unref (window->priv->print_settings);
1545 if (window->priv->print_page_setup)
1546 g_object_unref (window->priv->print_page_setup);
1548 window->priv->printer = g_object_ref (
1549 gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (dialog)));
1550 window->priv->print_settings = g_object_ref (
1551 gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (dialog)));
1552 window->priv->print_page_setup = g_object_ref (
1553 gtk_print_unix_dialog_get_page_setup (GTK_PRINT_UNIX_DIALOG (dialog)));
1555 if (!gtk_printer_accepts_ps (window->priv->printer)) {
1556 GtkWidget *msgdialog;
1558 msgdialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
1562 _("Printing is not supported on this printer."));
1564 gtk_dialog_run (GTK_DIALOG (msgdialog));
1565 gtk_widget_destroy (msgdialog);
1570 ev_window_clear_print_job (window);
1572 current_page = gtk_print_unix_dialog_get_current_page (GTK_PRINT_UNIX_DIALOG (dialog));
1573 print_pages = gtk_print_settings_get_print_pages (window->priv->print_settings);
1575 switch (print_pages) {
1576 case GTK_PRINT_PAGES_CURRENT:
1577 ranges = g_new0 (EvPrintRange, 1);
1579 ranges->start = current_page;
1580 ranges->end = current_page;
1584 case GTK_PRINT_PAGES_RANGES: {
1585 GtkPageRange *page_range;
1587 page_range = gtk_print_settings_get_page_ranges (window->priv->print_settings,
1590 ranges = g_memdup (page_range, n_ranges * sizeof (GtkPageRange));
1597 scale = gtk_print_settings_get_scale (window->priv->print_settings) * 0.01;
1598 page_cache = ev_page_cache_get (window->priv->document);
1599 ev_page_cache_get_size (page_cache,
1604 copies = gtk_print_settings_get_n_copies (window->priv->print_settings);
1605 collate = gtk_print_settings_get_collate (window->priv->print_settings);
1606 reverse = gtk_print_settings_get_reverse (window->priv->print_settings);
1608 window->priv->print_job = ev_job_print_new (window->priv->document,
1612 copies, collate, reverse);
1614 g_signal_connect (window->priv->print_job, "finished",
1615 G_CALLBACK (ev_window_print_job_cb),
1617 /* The priority doesn't matter for this job */
1618 ev_job_queue_add_job (window->priv->print_job, EV_JOB_PRIORITY_LOW);
1620 gtk_widget_destroy (GTK_WIDGET (dialog));
1621 window->priv->print_dialog = NULL;
1627 ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
1630 EvPageCache *page_cache;
1632 gint document_last_page;
1634 g_return_if_fail (EV_IS_WINDOW (ev_window));
1635 g_return_if_fail (ev_window->priv->document != NULL);
1637 if (ev_window->priv->print_dialog) {
1638 gtk_window_present (GTK_WINDOW (ev_window->priv->print_dialog));
1642 page_cache = ev_page_cache_get (ev_window->priv->document);
1643 current_page = ev_page_cache_get_current_page (page_cache);
1644 document_last_page = ev_page_cache_get_n_pages (page_cache);
1646 if (!ev_window->priv->print_settings)
1647 ev_window->priv->print_settings = gtk_print_settings_new ();
1649 if (first_page != 1 || last_page != document_last_page) {
1652 /* Ranges in GtkPrint are 0 - N */
1653 range.start = first_page - 1;
1654 range.end = last_page - 1;
1656 gtk_print_settings_set_print_pages (ev_window->priv->print_settings,
1657 GTK_PRINT_PAGES_RANGES);
1658 gtk_print_settings_set_page_ranges (ev_window->priv->print_settings,
1662 dialog = gtk_print_unix_dialog_new (_("Print"), GTK_WINDOW (ev_window));
1663 ev_window->priv->print_dialog = dialog;
1664 gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
1665 GTK_PRINT_CAPABILITY_PAGE_SET |
1666 GTK_PRINT_CAPABILITY_COPIES |
1667 GTK_PRINT_CAPABILITY_COLLATE |
1668 GTK_PRINT_CAPABILITY_REVERSE |
1669 GTK_PRINT_CAPABILITY_SCALE |
1670 GTK_PRINT_CAPABILITY_GENERATE_PS);
1671 gtk_print_unix_dialog_set_current_page (GTK_PRINT_UNIX_DIALOG (dialog),
1674 gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG (dialog),
1675 ev_window->priv->print_settings);
1677 if (ev_window->priv->print_page_setup)
1678 gtk_print_unix_dialog_set_page_setup (GTK_PRINT_UNIX_DIALOG (dialog),
1679 ev_window->priv->print_page_setup);
1681 g_signal_connect (G_OBJECT (dialog), "response",
1682 G_CALLBACK (ev_window_print_dialog_response_cb),
1685 gtk_widget_show (dialog);
1687 #endif /* WITH_GTK_PRINT */
1689 #ifdef WITH_GNOME_PRINT
1691 ev_window_print_dialog_response_cb (GtkDialog *print_dialog,
1693 EvWindow *ev_window)
1695 EvPrintJob *print_job;
1696 GnomePrintConfig *config;
1698 if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) {
1699 gtk_widget_destroy (GTK_WIDGET (print_dialog));
1700 ev_window->priv->print_dialog = NULL;
1701 g_object_unref (ev_window->priv->print_job);
1702 ev_window->priv->print_job = NULL;
1707 config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (print_dialog));
1709 /* FIXME: Change this when we have the first backend
1710 * that can print more than postscript
1712 if (using_pdf_printer (config)) {
1715 dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
1716 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1717 _("Generating PDF is not supported"));
1718 gtk_dialog_run (GTK_DIALOG (dialog));
1719 gtk_widget_destroy (dialog);
1722 } else if (!using_postscript_printer (config)) {
1725 dialog = gtk_message_dialog_new (GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
1726 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1727 _("Printing is not supported on this printer."));
1728 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
1729 _("You were trying to print to a printer using the “%s” driver. "
1730 "This program requires a PostScript printer driver."),
1731 gnome_print_config_get (config, (guchar *)"Settings.Engine.Backend.Driver"));
1732 gtk_dialog_run (GTK_DIALOG (dialog));
1733 gtk_widget_destroy (dialog);
1738 save_print_config_to_file (config);
1740 print_job = g_object_new (EV_TYPE_PRINT_JOB,
1741 "gnome_print_job", ev_window->priv->print_job,
1742 "document", ev_window->priv->document,
1743 "print_dialog", print_dialog,
1746 if (print_job != NULL) {
1747 ev_print_job_print (print_job, GTK_WINDOW (ev_window));
1748 g_object_unref (print_job);
1751 g_object_unref (config);
1753 gtk_widget_destroy (GTK_WIDGET (print_dialog));
1754 ev_window->priv->print_dialog = NULL;
1755 g_object_unref (ev_window->priv->print_job);
1756 ev_window->priv->print_job = NULL;
1762 ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
1764 GnomePrintConfig *config;
1767 g_return_if_fail (EV_IS_WINDOW (ev_window));
1768 g_return_if_fail (ev_window->priv->document != NULL);
1770 config = load_print_config_from_file ();
1772 if (ev_window->priv->print_job == NULL)
1773 ev_window->priv->print_job = gnome_print_job_new (config);
1775 if (ev_window->priv->print_dialog == NULL) {
1776 ev_window->priv->print_dialog =
1777 gnome_print_dialog_new (ev_window->priv->print_job,
1778 (guchar *) _("Print"),
1779 (GNOME_PRINT_DIALOG_RANGE |
1780 GNOME_PRINT_DIALOG_COPIES));
1783 gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->print_dialog),
1784 GTK_WINDOW (ev_window));
1785 g_object_unref (config);
1787 pages_label = g_strconcat (_("Pages"), " ", NULL);
1788 gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (ev_window->priv->print_dialog),
1789 GNOME_PRINT_RANGE_ALL |
1790 GNOME_PRINT_RANGE_RANGE,
1791 first_page, last_page,
1792 NULL, (const guchar *)pages_label);
1793 g_free (pages_label);
1795 gtk_dialog_set_response_sensitive (GTK_DIALOG (ev_window->priv->print_dialog),
1796 GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
1799 g_signal_connect (G_OBJECT (ev_window->priv->print_dialog), "response",
1800 G_CALLBACK (ev_window_print_dialog_response_cb),
1802 gtk_widget_show (ev_window->priv->print_dialog);
1804 #endif /* WITH_GNOME_PRINT */
1807 ev_window_print (EvWindow *window)
1809 EvPageCache *page_cache;
1812 page_cache = ev_page_cache_get (window->priv->document);
1813 last_page = ev_page_cache_get_n_pages (page_cache);
1816 ev_window_print_range (window, 1, last_page);
1821 ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
1823 ev_window_print (ev_window);
1827 ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window)
1829 if (ev_window->priv->properties == NULL) {
1830 ev_window->priv->properties = ev_properties_dialog_new ();
1831 ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
1832 ev_window->priv->document);
1833 g_object_add_weak_pointer (G_OBJECT (ev_window->priv->properties),
1834 (gpointer *) &(ev_window->priv->properties));
1835 gtk_window_set_transient_for (GTK_WINDOW (ev_window->priv->properties),
1836 GTK_WINDOW (ev_window));
1839 gtk_widget_show (ev_window->priv->properties);
1843 ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
1845 g_return_if_fail (EV_IS_WINDOW (ev_window));
1847 gtk_widget_destroy (GTK_WIDGET (ev_window));
1851 ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
1855 update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
1856 ev_window_set_action_sensitive (window, "ViewToolbar", FALSE);
1858 action = gtk_action_group_get_action (window->priv->action_group,
1859 PAGE_SELECTOR_ACTION);
1860 ev_page_action_grab_focus (EV_PAGE_ACTION (action));
1864 ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
1866 ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
1870 ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
1872 ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
1876 ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
1878 gboolean continuous;
1880 ev_window_stop_presentation (ev_window);
1881 continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
1882 g_object_set (G_OBJECT (ev_window->priv->view),
1883 "continuous", continuous,
1885 ev_window_update_actions (ev_window);
1889 ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
1893 ev_window_stop_presentation (ev_window);
1894 dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
1895 g_object_set (G_OBJECT (ev_window->priv->view),
1896 "dual-page", dual_page,
1898 ev_window_update_actions (ev_window);
1902 ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
1904 ev_window_stop_presentation (ev_window);
1906 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
1907 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
1909 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
1911 ev_window_update_actions (ev_window);
1915 ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
1917 ev_window_stop_presentation (ev_window);
1919 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
1920 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
1922 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
1924 ev_window_update_actions (ev_window);
1929 ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
1931 g_return_if_fail (EV_IS_WINDOW (ev_window));
1933 ev_view_select_all (EV_VIEW (ev_window->priv->view));
1937 ev_window_cmd_edit_find (GtkAction *action, EvWindow *ev_window)
1939 g_return_if_fail (EV_IS_WINDOW (ev_window));
1941 if (ev_window->priv->document == NULL || !EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
1942 g_error ("Find action should be insensitive since document doesn't support find");
1946 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, TRUE);
1947 gtk_widget_grab_focus (ev_window->priv->find_bar);
1951 ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window)
1953 g_return_if_fail (EV_IS_WINDOW (ev_window));
1955 ev_view_find_next (EV_VIEW (ev_window->priv->view));
1959 ev_window_cmd_edit_find_previous (GtkAction *action, EvWindow *ev_window)
1961 g_return_if_fail (EV_IS_WINDOW (ev_window));
1963 ev_view_find_previous (EV_VIEW (ev_window->priv->view));
1967 ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
1969 g_return_if_fail (EV_IS_WINDOW (ev_window));
1971 ev_view_copy (EV_VIEW (ev_window->priv->view));
1975 ev_window_update_fullscreen_popup (EvWindow *window)
1977 GtkWidget *popup = window->priv->fullscreen_popup;
1978 int popup_width, popup_height;
1980 GdkRectangle screen_rect;
1983 g_return_if_fail (popup != NULL);
1985 if (GTK_WIDGET (window)->window == NULL)
1988 toolbar = (window->priv->chrome & EV_CHROME_FULLSCREEN_TOOLBAR) != 0 ||
1989 (window->priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0;
1990 popup_width = popup->requisition.width;
1991 popup_height = popup->requisition.height;
1993 screen = gtk_widget_get_screen (GTK_WIDGET (window));
1994 gdk_screen_get_monitor_geometry (screen,
1995 gdk_screen_get_monitor_at_window
1997 GTK_WIDGET (window)->window),
2000 gtk_widget_set_size_request (popup,
2003 gtk_window_move (GTK_WINDOW (popup),
2008 if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL)
2010 gtk_window_move (GTK_WINDOW (popup),
2014 gtk_window_move (GTK_WINDOW (popup),
2015 screen_rect.x + screen_rect.width - popup_width,
2022 screen_size_changed_cb (GdkScreen *screen,
2025 ev_window_update_fullscreen_popup (window);
2029 ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
2030 EvWindow *ev_window)
2032 if (!ev_window_is_empty (ev_window))
2033 ev_metadata_manager_set_int (ev_window->priv->uri, "sidebar_size",
2034 gtk_paned_get_position (GTK_PANED (object)));
2038 destroy_fullscreen_popup (EvWindow *window)
2040 if (window->priv->fullscreen_popup != NULL)
2042 gtk_widget_destroy (window->priv->fullscreen_popup);
2043 window->priv->fullscreen_popup = NULL;
2048 exit_fullscreen_button_clicked_cb (GtkWidget *button, EvWindow *window)
2052 action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
2053 g_return_if_fail (action != NULL);
2055 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
2059 fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindow *window)
2061 ev_window_update_fullscreen_popup (window);
2065 fullscreen_timeout_cb (EvWindow *window)
2067 EvView *view = EV_VIEW (window->priv->view);
2069 if (!view || !ev_view_get_fullscreen (EV_VIEW (view)))
2072 update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, FALSE);
2073 ev_view_hide_cursor (EV_VIEW (window->priv->view));
2074 window->priv->fullscreen_timeout_id = 0;
2080 fullscreen_set_timeout (EvWindow *window)
2082 if (window->priv->fullscreen_timeout_id != 0) {
2083 g_source_remove (window->priv->fullscreen_timeout_id);
2086 window->priv->fullscreen_timeout_id =
2087 g_timeout_add (FULLSCREEN_TIMEOUT, (GSourceFunc)fullscreen_timeout_cb, window);
2089 update_chrome_flag (window, EV_CHROME_FULLSCREEN_TOOLBAR, TRUE);
2090 update_chrome_visibility (window);
2091 ev_view_show_cursor (EV_VIEW (window->priv->view));
2095 fullscreen_clear_timeout (EvWindow *window)
2097 if (window->priv->fullscreen_timeout_id != 0) {
2098 g_source_remove (window->priv->fullscreen_timeout_id);
2101 window->priv->fullscreen_timeout_id = 0;
2102 update_chrome_visibility (window);
2103 ev_view_show_cursor (EV_VIEW (window->priv->view));
2108 fullscreen_motion_notify_cb (GtkWidget *widget,
2109 GdkEventMotion *event,
2112 EvWindow *window = EV_WINDOW (user_data);
2114 fullscreen_set_timeout (window);
2120 fullscreen_leave_notify_cb (GtkWidget *widget,
2121 GdkEventCrossing *event,
2124 EvWindow *window = EV_WINDOW (user_data);
2126 fullscreen_clear_timeout (window);
2132 ev_window_get_exit_fullscreen_button (EvWindow *window)
2134 GtkWidget *button, *icon, *label, *hbox;
2136 button = gtk_button_new ();
2137 g_signal_connect (button, "clicked",
2138 G_CALLBACK (exit_fullscreen_button_clicked_cb),
2140 gtk_widget_show (button);
2142 hbox = gtk_hbox_new (FALSE, 2);
2143 gtk_widget_show (hbox);
2144 gtk_container_add (GTK_CONTAINER (button), hbox);
2146 icon = gtk_image_new_from_stock (EV_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_BUTTON);
2147 gtk_widget_show (icon);
2148 gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
2150 label = gtk_label_new (_("Leave Fullscreen"));
2151 gtk_widget_show (label);
2152 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2158 ev_window_create_fullscreen_popup (EvWindow *window)
2165 window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model
2166 (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
2168 popup = gtk_window_new (GTK_WINDOW_POPUP);
2169 hbox = gtk_hbox_new (FALSE, 0);
2170 button = ev_window_get_exit_fullscreen_button (window);
2172 gtk_container_add (GTK_CONTAINER (popup), hbox);
2173 gtk_box_pack_start (GTK_BOX (hbox), window->priv->fullscreen_toolbar,
2175 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
2177 gtk_widget_show (button);
2178 gtk_widget_show (hbox);
2180 gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
2182 screen = gtk_widget_get_screen (GTK_WIDGET (window));
2183 g_signal_connect_object (screen, "size-changed",
2184 G_CALLBACK (screen_size_changed_cb),
2186 g_signal_connect_object (popup, "size_request",
2187 G_CALLBACK (fullscreen_popup_size_request_cb),
2190 gtk_window_set_screen (GTK_WINDOW (popup),
2191 gtk_widget_get_screen (GTK_WIDGET (window)));
2198 ev_window_update_fullscreen_action (EvWindow *window)
2202 action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
2203 g_signal_handlers_block_by_func
2204 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
2205 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2206 ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
2207 g_signal_handlers_unblock_by_func
2208 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
2212 ev_window_run_fullscreen (EvWindow *window)
2214 if (window->priv->fullscreen_popup == NULL)
2215 window->priv->fullscreen_popup
2216 = ev_window_create_fullscreen_popup (window);
2218 g_object_set (G_OBJECT (window->priv->scrolled_window),
2219 "shadow-type", GTK_SHADOW_NONE,
2222 ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
2223 ev_window_update_fullscreen_action (window);
2225 gtk_window_fullscreen (GTK_WINDOW (window));
2226 gtk_widget_grab_focus (window->priv->view);
2227 ev_window_update_fullscreen_popup (window);
2229 g_signal_connect (window->priv->view,
2230 "motion-notify-event",
2231 G_CALLBACK (fullscreen_motion_notify_cb),
2233 g_signal_connect (window->priv->view,
2234 "leave-notify-event",
2235 G_CALLBACK (fullscreen_leave_notify_cb),
2237 fullscreen_set_timeout (window);
2239 if (!ev_window_is_empty (window))
2240 ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", TRUE);
2244 ev_window_stop_fullscreen (EvWindow *window)
2246 EvView *view = EV_VIEW (window->priv->view);
2248 if (!ev_view_get_fullscreen (EV_VIEW (view)))
2251 g_object_set (G_OBJECT (window->priv->scrolled_window),
2252 "shadow-type", GTK_SHADOW_IN,
2255 ev_view_set_fullscreen (view, FALSE);
2256 ev_window_update_fullscreen_action (window);
2257 gtk_window_unfullscreen (GTK_WINDOW (window));
2259 g_signal_handlers_disconnect_by_func (window->priv->view,
2260 (gpointer) fullscreen_motion_notify_cb,
2262 g_signal_handlers_disconnect_by_func (window->priv->view,
2263 (gpointer) fullscreen_leave_notify_cb,
2265 fullscreen_clear_timeout (window);
2267 if (!ev_window_is_empty (window))
2268 ev_metadata_manager_set_boolean (window->priv->uri, "fullscreen", FALSE);
2272 ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
2274 gboolean fullscreen;
2276 g_return_if_fail (EV_IS_WINDOW (window));
2277 ev_window_stop_presentation (window);
2279 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2281 ev_window_run_fullscreen (window);
2283 ev_window_stop_fullscreen (window);
2288 ev_window_update_presentation_action (EvWindow *window)
2292 action = gtk_action_group_get_action (window->priv->action_group, "ViewPresentation");
2293 g_signal_handlers_block_by_func
2294 (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
2295 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2296 ev_view_get_presentation (EV_VIEW (window->priv->view)));
2297 g_signal_handlers_unblock_by_func
2298 (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
2302 ev_window_run_presentation (EvWindow *window)
2304 g_object_set (G_OBJECT (window->priv->scrolled_window),
2305 "shadow-type", GTK_SHADOW_NONE,
2308 ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
2309 ev_window_update_presentation_action (window);
2311 gtk_widget_grab_focus (window->priv->view);
2312 gtk_window_fullscreen (GTK_WINDOW (window));
2314 g_signal_connect (window->priv->view,
2315 "motion-notify-event",
2316 G_CALLBACK (fullscreen_motion_notify_cb),
2318 g_signal_connect (window->priv->view,
2319 "leave-notify-event",
2320 G_CALLBACK (fullscreen_leave_notify_cb),
2322 fullscreen_set_timeout (window);
2324 if (!ev_window_is_empty (window))
2325 ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
2329 ev_window_stop_presentation (EvWindow *window)
2331 if (!ev_view_get_presentation (EV_VIEW (window->priv->view)))
2334 g_object_set (G_OBJECT (window->priv->scrolled_window),
2335 "shadow-type", GTK_SHADOW_IN,
2338 ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
2339 ev_window_update_presentation_action (window);
2340 gtk_window_unfullscreen (GTK_WINDOW (window));
2342 g_signal_handlers_disconnect_by_func (window->priv->view,
2343 (gpointer) fullscreen_motion_notify_cb,
2345 g_signal_handlers_disconnect_by_func (window->priv->view,
2346 (gpointer) fullscreen_leave_notify_cb,
2348 fullscreen_clear_timeout (window);
2350 if (!ev_window_is_empty (window))
2351 ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
2355 ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
2357 gboolean presentation;
2359 g_return_if_fail (EV_IS_WINDOW (window));
2360 ev_window_stop_fullscreen (window);
2362 presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2364 ev_window_run_presentation (window);
2366 ev_window_stop_presentation (window);
2371 ev_window_run_preview (EvWindow *window)
2373 EggToolbarsModel *model;
2374 EggTbModelFlags flags;
2376 model = egg_toolbars_model_new ();
2378 egg_toolbars_model_load_toolbars (model,
2379 DATADIR"/evince-toolbar.xml");
2381 flags = egg_toolbars_model_get_flags (model, 1);
2382 egg_toolbars_model_set_flags (model, 1, flags &= ~(EGG_TB_MODEL_HIDDEN));
2384 egg_editable_toolbar_set_model (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
2387 egg_editable_toolbar_hide (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
2389 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
2392 ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE);
2394 update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
2395 update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
2396 update_chrome_visibility (window);
2400 ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
2402 EvWindow *window = EV_WINDOW (widget);
2403 EvWindowPrivate *priv = window->priv;
2405 if (ev_view_get_fullscreen (EV_VIEW (priv->view)))
2406 fullscreen_set_timeout (window);
2408 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
2412 ev_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
2414 EvWindow *window = EV_WINDOW (widget);
2415 EvWindowPrivate *priv = window->priv;
2417 if (ev_view_get_fullscreen (EV_VIEW (priv->view))) {
2418 fullscreen_set_timeout (window);
2419 gtk_widget_hide (priv->fullscreen_popup);
2422 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
2426 ev_window_screen_changed (GtkWidget *widget,
2427 GdkScreen *old_screen)
2429 EvWindow *window = EV_WINDOW (widget);
2430 EvWindowPrivate *priv = window->priv;
2433 screen = gtk_widget_get_screen (widget);
2434 if (screen == old_screen)
2437 #ifdef HAVE_GTK_RECENT
2439 g_signal_handlers_disconnect_by_func (
2440 gtk_recent_manager_get_for_screen (old_screen),
2441 G_CALLBACK (ev_window_setup_recent), window);
2444 priv->recent_manager = gtk_recent_manager_get_for_screen (screen);
2445 g_signal_connect_swapped (priv->recent_manager,
2447 G_CALLBACK (ev_window_setup_recent),
2451 if (GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed) {
2452 GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed (widget, old_screen);
2455 if (priv->fullscreen_popup != NULL) {
2456 g_signal_handlers_disconnect_by_func
2457 (old_screen, G_CALLBACK (screen_size_changed_cb), window);
2459 g_signal_connect_object (screen, "size-changed",
2460 G_CALLBACK (screen_size_changed_cb),
2462 gtk_window_set_screen (GTK_WINDOW (priv->fullscreen_popup), screen);
2464 ev_window_update_fullscreen_popup (window);
2469 ev_window_set_page_mode (EvWindow *window,
2470 EvWindowPageMode page_mode)
2472 GtkWidget *child = NULL;
2473 GtkWidget *real_child;
2475 if (window->priv->page_mode == page_mode)
2478 window->priv->page_mode = page_mode;
2480 switch (page_mode) {
2481 case PAGE_MODE_DOCUMENT:
2482 child = window->priv->view;
2484 case PAGE_MODE_PASSWORD:
2485 child = window->priv->password_view;
2488 g_assert_not_reached ();
2491 real_child = gtk_bin_get_child (GTK_BIN (window->priv->scrolled_window));
2492 if (child != real_child) {
2493 gtk_container_remove (GTK_CONTAINER (window->priv->scrolled_window),
2495 gtk_container_add (GTK_CONTAINER (window->priv->scrolled_window),
2498 ev_window_update_actions (window);
2503 ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
2505 ev_view_rotate_left (EV_VIEW (ev_window->priv->view));
2509 ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
2511 ev_view_rotate_right (EV_VIEW (ev_window->priv->view));
2515 ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
2517 EvWindow *ev_window = EV_WINDOW (data);
2518 egg_editable_toolbar_set_edit_mode
2519 (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
2520 ev_application_save_toolbars_model (EV_APP);
2521 gtk_widget_destroy (GTK_WIDGET (dialog));
2525 ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
2530 dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
2531 GTK_WINDOW (ev_window),
2532 GTK_DIALOG_DESTROY_WITH_PARENT,
2536 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
2537 gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
2538 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
2539 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
2540 gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
2542 editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
2543 ev_application_get_toolbars_model (EV_APP));
2544 gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
2545 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
2547 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
2549 egg_editable_toolbar_set_edit_mode
2550 (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
2552 g_signal_connect (dialog, "response",
2553 G_CALLBACK (ev_window_cmd_edit_toolbar_cb),
2555 gtk_widget_show_all (dialog);
2559 ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
2561 g_return_if_fail (EV_IS_WINDOW (ev_window));
2563 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
2564 ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
2568 ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
2570 g_return_if_fail (EV_IS_WINDOW (ev_window));
2572 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
2573 ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
2577 ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
2579 g_return_if_fail (EV_IS_WINDOW (ev_window));
2581 ev_view_previous_page (EV_VIEW (ev_window->priv->view));
2585 ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
2587 g_return_if_fail (EV_IS_WINDOW (ev_window));
2589 ev_view_next_page (EV_VIEW (ev_window->priv->view));
2593 ev_window_cmd_go_first_page (GtkAction *action, EvWindow *ev_window)
2595 g_return_if_fail (EV_IS_WINDOW (ev_window));
2597 ev_page_cache_set_current_page (ev_window->priv->page_cache, 0);
2601 ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
2605 g_return_if_fail (EV_IS_WINDOW (ev_window));
2607 n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
2608 ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
2612 ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window)
2614 int n_pages, current_page;
2616 g_return_if_fail (EV_IS_WINDOW (ev_window));
2618 n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
2619 current_page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
2621 if (current_page + 10 < n_pages)
2622 ev_page_cache_set_current_page (ev_window->priv->page_cache, current_page + 10);
2626 ev_window_cmd_go_backward (GtkAction *action, EvWindow *ev_window)
2630 g_return_if_fail (EV_IS_WINDOW (ev_window));
2632 current_page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
2634 if (current_page - 10 >= 0)
2635 ev_page_cache_set_current_page (ev_window->priv->page_cache, current_page - 10);
2639 ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
2643 g_return_if_fail (EV_IS_WINDOW (ev_window));
2645 uri = g_strdup (ev_window->priv->uri);
2647 ev_window_open_uri (ev_window, uri, NULL, 0);
2653 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
2655 GError *error = NULL;
2657 g_return_if_fail (EV_IS_WINDOW (ev_window));
2659 gnome_help_display ("evince.xml", NULL, &error);
2662 g_warning (error->message);
2663 g_error_free (error);
2668 ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
2670 gtk_window_unfullscreen (GTK_WINDOW (window));
2674 ev_window_cmd_escape (GtkAction *action, EvWindow *window)
2678 widget = gtk_window_get_focus (GTK_WINDOW (window));
2679 if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
2680 update_chrome_flag (window, EV_CHROME_FINDBAR, FALSE);
2681 gtk_widget_grab_focus (window->priv->view);
2683 gboolean fullscreen;
2684 gboolean presentation;
2686 g_object_get (window->priv->view,
2687 "fullscreen", &fullscreen,
2688 "presentation", &presentation,
2692 ev_window_stop_fullscreen (window);
2693 } else if (presentation) {
2694 ev_window_stop_presentation (window);
2695 gtk_widget_grab_focus (window->priv->view);
2697 gtk_widget_grab_focus (window->priv->view);
2700 if (fullscreen && presentation)
2701 g_warning ("Both fullscreen and presentation set somehow");
2706 update_view_size (EvView *view, EvWindow *window)
2709 GtkRequisition vsb_requisition;
2710 GtkRequisition hsb_requisition;
2711 int scrollbar_spacing;
2713 /* Calculate the width available for the */
2714 width = window->priv->scrolled_window->allocation.width;
2715 height = window->priv->scrolled_window->allocation.height;
2717 if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)) == GTK_SHADOW_IN) {
2718 width -= 2 * window->priv->view->style->xthickness;
2719 height -= 2 * window->priv->view->style->ythickness;
2722 gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
2724 gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->hscrollbar,
2726 gtk_widget_style_get (window->priv->scrolled_window,
2727 "scrollbar_spacing", &scrollbar_spacing,
2730 ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
2733 vsb_requisition.width + scrollbar_spacing,
2734 hsb_requisition.height + scrollbar_spacing);
2738 save_sizing_mode (EvWindow *window)
2741 GEnumValue *enum_value;
2743 mode = ev_view_get_sizing_mode (EV_VIEW (window->priv->view));
2744 enum_value = g_enum_get_value (EV_SIZING_MODE_CLASS, mode);
2746 if (!ev_window_is_empty (window))
2747 ev_metadata_manager_set_string (window->priv->uri, "sizing_mode",
2748 enum_value->value_nick);
2752 ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
2753 EvWindow *ev_window)
2755 GtkWidget *scrolled_window;
2756 EvSizingMode sizing_mode;
2758 g_object_get (ev_window->priv->view,
2759 "sizing-mode", &sizing_mode,
2762 scrolled_window = ev_window->priv->scrolled_window;
2764 g_signal_handlers_disconnect_by_func (ev_window->priv->view, update_view_size, ev_window);
2766 if (sizing_mode != EV_SIZING_FREE)
2767 update_view_size (NULL, ev_window);
2769 switch (sizing_mode) {
2770 case EV_SIZING_BEST_FIT:
2771 g_object_set (G_OBJECT (scrolled_window),
2772 "hscrollbar-policy", GTK_POLICY_NEVER,
2773 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
2775 g_signal_connect (ev_window->priv->view, "zoom_invalid",
2776 G_CALLBACK (update_view_size),
2779 case EV_SIZING_FIT_WIDTH:
2780 g_object_set (G_OBJECT (scrolled_window),
2781 "hscrollbar-policy", GTK_POLICY_NEVER,
2782 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
2784 g_signal_connect (ev_window->priv->view, "zoom_invalid",
2785 G_CALLBACK (update_view_size),
2788 case EV_SIZING_FREE:
2789 g_object_set (G_OBJECT (scrolled_window),
2790 "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
2791 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
2796 update_sizing_buttons (ev_window);
2797 save_sizing_mode (ev_window);
2801 ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
2803 ev_window_update_actions (ev_window);
2805 if (ev_view_get_sizing_mode (view) == EV_SIZING_FREE && !ev_window_is_empty (ev_window)) {
2806 ev_metadata_manager_set_double (ev_window->priv->uri, "zoom",
2807 ev_view_get_zoom (view));
2812 ev_window_update_continuous_action (EvWindow *window)
2816 action = gtk_action_group_get_action (window->priv->action_group, "ViewContinuous");
2817 g_signal_handlers_block_by_func
2818 (action, G_CALLBACK (ev_window_cmd_continuous), window);
2819 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2820 ev_view_get_continuous (EV_VIEW (window->priv->view)));
2821 g_signal_handlers_unblock_by_func
2822 (action, G_CALLBACK (ev_window_cmd_continuous), window);
2826 ev_window_update_dual_page_action (EvWindow *window)
2830 action = gtk_action_group_get_action (window->priv->action_group, "ViewDual");
2831 g_signal_handlers_block_by_func
2832 (action, G_CALLBACK (ev_window_cmd_dual), window);
2833 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2834 ev_view_get_dual_page (EV_VIEW (window->priv->view)));
2835 g_signal_handlers_unblock_by_func
2836 (action, G_CALLBACK (ev_window_cmd_dual), window);
2840 ev_window_continuous_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
2842 ev_window_update_continuous_action (ev_window);
2844 if (!ev_window_is_empty (ev_window))
2845 ev_metadata_manager_set_boolean (ev_window->priv->uri, "continuous",
2846 ev_view_get_continuous (EV_VIEW (ev_window->priv->view)));
2850 ev_window_rotation_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
2854 rotation = ev_view_get_rotation (EV_VIEW (window->priv->view));
2856 if (!ev_window_is_empty (window))
2857 ev_metadata_manager_set_int (window->priv->uri, "rotation",
2860 ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
2865 ev_window_has_selection_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window)
2867 ev_window_update_actions (window);
2871 ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window)
2873 ev_window_update_dual_page_action (ev_window);
2875 if (!ev_window_is_empty (ev_window))
2876 ev_metadata_manager_set_boolean (ev_window->priv->uri, "dual-page",
2877 ev_view_get_dual_page (EV_VIEW (ev_window->priv->view)));
2881 build_comments_string (void)
2883 PopplerBackend backend;
2884 const char *backend_name;
2885 const char *version;
2887 backend = poppler_get_backend ();
2888 version = poppler_get_version ();
2890 case POPPLER_BACKEND_CAIRO:
2891 backend_name = "cairo";
2893 case POPPLER_BACKEND_SPLASH:
2894 backend_name = "splash";
2897 backend_name = "unknown";
2901 return g_strdup_printf (_("PostScript and PDF File Viewer.\n"
2902 "Using poppler %s (%s)"),
2903 version, backend_name);
2907 ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
2909 const char *authors[] = {
2910 "Martin Kretzschmar <m_kretzschmar@gmx.net>",
2911 "Jonathan Blandford <jrb@gnome.org>",
2912 "Marco Pesenti Gritti <marco@gnome.org>",
2913 "Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
2914 "Bryan Clark <clarkbw@gnome.org>",
2915 "Carlos Garcia Campos <carlosgc@gnome.org>",
2916 "Wouter Bolsterlee <wbolster@gnome.org>",
2920 const char *documenters[] = {
2921 "Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
2925 const char *license[] = {
2926 N_("Evince is free software; you can redistribute it and/or modify "
2927 "it under the terms of the GNU General Public License as published by "
2928 "the Free Software Foundation; either version 2 of the License, or "
2929 "(at your option) any later version.\n"),
2930 N_("Evince is distributed in the hope that it will be useful, "
2931 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
2932 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
2933 "GNU General Public License for more details.\n"),
2934 N_("You should have received a copy of the GNU General Public License "
2935 "along with Evince; if not, write to the Free Software Foundation, Inc., "
2936 "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
2939 char *license_trans;
2945 for (p = authors; *p; ++p)
2948 for (p = documenters; *p; ++p)
2952 license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
2953 _(license[2]), "\n", NULL);
2954 comments = build_comments_string ();
2956 gtk_show_about_dialog (
2957 GTK_WINDOW (ev_window),
2958 "name", _("Evince"),
2961 _("\xc2\xa9 1996-2005 The Evince authors"),
2962 "license", license_trans,
2963 "website", "http://www.gnome.org/projects/evince",
2964 "comments", comments,
2966 "documenters", documenters,
2967 "translator-credits", _("translator-credits"),
2968 "logo-icon-name", "evince",
2969 "wrap-license", TRUE,
2973 g_free (license_trans);
2977 ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
2981 active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
2982 update_chrome_flag (ev_window, EV_CHROME_TOOLBAR, active);
2983 ev_metadata_manager_set_boolean (NULL, "show_toolbar", active);
2987 ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
2989 update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
2990 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2994 ev_window_sidebar_current_page_changed_cb (EvSidebar *ev_sidebar,
2996 EvWindow *ev_window)
2998 GtkWidget *current_page;
3001 g_object_get (G_OBJECT (ev_sidebar), "current_page", ¤t_page, NULL);
3003 if (current_page == ev_window->priv->sidebar_links) {
3004 id = LINKS_SIDEBAR_ID;
3005 } else if (current_page == ev_window->priv->sidebar_thumbs) {
3006 id = THUMBNAILS_SIDEBAR_ID;
3007 } else if (current_page == ev_window->priv->sidebar_attachments) {
3008 id = ATTACHMENTS_SIDEBAR_ID;
3010 g_assert_not_reached();
3013 g_object_unref (current_page);
3015 if (!ev_window_is_empty (ev_window))
3016 ev_metadata_manager_set_string (ev_window->priv->uri, "sidebar_page", id);
3020 ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
3022 EvWindow *ev_window)
3024 EvView *view = EV_VIEW (ev_window->priv->view);
3027 action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
3028 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
3029 GTK_WIDGET_VISIBLE (ev_sidebar));
3031 if (!ev_view_get_presentation (view) &&
3032 !ev_view_get_fullscreen (view)) {
3033 ev_metadata_manager_set_boolean (ev_window->priv->uri, "sidebar_visibility",
3034 GTK_WIDGET_VISIBLE (ev_sidebar));
3039 view_menu_popup_cb (EvView *view,
3041 EvWindow *ev_window)
3044 gboolean show_external = FALSE;
3045 gboolean show_internal = FALSE;
3048 if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
3051 if (ev_window->priv->link)
3052 g_object_unref (ev_window->priv->link);
3055 ev_window->priv->link = g_object_ref (link);
3057 ev_window->priv->link = NULL;
3059 popup = ev_window->priv->view_popup;
3061 if (ev_window->priv->link) {
3062 EvLinkAction *ev_action;
3064 ev_action = ev_link_get_action (link);
3068 switch (ev_link_action_get_action_type (ev_action)) {
3069 case EV_LINK_ACTION_TYPE_GOTO_DEST:
3070 case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
3071 show_internal = TRUE;
3073 case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
3074 case EV_LINK_ACTION_TYPE_LAUNCH:
3075 show_external = TRUE;
3082 action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
3084 gtk_action_set_visible (action, show_external);
3086 action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
3088 gtk_action_set_visible (action, show_external);
3090 action = gtk_action_group_get_action (ev_window->priv->view_popup_action_group,
3092 gtk_action_set_visible (action, show_internal);
3094 gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
3096 3, gtk_get_current_event_time ());
3101 attachment_bar_menu_popup_cb (EvSidebarAttachments *attachbar,
3103 EvWindow *ev_window)
3107 g_assert (attach_list != NULL);
3109 if (ev_window->priv->attach_list) {
3110 g_list_foreach (ev_window->priv->attach_list,
3111 (GFunc) g_object_unref, NULL);
3112 g_list_free (ev_window->priv->attach_list);
3115 ev_window->priv->attach_list = attach_list;
3117 popup = ev_window->priv->attachment_popup;
3119 gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
3121 3, gtk_get_current_event_time ());
3127 view_find_status_changed_cb (EvView *view,
3129 EvWindow *ev_window)
3133 text = ev_view_get_find_status (view);
3134 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
3139 find_bar_previous_cb (EggFindBar *find_bar,
3140 EvWindow *ev_window)
3142 ev_view_find_previous (EV_VIEW (ev_window->priv->view));
3146 find_bar_next_cb (EggFindBar *find_bar,
3147 EvWindow *ev_window)
3149 ev_view_find_next (EV_VIEW (ev_window->priv->view));
3153 find_bar_close_cb (EggFindBar *find_bar,
3154 EvWindow *ev_window)
3156 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, FALSE);
3160 find_bar_search_changed_cb (EggFindBar *find_bar,
3162 EvWindow *ev_window)
3164 gboolean case_sensitive;
3166 const char *search_string;
3168 g_return_if_fail (EV_IS_WINDOW (ev_window));
3170 /* Either the string or case sensitivity could have changed,
3171 * we connect this callback to both. We also connect it
3172 * to ::visible so when the find bar is hidden, we should
3173 * pretend the search string is NULL/""
3176 case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
3177 visible = GTK_WIDGET_VISIBLE (find_bar);
3178 search_string = egg_find_bar_get_search_string (find_bar);
3180 ev_view_search_changed (EV_VIEW(ev_window->priv->view));
3182 if (ev_window->priv->document &&
3183 EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
3184 if (visible && search_string && search_string[0]) {
3185 ev_document_doc_mutex_lock ();
3186 ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
3187 ev_page_cache_get_current_page (ev_window->priv->page_cache),
3190 ev_document_doc_mutex_unlock ();
3192 ev_document_doc_mutex_lock ();
3193 ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
3194 ev_document_doc_mutex_unlock ();
3196 ev_window_update_actions (ev_window);
3197 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
3199 gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
3205 find_bar_scroll(EggFindBar *find_bar, GtkScrollType scroll, EvWindow* ev_window)
3207 ev_view_scroll(EV_VIEW(ev_window->priv->view), scroll, FALSE);
3211 zoom_control_changed_cb (EphyZoomAction *action,
3213 EvWindow *ev_window)
3217 g_return_if_fail (EV_IS_WINDOW (ev_window));
3219 if (zoom == EPHY_ZOOM_BEST_FIT) {
3220 mode = EV_SIZING_BEST_FIT;
3221 } else if (zoom == EPHY_ZOOM_FIT_WIDTH) {
3222 mode = EV_SIZING_FIT_WIDTH;
3224 mode = EV_SIZING_FREE;
3227 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
3229 if (mode == EV_SIZING_FREE) {
3230 ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
3235 ev_window_finalize (GObject *object)
3237 GList *windows = ev_application_get_windows (EV_APP);
3239 if (windows == NULL) {
3240 ev_application_shutdown (EV_APP);
3242 g_list_free (windows);
3245 G_OBJECT_CLASS (ev_window_parent_class)->finalize (object);
3249 ev_window_dispose (GObject *object)
3251 EvWindow *window = EV_WINDOW (object);
3252 EvWindowPrivate *priv = window->priv;
3255 ev_window_title_free (priv->title);
3259 if (priv->ui_manager) {
3260 g_object_unref (priv->ui_manager);
3261 priv->ui_manager = NULL;
3264 if (priv->action_group) {
3265 g_object_unref (priv->action_group);
3266 priv->action_group = NULL;
3269 if (priv->view_popup_action_group) {
3270 g_object_unref (priv->view_popup_action_group);
3271 priv->view_popup_action_group = NULL;
3274 if (priv->attachment_popup_action_group) {
3275 g_object_unref (priv->attachment_popup_action_group);
3276 priv->attachment_popup_action_group = NULL;
3279 #ifdef HAVE_GTK_RECENT
3280 if (priv->recent_action_group) {
3281 g_object_unref (priv->recent_action_group);
3282 priv->recent_action_group = NULL;
3285 if (priv->recent_manager) {
3286 g_signal_handlers_disconnect_by_func (priv->recent_manager,
3287 ev_window_setup_recent,
3289 priv->recent_manager = NULL;
3292 priv->recent_ui_id = 0;
3294 if (priv->recent_view) {
3295 g_object_unref (priv->recent_view);
3296 priv->recent_view = NULL;
3298 #endif /* HAVE_GTK_RECENT */
3300 if (priv->page_cache) {
3301 g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
3302 priv->page_cache = NULL;
3305 if (priv->document) {
3306 g_object_unref (priv->document);
3307 priv->document = NULL;
3311 g_object_unref (priv->view);
3315 if (priv->password_view) {
3316 g_object_unref (priv->password_view);
3317 priv->password_view = NULL;
3320 if (priv->xfer_job) {
3321 ev_window_clear_xfer_job (window);
3324 if (priv->local_uri) {
3325 ev_window_clear_local_uri (window);
3328 ev_window_close_dialogs (window);
3330 #ifdef WITH_GTK_PRINT
3331 ev_window_clear_print_job (window);
3333 if (window->priv->gtk_print_job) {
3334 g_object_unref (window->priv->gtk_print_job);
3335 window->priv->gtk_print_job = NULL;
3338 if (window->priv->printer) {
3339 g_object_unref (window->priv->printer);
3340 window->priv->printer = NULL;
3343 if (window->priv->print_settings) {
3344 g_object_unref (window->priv->print_settings);
3345 window->priv->print_settings = NULL;
3348 if (window->priv->print_page_setup) {
3349 g_object_unref (window->priv->print_page_setup);
3350 window->priv->print_page_setup = NULL;
3355 g_object_unref (priv->link);
3359 if (priv->attach_list) {
3360 g_list_foreach (priv->attach_list,
3361 (GFunc) g_object_unref,
3363 g_list_free (priv->attach_list);
3364 priv->attach_list = NULL;
3367 if (priv->find_bar) {
3368 g_signal_handlers_disconnect_by_func
3369 (window->priv->find_bar,
3370 G_CALLBACK (find_bar_close_cb),
3372 priv->find_bar = NULL;
3381 g_object_unref (priv->dest);
3385 if (priv->fullscreen_timeout_id) {
3386 g_source_remove (priv->fullscreen_timeout_id);
3387 priv->fullscreen_timeout_id = 0;
3389 destroy_fullscreen_popup (window);
3391 G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
3395 ev_window_class_init (EvWindowClass *ev_window_class)
3397 GObjectClass *g_object_class = G_OBJECT_CLASS (ev_window_class);
3398 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
3400 g_object_class->dispose = ev_window_dispose;
3401 g_object_class->finalize = ev_window_finalize;
3403 widget_class->focus_in_event = ev_window_focus_in_event;
3404 widget_class->focus_out_event = ev_window_focus_out_event;
3405 widget_class->screen_changed = ev_window_screen_changed;
3407 g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
3411 static const GtkActionEntry entries[] = {
3412 { "File", NULL, N_("_File") },
3413 { "Edit", NULL, N_("_Edit") },
3414 { "View", NULL, N_("_View") },
3415 { "Go", NULL, N_("_Go") },
3416 { "Help", NULL, N_("_Help") },
3419 { "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
3420 N_("Open an existing document"),
3421 G_CALLBACK (ev_window_cmd_file_open) },
3422 { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), "<control>S",
3423 N_("Save a copy of the current document"),
3424 G_CALLBACK (ev_window_cmd_save_as) },
3425 { "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
3426 N_("Print this document"),
3427 G_CALLBACK (ev_window_cmd_file_print) },
3428 { "FileProperties", GTK_STOCK_PROPERTIES, N_("P_roperties"), "<alt>Return", NULL,
3429 G_CALLBACK (ev_window_cmd_file_properties) },
3430 { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W", NULL,
3431 G_CALLBACK (ev_window_cmd_file_close_window) },
3434 { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C", NULL,
3435 G_CALLBACK (ev_window_cmd_edit_copy) },
3436 { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
3437 G_CALLBACK (ev_window_cmd_edit_select_all) },
3438 { "EditFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F",
3439 N_("Find a word or phrase in the document"),
3440 G_CALLBACK (ev_window_cmd_edit_find) },
3441 { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL,
3442 G_CALLBACK (ev_window_cmd_edit_find_next) },
3443 { "EditFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
3444 G_CALLBACK (ev_window_cmd_edit_find_previous) },
3445 { "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
3446 G_CALLBACK (ev_window_cmd_edit_toolbar) },
3447 { "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL,
3448 G_CALLBACK (ev_window_cmd_edit_rotate_left) },
3449 { "EditRotateRight", NULL, N_("Rotate _Right"), NULL, NULL,
3450 G_CALLBACK (ev_window_cmd_edit_rotate_right) },
3453 { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
3454 N_("Enlarge the document"),
3455 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3456 { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, NULL, "<control>minus",
3457 N_("Shrink the document"),
3458 G_CALLBACK (ev_window_cmd_view_zoom_out) },
3459 { "ViewReload", GTK_STOCK_REFRESH, N_("_Reload"), "<control>R",
3460 N_("Reload the document"),
3461 G_CALLBACK (ev_window_cmd_view_reload) },
3464 { "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",
3465 N_("Go to the previous page"),
3466 G_CALLBACK (ev_window_cmd_go_previous_page) },
3467 { "GoNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<control>Page_Down",
3468 N_("Go to the next page"),
3469 G_CALLBACK (ev_window_cmd_go_next_page) },
3470 { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home",
3471 N_("Go to the first page"),
3472 G_CALLBACK (ev_window_cmd_go_first_page) },
3473 { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End",
3474 N_("Go to the last page"),
3475 G_CALLBACK (ev_window_cmd_go_last_page) },
3478 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL,
3479 G_CALLBACK (ev_window_cmd_help_contents) },
3481 { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL,
3482 G_CALLBACK (ev_window_cmd_help_about) },
3485 { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
3486 N_("Leave fullscreen mode"),
3487 G_CALLBACK (ev_window_cmd_leave_fullscreen) },
3490 { "Escape", NULL, "", "Escape", "",
3491 G_CALLBACK (ev_window_cmd_escape) },
3492 { "Slash", GTK_STOCK_FIND, NULL, "slash", NULL,
3493 G_CALLBACK (ev_window_cmd_edit_find) },
3494 { "PageDown", NULL, "", "Page_Down", NULL,
3495 G_CALLBACK (ev_window_cmd_scroll_forward) },
3496 { "PageUp", NULL, "", "Page_Up", NULL,
3497 G_CALLBACK (ev_window_cmd_scroll_backward) },
3498 { "Space", NULL, "", "space", NULL,
3499 G_CALLBACK (ev_window_cmd_scroll_forward) },
3500 { "ShiftSpace", NULL, "", "<shift>space", NULL,
3501 G_CALLBACK (ev_window_cmd_scroll_backward) },
3502 { "BackSpace", NULL, "", "BackSpace", NULL,
3503 G_CALLBACK (ev_window_cmd_scroll_backward) },
3504 { "ShiftBackSpace", NULL, "", "<shift>BackSpace", NULL,
3505 G_CALLBACK (ev_window_cmd_scroll_forward) },
3506 { "Return", NULL, "", "Return", NULL,
3507 G_CALLBACK (ev_window_cmd_scroll_forward) },
3508 { "ShiftReturn", NULL, "", "<shift>Return", NULL,
3509 G_CALLBACK (ev_window_cmd_scroll_backward) },
3510 { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus", NULL,
3511 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3512 { "CtrlEqual", GTK_STOCK_ZOOM_IN, NULL, "<control>equal", NULL,
3513 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3514 { "Equal", GTK_STOCK_ZOOM_IN, NULL, "equal", NULL,
3515 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3516 { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus", NULL,
3517 G_CALLBACK (ev_window_cmd_view_zoom_out) },
3518 { "FocusPageSelector", NULL, "", "<control>l", NULL,
3519 G_CALLBACK (ev_window_cmd_focus_page_selector) },
3520 { "GoBackwardFast", NULL, "", "<shift>Page_Up", NULL,
3521 G_CALLBACK (ev_window_cmd_go_backward) },
3522 { "GoForwardFast", NULL, "", "<shift>Page_Down", NULL,
3523 G_CALLBACK (ev_window_cmd_go_forward) },
3524 { "KpPlus", GTK_STOCK_ZOOM_IN, NULL, "KP_Add", NULL,
3525 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3526 { "KpMinus", GTK_STOCK_ZOOM_OUT, NULL, "KP_Subtract", NULL,
3527 G_CALLBACK (ev_window_cmd_view_zoom_out) },
3528 { "CtrlKpPlus", GTK_STOCK_ZOOM_IN, NULL, "<control>KP_Add", NULL,
3529 G_CALLBACK (ev_window_cmd_view_zoom_in) },
3530 { "CtrlKpMinus", GTK_STOCK_ZOOM_OUT, NULL, "<control>KP_Subtract", NULL,
3531 G_CALLBACK (ev_window_cmd_view_zoom_out) },
3535 static const GtkToggleActionEntry toggle_entries[] = {
3537 { "ViewToolbar", NULL, N_("_Toolbar"), NULL,
3538 N_("Show or hide the toolbar"),
3539 G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
3540 { "ViewSidebar", GTK_STOCK_INDEX, N_("Side _Pane"), "F9",
3541 N_("Show or hide the side pane"),
3542 G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
3543 { "ViewContinuous", EV_STOCK_VIEW_CONTINUOUS, N_("_Continuous"), NULL,
3544 N_("Show the entire document"),
3545 G_CALLBACK (ev_window_cmd_continuous), TRUE },
3546 { "ViewDual", EV_STOCK_VIEW_DUAL, N_("_Dual"), NULL,
3547 N_("Show two pages at once"),
3548 G_CALLBACK (ev_window_cmd_dual), FALSE },
3549 { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
3550 N_("Expand the window to fill the screen"),
3551 G_CALLBACK (ev_window_cmd_view_fullscreen) },
3552 { "ViewPresentation", NULL, N_("_Presentation"), "F5",
3553 N_("Run document as a presentation"),
3554 G_CALLBACK (ev_window_cmd_view_presentation) },
3555 { "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
3556 N_("Make the current document fill the window"),
3557 G_CALLBACK (ev_window_cmd_view_best_fit) },
3558 { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL,
3559 N_("Make the current document fill the window width"),
3560 G_CALLBACK (ev_window_cmd_view_page_width) },
3563 /* Popups specific items */
3564 static const GtkActionEntry view_popup_entries [] = {
3566 { "OpenLink", GTK_STOCK_OPEN, N_("_Open Link"), NULL,
3567 NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
3568 { "GoLink", GTK_STOCK_GO_FORWARD, N_("_Go To"), NULL,
3569 NULL, G_CALLBACK (ev_view_popup_cmd_open_link) },
3570 { "CopyLinkAddress", NULL, N_("_Copy Link Address"), NULL,
3572 G_CALLBACK (ev_view_popup_cmd_copy_link_address) },
3575 static const GtkActionEntry attachment_popup_entries [] = {
3576 { "OpenAttachment", GTK_STOCK_OPEN, N_("_Open..."), NULL,
3577 NULL, G_CALLBACK (ev_attachment_popup_cmd_open_attachment) },
3578 { "SaveAttachmentAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
3579 NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
3583 drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
3584 gint x, gint y, GtkSelectionData *selection_data,
3585 guint info, guint time, gpointer gdata)
3587 GList *uri_list = NULL;
3588 GSList *uris = NULL;
3591 uri_list = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
3595 uri = gnome_vfs_uri_to_string (uri_list->data, GNOME_VFS_URI_HIDE_NONE);
3596 uris = g_slist_append (uris, (gpointer) uri);
3598 uri_list = g_list_next (uri_list);
3601 gnome_vfs_uri_list_free (uri_list);
3603 ev_application_open_uri_list (EV_APP, uris, 0);
3605 g_slist_free (uris);
3610 activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
3612 ev_view_handle_link (EV_VIEW (window->priv->view), link);
3613 gtk_widget_grab_focus (window->priv->view);
3617 activate_label_cb (EvPageAction *page_action, char *label, EvWindow *window)
3619 g_return_val_if_fail (EV_IS_WINDOW (window), FALSE);
3621 gtk_widget_grab_focus (window->priv->view);
3623 return ev_page_cache_set_page_label (window->priv->page_cache, label);
3627 register_custom_actions (EvWindow *window, GtkActionGroup *group)
3631 action = g_object_new (EV_TYPE_PAGE_ACTION,
3632 "name", PAGE_SELECTOR_ACTION,
3634 "tooltip", _("Select Page"),
3635 "visible_overflown", FALSE,
3637 g_signal_connect (action, "activate_link",
3638 G_CALLBACK (activate_link_cb), window);
3639 g_signal_connect (action, "activate_label",
3640 G_CALLBACK (activate_label_cb), window);
3641 gtk_action_group_add_action (group, action);
3642 g_object_unref (action);
3644 action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
3645 "name", ZOOM_CONTROL_ACTION,
3647 "stock_id", GTK_STOCK_ZOOM_IN,
3648 "tooltip", _("Adjust the zoom level"),
3651 g_signal_connect (action, "zoom_to_level",
3652 G_CALLBACK (zoom_control_changed_cb), window);
3653 gtk_action_group_add_action (group, action);
3654 g_object_unref (action);
3658 set_action_properties (GtkActionGroup *action_group)
3662 action = gtk_action_group_get_action (action_group, "GoPreviousPage");
3663 /*translators: this is the label for toolbar button*/
3664 g_object_set (action, "short_label", _("Previous"), NULL);
3665 g_object_set (action, "is-important", TRUE, NULL);
3667 action = gtk_action_group_get_action (action_group, "GoNextPage");
3668 g_object_set (action, "is-important", TRUE, NULL);
3669 /*translators: this is the label for toolbar button*/
3670 g_object_set (action, "short_label", _("Next"), NULL);
3672 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
3673 /*translators: this is the label for toolbar button*/
3674 g_object_set (action, "short_label", _("Zoom In"), NULL);
3675 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
3677 action = gtk_action_group_get_action (action_group, "ViewZoomOut");
3678 /*translators: this is the label for toolbar button*/
3679 g_object_set (action, "short_label", _("Zoom Out"), NULL);
3680 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
3682 action = gtk_action_group_get_action (action_group, "ViewBestFit");
3683 /*translators: this is the label for toolbar button*/
3684 g_object_set (action, "short_label", _("Best Fit"), NULL);
3685 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
3687 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
3688 /*translators: this is the label for toolbar button*/
3689 g_object_set (action, "short_label", _("Fit Width"), NULL);
3690 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
3692 action = gtk_action_group_get_action (action_group, "LeaveFullscreen");
3693 g_object_set (action, "is-important", TRUE, NULL);
3697 set_chrome_actions (EvWindow *window)
3699 EvWindowPrivate *priv = window->priv;
3700 GtkActionGroup *action_group = priv->action_group;
3703 action= gtk_action_group_get_action (action_group, "ViewToolbar");
3704 g_signal_handlers_block_by_func
3705 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
3706 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
3707 (priv->chrome & EV_CHROME_TOOLBAR) != 0);
3708 g_signal_handlers_unblock_by_func
3709 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
3713 sidebar_widget_model_set (EvSidebarLinks *ev_sidebar_links,
3715 EvWindow *ev_window)
3717 GtkTreeModel *model;
3720 g_object_get (G_OBJECT (ev_sidebar_links),
3724 action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
3725 ev_page_action_set_model (EV_PAGE_ACTION (action), model);
3726 g_object_unref (model);
3730 view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
3732 update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE);
3733 ev_window_set_action_sensitive (window, "ViewToolbar", TRUE);
3735 ev_window_set_view_accels_sensitivity (window, TRUE);
3741 view_actions_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
3743 ev_window_set_view_accels_sensitivity (window, FALSE);
3749 sidebar_page_main_widget_update_cb (GObject *ev_sidebar_page,
3751 EvWindow *ev_window)
3755 g_object_get (ev_sidebar_page, "main_widget", &widget, NULL);
3757 if (widget != NULL) {
3758 g_signal_connect_object (widget, "focus_in_event",
3759 G_CALLBACK (view_actions_focus_in_cb),
3761 g_signal_connect_object (widget, "focus_out_event",
3762 G_CALLBACK (view_actions_focus_out_cb),
3764 g_object_unref (widget);
3769 window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
3771 if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
3774 maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
3775 if (!ev_window_is_empty (window))
3776 ev_metadata_manager_set_boolean (window->priv->uri, "window_maximized", maximized);
3783 window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer dummy)
3785 char *uri = window->priv->uri;
3786 GdkWindowState state;
3787 int x, y, width, height, document_width, document_height;
3789 state = gdk_window_get_state (GTK_WIDGET (window)->window);
3791 if (!(state & GDK_WINDOW_STATE_FULLSCREEN)) {
3792 gtk_window_get_position (GTK_WINDOW (window), &x, &y);
3793 gtk_window_get_size (GTK_WINDOW (window), &width, &height);
3795 if (!ev_window_is_empty (window) && window->priv->page_cache) {
3796 ev_page_cache_get_max_width (window->priv->page_cache,
3799 ev_page_cache_get_max_height (window->priv->page_cache,
3802 ev_metadata_manager_set_int (uri, "window_x", x);
3803 ev_metadata_manager_set_int (uri, "window_y", y);
3804 ev_metadata_manager_set_double (uri, "window_width_ratio",
3805 (double)width/document_width);
3806 ev_metadata_manager_set_double (uri, "window_height_ratio",
3807 (double)height/document_height);
3815 sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
3817 ev_view_handle_link (EV_VIEW (window->priv->view), link);
3821 launch_action (EvWindow *window, EvLinkAction *action)
3823 const char *filename = ev_link_action_get_filename (action);
3826 if (filename && g_path_is_absolute (filename)) {
3827 uri = gnome_vfs_get_uri_from_local_path (filename);
3829 GnomeVFSURI *base_uri, *resolved_uri;
3831 base_uri = gnome_vfs_uri_new (window->priv->uri);
3832 if (base_uri && filename) {
3833 resolved_uri = gnome_vfs_uri_resolve_relative (base_uri, filename);
3835 uri = gnome_vfs_uri_to_string (resolved_uri, GNOME_VFS_URI_HIDE_NONE);
3836 gnome_vfs_uri_unref (resolved_uri);
3838 gnome_vfs_uri_unref (base_uri);
3843 gnome_vfs_url_show (uri);
3845 gnome_vfs_url_show (filename);
3850 /* According to the PDF spec filename can be an executable. I'm not sure
3851 allowing to launch executables is a good idea though. -- marco */
3855 launch_external_uri (EvWindow *window, EvLinkAction *action)
3860 uri = ev_link_action_get_uri (action);
3861 escaped = gnome_vfs_escape_host_and_path_string (uri);
3863 gnome_vfs_url_show (escaped);
3868 open_remote_link (EvWindow *window, EvLinkAction *action)
3873 dir = g_path_get_dirname (window->priv->uri);
3875 uri = g_build_filename (dir, ev_link_action_get_filename (action),
3879 ev_application_open_uri_at_dest (EV_APP, uri,
3880 ev_link_action_get_dest (action),
3888 do_action_named (EvWindow *window, EvLinkAction *action)
3890 const gchar *name = ev_link_action_get_name (action);
3892 if (g_ascii_strcasecmp (name, "FirstPage") == 0) {
3893 ev_window_cmd_go_first_page (NULL, window);
3894 } else if (g_ascii_strcasecmp (name, "PrevPage") == 0) {
3895 ev_window_cmd_go_previous_page (NULL, window);
3896 } else if (g_ascii_strcasecmp (name, "NextPage") == 0) {
3897 ev_window_cmd_go_next_page (NULL, window);
3898 } else if (g_ascii_strcasecmp (name, "LastPage") == 0) {
3899 ev_window_cmd_go_last_page (NULL, window);
3900 } else if (g_ascii_strcasecmp (name, "GoToPage") == 0) {
3901 ev_window_cmd_focus_page_selector (NULL, window);
3902 } else if (g_ascii_strcasecmp (name, "Find") == 0) {
3903 ev_window_cmd_edit_find (NULL, window);
3904 } else if (g_ascii_strcasecmp (name, "Close") == 0) {
3905 ev_window_cmd_file_close_window (NULL, window);
3907 g_warning ("Unimplemented named action: %s, please post a "
3908 "bug report in Evince bugzilla "
3909 "(http://bugzilla.gnome.org) with a testcase.",
3915 view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
3917 switch (ev_link_action_get_action_type (action)) {
3918 case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
3919 launch_external_uri (window, action);
3921 case EV_LINK_ACTION_TYPE_LAUNCH:
3922 launch_action (window, action);
3924 case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
3925 open_remote_link (window, action);
3927 case EV_LINK_ACTION_TYPE_NAMED:
3928 do_action_named (window, action);
3931 g_assert_not_reached ();
3936 ev_view_popup_cmd_open_link (GtkAction *action, EvWindow *window)
3938 ev_view_handle_link (EV_VIEW (window->priv->view), window->priv->link);
3942 ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
3944 GtkClipboard *clipboard;
3945 EvLinkAction *ev_action;
3948 ev_action = ev_link_get_action (window->priv->link);
3952 uri = ev_link_action_get_uri (ev_action);
3954 clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
3955 GDK_SELECTION_CLIPBOARD);
3956 gtk_clipboard_set_text (clipboard, uri, -1);
3960 ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
3964 if (!window->priv->attach_list)
3967 for (l = window->priv->attach_list; l && l->data; l = g_list_next (l)) {
3968 EvAttachment *attachment;
3969 GError *error = NULL;
3971 attachment = (EvAttachment *) l->data;
3973 ev_attachment_open (attachment, &error);
3976 ev_window_error_dialog (GTK_WINDOW (window),
3977 _("Unable to open attachment"),
3979 g_error_free (error);
3985 attachment_save_dialog_response_cb (GtkWidget *fc,
3987 EvWindow *ev_window)
3991 GtkFileChooserAction fc_action;
3994 if (response_id != GTK_RESPONSE_OK) {
3995 gtk_widget_destroy (fc);
3999 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
4001 g_object_get (G_OBJECT (fc), "action", &fc_action, NULL);
4002 is_dir = (fc_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
4004 for (l = ev_window->priv->attach_list; l && l->data; l = g_list_next (l)) {
4005 EvAttachment *attachment;
4007 GError *error = NULL;
4009 attachment = (EvAttachment *) l->data;
4012 filename = g_strjoin ("/", uri,
4013 ev_attachment_get_name (attachment),
4016 filename = g_strdup (uri);
4019 ev_attachment_save (attachment, filename, &error);
4023 ev_window_error_dialog (GTK_WINDOW (fc),
4024 _("The attachment could not be saved."),
4026 g_error_free (error);
4032 gtk_widget_destroy (fc);
4036 ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, EvWindow *window)
4039 EvAttachment *attachment = NULL;
4041 if (!window->priv->attach_list)
4044 if (g_list_length (window->priv->attach_list) == 1)
4045 attachment = (EvAttachment *) window->priv->attach_list->data;
4047 fc = gtk_file_chooser_dialog_new (
4049 GTK_WINDOW (window),
4050 attachment ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
4052 GTK_RESPONSE_CANCEL,
4053 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
4056 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
4057 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE);
4060 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc),
4061 ev_attachment_get_name (attachment));
4063 g_signal_connect (fc, "response",
4064 G_CALLBACK (attachment_save_dialog_response_cb),
4067 gtk_widget_show (fc);
4071 ev_window_init (EvWindow *ev_window)
4073 GtkActionGroup *action_group;
4074 GtkAccelGroup *accel_group;
4075 GError *error = NULL;
4076 GtkWidget *sidebar_widget, *toolbar_dock;
4078 g_signal_connect (ev_window, "configure_event",
4079 G_CALLBACK (window_configure_event_cb), NULL);
4080 g_signal_connect (ev_window, "window_state_event",
4081 G_CALLBACK (window_state_event_cb), NULL);
4082 g_signal_connect (ev_window, "notify",
4083 G_CALLBACK (fullscreen_timeout_cb), NULL);
4085 ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
4087 ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
4088 ev_window->priv->title = ev_window_title_new (ev_window);
4090 ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
4091 gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
4092 gtk_widget_show (ev_window->priv->main_box);
4094 action_group = gtk_action_group_new ("MenuActions");
4095 ev_window->priv->action_group = action_group;
4096 gtk_action_group_set_translation_domain (action_group, NULL);
4097 gtk_action_group_add_actions (action_group, entries,
4098 G_N_ELEMENTS (entries), ev_window);
4099 gtk_action_group_add_toggle_actions (action_group, toggle_entries,
4100 G_N_ELEMENTS (toggle_entries),
4102 set_action_properties (action_group);
4103 register_custom_actions (ev_window, action_group);
4105 ev_window->priv->ui_manager = gtk_ui_manager_new ();
4106 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
4110 gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
4111 gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
4113 ev_window_set_view_accels_sensitivity (ev_window, FALSE);
4115 action_group = gtk_action_group_new ("ViewPopupActions");
4116 ev_window->priv->view_popup_action_group = action_group;
4117 gtk_action_group_set_translation_domain (action_group, NULL);
4118 gtk_action_group_add_actions (action_group, view_popup_entries,
4119 G_N_ELEMENTS (view_popup_entries),
4121 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
4124 action_group = gtk_action_group_new ("AttachmentPopupActions");
4125 ev_window->priv->attachment_popup_action_group = action_group;
4126 gtk_action_group_set_translation_domain (action_group, NULL);
4127 gtk_action_group_add_actions (action_group, attachment_popup_entries,
4128 G_N_ELEMENTS (attachment_popup_entries),
4130 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
4133 if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
4134 DATADIR"/evince-ui.xml",
4136 g_warning ("building menus failed: %s", error->message);
4137 g_error_free (error);
4140 #ifdef HAVE_GTK_RECENT
4141 ev_window->priv->recent_manager = gtk_recent_manager_get_for_screen (
4142 gtk_widget_get_screen (GTK_WIDGET (ev_window)));
4143 ev_window->priv->recent_action_group = NULL;
4144 ev_window->priv->recent_ui_id = 0;
4145 g_signal_connect_swapped (ev_window->priv->recent_manager,
4147 G_CALLBACK (ev_window_setup_recent),
4149 #endif /* HAVE_GTK_RECENT */
4151 ev_window->priv->menubar =
4152 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
4154 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
4155 ev_window->priv->menubar,
4158 /* This sucks, but there is no way to have a draw=no, expand=true separator
4159 * in a GtkUIManager-built toolbar. So, just add another toolbar.
4160 * See gtk+ bug 166489.
4162 toolbar_dock = ev_window->priv->toolbar_dock = gtk_hbox_new (FALSE, 0);
4163 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar_dock,
4165 gtk_widget_show (toolbar_dock);
4167 ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
4168 (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL);
4169 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
4171 gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
4173 gtk_widget_show (ev_window->priv->toolbar);
4175 /* Add the main area */
4176 ev_window->priv->hpaned = gtk_hpaned_new ();
4177 g_signal_connect (ev_window->priv->hpaned,
4179 G_CALLBACK (ev_window_sidebar_position_change_cb),
4182 gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned), SIDEBAR_DEFAULT_SIZE);
4183 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
4185 gtk_widget_show (ev_window->priv->hpaned);
4187 ev_window->priv->sidebar = ev_sidebar_new ();
4188 gtk_paned_pack1 (GTK_PANED (ev_window->priv->hpaned),
4189 ev_window->priv->sidebar, FALSE, FALSE);
4190 gtk_widget_show (ev_window->priv->sidebar);
4192 /* Stub sidebar, for now */
4194 sidebar_widget = ev_sidebar_links_new ();
4195 ev_window->priv->sidebar_links = sidebar_widget;
4196 g_signal_connect (sidebar_widget,
4198 G_CALLBACK (sidebar_widget_model_set),
4200 g_signal_connect (sidebar_widget,
4202 G_CALLBACK (sidebar_links_link_activated_cb),
4204 sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window);
4205 gtk_widget_show (sidebar_widget);
4206 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
4209 sidebar_widget = ev_sidebar_attachments_new ();
4210 ev_window->priv->sidebar_attachments = sidebar_widget;
4211 g_signal_connect_object (sidebar_widget,
4213 G_CALLBACK (attachment_bar_menu_popup_cb),
4215 gtk_widget_show (sidebar_widget);
4216 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
4219 sidebar_widget = ev_sidebar_thumbnails_new ();
4220 ev_window->priv->sidebar_thumbs = sidebar_widget;
4221 g_signal_connect (sidebar_widget,
4222 "notify::main-widget",
4223 G_CALLBACK (sidebar_page_main_widget_update_cb),
4225 sidebar_page_main_widget_update_cb (G_OBJECT (sidebar_widget), NULL, ev_window);
4226 gtk_widget_show (sidebar_widget);
4227 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
4230 ev_window->priv->scrolled_window =
4231 GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
4232 "shadow-type", GTK_SHADOW_IN,
4234 gtk_widget_show (ev_window->priv->scrolled_window);
4236 gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
4237 ev_window->priv->scrolled_window);
4239 ev_window->priv->view = ev_view_new ();
4240 ev_window->priv->password_view = ev_password_view_new ();
4241 g_signal_connect_swapped (ev_window->priv->password_view,
4243 G_CALLBACK (ev_window_popup_password_dialog),
4245 g_signal_connect_object (ev_window->priv->view, "focus_in_event",
4246 G_CALLBACK (view_actions_focus_in_cb),
4248 g_signal_connect_object (ev_window->priv->view, "focus_out_event",
4249 G_CALLBACK (view_actions_focus_out_cb),
4251 g_signal_connect_object (ev_window->priv->view, "external-link",
4252 G_CALLBACK (view_external_link_cb),
4254 g_signal_connect_object (ev_window->priv->view,
4256 G_CALLBACK (view_menu_popup_cb),
4258 gtk_widget_show (ev_window->priv->view);
4259 gtk_widget_show (ev_window->priv->password_view);
4262 ev_window->priv->find_bar = egg_find_bar_new ();
4263 gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
4264 ev_window->priv->find_bar,
4267 /* We own a ref on these widgets, as we can swap them in and out */
4268 g_object_ref (ev_window->priv->view);
4269 g_object_ref (ev_window->priv->password_view);
4271 gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
4272 ev_window->priv->view);
4274 g_signal_connect (ev_window->priv->view,
4275 "notify::find-status",
4276 G_CALLBACK (view_find_status_changed_cb),
4278 g_signal_connect (ev_window->priv->view,
4279 "notify::sizing-mode",
4280 G_CALLBACK (ev_window_sizing_mode_changed_cb),
4282 g_signal_connect (ev_window->priv->view,
4284 G_CALLBACK (ev_window_zoom_changed_cb),
4286 g_signal_connect (ev_window->priv->view,
4287 "notify::dual-page",
4288 G_CALLBACK (ev_window_dual_mode_changed_cb),
4290 g_signal_connect (ev_window->priv->view,
4291 "notify::continuous",
4292 G_CALLBACK (ev_window_continuous_changed_cb),
4294 g_signal_connect (ev_window->priv->view,
4296 G_CALLBACK (ev_window_rotation_changed_cb),
4298 g_signal_connect (ev_window->priv->view,
4299 "notify::has-selection",
4300 G_CALLBACK (ev_window_has_selection_changed_cb),
4303 /* Connect sidebar signals */
4304 g_signal_connect (ev_window->priv->sidebar,
4306 G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
4308 g_signal_connect (ev_window->priv->sidebar,
4309 "notify::current-page",
4310 G_CALLBACK (ev_window_sidebar_current_page_changed_cb),
4313 /* Connect to find bar signals */
4314 g_signal_connect (ev_window->priv->find_bar,
4316 G_CALLBACK (find_bar_previous_cb),
4318 g_signal_connect (ev_window->priv->find_bar,
4320 G_CALLBACK (find_bar_next_cb),
4322 g_signal_connect (ev_window->priv->find_bar,
4324 G_CALLBACK (find_bar_close_cb),
4326 g_signal_connect (ev_window->priv->find_bar,
4327 "notify::search-string",
4328 G_CALLBACK (find_bar_search_changed_cb),
4330 g_signal_connect (ev_window->priv->find_bar,
4331 "notify::case-sensitive",
4332 G_CALLBACK (find_bar_search_changed_cb),
4334 g_signal_connect (ev_window->priv->find_bar,
4336 G_CALLBACK (find_bar_search_changed_cb),
4338 g_signal_connect (ev_window->priv->find_bar,
4340 G_CALLBACK (find_bar_scroll),
4344 ev_window->priv->view_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
4346 ev_window->priv->link = NULL;
4348 ev_window->priv->attachment_popup = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
4349 "/AttachmentPopup");
4350 ev_window->priv->attach_list = NULL;
4352 /* Give focus to the document view */
4353 gtk_widget_grab_focus (ev_window->priv->view);
4356 gtk_drag_dest_unset (GTK_WIDGET (ev_window->priv->view));
4357 gtk_drag_dest_set (GTK_WIDGET (ev_window->priv->view),
4358 GTK_DEST_DEFAULT_ALL,
4360 sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
4362 g_signal_connect_swapped (G_OBJECT (ev_window->priv->view), "drag-data-received",
4363 G_CALLBACK (drag_data_received_cb),
4366 /* Set it user interface params */
4368 ev_window_setup_recent (ev_window);
4370 setup_chrome_from_metadata (ev_window);
4371 set_chrome_actions (ev_window);
4372 update_chrome_visibility (ev_window);
4374 gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600);
4376 setup_view_from_metadata (ev_window);
4377 setup_sidebar_from_metadata (ev_window, NULL);
4379 ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
4380 ev_window_setup_action_sensitivity (ev_window);
4384 ev_window_new (void)
4386 GtkWidget *ev_window;
4388 ev_window = GTK_WIDGET (g_object_new (EV_TYPE_WINDOW,
4389 "type", GTK_WINDOW_TOPLEVEL,