]> www.fi.muni.cz Git - evince.git/blob - shell/ev-window.c
14733fe243cb11380c1ac5fdfcd30da604b0ca6d
[evince.git] / shell / ev-window.c
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
3  *
4  *  Copyright (C) 2004 Martin Kretzschmar
5  *  Copyright (C) 2004 Red Hat, Inc.
6  *
7  *  Author:
8  *    Martin Kretzschmar <martink@gnome.org>
9  *
10  * Evince is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * Evince is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include "ev-window.h"
30 #include "ev-sidebar.h"
31 #include "eggfindbar.h"
32
33 #include <glib/gi18n.h>
34 #include <gtk/gtk.h>
35 #include <libgnomevfs/gnome-vfs-mime-utils.h>
36
37 #include <string.h>
38
39 #include "ev-application.h"
40
41 enum {
42         PROP_0,
43         PROP_ATTRIBUTE
44 };
45
46 enum {
47         SIGNAL,
48         N_SIGNALS
49 };
50
51 struct _EvWindowPrivate {
52         GtkWidget *main_box;
53         GtkWidget *hpaned;
54         GtkWidget *sidebar;
55         GtkWidget *find_bar;
56         GtkWidget *bonobo_widget;
57         GtkUIManager *ui_manager;
58         GtkWidget *statusbar;
59         guint help_message_cid;
60 };
61
62 #if 0
63 /* enable these to add support for signals */
64 static guint ev_window_signals [N_SIGNALS] = { 0 };
65 #endif
66
67 static GObjectClass *parent_class = NULL;
68
69 G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
70
71 #define EV_WINDOW_GET_PRIVATE(object) \
72         (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
73
74 #if 0
75 const char *
76 ev_window_get_attribute (EvWindow *self)
77 {
78         g_return_val_if_fail (self != NULL && EV_IS_WINDOW (self), NULL);
79         
80         return self->priv->attribute;
81 }
82
83 void
84 ev_window_set_attribute (EvWindow* self, const char *attribute)
85 {
86         g_assert (self != NULL && EV_IS_WINDOW (self));
87         g_assert (attribute != NULL);
88
89         if (self->priv->attribute != NULL) {
90                 g_free (self->priv->attribute);
91         }
92
93         self->priv->attribute = g_strdup (attribute);
94
95         g_object_notify (G_OBJECT (self), "attribute");
96 }
97
98 static void
99 ev_window_get_property (GObject *object, guint prop_id, GValue *value,
100                         GParamSpec *param_spec)
101 {
102         EvWindow *self;
103
104         self = EV_WINDOW (object);
105
106         switch (prop_id) {
107         case PROP_ATTRIBUTE:
108                 g_value_set_string (value, self->priv->attribute);
109                 break;
110         default:
111                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
112                                                    prop_id,
113                                                    param_spec);
114                 break;
115         }
116 }
117
118 static void
119 ev_window_set_property (GObject *object, guint prop_id, const GValue *value,
120                         GParamSpec *param_spec)
121 {
122         EvWindow *self;
123         
124         self = EV_WINDOW (object);
125         
126         switch (prop_id) {
127         case PROP_ATTRIBUTE:
128                 ev_window_set_attribute (self, g_value_get_string (value));
129                 break;
130         default:
131                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
132                                                    prop_id,
133                                                    param_spec);
134                 break;
135         }
136 }
137 #endif
138
139 gboolean
140 ev_window_is_empty (const EvWindow *ev_window)
141 {
142         g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
143         
144         return ev_window->priv->bonobo_widget == NULL;
145 }
146
147 void
148 ev_window_open (EvWindow *ev_window, const char *uri)
149 {
150 #if 0
151         char *mime_type;
152         BonoboObject *bonobo_control;
153         CORBA_Environment ev;
154         Bonobo_PersistFile pf;
155
156         mime_type = gnome_vfs_get_mime_type (uri);
157
158         g_return_if_fail (mime_type != NULL); /* FIXME set error */
159
160         if (!strcmp (mime_type, "application/pdf")) {
161                 bonobo_control = create_gpdf_control ();
162         } else if (!strcmp (mime_type, "application/postscript")) {
163                 bonobo_control = create_ggv_control ();
164         } else if (!strcmp (mime_type, "application/x-gzip")) {
165                 g_message ("Cannot open gzip-compressed file %s.", uri);
166                 goto finally;
167         } else if (!strcmp (mime_type, "application/x-bzip")) {
168                 g_message ("Cannot open bzip2-compressed file %s.", uri);
169                 goto finally;
170         } else {
171                 g_warning ("Don't know how to open %s file %s.",
172                            mime_type, uri); /* FIXME set error */
173                 goto finally;
174         }
175
176         ev_window->priv->bonobo_widget = bonobo_widget_new_control_from_objref (
177                 bonobo_object_corba_objref (bonobo_control), CORBA_OBJECT_NIL);
178         gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
179                             ev_window->priv->bonobo_widget,
180                             TRUE, TRUE, 0);
181         CORBA_exception_init (&ev);
182         pf = bonobo_object_query_interface (
183                 bonobo_control, "IDL:Bonobo/PersistFile:1.0", &ev);
184         Bonobo_PersistFile_load (pf, uri, &ev);
185         gtk_widget_show (ev_window->priv->bonobo_widget);
186         bonobo_object_release_unref (pf, &ev);
187         bonobo_object_unref (bonobo_control);
188         CORBA_exception_free (&ev);
189
190 finally:
191         g_free (mime_type);
192 #endif
193 }
194
195 static void
196 ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
197 {
198         ev_application_open (EV_APP, NULL);
199 }
200
201 static void
202 ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
203 {
204         g_return_if_fail (EV_IS_WINDOW (ev_window));
205         /* FIXME */
206 }
207
208 static void
209 ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
210 {
211         g_return_if_fail (EV_IS_WINDOW (ev_window));
212
213         gtk_widget_destroy (GTK_WIDGET (ev_window));
214 }
215
216 static void
217 ev_window_cmd_edit_find (GtkAction *action, EvWindow *ev_window)
218 {
219         g_return_if_fail (EV_IS_WINDOW (ev_window));
220
221         gtk_widget_show (ev_window->priv->find_bar);
222         egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar));
223 }
224
225 static void
226 ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window)
227 {
228         g_return_if_fail (EV_IS_WINDOW (ev_window));
229
230         /* FIXME */
231 }
232
233 static void
234 ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *ev_window)
235 {
236         g_return_if_fail (EV_IS_WINDOW (ev_window));
237
238         /* FIXME */
239 }
240
241 static void
242 ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window)
243 {
244         g_return_if_fail (EV_IS_WINDOW (ev_window));
245
246         /* FIXME */
247 }
248
249 static void
250 ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window)
251 {
252         g_return_if_fail (EV_IS_WINDOW (ev_window));
253
254         /* FIXME */
255 }
256
257 static void
258 ev_window_cmd_view_normal_size (GtkAction *action, EvWindow *ev_window)
259 {
260         g_return_if_fail (EV_IS_WINDOW (ev_window));
261
262         /* FIXME */
263 }
264
265 static void
266 ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
267 {
268         g_return_if_fail (EV_IS_WINDOW (ev_window));
269
270         /* FIXME */
271 }
272
273 static void
274 ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
275 {
276         g_return_if_fail (EV_IS_WINDOW (ev_window));
277
278         /* FIXME */
279 }
280
281 static void
282 ev_window_cmd_go_back (GtkAction *action, EvWindow *ev_window)
283 {
284         g_return_if_fail (EV_IS_WINDOW (ev_window));
285
286         /* FIXME */
287 }
288
289 static void
290 ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window)
291 {
292         g_return_if_fail (EV_IS_WINDOW (ev_window));
293
294         /* FIXME */
295 }
296
297 static void
298 ev_window_cmd_go_previous_page (GtkAction *action, EvWindow *ev_window)
299 {
300         g_return_if_fail (EV_IS_WINDOW (ev_window));
301
302         /* FIXME */
303 }
304
305 static void
306 ev_window_cmd_go_next_page (GtkAction *action, EvWindow *ev_window)
307 {
308         g_return_if_fail (EV_IS_WINDOW (ev_window));
309
310         /* FIXME */
311 }
312
313 static void
314 ev_window_cmd_go_first_page (GtkAction *action, EvWindow *ev_window)
315 {
316         g_return_if_fail (EV_IS_WINDOW (ev_window));
317
318         /* FIXME */
319 }
320
321 static void
322 ev_window_cmd_go_last_page (GtkAction *action, EvWindow *ev_window)
323 {
324         g_return_if_fail (EV_IS_WINDOW (ev_window));
325
326         /* FIXME */
327 }
328
329 static void
330 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
331 {
332         g_return_if_fail (EV_IS_WINDOW (ev_window));
333
334         /* FIXME */
335 }
336
337 static void
338 ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
339 {
340         const char *authors[] = {
341                 N_("Many..."),
342                 NULL
343         };
344
345         const char *documenters[] = {
346                 N_("Not so many..."),
347                 NULL
348         };
349
350         const char *license[] = {
351                 N_("Evince is free software; you can redistribute it and/or modify\n"
352                    "it under the terms of the GNU General Public License as published by\n"
353                    "the Free Software Foundation; either version 2 of the License, or\n"
354                    "(at your option) any later version.\n"),            
355                 N_("Evince is distributed in the hope that it will be useful,\n"
356                    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
357                    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
358                    "GNU General Public License for more details.\n"),
359                 N_("You should have received a copy of the GNU General Public License\n"
360                    "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
361                    "59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n")
362         };
363
364         char *license_trans;
365
366 #ifdef ENABLE_NLS
367         const char **p;
368
369         for (p = authors; *p; ++p)
370                 *p = _(*p);
371
372         for (p = documenters; *p; ++p)
373                 *p = _(*p);
374 #endif
375
376         license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
377                                      _(license[2]), "\n", NULL);
378
379         gtk_show_about_dialog (
380                 GTK_WINDOW (ev_window),
381                 "name", _("Evince"),
382                 "version", VERSION,
383                 "copyright",
384                 _("\xc2\xa9 1996-2004 The Evince authors"),
385                 "license", license_trans,
386                 "website", "http://www.gnome.org/projects/evince",
387                 "comments", _("PostScript and PDF File Viewer."),
388                 "authors", authors,
389                 "documenters", documenters,
390                 "translator-credits", _("translator-credits"),
391                 NULL);
392
393         g_free (license_trans);
394 }
395
396 static void
397 ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
398 {
399         g_object_set (
400                 G_OBJECT (gtk_ui_manager_get_widget (
401                                   ev_window->priv->ui_manager,
402                                   "/ToolBar")),
403                 "visible",
404                 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
405                 NULL);
406 }
407
408 static void
409 ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
410 {
411         g_object_set (
412                 ev_window->priv->statusbar,
413                 "visible",
414                 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
415                 NULL);
416 }
417
418 static void
419 ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
420 {
421         /* FIXME */
422 }
423
424 static void
425 menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
426 {
427         GtkAction *action;
428         char *message;
429
430         action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
431         g_return_if_fail (action != NULL);
432         
433         g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
434         if (message) {
435                 gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
436                                     ev_window->priv->help_message_cid, message);
437                 g_free (message);
438         }
439 }
440
441 static void
442 menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
443 {
444         gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
445                            ev_window->priv->help_message_cid);
446 }
447
448 static void
449 connect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
450                   GtkWidget *proxy, EvWindow *ev_window)
451 {
452         if (GTK_IS_MENU_ITEM (proxy)) {
453                 g_signal_connect (proxy, "select",
454                                   G_CALLBACK (menu_item_select_cb), ev_window);
455                 g_signal_connect (proxy, "deselect",
456                                   G_CALLBACK (menu_item_deselect_cb),
457                                   ev_window);
458         }
459 }
460
461 static void
462 disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
463                      GtkWidget *proxy, EvWindow *ev_window)
464 {
465         if (GTK_IS_MENU_ITEM (proxy)) {
466                 g_signal_handlers_disconnect_by_func
467                         (proxy, G_CALLBACK (menu_item_select_cb), ev_window);
468                 g_signal_handlers_disconnect_by_func
469                         (proxy, G_CALLBACK (menu_item_deselect_cb), ev_window);
470         }
471 }
472
473 static void
474 find_bar_previous_cb (EggFindBar *find_bar,
475                       EvWindow   *ev_window)
476 {
477         /* FIXME - highlight previous result */
478         g_printerr ("Find Previous\n");
479
480 }
481
482 static void
483 find_bar_next_cb (EggFindBar *find_bar,
484                   EvWindow   *ev_window)
485 {
486         /* FIXME - highlight next result */
487         g_printerr ("Find Next\n");
488 }
489
490 static void
491 find_bar_close_cb (EggFindBar *find_bar,
492                    EvWindow   *ev_window)
493 {
494         gtk_widget_hide (ev_window->priv->find_bar);
495 }
496
497 static void
498 find_bar_search_changed_cb (EggFindBar *find_bar,
499                             GParamSpec *param,
500                             EvWindow   *ev_window)
501 {
502         gboolean case_sensitive;
503         gboolean visible;
504         const char *search_string;
505
506         g_return_if_fail (EV_IS_WINDOW (ev_window));
507         
508         /* Either the string or case sensitivity could have changed,
509          * we connect this callback to both. We also connect it
510          * to ::visible so when the find bar is hidden, we should
511          * pretend the search string is NULL/""
512          */
513
514         case_sensitive = egg_find_bar_get_case_sensitive (find_bar);
515         visible = GTK_WIDGET_VISIBLE (find_bar);
516         search_string = egg_find_bar_get_search_string (find_bar);
517         
518         /* FIXME */
519         g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)");
520 }
521
522 static void
523 ev_window_dispose (GObject *object)
524 {
525         EvWindowPrivate *priv;
526
527         g_return_if_fail (object != NULL && EV_IS_WINDOW (object));
528
529         priv = EV_WINDOW (object)->priv;
530
531         if (priv->ui_manager) {
532                 g_object_unref (priv->ui_manager);
533                 priv->ui_manager = NULL;
534         }
535
536         G_OBJECT_CLASS (parent_class)->dispose (object);
537 }
538
539 static void
540 ev_window_class_init (EvWindowClass *ev_window_class)
541 {
542         GObjectClass *g_object_class;
543
544         parent_class = g_type_class_peek_parent (ev_window_class);
545
546         g_object_class = G_OBJECT_CLASS (ev_window_class);
547         g_object_class->dispose = ev_window_dispose;
548
549         g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
550
551 #if 0
552         /* setting up signal system */
553         ev_window_class->signal = ev_window_signal;
554
555         ev_window_signals [SIGNAL] = g_signal_new (
556                 "signal",
557                 EV_TYPE_WINDOW,
558                 G_SIGNAL_RUN_LAST,
559                 G_STRUCT_OFFSET (EvWindowClass,
560                                  signal),
561                 NULL,
562                 NULL,
563                 g_cclosure_marshal_VOID__STRING,
564                 G_TYPE_NONE,
565                 0);
566         /* setting up property system */
567         g_object_class->set_property = ev_window_set_property;
568         g_object_class->get_property = ev_window_get_property;
569
570         g_object_class_install_property (
571                 g_object_class,
572                 PROP_ATTRIBUTE,
573                 g_param_spec_string ("attribute",
574                                      "Attribute",
575                                      "A simple unneccessary attribute that "
576                                      "does nothing special except being a "
577                                      "demonstration for the correct implem"
578                                      "entation of a GObject property",
579                                      "default_value",
580                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
581 #endif
582 }
583
584 /* Normal items */
585 static GtkActionEntry entries[] = {
586         { "File", NULL, N_("_File") },
587         { "Edit", NULL, N_("_Edit") },
588         { "View", NULL, N_("_View") },
589         { "Go", NULL, N_("_Go") },
590         { "Help", NULL, N_("_Help") },
591
592         /* File menu */
593         { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "<control>O",
594           N_("Open a file"),
595           G_CALLBACK (ev_window_cmd_file_open) },
596         { "FilePrint", GTK_STOCK_PRINT, N_("_Print"), "<control>P",
597           N_("Print this document"),
598           G_CALLBACK (ev_window_cmd_file_print) },
599         { "FileCloseWindow", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
600           N_("Close this window"),
601           G_CALLBACK (ev_window_cmd_file_close_window) },
602
603         /* Edit menu */
604         { "EditCopy", GTK_STOCK_COPY, N_("_Copy"), "<control>C",
605           N_("Copy text from the document"),
606           G_CALLBACK (ev_window_cmd_edit_copy) },
607         
608         { "EditFind", GTK_STOCK_FIND, N_("_Find"), "<control>F",
609           N_("Find a word or phrase in the document"),
610           G_CALLBACK (ev_window_cmd_edit_find) },
611
612         /* View menu */
613         { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
614           N_("Expand the window to fill the screen"),
615           G_CALLBACK (ev_window_cmd_view_fullscreen) },
616         { "ViewZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _In"), "<control>plus",
617           N_("Enlarge the document"),
618           G_CALLBACK (ev_window_cmd_view_zoom_in) },
619         { "ViewZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _Out"), "<control>minus",
620           N_("Shrink the document"),
621           G_CALLBACK (ev_window_cmd_view_zoom_out) },
622         { "ViewNormalSize", GTK_STOCK_ZOOM_100, N_("_Normal Size"), "<control>0",
623           N_("Zoom to the normal size"),
624           G_CALLBACK (ev_window_cmd_view_normal_size) },
625         { "ViewBestFit", GTK_STOCK_ZOOM_FIT, N_("_Best Fit"), NULL,
626           N_("Zoom to fit the document to the current window"),
627           G_CALLBACK (ev_window_cmd_view_best_fit) },
628         { "ViewPageWidth", NULL, N_("Fit Page _Width"), NULL,
629           N_("Zoom to fit the width of the current window "),
630           G_CALLBACK (ev_window_cmd_view_page_width) },
631
632         /* Go menu */
633         { "GoBack", GTK_STOCK_GO_BACK, N_("_Back"), "<mod1>Left",
634           N_("Go to the page viewed before this one"),
635           G_CALLBACK (ev_window_cmd_go_back) },
636         { "GoForward", GTK_STOCK_GO_FORWARD, N_("Fo_rward"), "<mod1>Right",
637           N_("Go to the page viewed before this one"),
638           G_CALLBACK (ev_window_cmd_go_forward) },
639         { "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",
640           N_("Go to the previous page"),
641           G_CALLBACK (ev_window_cmd_go_previous_page) },
642         { "GoNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<control>Page_Down",
643           N_("Go to the next page"),
644           G_CALLBACK (ev_window_cmd_go_next_page) },
645         { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home",
646           N_("Go to the first page"),
647           G_CALLBACK (ev_window_cmd_go_first_page) },        
648         { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End",
649           N_("Go to the last page"),
650           G_CALLBACK (ev_window_cmd_go_last_page) },
651         
652         /* Help menu */
653         { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL,
654           N_("Display help for the viewer application"),
655           G_CALLBACK (ev_window_cmd_help_contents) },
656         
657         { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL,
658           N_("Display credits for the document viewer creators"),
659           G_CALLBACK (ev_window_cmd_help_about) },
660 };
661
662 /* Toggle items */
663 static GtkToggleActionEntry toggle_entries[] = {
664         /* View Menu */
665         { "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
666           N_("Show or hide toolbar"),
667           G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
668         { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
669           N_("Show or hide statusbar"),
670           G_CALLBACK (ev_window_view_statusbar_cb), TRUE },
671         { "ViewSidebar", NULL, N_("Side_bar"), "F9",
672           N_("Show or hide sidebar"),
673           G_CALLBACK (ev_window_view_sidebar_cb), FALSE },
674 };
675
676 static void
677 ev_window_init (EvWindow *ev_window)
678 {
679         GtkActionGroup *action_group;
680         GtkAccelGroup *accel_group;
681         GError *error = NULL;
682         GtkWidget *menubar;
683         GtkWidget *toolbar;
684         GtkWidget *darea;
685
686         ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
687
688         gtk_window_set_title (GTK_WINDOW (ev_window), _("Document Viewer"));
689
690         ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
691         gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
692         gtk_widget_show (ev_window->priv->main_box);
693
694         action_group = gtk_action_group_new ("MenuActions");
695         gtk_action_group_set_translation_domain (action_group, NULL);
696         gtk_action_group_add_actions (action_group, entries,
697                                       G_N_ELEMENTS (entries), ev_window);
698         gtk_action_group_add_toggle_actions (action_group, toggle_entries,
699                                              G_N_ELEMENTS (toggle_entries),
700                                              ev_window);
701
702         ev_window->priv->ui_manager = gtk_ui_manager_new ();
703         gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
704                                             action_group, 0);
705
706         accel_group =
707                 gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
708         gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
709
710         g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
711                           G_CALLBACK (connect_proxy_cb), ev_window);
712         g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
713                           G_CALLBACK (disconnect_proxy_cb), ev_window);
714
715         if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
716                                               DATADIR"/evince-ui.xml",
717                                               &error)) {
718                 g_message ("building menus failed: %s", error->message);
719                 g_error_free (error);
720         }
721
722         menubar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
723                                              "/MainMenu");
724         gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), menubar,
725                             FALSE, FALSE, 0);
726
727         toolbar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
728                                              "/ToolBar");
729         gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar,
730                             FALSE, FALSE, 0);
731
732         /* Add the main area */
733         ev_window->priv->hpaned = gtk_hpaned_new ();
734         gtk_widget_show (ev_window->priv->hpaned);
735         gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->hpaned,
736                             TRUE, TRUE, 0);
737
738         ev_window->priv->sidebar = ev_sidebar_new ();
739         gtk_widget_show (ev_window->priv->sidebar);
740         gtk_paned_add1 (GTK_PANED (ev_window->priv->hpaned),
741                         ev_window->priv->sidebar);
742
743         /* Stub widget, for now */
744         darea = gtk_drawing_area_new ();
745         gtk_widget_show (darea);
746         gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
747                         darea);
748
749         ev_window->priv->statusbar = gtk_statusbar_new ();
750         gtk_widget_show (ev_window->priv->statusbar);
751         gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
752                           ev_window->priv->statusbar,
753                           FALSE, TRUE, 0);
754         ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
755                 (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
756
757         ev_window->priv->find_bar = egg_find_bar_new ();
758         gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
759                           ev_window->priv->find_bar,
760                           FALSE, TRUE, 0);
761         
762         /* Connect to find bar signals */
763         g_signal_connect (ev_window->priv->find_bar,
764                           "previous",
765                           G_CALLBACK (find_bar_previous_cb),
766                           ev_window);
767         g_signal_connect (ev_window->priv->find_bar,
768                           "next",
769                           G_CALLBACK (find_bar_next_cb),
770                           ev_window);
771         g_signal_connect (ev_window->priv->find_bar,
772                           "close",
773                           G_CALLBACK (find_bar_close_cb),
774                           ev_window);
775         g_signal_connect (ev_window->priv->find_bar,
776                           "notify::search-string",
777                           G_CALLBACK (find_bar_search_changed_cb),
778                           ev_window);
779         g_signal_connect (ev_window->priv->find_bar,
780                           "notify::case-sensitive",
781                           G_CALLBACK (find_bar_search_changed_cb),
782                           ev_window);
783         g_signal_connect (ev_window->priv->find_bar,
784                           "notify::visible",
785                           G_CALLBACK (find_bar_search_changed_cb),
786                           ev_window);
787 }