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-page-view.h"
38 #include "ev-password.h"
39 #include "ev-password-view.h"
40 #include "ev-print-job.h"
41 #include "ev-document-find.h"
42 #include "ev-document-security.h"
43 #include "eggfindbar.h"
45 #include "pdf-document.h"
46 #include "pixbuf-document.h"
47 #include "ps-document.h"
49 #include <glib/gi18n.h>
52 #include <libgnomevfs/gnome-vfs-mime-utils.h>
53 #include <libgnomevfs/gnome-vfs-uri.h>
54 #include <libgnomeprintui/gnome-print-dialog.h>
56 #include <gconf/gconf-client.h>
60 #include "ev-application.h"
61 #include "ev-stock-icons.h"
70 PAGE_MODE_SINGLE_PAGE,
71 PAGE_MODE_CONTINUOUS_PAGE,
76 EV_CHROME_MENUBAR = 1 << 0,
77 EV_CHROME_TOOLBAR = 1 << 1,
78 EV_CHROME_SIDEBAR = 1 << 2,
79 EV_CHROME_FINDBAR = 1 << 3,
80 EV_CHROME_STATUSBAR = 1 << 4,
81 EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR | EV_CHROME_STATUSBAR
84 struct _EvWindowPrivate {
87 GtkWidget *toolbar_dock;
91 GtkWidget *thumbs_sidebar;
93 GtkWidget *scrolled_window;
96 GtkWidget *password_view;
97 GtkActionGroup *action_group;
98 GtkUIManager *ui_manager;
100 guint help_message_cid;
101 guint view_message_cid;
102 GtkWidget *fullscreen_toolbar;
103 GtkWidget *fullscreen_popup;
106 EvDocument *document;
108 EvWindowPageMode page_mode;
109 /* These members are used temporarily when in PAGE_MODE_PASSWORD */
110 EvDocument *password_document;
111 GtkWidget *password_dialog;
115 gboolean fullscreen_mode;
116 EvSizingMode sizing_mode;
117 GSource *fullscreen_timeout_source;
120 static GtkTargetEntry ev_drop_types[] = {
121 { "text/uri-list", 0, 0 }
125 #define EV_WINDOW_GET_PRIVATE(object) \
126 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
128 #define PAGE_SELECTOR_ACTION "PageSelector"
130 #define GCONF_CHROME_TOOLBAR "/apps/evince/show_toolbar"
131 #define GCONF_CHROME_SIDEBAR "/apps/evince/show_sidebar"
132 #define GCONF_CHROME_STATUSBAR "/apps/evince/show_statusbar"
134 static void ev_window_update_fullscreen_popup (EvWindow *window);
135 static void ev_window_set_page_mode (EvWindow *window,
136 EvWindowPageMode page_mode);
137 static gboolean start_loading_document (EvWindow *ev_window,
138 EvDocument *document,
140 static void ev_window_set_sizing_mode (EvWindow *ev_window,
141 EvSizingMode sizing_mode);
143 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
146 set_action_sensitive (EvWindow *ev_window,
150 GtkAction *action = gtk_action_group_get_action (ev_window->priv->action_group,
152 gtk_action_set_sensitive (action, sensitive);
156 update_action_sensitivity (EvWindow *ev_window)
158 EvDocument *document;
159 EvWindowPageMode page_mode;
162 document = ev_window->priv->document;
163 page_mode = ev_window->priv->page_mode;
165 view = EV_VIEW (ev_window->priv->view);
168 /* "FileOpen": always sensitive */
169 set_action_sensitive (ev_window, "FileSaveAs", document!=NULL);
170 set_action_sensitive (ev_window, "FilePrint", document!=NULL);
171 /* "FileCloseWindow": always sensitive */
174 set_action_sensitive (ev_window, "EditCopy", document!=NULL);
175 set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
178 set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
180 set_action_sensitive (ev_window, "EditFind", FALSE);
183 set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
184 set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
185 set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL);
186 set_action_sensitive (ev_window, "ViewBestFit", document!=NULL);
187 set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL);
194 page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
195 n_pages = ev_document_get_n_pages (document);
197 set_action_sensitive (ev_window, "GoPreviousPage", page > 1);
198 set_action_sensitive (ev_window, "GoNextPage", page < n_pages);
199 set_action_sensitive (ev_window, "GoFirstPage", page > 1);
200 set_action_sensitive (ev_window, "GoLastPage", page < n_pages);
202 set_action_sensitive (ev_window, "GoFirstPage", FALSE);
203 set_action_sensitive (ev_window, "GoPreviousPage", FALSE);
204 set_action_sensitive (ev_window, "GoNextPage", FALSE);
205 set_action_sensitive (ev_window, "GoLastPage", FALSE);
208 /* Page View radio group */
210 set_action_sensitive (ev_window, "SinglePage", page_mode != PAGE_MODE_PASSWORD);
211 set_action_sensitive (ev_window, "ContinuousPage", page_mode != PAGE_MODE_PASSWORD);
213 set_action_sensitive (ev_window, "SinglePage", FALSE);
214 set_action_sensitive (ev_window, "ContinuousPage", FALSE);
217 /* "HelpContents": always sensitive */
218 /* "HelpAbout": always sensitive */
220 /* Toolbar-specific actions: */
221 set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
225 set_widget_visibility (GtkWidget *widget, gboolean visible)
228 gtk_widget_show (widget);
230 gtk_widget_hide (widget);
234 update_chrome_visibility (EvWindow *window)
236 EvWindowPrivate *priv = window->priv;
237 gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
239 menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !priv->fullscreen_mode;
240 toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !priv->fullscreen_mode;
241 sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !priv->fullscreen_mode;
242 fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
243 statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
244 findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
246 set_widget_visibility (priv->menubar, menubar);
247 set_widget_visibility (priv->toolbar_dock, toolbar);
248 set_widget_visibility (priv->sidebar, sidebar);
249 set_widget_visibility (priv->find_bar, findbar);
250 set_widget_visibility (priv->statusbar, statusbar);
251 set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
253 if (priv->fullscreen_popup != NULL) {
254 set_widget_visibility (priv->fullscreen_popup, priv->fullscreen_mode);
259 update_chrome_flag (EvWindow *window, EvChrome flag, const char *pref, gboolean active)
261 EvWindowPrivate *priv = window->priv;
265 priv->chrome |= flag;
268 priv->chrome &= ~flag;
272 client = gconf_client_get_default ();
273 gconf_client_set_bool (client, pref, active, NULL);
274 g_object_unref (client);
277 update_chrome_visibility (window);
281 ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
283 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
284 ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT);
286 ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
291 ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
293 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
294 ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH);
296 ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
301 update_sizing_buttons (EvWindow *window)
303 GtkActionGroup *action_group = window->priv->action_group;
305 gboolean best_fit, page_width;
307 switch (window->priv->sizing_mode) {
308 case EV_SIZING_BEST_FIT:
312 case EV_SIZING_FIT_WIDTH:
317 best_fit = page_width = FALSE;
321 action = gtk_action_group_get_action (action_group, "ViewBestFit");
322 g_signal_handlers_block_by_func
323 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
324 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), best_fit);
325 g_signal_handlers_unblock_by_func
326 (action, G_CALLBACK (ev_window_cmd_view_best_fit), window);
328 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
329 g_signal_handlers_block_by_func
330 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
331 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), page_width);
332 g_signal_handlers_unblock_by_func
333 (action, G_CALLBACK (ev_window_cmd_view_page_width), window);
337 ev_window_open_page (EvWindow *ev_window, int page)
339 ev_view_set_page (EV_VIEW (ev_window->priv->view), page);
343 ev_window_open_link (EvWindow *ev_window, EvLink *link)
345 ev_view_go_to_link (EV_VIEW (ev_window->priv->view), link);
349 ev_window_is_empty (const EvWindow *ev_window)
351 g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
353 return ev_window->priv->document == NULL;
357 unable_to_load (EvWindow *ev_window,
358 const char *error_message)
362 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
363 GTK_DIALOG_DESTROY_WITH_PARENT,
366 _("Unable to open document"));
367 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
368 "%s", error_message);
369 gtk_dialog_run (GTK_DIALOG (dialog));
370 gtk_widget_destroy (dialog);
373 /* Would be nice to have this in gdk-pixbuf */
375 mime_type_supported_by_gdk_pixbuf (const gchar *mime_type)
377 GSList *formats, *list;
378 gboolean retval = FALSE;
380 formats = gdk_pixbuf_get_formats ();
384 GdkPixbufFormat *format = list->data;
388 if (gdk_pixbuf_format_is_disabled (format))
391 mime_types = gdk_pixbuf_format_get_mime_types (format);
393 for (i = 0; mime_types[i] != NULL; i++) {
394 if (strcmp (mime_types[i], mime_type) == 0) {
406 g_slist_free (formats);
412 update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_window)
415 char *doc_title = NULL;
416 gboolean password_needed;
418 password_needed = (ev_window->priv->password_document != NULL);
421 doc_title = ev_document_get_title (document);
423 /* Make sure we get a valid title back */
425 if (doc_title[0] == '\000' ||
426 !g_utf8_validate (doc_title, -1, NULL)) {
436 for (p = doc_title; *p; ++p) {
437 /* an '\n' byte is always ASCII, no need for UTF-8 special casing */
443 if (doc_title == NULL && ev_window->priv->uri) {
444 doc_title = g_path_get_basename (ev_window->priv->uri);
447 if (password_needed) {
448 if (doc_title == NULL) {
449 title = g_strdup (_("Document Viewer - Password Required"));
451 title = g_strdup_printf (_("%s - Password Required"), doc_title);
454 if (doc_title == NULL) {
455 title = g_strdup (_("Document Viewer"));
457 title = g_strdup (doc_title);
461 gtk_window_set_title (GTK_WINDOW (ev_window), title);
468 update_total_pages (EvWindow *ev_window)
473 pages = ev_document_get_n_pages (ev_window->priv->document);
474 action = gtk_action_group_get_action
475 (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
476 ev_page_action_set_total_pages (EV_PAGE_ACTION (action), pages);
479 /* This function assumes that ev_window just had ev_window->document set.
482 ev_window_setup_document (EvWindow *ev_window)
484 EvDocument *document;
485 EvView *view = EV_VIEW (ev_window->priv->view);
486 EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
488 document = ev_window->priv->document;
490 g_signal_connect_object (G_OBJECT (document),
492 G_CALLBACK (update_window_title),
495 ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
497 ev_sidebar_set_document (sidebar, document);
498 ev_view_set_document (view, document);
500 update_window_title (document, NULL, ev_window);
501 update_total_pages (ev_window);
502 update_action_sensitivity (ev_window);
506 password_dialog_response (GtkWidget *password_dialog,
512 if (response_id == GTK_RESPONSE_OK) {
513 EvDocument *document;
516 password = ev_password_dialog_get_password (password_dialog);
518 ev_document_security_set_password (EV_DOCUMENT_SECURITY (ev_window->priv->password_document),
522 document = ev_window->priv->password_document;
523 uri = ev_window->priv->password_uri;
525 ev_window->priv->password_document = NULL;
526 ev_window->priv->password_uri = NULL;
528 if (start_loading_document (ev_window, document, uri)) {
529 gtk_widget_destroy (password_dialog);
532 g_object_unref (document);
538 gtk_widget_set_sensitive (ev_window->priv->password_view, TRUE);
539 gtk_widget_destroy (password_dialog);
542 /* Called either by start_loading_document or by the "unlock" callback on the
543 * password_view page. It assumes that ev_window->priv->password_* has been set
544 * correctly. These are cleared by password_dialog_response() */
547 ev_window_popup_password_dialog (EvWindow *ev_window)
549 g_assert (ev_window->priv->password_document);
550 g_assert (ev_window->priv->password_uri);
552 gtk_widget_set_sensitive (ev_window->priv->password_view, FALSE);
554 update_window_title (ev_window->priv->password_document, NULL, ev_window);
555 if (ev_window->priv->password_dialog == NULL) {
558 file_name = g_path_get_basename (ev_window->priv->password_uri);
559 ev_window->priv->password_dialog =
560 ev_password_dialog_new (GTK_WIDGET (ev_window), file_name);
561 g_object_add_weak_pointer (G_OBJECT (ev_window->priv->password_dialog),
562 (gpointer *) &(ev_window->priv->password_dialog));
563 g_signal_connect (ev_window->priv->password_dialog,
565 G_CALLBACK (password_dialog_response),
568 gtk_widget_show (ev_window->priv->password_dialog);
570 ev_password_dialog_set_bad_pass (ev_window->priv->password_dialog);
574 /* This wil try to load the document. It might be called multiple times on the
575 * same document by the password dialog.
577 * Since the flow of the error dialog is very confusing, we assume that both
578 * document and uri will go away after this function is called, and thus we need
579 * to ref/dup them. Additionally, it needs to clear
580 * ev_window->priv->password_{uri,document}, and thus people who call this
581 * function should _not_ necessarily expect those to exist after being
584 start_loading_document (EvWindow *ev_window,
585 EvDocument *document,
589 GError *error = NULL;
592 g_assert (document != ev_window->priv->document);
594 if (ev_window->priv->password_document) {
595 g_object_unref (ev_window->priv->password_document);
596 ev_window->priv->password_document = NULL;
598 if (ev_window->priv->password_uri) {
599 g_free (ev_window->priv->password_uri);
600 ev_window->priv->password_uri = NULL;
603 result = ev_document_load (document, uri, &error);
607 if (ev_window->priv->document)
608 g_object_unref (ev_window->priv->document);
609 ev_window->priv->document = g_object_ref (document);
610 ev_window_setup_document (ev_window);
615 /* unable to load the document */
616 g_assert (error != NULL);
618 if (error->domain == EV_DOCUMENT_ERROR &&
619 error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
622 ev_window->priv->password_document = g_object_ref (document);
623 ev_window->priv->password_uri = g_strdup (uri);
625 file_name = g_path_get_basename (uri);
626 ev_password_view_set_file_name (EV_PASSWORD_VIEW (ev_window->priv->password_view),
629 ev_window_set_page_mode (ev_window, PAGE_MODE_PASSWORD);
631 ev_window_popup_password_dialog (ev_window);
633 unable_to_load (ev_window, error->message);
635 g_error_free (error);
641 is_file_supported (const gchar *mime_type)
643 static char *supported_types [] = {
645 "application/postscript",
646 "application/x-gzpostscript",
652 g_return_val_if_fail (mime_type != NULL, FALSE);
654 if (mime_type_supported_by_gdk_pixbuf (mime_type))
657 for (i = 0; supported_types[i] != NULL; i++) {
658 if (g_ascii_strcasecmp (mime_type, supported_types[i]) == 0)
666 ev_window_open (EvWindow *ev_window, const char *uri)
668 EvDocument *document = NULL;
671 g_free (ev_window->priv->uri);
672 ev_window->priv->uri = g_strdup (uri);
674 mime_type = gnome_vfs_get_mime_type (uri);
676 if (mime_type == NULL)
678 else if (!strcmp (mime_type, "application/pdf"))
679 document = g_object_new (PDF_TYPE_DOCUMENT, NULL);
680 else if (!strcmp (mime_type, "application/postscript") ||
681 !strcmp (mime_type, "application/x-gzpostscript") ||
682 !strcmp (mime_type, "image/x-eps"))
683 document = g_object_new (PS_TYPE_DOCUMENT, NULL);
684 else if (mime_type_supported_by_gdk_pixbuf (mime_type))
685 document = g_object_new (PIXBUF_TYPE_DOCUMENT, NULL);
688 start_loading_document (ev_window, document, uri);
689 /* See the comment on start_loading_document on ref counting.
690 * As the password dialog flow is confusing, we're very explicit
691 * on ref counting. */
692 g_object_unref (document);
696 error_message = g_strdup_printf (_("Unhandled MIME type: '%s'"),
697 mime_type?mime_type:"<Unknown MIME Type>");
698 unable_to_load (ev_window, error_message);
699 g_free (error_message);
706 ev_window_open_uri_list (EvWindow *ev_window, GList *uri_list)
709 gchar *uri, *mime_type;
711 g_return_if_fail (uri_list != NULL);
715 uri = gnome_vfs_uri_to_string (list->data, GNOME_VFS_URI_HIDE_NONE);
716 mime_type = gnome_vfs_get_mime_type (uri);
718 if (is_file_supported (mime_type)) {
719 if (ev_window_is_empty (EV_WINDOW (ev_window))) {
720 ev_window_open (ev_window, uri);
722 gtk_widget_show (GTK_WIDGET (ev_window));
724 EvWindow *new_window;
726 new_window = ev_application_new_window (EV_APP);
727 ev_window_open (new_window, uri);
729 gtk_widget_show (GTK_WIDGET (new_window));
736 list = g_list_next (list);
741 ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
743 ev_application_open (EV_APP, NULL);
748 overwrite_existing_file (GtkWindow *window, const gchar *file_name)
751 gchar *utf8_file_name;
755 utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
756 msgbox = gtk_message_dialog_new (
758 (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
759 GTK_MESSAGE_QUESTION,
761 _("A file named \"%s\" already exists."),
763 g_free (utf8_file_name);
765 gtk_message_dialog_format_secondary_text (
766 GTK_MESSAGE_DIALOG (msgbox),
767 _("Do you want to replace it with the one you are saving?"));
769 gtk_dialog_add_button (GTK_DIALOG (msgbox),
770 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
772 gtk_dialog_add_button (GTK_DIALOG (msgbox),
773 _("_Replace"), GTK_RESPONSE_YES);
775 gtk_dialog_set_default_response (GTK_DIALOG (msgbox),
776 GTK_RESPONSE_CANCEL);
778 obj = gtk_widget_get_accessible (msgbox);
780 if (GTK_IS_ACCESSIBLE (obj))
781 atk_object_set_name (obj, _("Question"));
783 ret = gtk_dialog_run (GTK_DIALOG (msgbox));
784 gtk_widget_destroy (msgbox);
786 return (ret == GTK_RESPONSE_YES);
791 save_error_dialog (GtkWindow *window, const gchar *file_name)
793 GtkWidget *error_dialog;
795 error_dialog = gtk_message_dialog_new (
797 (GtkDialogFlags)GTK_DIALOG_DESTROY_WITH_PARENT,
800 _("The file could not be saved as \"%s\"."),
803 /* Easy way to make the text bold while keeping the string
804 * above free from pango markup (FIXME ?) */
805 gtk_message_dialog_format_secondary_text (
806 GTK_MESSAGE_DIALOG (error_dialog), " ");
808 gtk_dialog_run (GTK_DIALOG (error_dialog));
809 gtk_widget_destroy (error_dialog);
813 ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
816 GtkFileFilter *pdf_filter, *all_filter;
819 fc = gtk_file_chooser_dialog_new (
821 NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
822 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
823 GTK_STOCK_SAVE, GTK_RESPONSE_OK,
825 gtk_window_set_modal (GTK_WINDOW (fc), TRUE);
827 pdf_filter = gtk_file_filter_new ();
828 gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
829 gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
830 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
832 all_filter = gtk_file_filter_new ();
833 gtk_file_filter_set_name (all_filter, _("All Files"));
834 gtk_file_filter_add_pattern (all_filter, "*");
835 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), all_filter);
836 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fc), pdf_filter);
838 gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK);
840 gtk_widget_show (fc);
842 while (gtk_dialog_run (GTK_DIALOG (fc)) == GTK_RESPONSE_OK) {
843 uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc));
846 if (g_file_test (uri, G_FILE_TEST_EXISTS) &&
847 !overwrite_existing_file (GTK_WINDOW (fc), uri))
851 if (ev_document_save (ev_window->priv->document, uri, NULL))
854 save_error_dialog (GTK_WINDOW (fc), uri);
856 gtk_widget_destroy (fc);
860 using_postscript_printer (GnomePrintConfig *config)
862 const guchar *driver;
863 const guchar *transport;
865 driver = gnome_print_config_get (
866 config, (const guchar *)"Settings.Engine.Backend.Driver");
868 transport = gnome_print_config_get (
869 config, (const guchar *)"Settings.Transport.Backend");
872 if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
876 } else if (transport) {
877 if (!strcmp ((const gchar *)transport, "CUPS"))
885 ev_window_print (EvWindow *ev_window)
887 GnomePrintConfig *config;
889 GtkWidget *print_dialog;
890 EvPrintJob *print_job = NULL;
892 g_return_if_fail (EV_IS_WINDOW (ev_window));
893 g_return_if_fail (ev_window->priv->document != NULL);
895 config = gnome_print_config_default ();
896 job = gnome_print_job_new (config);
898 print_dialog = gnome_print_dialog_new (job, _("Print"),
899 (GNOME_PRINT_DIALOG_RANGE |
900 GNOME_PRINT_DIALOG_COPIES));
901 gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
902 GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
907 response = gtk_dialog_run (GTK_DIALOG (print_dialog));
909 if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
912 /* FIXME: Change this when we have the first backend
913 * that can print more than postscript
915 if (!using_postscript_printer (config)) {
918 dialog = gtk_message_dialog_new (
919 GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
920 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
921 _("Printing is not supported on this printer."));
922 gtk_message_dialog_format_secondary_text (
923 GTK_MESSAGE_DIALOG (dialog),
924 _("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
925 gnome_print_config_get (
926 config, "Settings.Engine.Backend.Driver"));
927 gtk_dialog_run (GTK_DIALOG (dialog));
928 gtk_widget_destroy (dialog);
933 print_job = g_object_new (EV_TYPE_PRINT_JOB,
934 "gnome_print_job", job,
935 "document", ev_window->priv->document,
936 "print_dialog", print_dialog,
941 gtk_widget_destroy (print_dialog);
943 if (print_job != NULL) {
944 ev_print_job_print (print_job, GTK_WINDOW (ev_window));
945 g_object_unref (print_job);
950 ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
952 ev_window_print (ev_window);
956 ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
958 g_return_if_fail (EV_IS_WINDOW (ev_window));
960 gtk_widget_destroy (GTK_WIDGET (ev_window));
964 find_not_supported_dialog (EvWindow *ev_window)
968 /* If you change this so it isn't modal, be sure you don't
969 * allow multiple copies of the dialog...
972 dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
973 GTK_DIALOG_DESTROY_WITH_PARENT,
976 _("The \"Find\" feature will not work with this document"));
977 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
978 _("Searching for text is only supported for PDF documents."));
979 gtk_dialog_run (GTK_DIALOG (dialog));
980 gtk_widget_destroy (dialog);
984 ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
986 g_return_if_fail (EV_IS_WINDOW (ev_window));
988 ev_view_select_all (EV_VIEW (ev_window->priv->view));
992 ev_window_cmd_edit_find (GtkAction *action, EvWindow *ev_window)
994 g_return_if_fail (EV_IS_WINDOW (ev_window));
996 if (ev_window->priv->document == NULL) {
997 g_printerr ("We should have set the Find menu item insensitive since there's no document\n");
998 } else if (!EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
999 find_not_supported_dialog (ev_window);
1001 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, TRUE);
1003 egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar));
1008 ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
1010 g_return_if_fail (EV_IS_WINDOW (ev_window));
1012 ev_view_copy (EV_VIEW (ev_window->priv->view));
1016 ev_window_update_fullscreen_popup (EvWindow *window)
1018 GtkWidget *popup = window->priv->fullscreen_popup;
1019 int popup_width, popup_height;
1020 GdkRectangle screen_rect;
1023 g_return_if_fail (popup != NULL);
1025 toolbar = (window->priv->chrome & EV_CHROME_TOOLBAR) != 0;
1026 popup_width = popup->requisition.width;
1027 popup_height = popup->requisition.height;
1029 /* FIXME multihead */
1030 gdk_screen_get_monitor_geometry (gdk_screen_get_default (),
1031 gdk_screen_get_monitor_at_window
1032 (gdk_screen_get_default (),
1033 GTK_WIDGET (window)->window),
1036 gtk_widget_set_size_request (popup,
1039 gtk_window_move (GTK_WINDOW (popup),
1044 if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL)
1046 gtk_window_move (GTK_WINDOW (popup),
1050 gtk_window_move (GTK_WINDOW (popup),
1051 screen_rect.x + screen_rect.width - popup_width,
1058 screen_size_changed_cb (GdkScreen *screen,
1061 ev_window_update_fullscreen_popup (window);
1065 destroy_fullscreen_popup (EvWindow *window)
1067 if (window->priv->fullscreen_popup != NULL)
1069 /* FIXME multihead */
1070 g_signal_handlers_disconnect_by_func
1071 (gdk_screen_get_default (),
1072 G_CALLBACK (screen_size_changed_cb), window);
1074 gtk_widget_destroy (window->priv->fullscreen_popup);
1075 window->priv->fullscreen_popup = NULL;
1080 exit_fullscreen_button_clicked_cb (GtkWidget *button, EvWindow *window)
1084 action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
1085 g_return_if_fail (action != NULL);
1087 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
1091 fullscreen_popup_size_request_cb (GtkWidget *popup, GtkRequisition *req, EvWindow *window)
1093 ev_window_update_fullscreen_popup (window);
1097 fullscreen_timeout_cb (gpointer data)
1099 EvWindow *window = EV_WINDOW (data);
1101 g_object_set (window->priv->fullscreen_popup, "visible", FALSE, NULL);
1102 ev_view_hide_cursor (EV_VIEW (window->priv->view));
1103 window->priv->fullscreen_timeout_source = NULL;
1109 fullscreen_set_timeout (EvWindow *window)
1113 if (window->priv->fullscreen_timeout_source != NULL)
1114 g_source_destroy (window->priv->fullscreen_timeout_source);
1116 source = g_timeout_source_new (1000);
1117 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL);
1118 g_source_attach (source, NULL);
1119 window->priv->fullscreen_timeout_source = source;
1123 fullscreen_clear_timeout (EvWindow *window)
1125 if (window->priv->fullscreen_timeout_source != NULL)
1126 g_source_destroy (window->priv->fullscreen_timeout_source);
1128 window->priv->fullscreen_timeout_source = NULL;
1129 ev_view_show_cursor (EV_VIEW (window->priv->view));
1133 fullscreen_motion_notify_cb (GtkWidget *widget,
1134 GdkEventMotion *event,
1137 EvWindow *window = EV_WINDOW (user_data);
1139 if (!GTK_WIDGET_VISIBLE (window->priv->fullscreen_popup)) {
1140 g_object_set (window->priv->fullscreen_popup, "visible", TRUE, NULL);
1141 ev_view_show_cursor (EV_VIEW (window->priv->view));
1144 fullscreen_set_timeout (window);
1150 fullscreen_leave_notify_cb (GtkWidget *widget,
1151 GdkEventCrossing *event,
1154 EvWindow *window = EV_WINDOW (user_data);
1156 fullscreen_clear_timeout (window);
1162 ev_window_get_exit_fullscreen_button (EvWindow *window)
1164 GtkWidget *button, *icon, *label, *hbox;
1166 button = gtk_button_new ();
1167 g_signal_connect (button, "clicked",
1168 G_CALLBACK (exit_fullscreen_button_clicked_cb),
1170 gtk_widget_show (button);
1172 hbox = gtk_hbox_new (FALSE, 2);
1173 gtk_widget_show (hbox);
1174 gtk_container_add (GTK_CONTAINER (button), hbox);
1176 icon = gtk_image_new_from_stock (EV_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_BUTTON);
1177 gtk_widget_show (icon);
1178 gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
1180 label = gtk_label_new (_("Leave Fullscreen"));
1181 gtk_widget_show (label);
1182 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1188 ev_window_create_fullscreen_popup (EvWindow *window)
1194 popup = gtk_window_new (GTK_WINDOW_POPUP);
1195 hbox = gtk_hbox_new (FALSE, 0);
1196 button = ev_window_get_exit_fullscreen_button (window);
1198 gtk_container_add (GTK_CONTAINER (popup), hbox);
1199 gtk_box_pack_start (GTK_BOX (hbox), window->priv->fullscreen_toolbar,
1201 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
1203 gtk_widget_show (button);
1204 gtk_widget_show (hbox);
1206 gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
1208 /* FIXME multihead */
1209 g_signal_connect (gdk_screen_get_default (), "size-changed",
1210 G_CALLBACK (screen_size_changed_cb), window);
1211 g_signal_connect (popup, "size_request",
1212 G_CALLBACK (fullscreen_popup_size_request_cb), window);
1218 ev_window_fullscreen (EvWindow *window)
1220 window->priv->fullscreen_mode = TRUE;
1222 if (window->priv->fullscreen_popup == NULL)
1223 window->priv->fullscreen_popup
1224 = ev_window_create_fullscreen_popup (window);
1225 update_chrome_visibility (window);
1227 g_object_set (G_OBJECT (window->priv->scrolled_window),
1228 "shadow-type", GTK_SHADOW_NONE,
1231 g_signal_connect (window->priv->view,
1232 "motion-notify-event",
1233 G_CALLBACK (fullscreen_motion_notify_cb),
1235 g_signal_connect (window->priv->view,
1236 "leave-notify-event",
1237 G_CALLBACK (fullscreen_leave_notify_cb),
1239 fullscreen_set_timeout (window);
1241 gtk_widget_grab_focus (window->priv->view);
1243 ev_window_update_fullscreen_popup (window);
1247 ev_window_unfullscreen (EvWindow *window)
1249 window->priv->fullscreen_mode = FALSE;
1251 g_object_set (G_OBJECT (window->priv->scrolled_window),
1252 "shadow-type", GTK_SHADOW_IN,
1255 fullscreen_clear_timeout (window);
1257 g_signal_handlers_disconnect_by_func (window->priv->view,
1258 (gpointer) fullscreen_motion_notify_cb,
1261 // destroy_fullscreen_popup (window);
1263 update_chrome_visibility (window);
1267 ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *ev_window)
1269 gboolean fullscreen;
1271 g_return_if_fail (EV_IS_WINDOW (ev_window));
1273 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
1276 gtk_window_fullscreen (GTK_WINDOW (ev_window));
1278 gtk_window_unfullscreen (GTK_WINDOW (ev_window));
1283 ev_window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, EvWindow *window)
1285 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
1287 GtkActionGroup *action_group;
1289 gboolean fullscreen;
1291 fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
1295 ev_window_fullscreen (window);
1299 ev_window_unfullscreen (window);
1302 action_group = window->priv->action_group;
1304 action = gtk_action_group_get_action (action_group, "ViewFullscreen");
1305 g_signal_handlers_block_by_func
1306 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
1307 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
1308 g_signal_handlers_unblock_by_func
1309 (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
1317 ev_window_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
1319 EvWindow *window = EV_WINDOW (widget);
1320 EvWindowPrivate *priv = window->priv;
1322 if (priv->fullscreen_mode)
1324 gtk_widget_show (priv->fullscreen_popup);
1327 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
1331 ev_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
1333 EvWindow *window = EV_WINDOW (widget);
1334 EvWindowPrivate *priv = window->priv;
1336 if (priv->fullscreen_mode)
1338 gtk_widget_hide (priv->fullscreen_popup);
1341 return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
1345 ev_window_set_page_mode (EvWindow *window,
1346 EvWindowPageMode page_mode)
1348 GtkWidget *child = NULL;
1349 GtkWidget *real_child;
1351 if (window->priv->page_mode == page_mode)
1354 window->priv->page_mode = page_mode;
1356 switch (page_mode) {
1357 case PAGE_MODE_SINGLE_PAGE:
1358 child = window->priv->view;
1360 case PAGE_MODE_PASSWORD:
1361 child = window->priv->password_view;
1363 case PAGE_MODE_CONTINUOUS_PAGE:
1364 child = window->priv->page_view;
1367 g_assert_not_reached ();
1370 real_child = gtk_bin_get_child (GTK_BIN (window->priv->scrolled_window));
1371 if (child != real_child) {
1372 gtk_container_remove (GTK_CONTAINER (window->priv->scrolled_window),
1374 gtk_container_add (GTK_CONTAINER (window->priv->scrolled_window),
1377 update_action_sensitivity (window);
1381 ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
1383 g_return_if_fail (EV_IS_WINDOW (ev_window));
1385 ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
1387 ev_view_zoom_in (EV_VIEW (ev_window->priv->view));
1391 ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
1393 g_return_if_fail (EV_IS_WINDOW (ev_window));
1395 ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE);
1397 ev_view_zoom_out (EV_VIEW (ev_window->priv->view));
1401 ev_window_cmd_view_normal_size (GtkAction *action, EvWindow *ev_window)
1403 g_return_if_fail (EV_IS_WINDOW (ev_window));
1405 ev_view_set_size (EV_VIEW (ev_window->priv->view), -1, -1);
1409 ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
1411 g_return_if_fail (EV_IS_WINDOW (ev_window));
1413 ev_view_set_page (EV_VIEW (ev_window->priv->view),
1414 ev_view_get_page (EV_VIEW (ev_window->priv->view)) - 1);
1418 ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
1420 g_return_if_fail (EV_IS_WINDOW (ev_window));
1422 ev_view_set_page (EV_VIEW (ev_window->priv->view),
1423 ev_view_get_page (EV_VIEW (ev_window->priv->view)) + 1);
1427 ev_window_cmd_go_first_page (GtkAction *action, EvWindow *ev_window)
1429 g_return_if_fail (EV_IS_WINDOW (ev_window));
1431 ev_view_set_page (EV_VIEW (ev_window->priv->view), 1);
1435 ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
1437 g_return_if_fail (EV_IS_WINDOW (ev_window));
1439 ev_view_set_page (EV_VIEW (ev_window->priv->view), G_MAXINT);
1443 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
1445 g_return_if_fail (EV_IS_WINDOW (ev_window));
1451 ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window)
1453 gtk_window_unfullscreen (GTK_WINDOW (window));
1457 size_allocate_cb (GtkWidget *scrolled_window,
1458 GtkAllocation *allocation,
1459 EvWindow *ev_window)
1462 GtkRequisition vsb_requisition;
1463 int scrollbar_spacing;
1465 width = ev_window->priv->scrolled_window->allocation.width;
1466 height = ev_window->priv->scrolled_window->allocation.height;
1468 /* the scrolled window has a GTK_SHADOW_IN */
1469 width -= 2 * ev_window->priv->view->style->xthickness;
1470 height -= 2 * ev_window->priv->view->style->ythickness;
1472 if (ev_window->priv->sizing_mode == EV_SIZING_BEST_FIT) {
1473 ev_view_set_size (EV_VIEW (ev_window->priv->view),
1474 MAX (1, width), MAX (1, height));
1475 } else if (ev_window->priv->sizing_mode == EV_SIZING_FIT_WIDTH) {
1476 gtk_widget_size_request (GTK_SCROLLED_WINDOW (ev_window->priv->scrolled_window)->vscrollbar,
1478 gtk_widget_style_get (ev_window->priv->scrolled_window,
1479 "scrollbar_spacing", &scrollbar_spacing,
1481 ev_view_set_size (EV_VIEW (ev_window->priv->view),
1482 width - vsb_requisition.width - scrollbar_spacing, -1);
1487 ev_window_set_sizing_mode (EvWindow *ev_window,
1488 EvSizingMode sizing_mode)
1490 GtkWidget *scrolled_window;
1492 if (ev_window->priv->sizing_mode == sizing_mode)
1495 scrolled_window = ev_window->priv->scrolled_window;
1496 ev_window->priv->sizing_mode = sizing_mode;
1498 g_signal_handlers_disconnect_by_func (scrolled_window, size_allocate_cb, ev_window);
1500 switch (sizing_mode) {
1501 case EV_SIZING_BEST_FIT:
1502 g_object_set (G_OBJECT (scrolled_window),
1503 "hscrollbar-policy", GTK_POLICY_NEVER,
1504 "vscrollbar-policy", GTK_POLICY_NEVER,
1506 g_signal_connect (scrolled_window, "size-allocate",
1507 G_CALLBACK (size_allocate_cb),
1510 case EV_SIZING_FIT_WIDTH:
1511 g_object_set (G_OBJECT (scrolled_window),
1512 "hscrollbar-policy", GTK_POLICY_NEVER,
1513 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1515 g_signal_connect (scrolled_window, "size-allocate",
1516 G_CALLBACK (size_allocate_cb),
1519 case EV_SIZING_FREE:
1520 g_object_set (G_OBJECT (scrolled_window),
1521 "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
1522 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
1527 update_sizing_buttons (ev_window);
1531 ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
1533 const char *authors[] = {
1538 const char *documenters[] = {
1539 N_("Not so many..."),
1543 const char *license[] = {
1544 N_("Evince is free software; you can redistribute it and/or modify\n"
1545 "it under the terms of the GNU General Public License as published by\n"
1546 "the Free Software Foundation; either version 2 of the License, or\n"
1547 "(at your option) any later version.\n"),
1548 N_("Evince is distributed in the hope that it will be useful,\n"
1549 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1550 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1551 "GNU General Public License for more details.\n"),
1552 N_("You should have received a copy of the GNU General Public License\n"
1553 "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
1554 "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
1557 char *license_trans;
1562 for (p = authors; *p; ++p)
1565 for (p = documenters; *p; ++p)
1569 license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
1570 _(license[2]), "\n", NULL);
1572 gtk_show_about_dialog (
1573 GTK_WINDOW (ev_window),
1574 "name", _("Evince"),
1577 _("\xc2\xa9 1996-2004 The Evince authors"),
1578 "license", license_trans,
1579 "website", "http://www.gnome.org/projects/evince",
1580 "comments", _("PostScript and PDF File Viewer."),
1582 "documenters", documenters,
1583 "translator-credits", _("translator-credits"),
1586 g_free (license_trans);
1590 ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
1592 update_chrome_flag (ev_window, EV_CHROME_TOOLBAR,
1593 GCONF_CHROME_TOOLBAR,
1594 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
1598 ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
1600 update_chrome_flag (ev_window, EV_CHROME_STATUSBAR,
1601 GCONF_CHROME_STATUSBAR,
1602 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
1606 ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
1608 update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
1609 GCONF_CHROME_SIDEBAR,
1610 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
1614 ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
1615 EvWindow *ev_window)
1620 visible = GTK_WIDGET_VISIBLE (ev_sidebar);
1622 /* In fullscreen mode the sidebar is not visible,
1623 * but we don't want to update the chrome
1625 if (ev_window->priv->fullscreen_mode)
1628 action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
1630 g_signal_handlers_block_by_func
1631 (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
1632 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
1633 g_signal_handlers_unblock_by_func
1634 (action, G_CALLBACK (ev_window_view_sidebar_cb), ev_window);
1636 update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
1637 GCONF_CHROME_SIDEBAR, visible);
1641 menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
1646 action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
1647 g_return_if_fail (action != NULL);
1649 g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
1651 gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
1652 ev_window->priv->help_message_cid, message);
1658 menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
1660 gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
1661 ev_window->priv->help_message_cid);
1665 connect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
1666 GtkWidget *proxy, EvWindow *ev_window)
1668 if (GTK_IS_MENU_ITEM (proxy)) {
1669 g_signal_connect (proxy, "select",
1670 G_CALLBACK (menu_item_select_cb), ev_window);
1671 g_signal_connect (proxy, "deselect",
1672 G_CALLBACK (menu_item_deselect_cb),
1678 disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
1679 GtkWidget *proxy, EvWindow *ev_window)
1681 if (GTK_IS_MENU_ITEM (proxy)) {
1682 g_signal_handlers_disconnect_by_func
1683 (proxy, G_CALLBACK (menu_item_select_cb), ev_window);
1684 g_signal_handlers_disconnect_by_func
1685 (proxy, G_CALLBACK (menu_item_deselect_cb), ev_window);
1690 update_current_page (EvWindow *ev_window,
1695 EvSidebarThumbnails *thumbs;
1697 thumbs = EV_SIDEBAR_THUMBNAILS (ev_window->priv->thumbs_sidebar);
1698 ev_sidebar_thumbnails_select_page (thumbs, ev_view_get_page (view));
1700 action = gtk_action_group_get_action
1701 (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
1703 page = ev_view_get_page (EV_VIEW (ev_window->priv->view));
1704 ev_page_action_set_current_page (EV_PAGE_ACTION (action), page);
1708 view_page_changed_cb (EvView *view,
1709 EvWindow *ev_window)
1711 update_current_page (ev_window, view);
1712 update_action_sensitivity (ev_window);
1716 view_status_changed_cb (EvView *view,
1718 EvWindow *ev_window)
1720 const char *message;
1722 gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
1723 ev_window->priv->view_message_cid);
1725 message = ev_view_get_status (view);
1727 gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
1728 ev_window->priv->view_message_cid, message);
1733 view_find_status_changed_cb (EvView *view,
1735 EvWindow *ev_window)
1739 text = ev_view_get_find_status (view);
1740 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
1745 find_bar_previous_cb (EggFindBar *find_bar,
1746 EvWindow *ev_window)
1748 ev_view_find_previous (EV_VIEW (ev_window->priv->view));
1752 find_bar_next_cb (EggFindBar *find_bar,
1753 EvWindow *ev_window)
1755 ev_view_find_next (EV_VIEW (ev_window->priv->view));
1759 find_bar_close_cb (EggFindBar *find_bar,
1760 EvWindow *ev_window)
1762 update_chrome_flag (ev_window, EV_CHROME_FINDBAR, NULL, FALSE);
1766 ev_window_page_mode_cb (GtkRadioAction *action,
1767 GtkRadioAction *activated_action,
1772 mode = gtk_radio_action_get_current_value (action);
1774 g_assert (mode == PAGE_MODE_CONTINUOUS_PAGE ||
1775 mode == PAGE_MODE_SINGLE_PAGE);
1777 ev_window_set_page_mode (window, (EvWindowPageMode) mode);
1781 find_bar_search_changed_cb (EggFindBar *find_bar,
1783 EvWindow *ev_window)
1785 gboolean case_sensitive;
1787 const char *search_string;
1789 g_return_if_fail (EV_IS_WINDOW (ev_window));
1791 /* Either the string or case sensitivity could have changed,
1792 * we connect this callback to both. We also connect it
1793 * to ::visible so when the find bar is hidden, we should
1794 * pretend the search string is NULL/""
1797 case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
1798 visible = GTK_WIDGET_VISIBLE (find_bar);
1799 search_string = egg_find_bar_get_search_string (find_bar);
1802 g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)");
1805 if (ev_window->priv->document &&
1806 EV_IS_DOCUMENT_FIND (ev_window->priv->document)) {
1807 if (visible && search_string) {
1808 ev_document_find_begin (EV_DOCUMENT_FIND (ev_window->priv->document), search_string, case_sensitive);
1810 ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
1811 egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
1813 gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
1819 ev_window_dispose (GObject *object)
1821 EvWindow *window = EV_WINDOW (object);
1822 EvWindowPrivate *priv = window->priv;
1824 if (priv->ui_manager) {
1825 g_object_unref (priv->ui_manager);
1826 priv->ui_manager = NULL;
1829 if (priv->action_group) {
1830 g_object_unref (priv->action_group);
1831 priv->action_group = NULL;
1834 if (priv->document) {
1835 g_object_unref (priv->document);
1836 priv->document = NULL;
1840 g_object_unref (priv->view);
1844 if (priv->page_view) {
1845 g_object_unref (priv->page_view);
1846 priv->page_view = NULL;
1849 if (priv->password_document) {
1850 g_object_unref (priv->password_document);
1851 priv->password_document = NULL;
1854 if (priv->password_uri) {
1855 g_free (priv->password_uri);
1856 priv->password_uri = NULL;
1859 destroy_fullscreen_popup (window);
1861 G_OBJECT_CLASS (ev_window_parent_class)->dispose (object);
1865 ev_window_class_init (EvWindowClass *ev_window_class)
1867 GObjectClass *g_object_class = G_OBJECT_CLASS (ev_window_class);
1868 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ev_window_class);
1870 g_object_class->dispose = ev_window_dispose;
1872 widget_class->focus_in_event = ev_window_focus_in_event;
1873 widget_class->focus_out_event = ev_window_focus_out_event;
1875 g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
1879 static GtkActionEntry entries[] = {
1880 { "File", NULL, N_("_File") },
1881 { "Edit", NULL, N_("_Edit") },
1882 { "View", NULL, N_("_View") },
1883 { "Go", NULL, N_("_Go") },
1884 { "Help", NULL, N_("_Help") },
1887 { "FileOpen", GTK_STOCK_OPEN, NULL, "<control>O",
1888 N_("Open an existing document"),
1889 G_CALLBACK (ev_window_cmd_file_open) },
1890 { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy..."), NULL,
1891 N_("Save the current document with a new filename"),
1892 G_CALLBACK (ev_window_cmd_save_as) },
1893 { "FilePrint", GTK_STOCK_PRINT, N_("Print..."), "<control>P",
1894 N_("Print this document"),
1895 G_CALLBACK (ev_window_cmd_file_print) },
1896 { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
1897 N_("Close this window"),
1898 G_CALLBACK (ev_window_cmd_file_close_window) },
1901 { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
1902 N_("Copy text from the document"),
1903 G_CALLBACK (ev_window_cmd_edit_copy) },
1904 { "EditSelectAll", NULL, N_("Select _All"), "<control>A",
1905 N_("Select the entire page"),
1906 G_CALLBACK (ev_window_cmd_edit_select_all) },
1907 { "EditFind", GTK_STOCK_FIND, NULL, "<control>F",
1908 N_("Find a word or phrase in the document"),
1909 G_CALLBACK (ev_window_cmd_edit_find) },
1912 { "ViewZoomIn", GTK_STOCK_ZOOM_IN, NULL, "<control>plus",
1913 N_("Enlarge the document"),
1914 G_CALLBACK (ev_window_cmd_view_zoom_in) },
1915 { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, NULL, "<control>minus",
1916 N_("Shrink the document"),
1917 G_CALLBACK (ev_window_cmd_view_zoom_out) },
1918 { "ViewNormalSize", GTK_STOCK_ZOOM_100, NULL, "<control>0",
1919 N_("Reset the zoom level to the default value"),
1920 G_CALLBACK (ev_window_cmd_view_normal_size) },
1923 { "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "Page_Up",
1924 N_("Go to the previous page"),
1925 G_CALLBACK (ev_window_cmd_go_previous_page) },
1926 { "GoNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "Page_Down",
1927 N_("Go to the next page"),
1928 G_CALLBACK (ev_window_cmd_go_next_page) },
1929 { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home",
1930 N_("Go to the first page"),
1931 G_CALLBACK (ev_window_cmd_go_first_page) },
1932 { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End",
1933 N_("Go to the last page"),
1934 G_CALLBACK (ev_window_cmd_go_last_page) },
1937 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL,
1938 N_("Display help for the viewer application"),
1939 G_CALLBACK (ev_window_cmd_help_contents) },
1941 { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
1942 N_("Display credits for the document viewer creators"),
1943 G_CALLBACK (ev_window_cmd_help_about) },
1946 { "LeaveFullscreen", EV_STOCK_LEAVE_FULLSCREEN, N_("Leave Fullscreen"), "Escape",
1947 N_("Leave fullscreen mode"),
1948 G_CALLBACK (ev_window_cmd_leave_fullscreen) }
1952 static GtkToggleActionEntry toggle_entries[] = {
1954 { "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
1955 N_("Show or hide the toolbar"),
1956 G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
1957 { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
1958 N_("Show or hide the statusbar"),
1959 G_CALLBACK (ev_window_view_statusbar_cb), TRUE },
1960 { "ViewSidebar", NULL, N_("Side _pane"), "F9",
1961 N_("Show or hide the side pane"),
1962 G_CALLBACK (ev_window_view_sidebar_cb), TRUE },
1963 { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
1964 N_("Expand the window to fill the screen"),
1965 G_CALLBACK (ev_window_cmd_view_fullscreen) },
1966 { "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
1967 N_("Make the current document fill the window"),
1968 G_CALLBACK (ev_window_cmd_view_best_fit) },
1969 { "ViewPageWidth", EV_STOCK_ZOOM_WIDTH, N_("Fit Page _Width"), NULL,
1970 N_("Make the current document fill the window width"),
1971 G_CALLBACK (ev_window_cmd_view_page_width) },
1974 static GtkRadioActionEntry page_view_entries[] = {
1975 { "SinglePage", GTK_STOCK_DND, N_("Single"), NULL,
1976 N_("Show the document one page at a time"),
1977 PAGE_MODE_SINGLE_PAGE },
1978 { "ContinuousPage", GTK_STOCK_DND_MULTIPLE, N_("Multi"), NULL,
1979 N_("Show the full document at once"),
1980 PAGE_MODE_CONTINUOUS_PAGE }
1984 goto_page_cb (GtkAction *action, int page_number, EvWindow *ev_window)
1986 EvView *view = EV_VIEW (ev_window->priv->view);
1988 if (ev_view_get_page (view) != page_number) {
1989 ev_view_set_page (view, page_number);
1994 drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
1995 gint x, gint y, GtkSelectionData *selection_data,
1996 guint info, guint time, gpointer gdata)
1998 GList *uri_list = NULL;
2000 uri_list = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
2003 ev_window_open_uri_list (EV_WINDOW (widget), uri_list);
2005 gnome_vfs_uri_list_free (uri_list);
2007 gtk_drag_finish (context, TRUE, FALSE, time);
2012 register_custom_actions (EvWindow *window, GtkActionGroup *group)
2016 action = g_object_new (EV_TYPE_PAGE_ACTION,
2017 "name", PAGE_SELECTOR_ACTION,
2019 "tooltip", _("Select Page"),
2021 g_signal_connect (action, "goto_page",
2022 G_CALLBACK (goto_page_cb), window);
2023 gtk_action_group_add_action (group, action);
2024 g_object_unref (action);
2028 set_action_properties (GtkActionGroup *action_group)
2032 action = gtk_action_group_get_action (action_group, "GoPreviousPage");
2033 /*translators: this is the label for toolbar button*/
2034 g_object_set (action, "short_label", _("Previous"), NULL);
2035 g_object_set (action, "is-important", TRUE, NULL);
2036 action = gtk_action_group_get_action (action_group, "GoNextPage");
2037 /*translators: this is the label for toolbar button*/
2038 g_object_set (action, "is-important", TRUE, NULL);
2039 g_object_set (action, "short_label", _("Next"), NULL);
2040 action = gtk_action_group_get_action (action_group, "ViewPageWidth");
2041 /*translators: this is the label for toolbar button*/
2042 g_object_set (action, "short_label", _("Fit Width"), NULL);
2043 action = gtk_action_group_get_action (action_group, "ViewZoomIn");
2045 action = gtk_action_group_get_action (action_group, "LeaveFullscreen");
2046 g_object_set (action, "is-important", TRUE, NULL);
2050 set_chrome_actions (EvWindow *window)
2052 EvWindowPrivate *priv = window->priv;
2053 GtkActionGroup *action_group = priv->action_group;
2056 action= gtk_action_group_get_action (action_group, "ViewToolbar");
2057 g_signal_handlers_block_by_func
2058 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
2059 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2060 (priv->chrome & EV_CHROME_TOOLBAR) != 0);
2061 g_signal_handlers_unblock_by_func
2062 (action, G_CALLBACK (ev_window_view_toolbar_cb), window);
2064 action= gtk_action_group_get_action (action_group, "ViewSidebar");
2065 g_signal_handlers_block_by_func
2066 (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
2067 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2068 (priv->chrome & EV_CHROME_SIDEBAR) != 0);
2069 g_signal_handlers_unblock_by_func
2070 (action, G_CALLBACK (ev_window_view_sidebar_cb), window);
2072 action= gtk_action_group_get_action (action_group, "ViewStatusbar");
2073 g_signal_handlers_block_by_func
2074 (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
2075 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
2076 (priv->chrome & EV_CHROME_STATUSBAR) != 0);
2077 g_signal_handlers_unblock_by_func
2078 (action, G_CALLBACK (ev_window_view_statusbar_cb), window);
2084 EvChrome chrome = EV_CHROME_NORMAL;
2085 GConfClient *client;
2088 client = gconf_client_get_default ();
2090 value = gconf_client_get (client, GCONF_CHROME_TOOLBAR, NULL);
2091 if (value != NULL) {
2092 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2093 chrome &= ~EV_CHROME_TOOLBAR;
2095 gconf_value_free (value);
2098 value = gconf_client_get (client, GCONF_CHROME_SIDEBAR, NULL);
2099 if (value != NULL) {
2100 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2101 chrome &= ~EV_CHROME_SIDEBAR;
2103 gconf_value_free (value);
2106 value = gconf_client_get (client, GCONF_CHROME_STATUSBAR, NULL);
2107 if (value != NULL) {
2108 if (value->type == GCONF_VALUE_BOOL && !gconf_value_get_bool (value)) {
2109 chrome &= ~EV_CHROME_STATUSBAR;
2111 gconf_value_free (value);
2114 g_object_unref (client);
2120 ev_window_init (EvWindow *ev_window)
2122 GtkActionGroup *action_group;
2123 GtkAccelGroup *accel_group;
2124 GError *error = NULL;
2125 GtkWidget *sidebar_widget, *toolbar_dock;
2127 ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
2129 ev_window->priv->page_mode = PAGE_MODE_SINGLE_PAGE;
2130 update_window_title (NULL, NULL, ev_window);
2132 ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
2133 gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
2134 gtk_widget_show (ev_window->priv->main_box);
2136 action_group = gtk_action_group_new ("MenuActions");
2137 ev_window->priv->action_group = action_group;
2138 gtk_action_group_set_translation_domain (action_group, NULL);
2139 gtk_action_group_add_actions (action_group, entries,
2140 G_N_ELEMENTS (entries), ev_window);
2141 gtk_action_group_add_toggle_actions (action_group, toggle_entries,
2142 G_N_ELEMENTS (toggle_entries),
2144 gtk_action_group_add_radio_actions (action_group, page_view_entries,
2145 G_N_ELEMENTS (page_view_entries),
2146 ev_window->priv->page_mode,
2147 G_CALLBACK (ev_window_page_mode_cb),
2149 set_action_properties (action_group);
2150 register_custom_actions (ev_window, action_group);
2152 ev_window->priv->ui_manager = gtk_ui_manager_new ();
2153 gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
2157 gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
2158 gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
2160 g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
2161 G_CALLBACK (connect_proxy_cb), ev_window);
2162 g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
2163 G_CALLBACK (disconnect_proxy_cb), ev_window);
2165 if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
2166 DATADIR"/evince-ui.xml",
2168 g_message ("building menus failed: %s", error->message);
2169 g_error_free (error);
2172 ev_window->priv->menubar =
2173 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
2175 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
2176 ev_window->priv->menubar,
2179 /* This sucks, but there is no way to have a draw=no, expand=true separator
2180 * in a GtkUIManager-built toolbar. So, just add another toolbar.
2181 * See gtk+ bug 166489.
2183 toolbar_dock = ev_window->priv->toolbar_dock = gtk_hbox_new (FALSE, 0);
2184 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar_dock,
2186 gtk_widget_show (toolbar_dock);
2188 ev_window->priv->toolbar =
2189 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
2191 gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
2193 gtk_widget_show (ev_window->priv->toolbar);
2195 ev_window->priv->fullscreen_toolbar =
2196 gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/LeaveFullscreenToolbar");
2197 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), TRUE);
2198 gtk_toolbar_set_style (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), GTK_TOOLBAR_BOTH_HORIZ);
2200 /* Add the main area */
2201 ev_window->priv->hpaned = gtk_hpaned_new ();
2202 gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
2204 ev_window->priv->sidebar = ev_sidebar_new ();
2205 g_signal_connect (ev_window->priv->sidebar,
2207 G_CALLBACK (ev_window_sidebar_visibility_changed_cb),
2209 gtk_paned_pack1 (GTK_PANED (ev_window->priv->hpaned),
2210 ev_window->priv->sidebar, FALSE, FALSE);
2211 gtk_widget_show (ev_window->priv->hpaned);
2213 /* Stub sidebar, for now */
2214 sidebar_widget = ev_sidebar_links_new ();
2215 gtk_widget_show (sidebar_widget);
2216 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
2221 ev_window->priv->thumbs_sidebar = ev_sidebar_thumbnails_new ();
2222 gtk_widget_show (ev_window->priv->thumbs_sidebar);
2223 ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
2226 ev_window->priv->thumbs_sidebar);
2228 ev_window->priv->scrolled_window =
2229 GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
2230 "shadow-type", GTK_SHADOW_IN,
2232 gtk_widget_show (ev_window->priv->scrolled_window);
2234 gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
2235 ev_window->priv->scrolled_window);
2237 ev_window->priv->view = ev_view_new ();
2238 //ev_window->priv->page_view = ev_page_view_new ();
2239 ev_window->priv->password_view = ev_password_view_new ();
2240 g_signal_connect_swapped (ev_window->priv->password_view,
2242 G_CALLBACK (ev_window_popup_password_dialog),
2244 gtk_widget_show (ev_window->priv->view);
2245 //gtk_widget_show (ev_window->priv->page_view);
2246 gtk_widget_show (ev_window->priv->password_view);
2248 /* We own a ref on these widgets, as we can swap them in and out */
2249 g_object_ref (ev_window->priv->view);
2250 //g_object_ref (ev_window->priv->page_view);
2251 g_object_ref (ev_window->priv->password_view);
2253 gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
2254 ev_window->priv->view);
2255 g_signal_connect (ev_window->priv->view,
2257 G_CALLBACK (view_page_changed_cb),
2259 g_signal_connect (ev_window->priv->view,
2260 "notify::find-status",
2261 G_CALLBACK (view_find_status_changed_cb),
2263 g_signal_connect (ev_window->priv->view,
2265 G_CALLBACK (view_status_changed_cb),
2268 ev_window->priv->statusbar = gtk_statusbar_new ();
2269 gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
2270 ev_window->priv->statusbar,
2272 ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
2273 (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
2274 ev_window->priv->view_message_cid = gtk_statusbar_get_context_id
2275 (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message");
2277 ev_window->priv->find_bar = egg_find_bar_new ();
2278 gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
2279 ev_window->priv->find_bar,
2282 ev_window->priv->chrome = load_chrome ();
2283 set_chrome_actions (ev_window);
2284 update_chrome_visibility (ev_window);
2286 /* Connect to find bar signals */
2287 g_signal_connect (ev_window->priv->find_bar,
2289 G_CALLBACK (find_bar_previous_cb),
2291 g_signal_connect (ev_window->priv->find_bar,
2293 G_CALLBACK (find_bar_next_cb),
2295 g_signal_connect (ev_window->priv->find_bar,
2297 G_CALLBACK (find_bar_close_cb),
2299 g_signal_connect (ev_window->priv->find_bar,
2300 "notify::search-string",
2301 G_CALLBACK (find_bar_search_changed_cb),
2303 g_signal_connect (ev_window->priv->find_bar,
2304 "notify::case-sensitive",
2305 G_CALLBACK (find_bar_search_changed_cb),
2307 g_signal_connect (ev_window->priv->find_bar,
2309 G_CALLBACK (find_bar_search_changed_cb),
2312 g_signal_connect (ev_window, "window-state-event",
2313 G_CALLBACK (ev_window_state_event_cb),
2316 /* Give focus to the scrolled window */
2317 gtk_widget_grab_focus (ev_window->priv->scrolled_window);
2320 gtk_drag_dest_unset (GTK_WIDGET (ev_window));
2321 gtk_drag_dest_set (GTK_WIDGET (ev_window), GTK_DEST_DEFAULT_ALL, ev_drop_types,
2322 sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
2324 g_signal_connect (G_OBJECT (ev_window), "drag_data_received",
2325 G_CALLBACK (drag_data_received_cb), NULL);
2327 /* Set it to something random to force a change */
2328 ev_window->priv->sizing_mode = EV_SIZING_FREE;
2329 ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT);
2330 update_action_sensitivity (ev_window);