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