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-page-action.h"
33 #include "ev-sidebar.h"
34 #include "ev-sidebar-links.h"
35 #include "ev-sidebar-thumbnails.h"
37 #include "ev-password.h"
38 #include "ev-password-view.h"
39 #include "ev-print-job.h"
40 #include "ev-document-thumbnails.h"
41 #include "ev-document-links.h"
42 #include "ev-document-types.h"
43 #include "ev-document-find.h"
44 #include "ev-document-security.h"
45 #include "ev-job-queue.h"
46 #include "eggfindbar.h"
47 #include "egg-recent-view-gtk.h"
48 #include "egg-recent-view.h"
49 #include "egg-recent-model.h"
50 #include "egg-toolbar-editor.h"
51 #include "egg-toolbars-model.h"
52 #include "egg-editable-toolbar.h"
53 #include "ephy-zoom.h"
54 #include "ephy-zoom-action.h"
55 #include "ev-application.h"
56 #include "ev-stock-icons.h"
57 #include "ev-file-helpers.h"
60 #include <glib/gi18n.h>
64 #include <libgnomevfs/gnome-vfs-uri.h>
65 #include <libgnomevfs/gnome-vfs-utils.h>
66 #include <libgnomevfs/gnome-vfs-ops.h>
67 #include <libgnomeprintui/gnome-print-dialog.h>
69 #include <gconf/gconf-client.h>
79 EV_CHROME_MENUBAR = 1 << 0,
80 EV_CHROME_TOOLBAR = 1 << 1,
81 EV_CHROME_SIDEBAR = 1 << 2,
82 EV_CHROME_FINDBAR = 1 << 3,
83 EV_CHROME_STATUSBAR = 1 << 4,
84 EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR | EV_CHROME_STATUSBAR
87 struct _EvWindowPrivate {
90 GtkWidget *toolbar_dock;
95 GtkWidget *scrolled_window;
98 GtkWidget *password_view;
100 GtkActionGroup *action_group;
101 GtkUIManager *ui_manager;
104 EggToolbarsModel *toolbar_model;
106 GtkWidget *statusbar;
107 guint help_message_cid;
108 guint view_message_cid;
109 GtkWidget *fullscreen_toolbar;
110 GtkWidget *fullscreen_popup;
113 EvDocument *document;
114 EvPageCache *page_cache;
116 EvWindowPageMode page_mode;
117 /* These members are used temporarily when in PAGE_MODE_PASSWORD */
118 EvDocument *password_document;
119 GtkWidget *password_dialog;
123 GSource *fullscreen_timeout_source;
125 /* recent file stuff */
126 EggRecentModel *recent_model;
127 EggRecentViewGtk *recent_view;
130 static const GtkTargetEntry ev_drop_types[] = {
131 { "text/uri-list", 0, 0 }
135 #define EV_WINDOW_GET_PRIVATE(object) \
136 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
138 #define PAGE_SELECTOR_ACTION "PageSelector"
139 #define ZOOM_CONTROL_ACTION "ViewZoom"
141 #define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
142 #define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
143 #define GCONF_CHROME_STATUSBAR "/apps/evince/show_statusbar"
145 #define GCONF_SIDEBAR_SIZE "/apps/evince/sidebar_size"
147 #define SIDEBAR_DEFAULT_SIZE 132
149 static void ev_window_update_fullscreen_popup (EvWindow *window);
150 static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
152 EvWindow *ev_window);
153 static void ev_window_set_page_mode (EvWindow *window,
154 EvWindowPageMode page_mode);
155 static gboolean start_loading_document (EvWindow *ev_window,
156 EvDocument *document,
158 static void ev_window_sizing_mode_changed_cb (EvView *view,
160 EvWindow *ev_window);
161 static void ev_window_zoom_changed_cb (EvView *view,
163 EvWindow *ev_window);
164 static void ev_window_add_recent (EvWindow *window,
165 const char *filename);
166 static void ev_window_fullscreen (EvWindow *window);
167 static void ev_window_unfullscreen (EvWindow *window);
168 static void ev_window_cmd_view_fullscreen (GtkAction *action,
170 static void ev_window_run_presentation (EvWindow *window);
171 static void ev_window_stop_presentation (EvWindow *window);
172 static void ev_window_cmd_view_presentation (GtkAction *action,
176 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
179 set_action_sensitive (EvWindow *ev_window,
183 GtkAction *action = gtk_action_group_get_action (ev_window->priv->action_group,
185 gtk_action_set_sensitive (action, sensitive);
189 update_action_sensitivity (EvWindow *ev_window)
192 EvDocument *document;
193 EvWindowPageMode page_mode;
194 gboolean sensitive, has_pages = FALSE, has_document;
195 int n_pages = 0, page = -1;
197 view = EV_VIEW (ev_window->priv->view);
198 document = ev_window->priv->document;
199 page_mode = ev_window->priv->page_mode;
200 has_document = document != NULL;
201 if (has_document && ev_window->priv->page_cache) {
202 page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
203 n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
204 has_pages = has_document && n_pages > 0;
208 /* "FileOpen": always sensitive */
209 set_action_sensitive (ev_window, "FileSaveAs", has_document);
210 set_action_sensitive (ev_window, "FilePrint", has_pages);
211 /* "FileCloseWindow": always sensitive */
215 sensitive = has_pages && ev_document_can_get_text (document);
216 set_action_sensitive (ev_window, "EditCopy", sensitive);
217 set_action_sensitive (ev_window, "EditSelectAll", sensitive);
218 set_action_sensitive (ev_window, "EditFind",
219 has_pages && EV_IS_DOCUMENT_FIND (document));
220 set_action_sensitive (ev_window, "Slash",
221 has_pages && EV_IS_DOCUMENT_FIND (document));
222 set_action_sensitive (ev_window, "EditFindNext",
223 ev_view_can_find_next (view));
226 set_action_sensitive (ev_window, "ViewContinuous", has_pages);
227 set_action_sensitive (ev_window, "ViewDual", has_pages);
228 set_action_sensitive (ev_window, "ViewZoomIn",
229 has_pages && ev_view_can_zoom_in (view));
230 set_action_sensitive (ev_window, "ViewZoomOut",
231 has_pages && ev_view_can_zoom_out (view));
232 set_action_sensitive (ev_window, "ViewBestFit", has_pages);
233 set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
234 set_action_sensitive (ev_window, "ViewReload", has_pages);
238 set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
239 set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
240 set_action_sensitive (ev_window, "GoFirstPage", page > 0);
241 set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
243 set_action_sensitive (ev_window, "GoFirstPage", FALSE);
244 set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
245 set_action_sensitive (ev_window, "GoNextPage", FALSE);
246 set_action_sensitive (ev_window, "GoLastPage", FALSE);
249 /* Toolbar-specific actions: */
250 set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
251 set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
253 if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
258 action = gtk_action_group_get_action (ev_window->priv->action_group,
259 ZOOM_CONTROL_ACTION);
261 real_zoom = ev_view_get_zoom (EV_VIEW (ev_window->priv->view));
262 zoom = ephy_zoom_get_nearest_zoom_level (real_zoom);
264 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action), zoom);
269 set_widget_visibility (GtkWidget *widget, gboolean visible)
271 g_return_if_fail (GTK_IS_WIDGET (widget));
274 gtk_widget_show (widget);
276 gtk_widget_hide (widget);
280 update_chrome_visibility (EvWindow *window)
282 EvWindowPrivate *priv = window->priv;
283 gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
284 gboolean fullscreen_mode, presentation, fullscreen;
286 presentation = ev_view_get_presentation (EV_VIEW (priv->view));
287 fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
288 fullscreen_mode = fullscreen || presentation;
290 menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
291 toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode;
292 sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
293 fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
294 statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
295 findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
297 set_widget_visibility (priv->menubar, menubar);
299 set_widget_visibility (priv->toolbar_dock, toolbar);
300 set_action_sensitive (window, "EditToolbar", toolbar);
302 set_widget_visibility (priv->sidebar, sidebar);
303 set_widget_visibility (priv->find_bar, findbar);
304 set_widget_visibility (priv->statusbar, statusbar);
305 set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
307 if (priv->fullscreen_popup != NULL) {
308 set_widget_visibility (priv->fullscreen_popup, fullscreen);
313 update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
315 EvWindowPrivate *priv = window->priv;
319 priv->chrome |= flag;
322 priv->chrome &= ~flag;
326 client = gconf_client_get_default ();
327 gconf_client_set_bool (client, pref, active, NULL);
328 g_object_unref (client);
331 update_chrome_visibility (window);
335 ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
339 action = gtk_action_group_get_action (window->priv->action_group,
340 PAGE_SELECTOR_ACTION);
341 ev_page_action_grab_focus (EV_PAGE_ACTION (action));
345 ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
347 ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD);
351 ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
353 ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD);
357 ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
361 ev_window_stop_presentation (ev_window);
362 continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
363 g_object_set (G_OBJECT (ev_window->priv->view),
364 "continuous", continuous,
366 update_action_sensitivity (ev_window);
370 ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
374 ev_window_stop_presentation (ev_window);
375 dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
376 g_object_set (G_OBJECT (ev_window->priv->view),
377 "dual-page", dual_page,
379 update_action_sensitivity (ev_window);
383 ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
385 ev_window_stop_presentation (ev_window);
387 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
388 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
390 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
392 update_action_sensitivity (ev_window);
396 ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
398 ev_window_stop_presentation (ev_window);
400 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
401 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
403 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
405 update_action_sensitivity (ev_window);
409 update_sizing_buttons (EvWindow *window)
411 GtkActionGroup *action_group = window->priv->action_group;
413 gboolean best_fit, page_width;
414 EvSizingMode sizing_mode;
416 if (window->priv->view == NULL)
419 g_object_get (window->priv->view,
420 "sizing_mode", &sizing_mode,
423 switch (sizing_mode) {
424 case EV_SIZING_BEST_FIT:
428 case EV_SIZING_FIT_WIDTH:
434 best_fit = page_width = FALSE;
438 action = gtk_action_group_get_action (action_group, "ViewBestFit");
439 g_signal_handlers_block_by_func
440 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
441 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), best_fit);
442 g_signal_handlers_unblock_by_func
443 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
445 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
446 g_signal_handlers_block_by_func
447 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
449 g_signal_handlers_unblock_by_func
450 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
452 action = gtk_action_group_get_action (window->priv->action_group,
453 ZOOM_CONTROL_ACTION);
455 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
457 } else if (page_width) {
458 ephy_zoom_action_set_zoom_level (EPHY_ZOOM_ACTION (action),
459 EPHY_ZOOM_FIT_WIDTH);
464 ev_window_open_page_label (EvWindow *ev_window,
467 if (ev_window->priv->page_cache) {
468 ev_page_cache_set_page_label (ev_window->priv->page_cache,
474 ev_window_is_empty (const EvWindow *ev_window)
476 g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
478 return ev_window->priv->document == NULL;
482 unable_to_load (EvWindow *ev_window,
483 const char *error_message)
487 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
488 GTK_DIALOG_DESTROY_WITH_PARENT,
491 _("Unable to open document"));
492 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
493 "%s", error_message);
494 gtk_dialog_run (GTK_DIALOG (dialog));
495 gtk_widget_destroy (dialog);
499 update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_window)
502 char *doc_title = NULL;
503 gboolean password_needed;
505 password_needed = (ev_window->priv->password_document != NULL);
506 if (document && ev_window->priv->page_cache) {
507 doc_title = ev_page_cache_get_title (ev_window->priv->page_cache);
509 /* Make sure we get a valid title back */
511 if (doc_title[0] == '\000' ||
512 !g_utf8_validate (doc_title, -1, NULL)) {
522 for (p = doc_title; *p; ++p) {
523 /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
529 if (doc_title == NULL && ev_window->priv->uri) {
532 basename = g_path_get_basename (ev_window->priv->uri);
533 doc_title = gnome_vfs_unescape_string_for_display (basename);
537 if (password_needed) {
538 if (doc_title == NULL) {
539 title = g_strdup (_("Document Viewer - Password Required"));
541 title = g_strdup_printf (_("%s - Password Required"), doc_title);
544 if (doc_title == NULL) {
545 title = g_strdup (_("Document Viewer"));
547 title = g_strdup (doc_title);
551 gtk_window_set_title (GTK_WINDOW (ev_window), title);
558 find_changed_cb (EvDocument *document, int page, EvWindow *ev_window)
560 update_action_sensitivity (ev_window);
564 page_changed_cb (EvPageCache *page_cache,
568 update_action_sensitivity (ev_window);
572 update_document_mode (EvWindow *window, EvDocumentMode mode)
574 if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
575 ev_window_fullscreen (window);
576 } else if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
577 ev_window_run_presentation (window);
582 ev_window_setup_document (EvWindow *ev_window)
584 EvDocumentInfo *info;
585 EvDocument *document;
586 EvView *view = EV_VIEW (ev_window->priv->view);
587 EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
590 document = ev_window->priv->document;
591 ev_window->priv->page_cache = ev_document_get_page_cache (ev_window->priv->document);
592 g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
594 g_signal_connect_object (G_OBJECT (document),
596 G_CALLBACK (update_window_title),
598 if (EV_IS_DOCUMENT_FIND (document)) {
599 g_signal_connect_object (G_OBJECT (document),
601 G_CALLBACK (find_changed_cb),
605 ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
607 ev_sidebar_set_document (sidebar, document);
609 if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
610 ev_view_set_document (view, document);
613 update_window_title (document, NULL, ev_window);
614 action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
615 ev_page_action_set_document (EV_PAGE_ACTION (action), document);
616 update_action_sensitivity (ev_window);
618 info = ev_document_get_info (document);
619 update_document_mode (ev_window, info->mode);
620 ev_document_info_free (info);
624 password_dialog_response (GtkWidget *password_dialog,
630 if (response_id == GTK_RESPONSE_OK) {
631 EvDocument *document;
634 password = ev_password_dialog_get_password (password_dialog);
636 ev_document_doc_mutex_lock ();
637 ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
639 ev_document_doc_mutex_unlock ();
643 document = ev_window->priv->password_document;
644 uri = ev_window->priv->password_uri;
646 ev_window->priv->password_document = NULL;
647 ev_window->priv->password_uri = NULL;
649 if (start_loading_document (ev_window, document, uri)) {
650 gtk_widget_destroy (password_dialog);
653 g_object_unref (document);
659 gtk_widget_set_sensitive (ev_window->priv->password_view, TRUE);
660 gtk_widget_destroy (password_dialog);
663 /* Called either by start_loading_document or by the "unlock" callback on the
664 * password_view page. It assumes that ev_window->priv->password_* has been set
665 * correctly. These are cleared by password_dialog_response() */
668 ev_window_popup_password_dialog (EvWindow *ev_window)
670 g_assert (ev_window->priv->password_document);
671 g_assert (ev_window->priv->password_uri);
673 gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
675 update_window_title (ev_window->priv->password_document, NULL, ev_window);
676 if (ev_window->priv->password_dialog == NULL) {
677 gchar *basename, *file_name;
679 basename = g_path_get_basename (ev_window->priv->password_uri);
680 file_name = gnome_vfs_unescape_string_for_display (basename);
681 ev_window->priv->password_dialog =
682 ev_password_dialog_new (GTK_WIDGET (ev_window), file_name);
683 g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
684 (gpointer *) &(ev_window->priv->password_dialog));
685 g_signal_connect (ev_window->priv->password_dialog,
687 G_CALLBACK (password_dialog_response),
691 gtk_widget_show (ev_window->priv->password_dialog);
693 ev_password_dialog_set_bad_pass (ev_window->priv->password_dialog);
697 /* This wil try to load the document. It might be called multiple times on the
698 * same document by the password dialog.
700 * Since the flow of the error dialog is very confusing, we assume that both
701 * document and uri will go away after this function is called, and thus we need
702 * to ref/dup them. Additionally, it needs to clear
703 * ev_window->priv->password_{uri,document}, and thus people who call this
704 * function should _not_ necessarily expect those to exist after being
707 start_loading_document (EvWindow *ev_window,
708 EvDocument *document,
712 GError *error = NULL;
715 g_assert (document != ev_window->priv->document);
717 if (ev_window->priv->password_document) {
718 g_object_unref (ev_window->priv->password_document);
719 ev_window->priv->password_document = NULL;
721 if (ev_window->priv->password_uri) {
722 g_free (ev_window->priv->password_uri);
723 ev_window->priv->password_uri = NULL;
726 result = ev_document_load (document, uri, &error);
730 if (ev_window->priv->document)
731 g_object_unref (ev_window->priv->document);
732 ev_window->priv->document = g_object_ref (document);
733 ev_window_setup_document (ev_window);
735 ev_window_add_recent (ev_window, uri);
740 /* unable to load the document */
741 g_assert (error != NULL);
743 if (error->domain == EV_DOCUMENT_ERROR &&
744 error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
745 gchar *base_name, *file_name;
747 ev_window->priv->password_document = g_object_ref (document);
748 ev_window->priv->password_uri = g_strdup (uri);
750 base_name = g_path_get_basename (uri);
751 file_name = gnome_vfs_unescape_string_for_display (base_name);
753 ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
757 ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
759 ev_window_popup_password_dialog (ev_window);
761 unable_to_load (ev_window, error->message);
763 g_error_free (error);
769 sanity_check_uri (EvWindow *window, const char *uri)
771 gboolean result = FALSE;
772 GnomeVFSURI *vfs_uri;
775 vfs_uri = gnome_vfs_uri_new (uri);
777 if (gnome_vfs_uri_exists (vfs_uri)) {
783 err = g_strdup_printf (_("The file %s does not exist."), uri);
784 unable_to_load (window, err);
792 ev_window_open (EvWindow *ev_window, const char *uri)
794 EvDocument *document = NULL;
796 char *mime_type = NULL;
798 if (!sanity_check_uri (ev_window, uri)) {
802 g_free (ev_window->priv->uri);
803 ev_window->priv->uri = g_strdup (uri);
805 document_type = ev_document_type_lookup (uri, &mime_type);
806 if (document_type != G_TYPE_INVALID) {
807 document = g_object_new (document_type, NULL);
811 start_loading_document (ev_window, document, uri);
812 /* See the comment on start_loading_document on ref counting.
813 * As the password dialog flow is confusing, we're very explicit
814 * on ref counting. */
815 g_object_unref (document);
819 error_message = g_strdup_printf (_("Unhandled MIME type: '%s'"),
820 mime_type?mime_type:"<Unknown MIME Type>");
821 unable_to_load (ev_window, error_message);
822 g_free (error_message);
829 ev_window_open_uri_list (EvWindow *ev_window, GList *uri_list)
834 g_return_if_fail (uri_list != NULL);
838 uri = gnome_vfs_uri_to_string (list->data, GNOME_VFS_URI_HIDE_NONE);
840 if (ev_document_type_lookup (uri, NULL) != G_TYPE_INVALID) {
841 if (ev_window_is_empty (EV_WINDOW (ev_window))) {
842 ev_window_open (ev_window, uri);
844 gtk_widget_show (GTK_WIDGET (ev_window));
846 EvWindow *new_window;
848 new_window = ev_application_new_window (EV_APP);
849 ev_window_open (new_window, uri);
851 gtk_widget_show (GTK_WIDGET (new_window));
857 list = g_list_next (list);
862 ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
864 ev_application_open (EV_APP, NULL);
868 ev_window_cmd_recent_file_activate (EggRecentViewGtk *view, EggRecentItem *item,
874 uri = egg_recent_item_get_uri (item);
876 window = GTK_WIDGET (ev_application_get_empty_window (EV_APP));
877 gtk_widget_show (window);
878 ev_window_open (EV_WINDOW (window), uri);
884 ev_window_add_recent (EvWindow *window, const char *filename)
888 if (strstr (filename, "file:///") == NULL)
891 item = egg_recent_item_new_from_uri (filename);
892 egg_recent_item_add_group (item, "Evince");
893 egg_recent_model_add_full (window->priv->recent_model, item);
897 ev_window_setup_recent (EvWindow *ev_window)
899 GtkWidget *menu_item;
902 menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu");
903 menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
904 menu_item = gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/MainMenu/FileMenu/RecentFilesMenu");
906 g_return_if_fail (menu != NULL);
907 g_return_if_fail (menu_item != NULL);
909 /* it would be better if we just filtered by mime-type, but there
910 * doesn't seem to be an easy way to figure out which mime-types we
912 ev_window->priv->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
914 ev_window->priv->recent_view = egg_recent_view_gtk_new (menu, menu_item);
915 egg_recent_view_gtk_show_icons (EGG_RECENT_VIEW_GTK (ev_window->priv->recent_view), FALSE);
916 egg_recent_model_set_limit (ev_window->priv->recent_model, 5);
918 egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
919 ev_window->priv->recent_model);
921 egg_recent_model_set_filter_groups (ev_window->priv->recent_model,
924 egg_recent_view_gtk_set_trailing_sep (ev_window->priv->recent_view, TRUE);
926 g_signal_connect (ev_window->priv->recent_view, "activate",
927 G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
932 overwrite_existing_file (GtkWindow *window, const gchar *file_name)
935 gchar *utf8_file_name;
939 utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
940 msgbox = gtk_message_dialog_new (
942 (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
943 GTK_MESSAGE_QUESTION,
945 _("A file named \"%s\" already exists."),
947 g_free (utf8_file_name);
949 gtk_message_dialog_format_secondary_text (
950 GTK_MESSAGE_DIALOG (msgbox),
951 _("Do you want to replace it with the one you are saving?"));
953 gtk_dialog_add_button (GTK_DIALOG (msgbox),
954 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
956 gtk_dialog_add_button (GTK_DIALOG (msgbox),
957 _("_Replace"), GTK_RESPONSE_YES);
959 gtk_dialog_set_default_response (GTK_DIALOG (msgbox),
960 GTK_RESPONSE_CANCEL);
962 obj = gtk_widget_get_accessible (msgbox);
964 if (GTK_IS_ACCESSIBLE (obj))
965 atk_object_set_name (obj, _("Question"));
967 ret = gtk_dialog_run (GTK_DIALOG (msgbox));
968 gtk_widget_destroy (msgbox);
970 return (ret == GTK_RESPONSE_YES);
975 save_error_dialog (GtkWindow *window, const gchar *file_name)
977 GtkWidget *error_dialog;
979 error_dialog = gtk_message_dialog_new (
981 (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
984 _("The file could not be saved as \"%s\"."),
987 /* Easy way to make the text bold while keeping the string
988 * above free from pango markup (FIXME ?) */
989 gtk_message_dialog_format_secondary_text (
990 GTK_MESSAGE_DIALOG (error_dialog), " ");
992 gtk_dialog_run (GTK_DIALOG (error_dialog));
993 gtk_widget_destroy (error_dialog);
997 ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
1000 GtkFileFilter *pdf_filter, *all_filter;
1004 fc = gtk_file_chooser_dialog_new (
1006 NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
1007 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1008 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
1010 gtk_window_set_modal (GTK_WINDOW (fc), TRUE);
1012 pdf_filter = gtk_file_filter_new ();
1013 gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
1014 gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
1015 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
1017 all_filter = gtk_file_filter_new ();
1018 gtk_file_filter_set_name (all_filter, _("All Files"));
1019 gtk_file_filter_add_pattern (all_filter, "*");
1020 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), all_filter);
1021 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
1023 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
1025 gtk_widget_show (fc);
1027 while (gtk_dialog_run (GTK_DIALOG (fc)) == GTK_RESPONSE_OK) {
1028 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
1031 if (g_file_test (uri, G_FILE_TEST_EXISTS) &&
1032 !overwrite_existing_file (GTK_WINDOW (fc), uri))
1036 ev_document_doc_mutex_lock ();
1037 success = ev_document_save (ev_window->priv->document, uri, NULL);
1038 ev_document_doc_mutex_unlock ();
1043 save_error_dialog (GTK_WINDOW (fc), uri);
1045 gtk_widget_destroy (fc);
1049 using_postscript_printer (GnomePrintConfig *config)
1051 const guchar *driver;
1052 const guchar *transport;
1054 driver = gnome_print_config_get (
1055 config, (const guchar *)"Settings.Engine.Backend.Driver");
1057 transport = gnome_print_config_get (
1058 config, (const guchar *)"Settings.Transport.Backend");
1061 if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
1065 } else if (transport) {
1066 if (!strcmp ((const gchar *)transport, "CUPS"))
1068 else if (!strcmp ((const gchar *)transport, "LPD"))
1076 ev_window_print (EvWindow *window)
1078 EvPageCache *page_cache;
1081 page_cache = ev_document_get_page_cache (window->priv->document);
1082 last_page = ev_page_cache_get_n_pages (page_cache);
1084 ev_window_print_range (window, 1, -1);
1088 ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
1090 GnomePrintConfig *config;
1092 GtkWidget *print_dialog;
1094 EvPrintJob *print_job = NULL;
1095 EvPageCache *page_cache;
1097 g_return_if_fail (EV_IS_WINDOW (ev_window));
1098 g_return_if_fail (ev_window->priv->document != NULL);
1100 page_cache = ev_document_get_page_cache (ev_window->priv->document);
1101 if (last_page == -1) {
1102 last_page = ev_page_cache_get_n_pages (page_cache);
1105 config = gnome_print_config_default ();
1106 job = gnome_print_job_new (config);
1108 print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
1109 (GNOME_PRINT_DIALOG_RANGE |
1110 GNOME_PRINT_DIALOG_COPIES));
1112 pages_label = g_strconcat (_("Pages"), " ", NULL);
1113 gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (print_dialog),
1114 GNOME_PRINT_RANGE_ALL |
1115 GNOME_PRINT_RANGE_RANGE,
1116 first_page, last_page,
1117 NULL, (const guchar *)pages_label);
1118 g_free (pages_label);
1120 gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
1121 GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
1126 response = gtk_dialog_run (GTK_DIALOG (print_dialog));
1128 if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
1131 /* FIXME: Change this when we have the first backend
1132 * that can print more than postscript
1134 if (!using_postscript_printer (config)) {
1137 dialog = gtk_message_dialog_new (
1138 GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
1139 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1140 _("Printing is not supported on this printer."));
1141 gtk_message_dialog_format_secondary_text (
1142 GTK_MESSAGE_DIALOG (dialog),
1143 _("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
1144 gnome_print_config_get (
1145 config, (guchar *)"Settings.Engine.Backend.Driver"));
1146 gtk_dialog_run (GTK_DIALOG (dialog));
1147 gtk_widget_destroy (dialog);
1152 print_job = g_object_new (EV_TYPE_PRINT_JOB,
1153 "gnome_print_job", job,
1154 "document", ev_window->priv->document,
1155 "print_dialog", print_dialog,
1160 gtk_widget_destroy (print_dialog);
1162 if (print_job != NULL) {
1163 ev_print_job_print (print_job, GTK_WINDOW (ev_window));
1164 g_object_unref (print_job);
1169 ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
1171 ev_window_print (ev_window);
1175 ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
1177 g_return_if_fail (EV_IS_WINDOW (ev_window));
1179 gtk_widget_destroy (GTK_WIDGET (ev_window));
1183 find_not_supported_dialog (EvWindow *ev_window)
1187 /* If you change this so it isn't modal, be sure you don't
1188 * allow multiple copies of the dialog...
1191 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
1192 GTK_DIALOG_DESTROY_WITH_PARENT,
1195 _("The \"Find\" feature will not work with this document"));
1196 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
1197 _("Searching for text is only supported for PDF documents."));
1198 gtk_dialog_run (GTK_DIALOG (dialog));
1199 gtk_widget_destroy (dialog);
1203 ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
1205 g_return_if_fail (EV_IS_WINDOW (ev_window));
1207 ev_view_select_all (EV_VIEW (ev_window->priv->view));
1211 ev_window_cmd_edit_find (GtkAction *action, EvWindow *ev_window)
1213 g_return_if_fail (EV_IS_WINDOW (ev_window));
1215 if (ev_window->priv->document == NULL) {
1216 g_printerr ("We should have set the Find menu item insensitive since there's no document\n");
1217 } else if (!EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
1218 find_not_supported_dialog (ev_window);
1220 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
1222 gtk_widget_grab_focus (ev_window->priv->find_bar);
1227 ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window)
1229 g_return_if_fail (EV_IS_WINDOW (ev_window));
1231 ev_view_find_next (EV_VIEW (ev_window->priv->view));
1235 ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
1237 g_return_if_fail (EV_IS_WINDOW (ev_window));
1239 ev_view_copy (EV_VIEW (ev_window->priv->view));
1243 ev_window_update_fullscreen_popup (EvWindow *window)
1245 GtkWidget *popup = window->priv->fullscreen_popup;
1246 int popup_width, popup_height;
1247 GdkRectangle screen_rect;
1250 g_return_if_fail (popup != NULL);
1252 toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0;
1253 popup_width = popup->requisition.width;
1254 popup_height = popup->requisition.height;
1256 /* FIXME multihead */
1257 gdk_screen_get_monitor_geometry (gdk_screen_get_default (),
1258 gdk_screen_get_monitor_at_window
1259 (gdk_screen_get_default (),
1260 GTK_WIDGET (window)->window),
1263 gtk_widget_set_size_request (popup,
1266 gtk_window_move (GTK_WINDOW (popup),
1271 if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL)
1273 gtk_window_move (GTK_WINDOW (popup),
1277 gtk_window_move (GTK_WINDOW (popup),
1278 screen_rect.x + screen_rect.width - popup_width,
1285 screen_size_changed_cb (GdkScreen *screen,
1288 ev_window_update_fullscreen_popup (window);
1292 ev_window_sidebar_position_change_cb (GObject *object, GParamSpec *pspec,
1293 EvWindow *ev_window)
1295 GConfClient *client;
1298 sidebar_size = gtk_paned_get_position (GTK_PANED (object));
1300 client = gconf_client_get_default ();
1301 gconf_client_set_int (client, GCONF_SIDEBAR_SIZE, sidebar_size, NULL);
1302 g_object_unref (client);
1306 destroy_fullscreen_popup (EvWindow *window)
1308 if (window->priv->fullscreen_popup != NULL)
1310 gtk_widget_destroy (window->priv->fullscreen_popup);
1311 window->priv->fullscreen_popup = NULL;
1316 exit_fullscreen_button_clicked_cb (GtkWidget *button, EvWindow *window)
1320 action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
1321 g_return_if_fail (action != NULL);
1323 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
1327 fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindow *window)
1329 ev_window_update_fullscreen_popup (window);
1333 fullscreen_timeout_cb (gpointer data)
1335 EvWindow *window = EV_WINDOW (data);
1337 g_object_set (window->priv->fullscreen_popup, "visible", FALSE, NULL);
1338 ev_view_hide_cursor (EV_VIEW (window->priv->view));
1339 window->priv->fullscreen_timeout_source = NULL;
1345 fullscreen_set_timeout (EvWindow *window)
1349 if (window->priv->fullscreen_timeout_source != NULL)
1350 g_source_destroy (window->priv->fullscreen_timeout_source);
1352 source = g_timeout_source_new (1000);
1353 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
1354 g_source_attach (source, NULL);
1355 window->priv->fullscreen_timeout_source = source;
1359 fullscreen_clear_timeout (EvWindow *window)
1361 if (window->priv->fullscreen_timeout_source != NULL)
1362 g_source_destroy (window->priv->fullscreen_timeout_source);
1364 window->priv->fullscreen_timeout_source = NULL;
1365 ev_view_show_cursor (EV_VIEW (window->priv->view));
1369 fullscreen_motion_notify_cb (GtkWidget *widget,
1370 GdkEventMotion *event,
1373 EvWindow *window = EV_WINDOW (user_data);
1375 if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
1376 g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
1377 ev_view_show_cursor (EV_VIEW (window->priv->view));
1380 fullscreen_set_timeout (window);
1386 fullscreen_leave_notify_cb (GtkWidget *widget,
1387 GdkEventCrossing *event,
1390 EvWindow *window = EV_WINDOW (user_data);
1392 fullscreen_clear_timeout (window);
1398 ev_window_get_exit_fullscreen_button (EvWindow *window)
1400 GtkWidget *button, *icon, *label, *hbox;
1402 button = gtk_button_new ();
1403 g_signal_connect (button, "clicked",
1404 G_CALLBACK (exit_fullscreen_button_clicked_cb),
1406 gtk_widget_show (button);
1408 hbox = gtk_hbox_new (FALSE, 2);
1409 gtk_widget_show (hbox);
1410 gtk_container_add (GTK_CONTAINER (button), hbox);
1412 icon = gtk_image_new_from_stock (EV_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_BUTTON);
1413 gtk_widget_show (icon);
1414 gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
1416 label = gtk_label_new (_("Leave Fullscreen"));
1417 gtk_widget_show (label);
1418 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1424 ev_window_create_fullscreen_popup (EvWindow *window)
1430 popup = gtk_window_new (GTK_WINDOW_POPUP);
1431 hbox = gtk_hbox_new (FALSE, 0);
1432 button = ev_window_get_exit_fullscreen_button (window);
1434 gtk_container_add (GTK_CONTAINER (popup), hbox);
1435 gtk_box_pack_start (GTK_BOX (hbox), window->priv->fullscreen_toolbar,
1437 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
1439 gtk_widget_show (button);
1440 gtk_widget_show (hbox);
1442 gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
1444 /* FIXME multihead */
1445 g_signal_connect_object (gdk_screen_get_default (), "size-changed",
1446 G_CALLBACK (screen_size_changed_cb),
1448 g_signal_connect_object (popup, "size_request",
1449 G_CALLBACK (fullscreen_popup_size_request_cb),
1457 ev_window_update_fullscreen_action (EvWindow *window)
1461 action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
1462 g_signal_handlers_block_by_func
1463 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
1464 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
1465 ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
1466 g_signal_handlers_unblock_by_func
1467 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
1471 ev_window_fullscreen (EvWindow *window)
1473 ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
1474 if (window->priv->fullscreen_popup == NULL)
1475 window->priv->fullscreen_popup
1476 = ev_window_create_fullscreen_popup (window);
1477 update_chrome_visibility (window);
1479 g_object_set (G_OBJECT (window->priv->scrolled_window),
1480 "shadow-type", GTK_SHADOW_NONE,
1483 g_signal_connect (window->priv->view,
1484 "motion-notify-event",
1485 G_CALLBACK (fullscreen_motion_notify_cb),
1487 g_signal_connect (window->priv->view,
1488 "leave-notify-event",
1489 G_CALLBACK (fullscreen_leave_notify_cb),
1491 fullscreen_set_timeout (window);
1493 gtk_widget_grab_focus (window->priv->view);
1494 ev_window_update_fullscreen_action (window);
1495 gtk_window_fullscreen (GTK_WINDOW (window));
1496 ev_window_update_fullscreen_popup (window);
1500 ev_window_unfullscreen (EvWindow *window)
1502 EvView *view = EV_VIEW (window->priv->view);
1504 ev_view_set_fullscreen (view, FALSE);
1505 g_object_set (G_OBJECT (window->priv->scrolled_window),
1506 "shadow-type", GTK_SHADOW_IN,
1509 fullscreen_clear_timeout (window);
1511 g_signal_handlers_disconnect_by_func (view,
1512 (gpointer) fullscreen_motion_notify_cb,
1514 g_signal_handlers_disconnect_by_func (view,
1515 (gpointer) fullscreen_leave_notify_cb,
1517 ev_window_update_fullscreen_action (window);
1518 gtk_window_unfullscreen (GTK_WINDOW (window));
1519 update_chrome_visibility (window);
1523 ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
1525 gboolean fullscreen;
1527 g_return_if_fail (EV_IS_WINDOW (window));
1528 ev_window_stop_presentation (window);
1530 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
1532 ev_window_fullscreen (window);
1534 ev_window_unfullscreen (window);
1539 ev_window_update_presentation_action (EvWindow *window)
1543 action = gtk_action_group_get_action (window->priv->action_group, "ViewPresentation");
1544 g_signal_handlers_block_by_func
1545 (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
1546 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
1547 ev_view_get_presentation (EV_VIEW (window->priv->view)));
1548 g_signal_handlers_unblock_by_func
1549 (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
1553 ev_window_run_presentation (EvWindow *window)
1555 g_object_set (G_OBJECT (window->priv->scrolled_window),
1556 "shadow-type", GTK_SHADOW_NONE,
1559 gtk_widget_grab_focus (window->priv->view);
1560 ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
1561 gtk_window_fullscreen (GTK_WINDOW (window));
1562 ev_window_update_presentation_action (window);
1563 update_chrome_visibility (window);
1567 ev_window_stop_presentation (EvWindow *window)
1569 if (! ev_view_get_presentation (EV_VIEW (window->priv->view)))
1572 g_object_set (G_OBJECT (window->priv->scrolled_window),
1573 "shadow-type", GTK_SHADOW_IN,
1575 ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
1576 gtk_window_unfullscreen (GTK_WINDOW (window));
1577 ev_window_update_presentation_action (window);
1578 update_chrome_visibility (window);
1582 ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
1584 gboolean presentation;
1586 g_return_if_fail (EV_IS_WINDOW (window));
1588 presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
1590 ev_window_run_presentation (window);
1592 ev_window_stop_presentation (window);
1597 ev_window_state_event (GtkWidget *widget, GdkEventWindowState *event)
1599 EvWindow *window = EV_WINDOW (widget);
1601 if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
1604 show = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) == 0;
1606 gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar),
1614 ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
1616 EvWindow *window = EV_WINDOW (widget);
1617 EvWindowPrivate *priv = window->priv;
1618 gboolean fullscreen;
1620 g_object_get (priv->view,
1621 "fullscreen", &fullscreen,
1625 gtk_widget_show (priv->fullscreen_popup);
1627 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
1631 ev_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
1633 EvWindow *window = EV_WINDOW (widget);
1634 EvWindowPrivate *priv = window->priv;
1635 gboolean fullscreen;
1637 g_object_get (priv->view,
1638 "fullscreen", &fullscreen,
1642 gtk_widget_hide (priv->fullscreen_popup);
1644 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
1648 ev_window_set_page_mode (EvWindow *window,
1649 EvWindowPageMode page_mode)
1651 GtkWidget *child = NULL;
1652 GtkWidget *real_child;
1654 if (window->priv->page_mode == page_mode)
1657 window->priv->page_mode = page_mode;
1659 switch (page_mode) {
1660 case PAGE_MODE_DOCUMENT:
1661 child = window->priv->view;
1663 case PAGE_MODE_PASSWORD:
1664 child = window->priv->password_view;
1667 g_assert_not_reached ();
1670 real_child = gtk_bin_get_child (GTK_BIN (window->priv->scrolled_window));
1671 if (child != real_child) {
1672 gtk_container_remove (GTK_CONTAINER (window->priv->scrolled_window),
1674 gtk_container_add (GTK_CONTAINER (window->priv->scrolled_window),
1677 update_action_sensitivity (window);
1681 ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
1683 EvWindow *ev_window = EV_WINDOW (data);
1684 egg_editable_toolbar_set_edit_mode
1685 (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
1686 egg_toolbars_model_save (ev_window->priv->toolbar_model,
1687 ev_window->priv->toolbar_file, "1.0");
1688 gtk_widget_destroy (GTK_WIDGET (dialog));
1692 ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
1696 g_return_if_fail (EV_IS_WINDOW (ev_window));
1698 dialog = gtk_dialog_new_with_buttons (_("Toolbar editor"), GTK_WINDOW (ev_window),
1699 GTK_DIALOG_DESTROY_WITH_PARENT,
1701 GTK_RESPONSE_CANCEL,
1703 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
1704 gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
1706 editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
1707 ev_window->priv->toolbar_model);
1708 gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
1709 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
1711 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
1712 egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
1713 DATADIR"/evince-toolbar.xml");
1715 egg_editable_toolbar_set_edit_mode
1716 (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE);
1718 gtk_widget_show_all (dialog);
1720 g_signal_connect (G_OBJECT (dialog), "response",
1721 G_CALLBACK (ev_window_cmd_edit_toolbar_cb),
1726 ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
1728 g_return_if_fail (EV_IS_WINDOW (ev_window));
1730 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
1731 ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
1735 ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
1737 g_return_if_fail (EV_IS_WINDOW (ev_window));
1739 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
1740 ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
1744 ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
1746 g_return_if_fail (EV_IS_WINDOW (ev_window));
1748 ev_page_cache_prev_page (ev_window->priv->page_cache);
1752 ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
1754 g_return_if_fail (EV_IS_WINDOW (ev_window));
1756 ev_page_cache_next_page (ev_window->priv->page_cache);
1760 ev_window_cmd_go_first_page (GtkAction *action, EvWindow *ev_window)
1762 g_return_if_fail (EV_IS_WINDOW (ev_window));
1764 ev_page_cache_set_current_page (ev_window->priv->page_cache, 0);
1768 ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
1772 g_return_if_fail (EV_IS_WINDOW (ev_window));
1774 n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
1775 ev_page_cache_set_current_page (ev_window->priv->page_cache, n_pages - 1);
1779 ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window)
1784 g_return_if_fail (EV_IS_WINDOW (ev_window));
1786 page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
1787 uri = g_strdup (ev_window->priv->uri);
1789 ev_window_open (ev_window, uri);
1791 /* In case the number of pages in the document has changed. */
1792 page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache));
1794 ev_page_cache_set_current_page (ev_window->priv->page_cache, page);
1800 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
1802 GError *error = NULL;
1804 g_return_if_fail (EV_IS_WINDOW (ev_window));
1806 gnome_help_display ("evince.xml", NULL, &error);
1809 g_warning (error->message);
1810 g_error_free (error);
1815 ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
1817 gtk_window_unfullscreen (GTK_WINDOW (window));
1821 ev_window_cmd_escape (GtkAction *action, EvWindow *window)
1825 widget = gtk_window_get_focus (GTK_WINDOW (window));
1826 if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
1827 update_chrome_flag (window, EV_CHROME_FINDBAR, NULL, FALSE);
1829 gboolean fullscreen;
1830 gboolean presentation;
1832 g_object_get (window->priv->view,
1833 "fullscreen", &fullscreen,
1834 "presentation", &presentation,
1838 ev_window_unfullscreen (window);
1840 ev_window_stop_presentation (window);
1842 if (fullscreen && presentation)
1843 g_warning ("Both fullscreen and presentation set somehow");
1848 update_view_size (EvView *view, EvWindow *window)
1851 GtkRequisition vsb_requisition;
1852 GtkRequisition hsb_requisition;
1853 int scrollbar_spacing;
1855 /* Calculate the width available for the */
1856 width = window->priv->scrolled_window->allocation.width;
1857 height = window->priv->scrolled_window->allocation.height;
1859 if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)) == GTK_SHADOW_IN) {
1860 width -= 2 * window->priv->view->style->xthickness;
1861 height -= 2 * window->priv->view->style->ythickness;
1864 gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->vscrollbar,
1866 gtk_widget_size_request (GTK_SCROLLED_WINDOW (window->priv->scrolled_window)->hscrollbar,
1868 gtk_widget_style_get (window->priv->scrolled_window,
1869 "scrollbar_spacing", &scrollbar_spacing,
1872 ev_view_set_zoom_for_size (EV_VIEW (window->priv->view),
1875 vsb_requisition.width + scrollbar_spacing,
1876 hsb_requisition.height + scrollbar_spacing);
1880 ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
1881 EvWindow *ev_window)
1883 GtkWidget *scrolled_window;
1884 EvSizingMode sizing_mode;
1886 g_object_get (ev_window->priv->view,
1887 "sizing-mode", &sizing_mode,
1890 scrolled_window = ev_window->priv->scrolled_window;
1892 g_signal_handlers_disconnect_by_func (ev_window->priv->view, update_view_size, ev_window);
1894 if (sizing_mode != EV_SIZING_FREE)
1895 update_view_size (NULL, ev_window);
1897 switch (sizing_mode) {
1898 case EV_SIZING_BEST_FIT:
1899 g_object_set (G_OBJECT (scrolled_window),
1900 "hscrollbar-policy", GTK_POLICY_NEVER,
1901 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1903 g_signal_connect (ev_window->priv->view, "zoom_invalid",
1904 G_CALLBACK (update_view_size),
1907 case EV_SIZING_FIT_WIDTH:
1908 g_object_set (G_OBJECT (scrolled_window),
1909 "hscrollbar-policy", GTK_POLICY_NEVER,
1910 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1912 g_signal_connect (ev_window->priv->view, "zoom_invalid",
1913 G_CALLBACK (update_view_size),
1916 case EV_SIZING_FREE:
1917 g_object_set (G_OBJECT (scrolled_window),
1918 "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
1919 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1924 update_sizing_buttons (ev_window);
1928 ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec,
1929 EvWindow *ev_window)
1931 update_action_sensitivity (ev_window);
1935 build_comments_string (void)
1937 PopplerBackend backend;
1938 const char *backend_name;
1939 const char *version;
1941 backend = poppler_get_backend ();
1942 version = poppler_get_version ();
1944 case POPPLER_BACKEND_CAIRO:
1945 backend_name = "cairo";
1947 case POPPLER_BACKEND_SPLASH:
1948 backend_name = "splash";
1951 backend_name = "unknown";
1955 return g_strdup_printf (_("PostScript and PDF File Viewer.\n"
1956 "Using poppler %s (%s)"),
1957 version, backend_name);
1961 ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
1963 const char *authors[] = {
1964 "Martin Kretzschmar <m_kretzschmar@gmx.net>",
1965 "Jonathan Blandford <jrb@gnome.org>",
1966 "Marco Pesenti Gritti <marco@gnome.org>",
1967 "Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
1968 "Bryan Clark <clarkbw@gnome.org>",
1972 const char *documenters[] = {
1973 "Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
1977 const char *license[] = {
1978 N_("Evince is free software; you can redistribute it and/or modify\n"
1979 "it under the terms of the GNU General Public License as published by\n"
1980 "the Free Software Foundation; either version 2 of the License, or\n"
1981 "(at your option) any later version.\n"),
1982 N_("Evince is distributed in the hope that it will be useful,\n"
1983 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1984 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1985 "GNU General Public License for more details.\n"),
1986 N_("You should have received a copy of the GNU General Public License\n"
1987 "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
1988 "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
1991 char *license_trans;
1997 for (p = authors; *p; ++p)
2000 for (p = documenters; *p; ++p)
2004 license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
2005 _(license[2]), "\n", NULL);
2006 comments = build_comments_string ();
2008 gtk_show_about_dialog (
2009 GTK_WINDOW (ev_window),
2010 "name", _("Evince"),
2013 _("\xc2\xa9 1996-2004 The Evince authors"),
2014 "license", license_trans,
2015 "website", "http://www.gnome.org/projects/evince",
2016 "comments", comments,
2018 "documenters", documenters,
2019 "translator-credits", _("translator-credits"),
2023 g_free (license_trans);
2027 ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
2029 update_chrome_flag (ev_window, EV_CHROME_TOOLBAR,
2030 GCONF_CHROME_TOOLBAR,
2031 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2035 ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
2037 update_chrome_flag (ev_window, EV_CHROME_STATUSBAR,
2038 GCONF_CHROME_STATUSBAR,
2039 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2043 ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
2045 update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
2046 GCONF_CHROME_SIDEBAR,
2047 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
2051 ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
2052 EvWindow *ev_window)
2055 gboolean visible, fullscreen;
2057 g_object_get (ev_window->priv->view,
2058 "fullscreen", &fullscreen,
2060 visible = GTK_WIDGET_VISIBLE (ev_sidebar);
2062 /* In fullscreen mode the sidebar is not visible,
2063 * but we don't want to update the chrome
2068 action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
2070 g_signal_handlers_block_by_func
2071 (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
2072 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
2073 g_signal_handlers_unblock_by_func
2074 (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
2076 update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
2077 GCONF_CHROME_SIDEBAR, visible);
2081 menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
2086 action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
2087 g_return_if_fail (action != NULL);
2089 g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
2091 gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
2092 ev_window->priv->help_message_cid, message);
2098 menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
2100 gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
2101 ev_window->priv->help_message_cid);
2105 connect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
2106 GtkWidget *proxy, EvWindow *ev_window)
2108 if (GTK_IS_MENU_ITEM (proxy)) {
2109 g_signal_connect (proxy, "select",
2110 G_CALLBACK (menu_item_select_cb), ev_window);
2111 g_signal_connect (proxy, "deselect",
2112 G_CALLBACK (menu_item_deselect_cb),
2118 disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
2119 GtkWidget *proxy, EvWindow *ev_window)
2121 if (GTK_IS_MENU_ITEM (proxy)) {
2122 g_signal_handlers_disconnect_by_func
2123 (proxy, G_CALLBACK (menu_item_select_cb), ev_window);
2124 g_signal_handlers_disconnect_by_func
2125 (proxy, G_CALLBACK (menu_item_deselect_cb), ev_window);
2130 view_status_changed_cb (EvView *view,
2132 EvWindow *ev_window)
2134 const char *message;
2136 gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
2137 ev_window->priv->view_message_cid);
2139 message = ev_view_get_status (view);
2141 gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
2142 ev_window->priv->view_message_cid, message);
2147 view_find_status_changed_cb (EvView *view,
2149 EvWindow *ev_window)
2153 text = ev_view_get_find_status (view);
2154 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
2159 find_bar_previous_cb (EggFindBar *find_bar,
2160 EvWindow *ev_window)
2162 ev_view_find_previous (EV_VIEW (ev_window->priv->view));
2166 find_bar_next_cb (EggFindBar *find_bar,
2167 EvWindow *ev_window)
2169 ev_view_find_next (EV_VIEW (ev_window->priv->view));
2173 find_bar_close_cb (EggFindBar *find_bar,
2174 EvWindow *ev_window)
2176 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, FALSE);
2180 find_bar_search_changed_cb (EggFindBar *find_bar,
2182 EvWindow *ev_window)
2184 gboolean case_sensitive;
2186 const char *search_string;
2188 g_return_if_fail (EV_IS_WINDOW (ev_window));
2190 /* Either the string or case sensitivity could have changed,
2191 * we connect this callback to both. We also connect it
2192 * to ::visible so when the find bar is hidden, we should
2193 * pretend the search string is NULL/""
2196 case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
2197 visible = GTK_WIDGET_VISIBLE (find_bar);
2198 search_string = egg_find_bar_get_search_string (find_bar);
2201 g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)");
2204 if (ev_window->priv->document &&
2205 EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
2206 if (visible && search_string && search_string[0]) {
2207 ev_document_doc_mutex_lock ();
2208 ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document),
2209 ev_page_cache_get_current_page (ev_window->priv->page_cache),
2212 ev_document_doc_mutex_unlock ();
2214 ev_document_doc_mutex_lock ();
2215 ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
2216 ev_document_doc_mutex_unlock ();
2218 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
2220 gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
2226 zoom_control_changed_cb (EphyZoomAction *action,
2228 EvWindow *ev_window)
2232 g_return_if_fail (EV_IS_WINDOW (ev_window));
2234 if (zoom == EPHY_ZOOM_BEST_FIT) {
2235 mode = EV_SIZING_BEST_FIT;
2236 } else if (zoom == EPHY_ZOOM_FIT_WIDTH) {
2237 mode = EV_SIZING_FIT_WIDTH;
2239 mode = EV_SIZING_FREE;
2240 ev_view_set_zoom (EV_VIEW (ev_window->priv->view), zoom, FALSE);
2243 ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode);
2247 ev_window_dispose (GObject *object)
2249 EvWindow *window = EV_WINDOW (object);
2250 EvWindowPrivate *priv = window->priv;
2252 if (priv->toolbar_model) {
2253 g_object_unref (priv->toolbar_model);
2254 g_free (priv->toolbar_file);
2255 priv->toolbar_model = NULL;
2256 priv->toolbar_file = NULL;
2259 if (priv->ui_manager) {
2260 g_object_unref (priv->ui_manager);
2261 priv->ui_manager = NULL;
2264 if (priv->action_group) {
2265 g_object_unref (priv->action_group);
2266 priv->action_group = NULL;
2269 if (priv->page_cache) {
2270 g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
2271 priv->page_cache = NULL;
2274 if (priv->document) {
2275 g_object_unref (priv->document);
2276 priv->document = NULL;
2280 g_object_unref (priv->view);
2284 if (priv->page_view) {
2285 g_object_unref (priv->page_view);
2286 priv->page_view = NULL;
2289 if (priv->password_document) {
2290 g_object_unref (priv->password_document);
2291 priv->password_document = NULL;
2294 if (priv->password_uri) {
2295 g_free (priv->password_uri);
2296 priv->password_uri = NULL;
2299 if (priv->find_bar) {
2300 g_signal_handlers_disconnect_by_func
2301 (window->priv->find_bar,
2302 G_CALLBACK (find_bar_close_cb),
2304 priv->find_bar = NULL;
2307 destroy_fullscreen_popup (window);
2309 G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
2313 ev_window_class_init (EvWindowClass *ev_window_class)
2315 GObjectClass *g_object_class = G_OBJECT_CLASS (ev_window_class);
2316 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
2318 g_object_class->dispose = ev_window_dispose;
2320 widget_class->window_state_event = ev_window_state_event;
2321 widget_class->focus_in_event = ev_window_focus_in_event;
2322 widget_class->focus_out_event = ev_window_focus_out_event;
2324 g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
2328 static const GtkActionEntry entries[] = {
2329 { "File", NULL, N_("_File") },
2330 { "Edit", NULL, N_("_Edit") },
2331 { "View", NULL, N_("_View") },
2332 { "Go", NULL, N_("_Go") },
2333 { "Help", NULL, N_("_Help") },
2336 { "FileOpen", GTK_STOCK_OPEN, NULL, "<control>O",
2337 N_("Open an existing document"),
2338 G_CALLBACK (ev_window_cmd_file_open) },
2339 { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
2340 N_("Save the current document with a new filename"),
2341 G_CALLBACK (ev_window_cmd_save_as) },
2342 { "FilePrint", GTK_STOCK_PRINT, N_("Print..."), "<control>P",
2343 N_("Print this document"),
2344 G_CALLBACK (ev_window_cmd_file_print) },
2345 { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
2346 N_("Close this window"),
2347 G_CALLBACK (ev_window_cmd_file_close_window) },
2350 { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
2351 N_("Copy text from the document"),
2352 G_CALLBACK (ev_window_cmd_edit_copy) },
2353 { "EditSelectAll", NULL, N_("Select _All"), "<control>A",
2354 N_("Select the entire page"),
2355 G_CALLBACK (ev_window_cmd_edit_select_all) },
2356 { "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
2357 N_("Find a word or phrase in the document"),
2358 G_CALLBACK (ev_window_cmd_edit_find) },
2359 { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G",
2360 N_("Find next occurrence of the word or phrase"),
2361 G_CALLBACK (ev_window_cmd_edit_find_next) },
2362 { "EditToolbar", NULL, N_("T_oolbar"), NULL,
2363 N_("Customize the toolbar"),
2364 G_CALLBACK (ev_window_cmd_edit_toolbar) },
2367 { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
2368 N_("Enlarge the document"),
2369 G_CALLBACK (ev_window_cmd_view_zoom_in) },
2370 { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, NULL, "<control>minus",
2371 N_("Shrink the document"),
2372 G_CALLBACK (ev_window_cmd_view_zoom_out) },
2373 { "ViewReload", GTK_STOCK_REFRESH, N_("_Reload"), "<control>R",
2374 N_("Reload the document"),
2375 G_CALLBACK (ev_window_cmd_view_reload) },
2378 { "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",
2379 N_("Go to the previous page"),
2380 G_CALLBACK (ev_window_cmd_go_previous_page) },
2381 { "GoNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<control>Page_Down",
2382 N_("Go to the next page"),
2383 G_CALLBACK (ev_window_cmd_go_next_page) },
2384 { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home",
2385 N_("Go to the first page"),
2386 G_CALLBACK (ev_window_cmd_go_first_page) },
2387 { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End",
2388 N_("Go to the last page"),
2389 G_CALLBACK (ev_window_cmd_go_last_page) },
2392 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
2393 N_("Display help for the viewer application"),
2394 G_CALLBACK (ev_window_cmd_help_contents) },
2396 { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
2397 N_("Display credits for the document viewer creators"),
2398 G_CALLBACK (ev_window_cmd_help_about) },
2401 { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), NULL,
2402 N_("Leave fullscreen mode"),
2403 G_CALLBACK (ev_window_cmd_leave_fullscreen) },
2406 { "Escape", NULL, "", "Escape", "",
2407 G_CALLBACK (ev_window_cmd_escape) },
2408 { "Slash", GTK_STOCK_FIND, NULL, "slash",
2409 N_("Find a word or phrase in the document"),
2410 G_CALLBACK (ev_window_cmd_edit_find) },
2411 { "PageDown", NULL, "", "Page_Down",
2412 N_("Scroll one page forward"),
2413 G_CALLBACK (ev_window_cmd_scroll_forward) },
2414 { "PageUp", NULL, "", "Page_Up",
2415 N_("Scroll one page backward"),
2416 G_CALLBACK (ev_window_cmd_scroll_backward) },
2417 { "Space", NULL, "", "space",
2418 N_("Scroll one page forward"),
2419 G_CALLBACK (ev_window_cmd_scroll_forward) },
2420 { "ShiftSpace", NULL, "", "<shift>space",
2421 N_("Scroll one page backward"),
2422 G_CALLBACK (ev_window_cmd_scroll_backward) },
2423 { "BackSpace", NULL, "", "BackSpace",
2424 N_("Scroll one page backward"),
2425 G_CALLBACK (ev_window_cmd_scroll_backward) },
2426 { "ShiftBackSpace", NULL, "", "<shift>BackSpace",
2427 N_("Scroll one page forward"),
2428 G_CALLBACK (ev_window_cmd_scroll_forward) },
2429 { "Plus", GTK_STOCK_ZOOM_IN, NULL, "plus",
2430 N_("Enlarge the document"),
2431 G_CALLBACK (ev_window_cmd_view_zoom_in) },
2432 { "Minus", GTK_STOCK_ZOOM_OUT, NULL, "minus",
2433 N_("Shrink the document"),
2434 G_CALLBACK (ev_window_cmd_view_zoom_out) },
2435 { "FocusPageSelector", NULL, "", "<control>l",
2436 N_("Focus the page selector"),
2437 G_CALLBACK (ev_window_cmd_focus_page_selector) }
2441 static const GtkToggleActionEntry toggle_entries[] = {
2443 { "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
2444 N_("Show or hide the toolbar"),
2445 G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
2446 { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
2447 N_("Show or hide the statusbar"),
2448 G_CALLBACK (ev_window_view_statusbar_cb), TRUE },
2449 { "ViewSidebar", NULL, N_("Side _pane"), "F9",
2450 N_("Show or hide the side pane"),
2451 G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
2452 { "ViewContinuous", NULL, N_("_Continuous"), NULL,
2453 N_("Show the entire document"),
2454 G_CALLBACK (ev_window_cmd_continuous), TRUE },
2455 { "ViewDual", NULL, N_("_Dual"), NULL,
2456 N_("Show two pages at once"),
2457 G_CALLBACK (ev_window_cmd_dual), FALSE },
2458 { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
2459 N_("Expand the window to fill the screen"),
2460 G_CALLBACK (ev_window_cmd_view_fullscreen) },
2461 { "ViewPresentation", NULL, N_("_Presentation"), "F12",
2462 N_("Run document as a presentation"),
2463 G_CALLBACK (ev_window_cmd_view_presentation) },
2464 { "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
2465 N_("Make the current document fill the window"),
2466 G_CALLBACK (ev_window_cmd_view_best_fit) },
2467 { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL,
2468 N_("Make the current document fill the window width"),
2469 G_CALLBACK (ev_window_cmd_view_page_width) },
2473 drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
2474 gint x, gint y, GtkSelectionData *selection_data,
2475 guint info, guint time, gpointer gdata)
2477 GList *uri_list = NULL;
2479 uri_list = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
2482 ev_window_open_uri_list (EV_WINDOW (widget), uri_list);
2484 gnome_vfs_uri_list_free (uri_list);
2486 gtk_drag_finish (context, TRUE, FALSE, time);
2491 activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
2493 g_return_if_fail (EV_IS_WINDOW (window));
2495 ev_page_cache_set_link (window->priv->page_cache, link);
2496 gtk_widget_grab_focus (window->priv->view);
2500 activate_label_cb (EvPageAction *page_action, char *label, EvWindow *window)
2502 g_return_val_if_fail (EV_IS_WINDOW (window), FALSE);
2504 gtk_widget_grab_focus (window->priv->view);
2506 return ev_page_cache_set_page_label (window->priv->page_cache, label);
2510 register_custom_actions (EvWindow *window, GtkActionGroup *group)
2514 action = g_object_new (EV_TYPE_PAGE_ACTION,
2515 "name", PAGE_SELECTOR_ACTION,
2517 "tooltip", _("Select Page"),
2518 "visible_overflown", FALSE,
2520 g_signal_connect (action, "activate_link",
2521 G_CALLBACK (activate_link_cb), window);
2522 g_signal_connect (action, "activate_label",
2523 G_CALLBACK (activate_label_cb), window);
2524 gtk_action_group_add_action (group, action);
2525 g_object_unref (action);
2527 action = g_object_new (EPHY_TYPE_ZOOM_ACTION,
2528 "name", ZOOM_CONTROL_ACTION,
2530 "stock_id", GTK_STOCK_ZOOM_IN,
2531 "tooltip", _("Adjust the zoom level"),
2534 g_signal_connect (action, "zoom_to_level",
2535 G_CALLBACK (zoom_control_changed_cb), window);
2536 gtk_action_group_add_action (group, action);
2537 g_object_unref (action);
2541 set_action_properties (GtkActionGroup *action_group)
2545 action = gtk_action_group_get_action (action_group, "GoPreviousPage");
2546 /*translators: this is the label for toolbar button*/
2547 g_object_set (action, "short_label", _("Previous"), NULL);
2548 g_object_set (action, "is-important", TRUE, NULL);
2550 action = gtk_action_group_get_action (action_group, "GoNextPage");
2551 g_object_set (action, "is-important", TRUE, NULL);
2552 /*translators: this is the label for toolbar button*/
2553 g_object_set (action, "short_label", _("Next"), NULL);
2555 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2556 /*translators: this is the label for toolbar button*/
2557 g_object_set (action, "short_label", _("Zoom In"), NULL);
2558 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2560 action = gtk_action_group_get_action (action_group, "ViewZoomOut");
2561 /*translators: this is the label for toolbar button*/
2562 g_object_set (action, "short_label", _("Zoom Out"), NULL);
2563 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2565 action = gtk_action_group_get_action (action_group, "ViewBestFit");
2566 /*translators: this is the label for toolbar button*/
2567 g_object_set (action, "short_label", _("Best Fit"), NULL);
2568 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2570 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
2571 /*translators: this is the label for toolbar button*/
2572 g_object_set (action, "short_label", _("Fit Width"), NULL);
2573 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2575 action = gtk_action_group_get_action (action_group, "LeaveFullscreen");
2576 g_object_set (action, "is-important", TRUE, NULL);
2580 set_chrome_actions (EvWindow *window)
2582 EvWindowPrivate *priv = window->priv;
2583 GtkActionGroup *action_group = priv->action_group;
2586 action= gtk_action_group_get_action (action_group, "ViewToolbar");
2587 g_signal_handlers_block_by_func
2588 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
2589 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2590 (priv->chrome & EV_CHROME_TOOLBAR) != 0);
2591 g_signal_handlers_unblock_by_func
2592 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
2594 action= gtk_action_group_get_action (action_group, "ViewSidebar");
2595 g_signal_handlers_block_by_func
2596 (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
2597 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2598 (priv->chrome & EV_CHROME_SIDEBAR) != 0);
2599 g_signal_handlers_unblock_by_func
2600 (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
2602 action= gtk_action_group_get_action (action_group, "ViewStatusbar");
2603 g_signal_handlers_block_by_func
2604 (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
2605 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2606 (priv->chrome & EV_CHROME_STATUSBAR) != 0);
2607 g_signal_handlers_unblock_by_func
2608 (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
2614 EvChrome chrome = EV_CHROME_NORMAL;
2615 GConfClient *client;
2618 client = gconf_client_get_default ();
2620 value = gconf_client_get (client, GCONF_CHROME_TOOLBAR, NULL);
2621 if (value != NULL) {
2622 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2623 chrome &= ~EV_CHROME_TOOLBAR;
2625 gconf_value_free (value);
2628 value = gconf_client_get (client, GCONF_CHROME_SIDEBAR, NULL);
2629 if (value != NULL) {
2630 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2631 chrome &= ~EV_CHROME_SIDEBAR;
2633 gconf_value_free (value);
2636 value = gconf_client_get (client, GCONF_CHROME_STATUSBAR, NULL);
2637 if (value != NULL) {
2638 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2639 chrome &= ~EV_CHROME_STATUSBAR;
2641 gconf_value_free (value);
2644 g_object_unref (client);
2650 sidebar_widget_model_set (EvSidebarLinks *ev_sidebar_links,
2652 EvWindow *ev_window)
2654 GtkTreeModel *model;
2657 g_object_get (G_OBJECT (ev_sidebar_links),
2661 action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
2662 ev_page_action_set_model (EV_PAGE_ACTION (action), model);
2667 set_view_actions_sensitivity (EvWindow *window, gboolean sensitive)
2669 if (window->priv->action_group) {
2670 set_action_sensitive (window, "PageDown", sensitive);
2671 set_action_sensitive (window, "PageUp", sensitive);
2672 set_action_sensitive (window, "Space", sensitive);
2673 set_action_sensitive (window, "ShiftSpace", sensitive);
2674 set_action_sensitive (window, "BackSpace", sensitive);
2675 set_action_sensitive (window, "ShiftBackSpace", sensitive);
2676 set_action_sensitive (window, "Slash", sensitive);
2677 set_action_sensitive (window, "Plus", sensitive);
2678 set_action_sensitive (window, "Minus", sensitive);
2683 view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
2685 set_view_actions_sensitivity (window, TRUE);
2689 view_actions_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *window)
2691 set_view_actions_sensitivity (window, FALSE);
2695 enable_view_actions_for_widget (EvWindow *window, GtkWidget *widget)
2697 g_signal_connect_object (widget, "focus_in_event",
2698 G_CALLBACK (view_actions_focus_in_cb),
2700 g_signal_connect_object (widget, "focus_out_event",
2701 G_CALLBACK (view_actions_focus_out_cb),
2706 ev_window_init (EvWindow *ev_window)
2708 GtkActionGroup *action_group;
2709 GtkAccelGroup *accel_group;
2710 GError *error = NULL;
2711 GtkWidget *sidebar_widget, *toolbar_dock, *tree_view;
2713 GConfClient *client;
2716 ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
2718 ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
2719 update_window_title (NULL, NULL, ev_window);
2721 ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
2722 gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
2723 gtk_widget_show (ev_window->priv->main_box);
2725 action_group = gtk_action_group_new ("MenuActions");
2726 ev_window->priv->action_group = action_group;
2727 gtk_action_group_set_translation_domain (action_group, NULL);
2728 gtk_action_group_add_actions (action_group, entries,
2729 G_N_ELEMENTS (entries), ev_window);
2730 gtk_action_group_add_toggle_actions (action_group, toggle_entries,
2731 G_N_ELEMENTS (toggle_entries),
2733 set_action_properties (action_group);
2734 register_custom_actions (ev_window, action_group);
2736 ev_window->priv->ui_manager = gtk_ui_manager_new ();
2737 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
2741 gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
2742 gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
2744 set_view_actions_sensitivity (ev_window, FALSE);
2746 g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
2747 G_CALLBACK (connect_proxy_cb), ev_window);
2748 g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
2749 G_CALLBACK (disconnect_proxy_cb), ev_window);
2751 if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
2752 DATADIR"/evince-ui.xml",
2754 g_warning ("building menus failed: %s", error->message);
2755 g_error_free (error);
2758 ev_window->priv->menubar =
2759 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
2761 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
2762 ev_window->priv->menubar,
2765 /* Toolbar editor */
2766 ev_window->priv->toolbar_model = egg_toolbars_model_new ();
2768 ev_window->priv->toolbar_file = g_build_filename
2769 (ev_dot_dir (), "evince_toolbar.xml", NULL);
2771 if (!g_file_test (ev_window->priv->toolbar_file, G_FILE_TEST_EXISTS)) {
2772 egg_toolbars_model_load (ev_window->priv->toolbar_model,
2773 DATADIR"/evince-toolbar.xml");
2775 egg_toolbars_model_load (ev_window->priv->toolbar_model,
2776 ev_window->priv->toolbar_file);
2779 egg_toolbars_model_set_flags (ev_window->priv->toolbar_model, 0,
2780 EGG_TB_MODEL_NOT_REMOVABLE);
2782 /* This sucks, but there is no way to have a draw=no, expand=true separator
2783 * in a GtkUIManager-built toolbar. So, just add another toolbar.
2784 * See gtk+ bug 166489.
2786 toolbar_dock = ev_window->priv->toolbar_dock = gtk_hbox_new (FALSE, 0);
2787 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar_dock,
2789 gtk_widget_show (toolbar_dock);
2791 ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
2792 (ev_window->priv->ui_manager, ev_window->priv->toolbar_model);
2793 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
2795 gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
2797 gtk_widget_show (ev_window->priv->toolbar);
2799 ev_window->priv->fullscreen_toolbar =
2800 gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/LeaveFullscreenToolbar");
2801 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), TRUE);
2804 /* Add the main area */
2805 ev_window->priv->hpaned = gtk_hpaned_new ();
2806 g_signal_connect (ev_window->priv->hpaned,
2808 G_CALLBACK (ev_window_sidebar_position_change_cb),
2811 sidebar_size = SIDEBAR_DEFAULT_SIZE;
2812 client = gconf_client_get_default ();
2813 value = gconf_client_get (client, GCONF_SIDEBAR_SIZE, NULL);
2814 if (value != NULL) {
2815 if (value->type == GCONF_VALUE_INT) {
2816 sidebar_size = gconf_value_get_int (value);
2818 gconf_value_free (value);
2820 g_object_unref (client);
2821 gtk_paned_set_position (GTK_PANED (ev_window->priv->hpaned), sidebar_size);
2822 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
2824 gtk_widget_show (ev_window->priv->hpaned);
2826 ev_window->priv->sidebar = ev_sidebar_new ();
2827 gtk_paned_pack1 (GTK_PANED (ev_window->priv->hpaned),
2828 ev_window->priv->sidebar, FALSE, FALSE);
2829 gtk_widget_show (ev_window->priv->sidebar);
2831 /* Stub sidebar, for now */
2832 sidebar_widget = ev_sidebar_links_new ();
2833 g_signal_connect (sidebar_widget,
2835 G_CALLBACK (sidebar_widget_model_set),
2837 tree_view = ev_sidebar_links_get_treeview
2838 (EV_SIDEBAR_LINKS (sidebar_widget));
2839 enable_view_actions_for_widget (ev_window, tree_view);
2840 gtk_widget_show (sidebar_widget);
2841 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
2844 sidebar_widget = ev_sidebar_thumbnails_new ();
2845 tree_view = ev_sidebar_thumbnails_get_treeview
2846 (EV_SIDEBAR_THUMBNAILS (sidebar_widget));
2847 enable_view_actions_for_widget (ev_window, tree_view);
2848 gtk_widget_show (sidebar_widget);
2849 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
2852 ev_window->priv->scrolled_window =
2853 GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
2854 "shadow-type", GTK_SHADOW_IN,
2856 gtk_widget_show (ev_window->priv->scrolled_window);
2858 gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
2859 ev_window->priv->scrolled_window);
2861 ev_window->priv->view = ev_view_new ();
2862 ev_window->priv->password_view = ev_password_view_new ();
2863 g_signal_connect_swapped (ev_window->priv->password_view,
2865 G_CALLBACK (ev_window_popup_password_dialog),
2867 enable_view_actions_for_widget (ev_window, ev_window->priv->view);
2868 gtk_widget_show (ev_window->priv->view);
2869 gtk_widget_show (ev_window->priv->password_view);
2871 /* We own a ref on these widgets, as we can swap them in and out */
2872 g_object_ref (ev_window->priv->view);
2873 //g_object_ref (ev_window->priv->page_view);
2874 g_object_ref (ev_window->priv->password_view);
2876 gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
2877 ev_window->priv->view);
2879 g_signal_connect (ev_window->priv->view,
2880 "notify::find-status",
2881 G_CALLBACK (view_find_status_changed_cb),
2883 g_signal_connect (ev_window->priv->view,
2885 G_CALLBACK (view_status_changed_cb),
2887 g_signal_connect (ev_window->priv->view,
2888 "notify::sizing-mode",
2889 G_CALLBACK (ev_window_sizing_mode_changed_cb),
2891 g_signal_connect (ev_window->priv->view,
2893 G_CALLBACK (ev_window_zoom_changed_cb),
2896 ev_window->priv->statusbar = gtk_statusbar_new ();
2897 gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
2898 ev_window->priv->statusbar,
2900 ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
2901 (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
2902 ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
2903 (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
2905 ev_window->priv->find_bar = egg_find_bar_new ();
2906 gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
2907 ev_window->priv->find_bar,
2910 ev_window_setup_recent (ev_window);
2911 ev_window->priv->chrome = load_chrome ();
2912 set_chrome_actions (ev_window);
2913 update_chrome_visibility (ev_window);
2915 /* Connect sidebar signals */
2916 g_signal_connect (ev_window->priv->sidebar,
2918 G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
2921 /* Connect to find bar signals */
2922 g_signal_connect (ev_window->priv->find_bar,
2924 G_CALLBACK (find_bar_previous_cb),
2926 g_signal_connect (ev_window->priv->find_bar,
2928 G_CALLBACK (find_bar_next_cb),
2930 g_signal_connect (ev_window->priv->find_bar,
2932 G_CALLBACK (find_bar_close_cb),
2934 g_signal_connect (ev_window->priv->find_bar,
2935 "notify::search-string",
2936 G_CALLBACK (find_bar_search_changed_cb),
2938 g_signal_connect (ev_window->priv->find_bar,
2939 "notify::case-sensitive",
2940 G_CALLBACK (find_bar_search_changed_cb),
2942 g_signal_connect (ev_window->priv->find_bar,
2944 G_CALLBACK (find_bar_search_changed_cb),
2947 /* Give focus to the document view */
2948 gtk_widget_grab_focus (ev_window->priv->view);
2951 gtk_drag_dest_unset (GTK_WIDGET (ev_window));
2952 gtk_drag_dest_set (GTK_WIDGET (ev_window), GTK_DEST_DEFAULT_ALL, ev_drop_types,
2953 sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
2955 g_signal_connect (G_OBJECT (ev_window), "drag_data_received",
2956 G_CALLBACK (drag_data_received_cb), NULL);
2958 /* Set it to something random to force a change */
2960 ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
2961 update_action_sensitivity (ev_window);