X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=29b6a039b17b6987ac0df4487897b95be378bd2a;hb=3975d110064cd88af69d393f956f8158aae1878f;hp=169eb799d5e9ae02206093ca04140b39ba5ed287;hpb=7cbd380d5d1029427c6b6f1b516e3d0502b4041f;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 169eb799..29b6a039 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -33,11 +33,11 @@ #include "ev-page-action.h" #include "ev-sidebar.h" #include "ev-sidebar-links.h" +#include "ev-sidebar-attachments.h" #include "ev-sidebar-thumbnails.h" #include "ev-view.h" #include "ev-password.h" #include "ev-password-view.h" -#include "ev-attachment-bar.h" #include "ev-properties-dialog.h" #include "ev-ps-exporter.h" #include "ev-document-thumbnails.h" @@ -92,7 +92,6 @@ typedef enum { EV_CHROME_RAISE_TOOLBAR = 1 << 3, EV_CHROME_FULLSCREEN_TOOLBAR = 1 << 4, EV_CHROME_SIDEBAR = 1 << 5, - EV_CHROME_ATTACHBAR = 1 << 6, EV_CHROME_NORMAL = EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR } EvChrome; @@ -112,7 +111,7 @@ struct _EvWindowPrivate { GtkWidget *password_view; GtkWidget *sidebar_thumbs; GtkWidget *sidebar_links; - GtkWidget *attachment_bar; + GtkWidget *sidebar_attachments; /* Dialogs */ GtkWidget *properties; @@ -178,6 +177,7 @@ static const GtkTargetEntry ev_drop_types[] = { #define SIDEBAR_DEFAULT_SIZE 132 #define LINKS_SIDEBAR_ID "links" #define THUMBNAILS_SIDEBAR_ID "thumbnails" +#define ATTACHMENTS_SIDEBAR_ID "attachments" static void ev_window_update_actions (EvWindow *ev_window); static void ev_window_update_fullscreen_popup (EvWindow *window); @@ -419,7 +419,7 @@ static void update_chrome_visibility (EvWindow *window) { EvWindowPrivate *priv = window->priv; - gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar, attachbar; + gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar; gboolean fullscreen_mode, presentation, fullscreen; presentation = ev_view_get_presentation (EV_VIEW (priv->view)); @@ -433,13 +433,11 @@ update_chrome_visibility (EvWindow *window) (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen; findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0; sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode; - attachbar = (priv->chrome & EV_CHROME_ATTACHBAR) != 0 && !fullscreen_mode; set_widget_visibility (priv->menubar, menubar); set_widget_visibility (priv->toolbar_dock, toolbar); set_widget_visibility (priv->find_bar, findbar); set_widget_visibility (priv->sidebar, sidebar); - set_widget_visibility (priv->attachment_bar, attachbar); ev_window_set_action_sensitive (window, "EditToolbar", toolbar); gtk_widget_set_sensitive (priv->menubar, menubar); @@ -618,7 +616,6 @@ setup_chrome_from_metadata (EvWindow *window) window->priv->chrome = chrome; } - static void setup_sidebar_from_metadata (EvWindow *window, EvDocument *document) { @@ -626,6 +623,7 @@ setup_sidebar_from_metadata (EvWindow *window, EvDocument *document) GtkWidget *sidebar = window->priv->sidebar; GtkWidget *links = window->priv->sidebar_links; GtkWidget *thumbs = window->priv->sidebar_thumbs; + GtkWidget *attachments = window->priv->sidebar_attachments; GValue sidebar_size = { 0, }; GValue sidebar_page = { 0, }; GValue sidebar_visibility = { 0, }; @@ -634,19 +632,19 @@ setup_sidebar_from_metadata (EvWindow *window, EvDocument *document) gtk_paned_set_position (GTK_PANED (window->priv->hpaned), g_value_get_int (&sidebar_size)); } - - if (ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) { + + if (document && ev_metadata_manager_get (uri, "sidebar_page", &sidebar_page, FALSE)) { const char *page_id = g_value_get_string (&sidebar_page); - if (strcmp (page_id, "links") == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) { + if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) { ev_sidebar_set_page (EV_SIDEBAR (sidebar), links); - } else if (strcmp (page_id, "thumbnails") && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) { + } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) { + ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs); + } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) { ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs); } - } else { - if (ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) { - ev_sidebar_set_page (EV_SIDEBAR (sidebar), links); - } + } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) { + ev_sidebar_set_page (EV_SIDEBAR (sidebar), links); } if (ev_metadata_manager_get (uri, "sidebar_visibility", &sidebar_visibility, FALSE)) { @@ -764,7 +762,6 @@ ev_window_setup_document (EvWindow *ev_window) EvDocument *document; EvView *view = EV_VIEW (ev_window->priv->view); EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar); - EvAttachmentBar *attachbar = EV_ATTACHMENT_BAR (ev_window->priv->attachment_bar); GtkAction *action; document = ev_window->priv->document; @@ -785,11 +782,6 @@ ev_window_setup_document (EvWindow *ev_window) } ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT); - ev_attachment_bar_set_document (attachbar, document); - update_chrome_flag (ev_window, EV_CHROME_ATTACHBAR, - (ev_window->priv->document && - ev_document_has_attachments (ev_window->priv->document))); - ev_window_title_set_document (ev_window->priv->title, document); ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri); @@ -1183,9 +1175,7 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) ev_document_factory_add_filters (fc, ev_window->priv->document); gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK); -#ifdef HAVE_GTK_FILE_CHOOSER_SET_DO_OVERWRITE_CONFIRMATION gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (fc), TRUE); -#endif file_name = gnome_vfs_format_uri_for_display (ev_window->priv->uri); base_name = g_path_get_basename (file_name); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), base_name); @@ -1662,7 +1652,7 @@ ev_window_create_fullscreen_popup (EvWindow *window) GdkScreen *screen; window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model - (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP)); + (window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL); popup = gtk_window_new (GTK_WINDOW_POPUP); hbox = gtk_hbox_new (FALSE, 0); @@ -1998,8 +1988,6 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window) gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor); - egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor), - DATADIR "/evince-toolbar.xml"); egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), TRUE); @@ -2380,16 +2368,16 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) }; const char *license[] = { - 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" + N_("Evince is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2 of the License, or " "(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" + N_("Evince is distributed in the hope that it will be useful, " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " "GNU General Public License for more details.\n"), - N_("You should have received a copy of the GNU General Public License\n" - "along with Evince; if not, write to the Free Software Foundation, Inc.,\n" + N_("You should have received a copy of the GNU General Public License " + "along with Evince; if not, write to the Free Software Foundation, Inc., " "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n") }; @@ -2423,6 +2411,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) "documenters", documenters, "translator-credits", _("translator-credits"), "logo-icon-name", "evince", + "wrap-license", TRUE, NULL); g_free (comments); @@ -2460,6 +2449,8 @@ ev_window_sidebar_current_page_changed_cb (EvSidebar *ev_sidebar, id = LINKS_SIDEBAR_ID; } else if (current_page == ev_window->priv->sidebar_thumbs) { id = THUMBNAILS_SIDEBAR_ID; + } else if (current_page == ev_window->priv->sidebar_attachments) { + id = ATTACHMENTS_SIDEBAR_ID; } else { g_assert_not_reached(); } @@ -2483,25 +2474,12 @@ ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GTK_WIDGET_VISIBLE (ev_sidebar)); if (!ev_view_get_presentation (view) && - !ev_view_get_fullscreen (view) && - !ev_window_is_empty (ev_window)) { + !ev_view_get_fullscreen (view)) { ev_metadata_manager_set_boolean (ev_window->priv->uri, "sidebar_visibility", GTK_WIDGET_VISIBLE (ev_sidebar)); } } -static void -ev_window_attachment_bar_toggled_cb (EvAttachmentBar *ev_attachbar, - GParamSpec *param_spec, - EvWindow *ev_window) -{ - if (gtk_expander_get_expanded (GTK_EXPANDER (ev_attachbar))) { - gtk_widget_grab_focus (GTK_WIDGET (ev_attachbar)); - } else { - gtk_widget_grab_focus (ev_window->priv->view); - } -} - static gboolean view_menu_popup_cb (EvView *view, EvLink *link, @@ -2565,7 +2543,7 @@ view_menu_popup_cb (EvView *view, } static gboolean -attachment_bar_menu_popup_cb (EvAttachmentBar *attachbar, +attachment_bar_menu_popup_cb (EvSidebarAttachments *attachbar, GList *attach_list, EvWindow *ev_window) { @@ -3468,10 +3446,7 @@ ev_attachment_popup_cmd_save_attachment_as (GtkAction *action, EvWindow *window) NULL); gtk_dialog_set_default_response (GTK_DIALOG (fc), GTK_RESPONSE_OK); - -#ifdef HAVE_GTK_FILE_CHOOSER_SET_DO_OVERWRITE_CONFIRMATION gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fc), TRUE); -#endif if (attachment) gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fc), @@ -3571,7 +3546,7 @@ ev_window_init (EvWindow *ev_window) gtk_widget_show (toolbar_dock); ev_window->priv->toolbar = egg_editable_toolbar_new_with_model - (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP)); + (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP), NULL); egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), "DefaultToolBar"); gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar, @@ -3596,6 +3571,7 @@ ev_window_init (EvWindow *ev_window) gtk_widget_show (ev_window->priv->sidebar); /* Stub sidebar, for now */ + sidebar_widget = ev_sidebar_links_new (); ev_window->priv->sidebar_links = sidebar_widget; g_signal_connect (sidebar_widget, @@ -3611,6 +3587,15 @@ ev_window_init (EvWindow *ev_window) ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), sidebar_widget); + sidebar_widget = ev_sidebar_attachments_new (); + ev_window->priv->sidebar_attachments = sidebar_widget; + g_signal_connect_object (sidebar_widget, + "popup", + G_CALLBACK (attachment_bar_menu_popup_cb), + ev_window, 0); + ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), + sidebar_widget); + sidebar_widget = ev_sidebar_thumbnails_new (); ev_window->priv->sidebar_thumbs = sidebar_widget; g_signal_connect (sidebar_widget, @@ -3622,7 +3607,6 @@ ev_window_init (EvWindow *ev_window) ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar), sidebar_widget); - ev_window->priv->scrolled_window = GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW, "shadow-type", GTK_SHADOW_IN, @@ -3654,16 +3638,6 @@ ev_window_init (EvWindow *ev_window) gtk_widget_show (ev_window->priv->view); gtk_widget_show (ev_window->priv->password_view); - /* Attachments Bar */ - ev_window->priv->attachment_bar = ev_attachment_bar_new (); - gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box), - ev_window->priv->attachment_bar, - FALSE, TRUE, 0); - g_signal_connect_object (ev_window->priv->attachment_bar, - "popup", - G_CALLBACK (attachment_bar_menu_popup_cb), - ev_window, 0); - /* Find Bar */ ev_window->priv->find_bar = egg_find_bar_new (); gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box), @@ -3716,12 +3690,6 @@ ev_window_init (EvWindow *ev_window) G_CALLBACK (ev_window_sidebar_current_page_changed_cb), ev_window); - /* Connect attachment bar sgignals */ - g_signal_connect (G_OBJECT (ev_window->priv->attachment_bar), - "notify::expanded", - G_CALLBACK (ev_window_attachment_bar_toggled_cb), - ev_window); - /* Connect to find bar signals */ g_signal_connect (ev_window->priv->find_bar, "previous", @@ -3785,6 +3753,7 @@ ev_window_init (EvWindow *ev_window) gtk_window_set_default_size (GTK_WINDOW (ev_window), 600, 600); setup_view_from_metadata (ev_window); + setup_sidebar_from_metadata (ev_window, NULL); ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window); ev_window_setup_action_sensitivity (ev_window);