X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-window.c;h=d46d98d98de386107eea5d865576a730a0e887b6;hb=d3ea391eeabb901a8dfe269edc5980f0f800aa65;hp=ff4c5d2417bd1c1fe786a56d63cdcab7acdc3b6a;hpb=fed5ac607fbe74668f1b74c2022ef56b5ee25d61;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index ff4c5d24..d46d98d9 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -32,11 +32,13 @@ #include "ev-navigation-action.h" #include "ev-page-action.h" #include "ev-sidebar.h" -#include "ev-sidebar-bookmarks.h" +#include "ev-sidebar-links.h" #include "ev-sidebar-thumbnails.h" #include "ev-view.h" +#include "ev-password.h" #include "ev-print-job.h" #include "ev-document-find.h" +#include "ev-document-security.h" #include "eggfindbar.h" #include "pdf-document.h" @@ -45,6 +47,7 @@ #include #include + #include #include @@ -67,21 +70,26 @@ struct _EvWindowPrivate { GtkWidget *main_box; GtkWidget *hpaned; GtkWidget *sidebar; + GtkWidget *thumbs_sidebar; GtkWidget *find_bar; GtkWidget *view; GtkActionGroup *action_group; GtkUIManager *ui_manager; GtkWidget *statusbar; guint help_message_cid; + guint view_message_cid; GtkWidget *exit_fullscreen_popup; char *uri; - GtkAction *page_action; EvDocument *document; gboolean fullscreen_mode; }; +#define NAVIGATION_BACK_ACTION "NavigationBack" +#define NAVIGATION_FORWARD_ACTION "NavigationForward" +#define PAGE_SELECTOR_ACTION "PageSelector" + #if 0 /* enable these to add support for signals */ static guint ev_window_signals [N_SIGNALS] = { 0 }; @@ -101,7 +109,7 @@ const char * ev_window_get_attribute (EvWindow *self) { g_return_val_if_fail (self != NULL && EV_IS_WINDOW (self), NULL); - + return self->priv->attribute; } @@ -145,9 +153,9 @@ ev_window_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *param_spec) { EvWindow *self; - + self = EV_WINDOW (object); - + switch (prop_id) { case PROP_ATTRIBUTE: ev_window_set_attribute (self, g_value_get_string (value)); @@ -174,27 +182,91 @@ set_action_sensitive (EvWindow *ev_window, static void update_action_sensitivity (EvWindow *ev_window) { - int n_pages; - int page; + EvDocument *document; + EvView *view; + + gboolean can_go_back = FALSE; + gboolean can_go_forward = FALSE; + + document = ev_window->priv->document; + + view = EV_VIEW (ev_window->priv->view); + + if (document) { + can_go_back = ev_view_can_go_back (view); + can_go_forward = ev_view_can_go_forward (view); + } + + /* File menu */ + /* "FileOpen": always sensitive */ + set_action_sensitive (ev_window, "FileSaveAs", document!=NULL); + set_action_sensitive (ev_window, "FilePrint", document!=NULL); + /* "FileCloseWindow": always sensitive */ + + /* Edit menu */ + set_action_sensitive (ev_window, "EditCopy", document!=NULL); + set_action_sensitive (ev_window, "EditSelectAll", document!=NULL); - if (ev_window->priv->document) - n_pages = ev_document_get_n_pages (ev_window->priv->document); + if (document) + set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document)); else - n_pages = 1; + set_action_sensitive (ev_window, "EditFind", FALSE); - page = ev_view_get_page (EV_VIEW (ev_window->priv->view)); + /* View menu */ + set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL); + set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL); + set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL); + set_action_sensitive (ev_window, "ViewBestFit", document!=NULL); + set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL); + + /* Go menu */ + set_action_sensitive (ev_window, "GoBack", can_go_back); + set_action_sensitive (ev_window, "GoForward", can_go_forward); + if (document) { + int n_pages; + int page; + + page = ev_view_get_page (EV_VIEW (ev_window->priv->view)); + n_pages = ev_document_get_n_pages (document); + + set_action_sensitive (ev_window, "GoPageDown", page > 1); + set_action_sensitive (ev_window, "GoPageUp", page < n_pages); + set_action_sensitive (ev_window, "GoFirstPage", page > 1); + set_action_sensitive (ev_window, "GoLastPage", page < n_pages); + } else { + set_action_sensitive (ev_window, "GoFirstPage", FALSE); + set_action_sensitive (ev_window, "GoPageDown", FALSE); + set_action_sensitive (ev_window, "GoPageUp", FALSE); + set_action_sensitive (ev_window, "GoLastPage", FALSE); + } + + /* Help menu */ + /* "HelpContents": always sensitive */ + /* "HelpAbout": always sensitive */ + + /* Toolbar-specific actions: */ + set_action_sensitive (ev_window, NAVIGATION_BACK_ACTION, can_go_back); + set_action_sensitive (ev_window, NAVIGATION_FORWARD_ACTION, can_go_forward); + set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL); +} + +void +ev_window_open_page (EvWindow *ev_window, int page) +{ + ev_view_set_page (EV_VIEW (ev_window->priv->view), page); +} - set_action_sensitive (ev_window, "GoFirstPage", page > 1); - set_action_sensitive (ev_window, "GoPageDown", page > 1); - set_action_sensitive (ev_window, "GoPageUp", page < n_pages); - set_action_sensitive (ev_window, "GoLastPage", page < n_pages); +void +ev_window_open_link (EvWindow *ev_window, EvLink *link) +{ + ev_view_go_to_link (EV_VIEW (ev_window->priv->view), link); } gboolean ev_window_is_empty (const EvWindow *ev_window) { g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE); - + return ev_window->priv->document == NULL; } @@ -221,33 +293,33 @@ mime_type_supported_by_gdk_pixbuf (const gchar *mime_type) { GSList *formats, *list; gboolean retval = FALSE; - + formats = gdk_pixbuf_get_formats (); - + list = formats; while (list) { GdkPixbufFormat *format = list->data; int i; gchar **mime_types; - + if (gdk_pixbuf_format_is_disabled (format)) continue; mime_types = gdk_pixbuf_format_get_mime_types (format); - + for (i = 0; mime_types[i] != NULL; i++) { if (strcmp (mime_types[i], mime_type) == 0) { retval = TRUE; break; } } - + if (retval) break; - + list = list->next; } - + g_slist_free (formats); return retval; @@ -263,7 +335,7 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo } else { title = ev_document_get_title (document); - if (title == NULL) { + if (title == NULL || (title && strlen (title) == 0)) { title = g_path_get_basename (ev_window->priv->uri); } } @@ -276,12 +348,59 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo static void update_total_pages (EvWindow *ev_window) { - EvPageAction *page_action; + GtkAction *action; int pages; pages = ev_document_get_n_pages (ev_window->priv->document); - page_action = EV_PAGE_ACTION (ev_window->priv->page_action); - ev_page_action_set_total_pages (page_action, pages); + action = gtk_action_group_get_action + (ev_window->priv->action_group, PAGE_SELECTOR_ACTION); + ev_page_action_set_total_pages (EV_PAGE_ACTION (action), pages); +} + +/* This function assumes that ev_window just had ev_window->document set. + */ +static void +ev_window_setup_document (EvWindow *ev_window) +{ + EvDocument *document; + EvHistory *history; + EvView *view = EV_VIEW (ev_window->priv->view); + EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar); + GtkAction *action; + + document = ev_window->priv->document; + + ev_sidebar_set_document (sidebar, document); + ev_view_set_document (view, document); + + history = ev_history_new (); + ev_view_set_history (view, history); + g_object_unref (history); + + action = gtk_action_group_get_action + (ev_window->priv->action_group, NAVIGATION_BACK_ACTION); + ev_navigation_action_set_history + (EV_NAVIGATION_ACTION (action), history); + + action = gtk_action_group_get_action + (ev_window->priv->action_group, NAVIGATION_FORWARD_ACTION); + ev_navigation_action_set_history + (EV_NAVIGATION_ACTION (action), history); + + update_total_pages (ev_window); + update_action_sensitivity (ev_window); +} + + +static gchar * +ev_window_get_password (GtkWidget *password_dialog) +{ + gchar *password = NULL; + + if (gtk_dialog_run (GTK_DIALOG (password_dialog)) == GTK_RESPONSE_OK) + password = ev_password_dialog_get_password (password_dialog); + + return password; } void @@ -289,7 +408,7 @@ ev_window_open (EvWindow *ev_window, const char *uri) { EvDocument *document = NULL; char *mime_type; - + g_free (ev_window->priv->uri); ev_window->priv->uri = g_strdup (uri); @@ -303,32 +422,62 @@ ev_window_open (EvWindow *ev_window, const char *uri) document = g_object_new (PS_TYPE_DOCUMENT, NULL); else if (mime_type_supported_by_gdk_pixbuf (mime_type)) document = g_object_new (PIXBUF_TYPE_DOCUMENT, NULL); - + if (document) { GError *error = NULL; + GtkWidget *password_dialog = NULL; g_signal_connect_object (G_OBJECT (document), "notify::title", G_CALLBACK (update_window_title), ev_window, 0); - if (ev_document_load (document, uri, &error)) { - if (ev_window->priv->document) - g_object_unref (ev_window->priv->document); - ev_window->priv->document = document; + /* If we get an error while loading the document, we try to fix + * it and try again. This is an ugly loop that could do with + * some refactoring.*/ + while (TRUE) { + gboolean result; - ev_view_set_document (EV_VIEW (ev_window->priv->view), - document); - ev_sidebar_set_document (EV_SIDEBAR (ev_window->priv->sidebar), - document); + result = ev_document_load (document, uri, &error); + + if (result) { + if (ev_window->priv->document) + g_object_unref (ev_window->priv->document); + ev_window->priv->document = document; + ev_window_setup_document (ev_window); + + if (password_dialog) + gtk_widget_destroy (password_dialog); + break; + } - update_total_pages (ev_window); - update_action_sensitivity (ev_window); - } else { g_assert (error != NULL); + + if (error->domain == EV_DOCUMENT_ERROR && + error->code == EV_DOCUMENT_ERROR_ENCRYPTED) { + char *password; + + if (password_dialog == NULL) + password_dialog = ev_password_dialog_new (GTK_WIDGET (ev_window), uri); + else + ev_password_dialog_set_bad_pass (password_dialog); + password = ev_window_get_password (password_dialog); + if (password) { + ev_document_security_set_password (EV_DOCUMENT_SECURITY (document), + password); + g_free (password); + g_error_free (error); + error = NULL; + continue; + } else { + gtk_widget_destroy (password_dialog); + } + } else { + unable_to_load (ev_window, error->message); + } g_object_unref (document); - unable_to_load (ev_window, error->message); g_error_free (error); + break; } } else { char *error_message; @@ -371,7 +520,7 @@ overwrite_existing_file (GtkWindow *window, const gchar *file_name) GTK_MESSAGE_DIALOG (msgbox), _("Do you want to replace it with the one you are saving?")); - gtk_dialog_add_button (GTK_DIALOG (msgbox), + gtk_dialog_add_button (GTK_DIALOG (msgbox), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (msgbox), @@ -419,7 +568,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) { GtkWidget *fc; GtkFileFilter *pdf_filter, *all_filter; - gchar *uri = NULL; + gchar *uri = NULL; fc = gtk_file_chooser_dialog_new ( _("Save a Copy"), @@ -439,7 +588,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) gtk_file_filter_add_pattern (all_filter, "*"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fc), all_filter); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fc), pdf_filter); - + gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK); gtk_widget_show (fc); @@ -448,7 +597,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fc)); /* FIXME - if (g_file_test (uri, G_FILE_TEST_EXISTS) && + if (g_file_test (uri, G_FILE_TEST_EXISTS) && !overwrite_existing_file (GTK_WINDOW (fc), uri)) continue; */ @@ -456,7 +605,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) if (ev_document_save (ev_window->priv->document, uri, NULL)) break; else - save_error_dialog (GTK_WINDOW (fc), uri); + save_error_dialog (GTK_WINDOW (fc), uri); } gtk_widget_destroy (fc); } @@ -469,20 +618,20 @@ using_postscript_printer (GnomePrintConfig *config) driver = gnome_print_config_get ( config, (const guchar *)"Settings.Engine.Backend.Driver"); - + transport = gnome_print_config_get ( config, (const guchar *)"Settings.Transport.Backend"); - + if (driver) { if (!strcmp ((const gchar *)driver, "gnome-print-ps")) return TRUE; - else + else return FALSE; } else if (transport) { if (!strcmp ((const gchar *)transport, "CUPS")) return TRUE; } - + return FALSE; } @@ -506,11 +655,11 @@ ev_window_print (EvWindow *ev_window) gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog), GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, FALSE); - + while (TRUE) { int response; response = gtk_dialog_run (GTK_DIALOG (print_dialog)); - + if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT) break; @@ -519,7 +668,7 @@ ev_window_print (EvWindow *ev_window) */ if (!using_postscript_printer (config)) { GtkWidget *dialog; - + dialog = gtk_message_dialog_new ( GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, @@ -542,7 +691,7 @@ ev_window_print (EvWindow *ev_window) NULL); break; } - + gtk_widget_destroy (print_dialog); if (print_job != NULL) { @@ -573,7 +722,7 @@ find_not_supported_dialog (EvWindow *ev_window) /* If you change this so it isn't modal, be sure you don't * allow multiple copies of the dialog... */ - + dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, @@ -605,9 +754,9 @@ ev_window_cmd_edit_find (GtkAction *action, EvWindow *ev_window) } else { gtk_widget_show (ev_window->priv->find_bar); - if (ev_window->priv->exit_fullscreen_popup) + if (ev_window->priv->exit_fullscreen_popup) update_fullscreen_popup (ev_window); - + egg_find_bar_grab_focus (EGG_FIND_BAR (ev_window->priv->find_bar)); } } @@ -631,7 +780,7 @@ update_fullscreen_popup (EvWindow *window) if (!popup) return; - + popup_width = popup->requisition.width; popup_height = popup->requisition.height; @@ -646,10 +795,10 @@ update_fullscreen_popup (EvWindow *window) GtkRequisition req; gtk_widget_size_request (window->priv->find_bar, &req); - + screen_rect.height -= req.height; } - + if (gtk_widget_get_direction (popup) == GTK_TEXT_DIR_RTL) { gtk_window_move (GTK_WINDOW (popup), @@ -742,7 +891,7 @@ ev_window_fullscreen (EvWindow *window) main_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu"); gtk_widget_hide (main_menu); gtk_widget_hide (window->priv->statusbar); - + update_fullscreen_popup (window); gtk_widget_show (popup); @@ -752,21 +901,21 @@ static void ev_window_unfullscreen (EvWindow *window) { GtkWidget *main_menu; - + window->priv->fullscreen_mode = FALSE; main_menu = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu"); gtk_widget_show (main_menu); gtk_widget_show (window->priv->statusbar); - + destroy_exit_fullscreen_popup (window); } - + static void ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *ev_window) { gboolean fullscreen; - + g_return_if_fail (EV_IS_WINDOW (ev_window)); fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); @@ -816,7 +965,7 @@ static gboolean ev_window_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *ev_window) { gtk_window_unfullscreen (GTK_WINDOW (ev_window)); - + return FALSE; } @@ -866,7 +1015,7 @@ ev_window_cmd_go_back (GtkAction *action, EvWindow *ev_window) { g_return_if_fail (EV_IS_WINDOW (ev_window)); - /* FIXME */ + ev_view_go_back (EV_VIEW (ev_window->priv->view)); } static void @@ -874,7 +1023,7 @@ ev_window_cmd_go_forward (GtkAction *action, EvWindow *ev_window) { g_return_if_fail (EV_IS_WINDOW (ev_window)); - /* FIXME */ + ev_view_go_forward (EV_VIEW (ev_window->priv->view)); } static void @@ -936,7 +1085,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) N_("Evince is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n"), + "(at your option) any later version.\n"), N_("Evince is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" @@ -1018,7 +1167,7 @@ menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window) action = g_object_get_data (G_OBJECT (proxy), "gtk-action"); g_return_if_fail (action != NULL); - + g_object_get (G_OBJECT (action), "tooltip", &message, NULL); if (message) { gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar), @@ -1060,36 +1209,58 @@ disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action, } static void -update_current_page (EvWindow *ev_window) +update_current_page (EvWindow *ev_window, + EvView *view) { - EvPageAction *page_action; int page; + GtkAction *action; + EvSidebarThumbnails *thumbs; + + thumbs = EV_SIDEBAR_THUMBNAILS (ev_window->priv->thumbs_sidebar); + ev_sidebar_thumbnails_select_page (thumbs, ev_view_get_page (view)); + + action = gtk_action_group_get_action + (ev_window->priv->action_group, PAGE_SELECTOR_ACTION); page = ev_view_get_page (EV_VIEW (ev_window->priv->view)); - page_action = EV_PAGE_ACTION (ev_window->priv->page_action); - ev_page_action_set_current_page (page_action, page); + ev_page_action_set_current_page (EV_PAGE_ACTION (action), page); } static void view_page_changed_cb (EvView *view, EvWindow *ev_window) { - update_current_page (ev_window); + update_current_page (ev_window, view); update_action_sensitivity (ev_window); } static void -view_find_status_changed_cb (EvView *view, - EvWindow *ev_window) +view_status_changed_cb (EvView *view, + GParamSpec *pspec, + EvWindow *ev_window) { - char *text; + const char *message; - text = ev_view_get_find_status_message (view); + gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar), + ev_window->priv->view_message_cid); + + message = ev_view_get_status (view); + if (message) { + gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar), + ev_window->priv->view_message_cid, message); + } +} + +static void +view_find_status_changed_cb (EvView *view, + GParamSpec *pspec, + EvWindow *ev_window) +{ + const char *text; + text = ev_view_get_find_status (view); egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), text); - - g_free (text); } static void @@ -1129,7 +1300,7 @@ find_bar_search_changed_cb (EggFindBar *find_bar, const char *search_string; g_return_if_fail (EV_IS_WINDOW (ev_window)); - + /* Either the string or case sensitivity could have changed, * we connect this callback to both. We also connect it * to ::visible so when the find bar is hidden, we should @@ -1139,7 +1310,7 @@ find_bar_search_changed_cb (EggFindBar *find_bar, case_sensitive = egg_find_bar_get_case_sensitive (find_bar); visible = GTK_WIDGET_VISIBLE (find_bar); search_string = egg_find_bar_get_search_string (find_bar); - + #if 0 g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)"); #endif @@ -1174,7 +1345,7 @@ ev_window_dispose (GObject *object) g_object_unref (priv->action_group); priv->action_group = NULL; } - + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -1251,7 +1422,7 @@ static GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_edit_copy) }, { "EditSelectAll", NULL, N_("Select _All"), "A", N_("Select the entire page"), - G_CALLBACK (ev_window_cmd_edit_select_all) }, + G_CALLBACK (ev_window_cmd_edit_select_all) }, { "EditFind", GTK_STOCK_FIND, N_("_Find"), "F", N_("Find a word or phrase in the document"), G_CALLBACK (ev_window_cmd_edit_find) }, @@ -1288,16 +1459,16 @@ static GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_go_page_down) }, { "GoFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "Home", N_("Go to the first page"), - G_CALLBACK (ev_window_cmd_go_first_page) }, + G_CALLBACK (ev_window_cmd_go_first_page) }, { "GoLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "End", N_("Go to the last page"), G_CALLBACK (ev_window_cmd_go_last_page) }, - + /* Help menu */ { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), NULL, N_("Display help for the viewer application"), G_CALLBACK (ev_window_cmd_help_contents) }, - + { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, N_("Display credits for the document viewer creators"), G_CALLBACK (ev_window_cmd_help_about) }, @@ -1323,8 +1494,11 @@ static GtkToggleActionEntry toggle_entries[] = { static void goto_page_cb (GtkAction *action, int page_number, EvWindow *ev_window) { + EvView *view = EV_VIEW (ev_window->priv->view); - ev_view_set_page (EV_VIEW (ev_window->priv->view), page_number); + if (ev_view_get_page (view) != page_number) { + ev_view_set_page (view, page_number); + } } static void @@ -1333,7 +1507,7 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group) GtkAction *action; action = g_object_new (EV_TYPE_NAVIGATION_ACTION, - "name", "NavigationBack", + "name", NAVIGATION_BACK_ACTION, "label", _("Back"), "stock_id", GTK_STOCK_GO_BACK, "tooltip", _("Go back"), @@ -1341,32 +1515,48 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group) "direction", EV_NAVIGATION_DIRECTION_BACK, "is_important", TRUE, NULL); + g_signal_connect (action, "activate", + G_CALLBACK (ev_window_cmd_go_back), window); gtk_action_group_add_action (group, action); g_object_unref (action); action = g_object_new (EV_TYPE_NAVIGATION_ACTION, - "name", "NavigationForward", + "name", NAVIGATION_FORWARD_ACTION, "label", _("Forward"), "stock_id", GTK_STOCK_GO_FORWARD, "tooltip", _("Go forward"), "arrow-tooltip", _("Forward history"), "direction", EV_NAVIGATION_DIRECTION_FORWARD, NULL); + g_signal_connect (action, "activate", + G_CALLBACK (ev_window_cmd_go_forward), window); gtk_action_group_add_action (group, action); g_object_unref (action); action = g_object_new (EV_TYPE_PAGE_ACTION, - "name", "PageSelector", + "name", PAGE_SELECTOR_ACTION, "label", _("Page"), "tooltip", _("Select Page"), NULL); g_signal_connect (action, "goto_page", G_CALLBACK (goto_page_cb), window); - window->priv->page_action = action; gtk_action_group_add_action (group, action); g_object_unref (action); } +static void +set_short_labels (GtkActionGroup *action_group) +{ + GtkAction *action; + + action = gtk_action_group_get_action (action_group, "GoPageUp"); + g_object_set (action, "short_label", _("Up"), NULL); + action = gtk_action_group_get_action (action_group, "GoPageDown"); + g_object_set (action, "short_label", _("Down"), NULL); + action = gtk_action_group_get_action (action_group, "ViewPageWidth"); + g_object_set (action, "short_label", _("Fit Width"), NULL); +} + static void ev_window_init (EvWindow *ev_window) { @@ -1385,7 +1575,7 @@ ev_window_init (EvWindow *ev_window) ev_window->priv->main_box = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box); gtk_widget_show (ev_window->priv->main_box); - + action_group = gtk_action_group_new ("MenuActions"); ev_window->priv->action_group = action_group; gtk_action_group_set_translation_domain (action_group, NULL); @@ -1394,7 +1584,7 @@ ev_window_init (EvWindow *ev_window) gtk_action_group_add_toggle_actions (action_group, toggle_entries, G_N_ELEMENTS (toggle_entries), ev_window); - + set_short_labels (action_group); register_custom_actions (ev_window, action_group); ev_window->priv->ui_manager = gtk_ui_manager_new (); @@ -1439,20 +1629,20 @@ ev_window_init (EvWindow *ev_window) ev_window->priv->sidebar); /* Stub sidebar, for now */ - sidebar_widget = ev_sidebar_bookmarks_new (); + sidebar_widget = ev_sidebar_links_new (); gtk_widget_show (sidebar_widget); ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), - "bookmarks", - _("Bookmarks"), + "index", + _("Index"), sidebar_widget); - sidebar_widget = ev_sidebar_thumbnails_new (); - gtk_widget_show (sidebar_widget); + ev_window->priv->thumbs_sidebar = ev_sidebar_thumbnails_new (); + gtk_widget_show (ev_window->priv->thumbs_sidebar); ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), "thumbnails", _("Thumbnails"), - sidebar_widget); - + ev_window->priv->thumbs_sidebar); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolled_window); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), @@ -1470,10 +1660,14 @@ ev_window_init (EvWindow *ev_window) G_CALLBACK (view_page_changed_cb), ev_window); g_signal_connect (ev_window->priv->view, - "find-status-changed", + "notify::find-status", G_CALLBACK (view_find_status_changed_cb), ev_window); - + g_signal_connect (ev_window->priv->view, + "notify::status", + G_CALLBACK (view_status_changed_cb), + ev_window); + ev_window->priv->statusbar = gtk_statusbar_new (); gtk_widget_show (ev_window->priv->statusbar); gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box), @@ -1481,12 +1675,14 @@ ev_window_init (EvWindow *ev_window) FALSE, TRUE, 0); ev_window->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message"); + ev_window->priv->view_message_cid = gtk_statusbar_get_context_id + (GTK_STATUSBAR (ev_window->priv->statusbar), "view_message"); ev_window->priv->find_bar = egg_find_bar_new (); gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box), ev_window->priv->find_bar, FALSE, TRUE, 0); - + /* Connect to find bar signals */ g_signal_connect (ev_window->priv->find_bar, "previous", @@ -1519,9 +1715,9 @@ ev_window_init (EvWindow *ev_window) g_signal_connect (ev_window, "focus_out_event", G_CALLBACK (ev_window_focus_out_cb), ev_window); - + /* Give focus to the scrolled window */ gtk_widget_grab_focus (scrolled_window); - + update_action_sensitivity (ev_window); -} +}