X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-window.c;h=d76fddc1486dc34ea3276892190e98cd97d904cf;hb=ffc1f12a9dd407c4924960276a018ec785c3740b;hp=3c41017d46c141b4d1d1f2981acc8fa468516b40;hpb=62844084382c2c4fcf8baf960ce84d99b7b9093d;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index 3c41017d..d76fddc1 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -51,6 +51,7 @@ #include "ephy-zoom.h" #include "ev-application.h" +#include "ev-dualscreen.h" #include "ev-document-factory.h" #include "ev-document-find.h" #include "ev-document-fonts.h" @@ -309,9 +310,9 @@ static void ev_window_stop_fullscreen (EvWindow *windo gboolean unfullscreen_window); static void ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window); -static void ev_window_run_presentation (EvWindow *window); -static void ev_window_stop_presentation (EvWindow *window, - gboolean unfullscreen_window); +static void ev_window_run_presentation_wrapper (EvWindow *window); +static void ev_window_stop_presentation_wrapper (EvWindow *window, + gboolean unfullscreen_window); static void ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window); static void ev_view_popup_cmd_open_link (GtkAction *action, @@ -370,6 +371,12 @@ get_screen_dpi (EvWindow *window) return ev_document_misc_get_screen_dpi (screen); } +static gboolean +ev_window_is_editing_toolbar (EvWindow *ev_window) +{ + return egg_editable_toolbar_get_edit_mode (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar)); +} + static void ev_window_set_action_sensitive (EvWindow *ev_window, const char *name, @@ -442,6 +449,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy); ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print); ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties); + ev_window_set_action_sensitive (ev_window, "FileOpenContainingFolder", has_document); /* Edit menu */ ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text); @@ -451,6 +459,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window) ev_window_set_action_sensitive (ev_window, "EditRotateRight", has_pages); /* View menu */ + ev_window_set_action_sensitive (ev_window, "ViewToolbar", !ev_window_is_editing_toolbar (ev_window)); ev_window_set_action_sensitive (ev_window, "ViewContinuous", has_pages); ev_window_set_action_sensitive (ev_window, "ViewDual", has_pages); ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages); @@ -1018,7 +1027,7 @@ static void update_document_mode (EvWindow *window, EvDocumentMode mode) { if (mode == EV_DOCUMENT_MODE_PRESENTATION) { - ev_window_run_presentation (window); + ev_window_run_presentation_wrapper (window); } else if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) { ev_window_run_fullscreen (window); @@ -1309,7 +1318,7 @@ setup_view_from_metadata (EvWindow *window) /* Presentation */ if (ev_metadata_get_boolean (window->priv->metadata, "presentation", &presentation)) { if (presentation) { - ev_window_run_presentation (window); + ev_window_run_presentation_wrapper (window); } } } @@ -1466,9 +1475,16 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) } if (EV_WINDOW_IS_PRESENTATION (ev_window)) { + gint current_page; + + current_page = ev_view_presentation_get_current_page ( + EV_VIEW_PRESENTATION (ev_window->priv->presentation_view)); gtk_widget_destroy (ev_window->priv->presentation_view); ev_window->priv->presentation_view = NULL; - ev_window_run_presentation (ev_window); + + /* Update the model with the current presentation page */ + ev_document_model_set_page (ev_window->priv->model, current_page); + ev_window_run_presentation_wrapper (ev_window); } if (ev_window->priv->setup_document_idle > 0) @@ -1605,7 +1621,7 @@ ev_window_load_job_cb (EvJob *job, ev_window_run_fullscreen (ev_window); break; case EV_WINDOW_MODE_PRESENTATION: - ev_window_run_presentation (ev_window); + ev_window_run_presentation_wrapper (ev_window); break; default: break; @@ -2142,7 +2158,7 @@ ev_window_open_document (EvWindow *ev_window, ev_window_run_fullscreen (ev_window); break; case EV_WINDOW_MODE_PRESENTATION: - ev_window_run_presentation (ev_window); + ev_window_run_presentation_wrapper (ev_window); break; default: break; @@ -3968,7 +3984,42 @@ ev_window_view_presentation_finished (EvWindow *window) ev_window_stop_presentation (window, TRUE); } +static gboolean +ev_window_view_presentation_focus_in (EvWindow *window) +{ + ev_application_screensaver_disable (EV_APP); + + return FALSE; +} + +static gboolean +ev_window_view_presentation_focus_out (EvWindow *window) +{ + ev_application_screensaver_enable (EV_APP); + + return FALSE; +} + +static void +ev_window_run_presentation_wrapper (EvWindow *window) +{ + if ( get_num_monitors(GTK_WINDOW(window)) > 1) { + EvWindow *presentation_window = window; + EvDSCWindow *control = ev_dscwindow_get_control(); + + ev_dscwindow_set_presentation (control, presentation_window, + presentation_window->priv->document); + gtk_window_present (GTK_WINDOW (control)); + } else + ev_window_run_presentation (window); + +} static void +ev_window_stop_presentation_wrapper(EvWindow *window, gboolean unfullscreen_window) +{ +} + +void ev_window_run_presentation (EvWindow *window) { gboolean fullscreen_window = TRUE; @@ -3997,6 +4048,12 @@ ev_window_run_presentation (EvWindow *window) g_signal_connect_swapped (window->priv->presentation_view, "external-link", G_CALLBACK (view_external_link_cb), window); + g_signal_connect_swapped (window->priv->presentation_view, "focus-in-event", + G_CALLBACK (ev_window_view_presentation_focus_in), + window); + g_signal_connect_swapped (window->priv->presentation_view, "focus-out-event", + G_CALLBACK (ev_window_view_presentation_focus_out), + window); gtk_box_pack_start (GTK_BOX (window->priv->main_box), window->priv->presentation_view, @@ -4018,17 +4075,20 @@ ev_window_run_presentation (EvWindow *window) ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE); } -static void +void ev_window_stop_presentation (EvWindow *window, gboolean unfullscreen_window) { guint current_page; + guint rotation; if (!EV_WINDOW_IS_PRESENTATION (window)) return; current_page = ev_view_presentation_get_current_page (EV_VIEW_PRESENTATION (window->priv->presentation_view)); ev_document_model_set_page (window->priv->model, current_page); + rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (window->priv->presentation_view)); + ev_document_model_set_rotation (window->priv->model, rotation); gtk_container_remove (GTK_CONTAINER (window->priv->main_box), window->priv->presentation_view); @@ -4055,7 +4115,7 @@ ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window) presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); if (presentation) { - ev_window_run_presentation (window); + ev_window_run_presentation_wrapper (window); } } @@ -4200,17 +4260,33 @@ ev_window_set_page_mode (EvWindow *window, static void ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window) { - gint rotation = ev_document_model_get_rotation (ev_window->priv->model); + gint rotation; - ev_document_model_set_rotation (ev_window->priv->model, rotation - 90); + if (EV_WINDOW_IS_PRESENTATION (ev_window)) { + rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view)); + ev_view_presentation_set_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view), + rotation - 90); + } else { + rotation = ev_document_model_get_rotation (ev_window->priv->model); + + ev_document_model_set_rotation (ev_window->priv->model, rotation - 90); + } } static void ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window) { - gint rotation = ev_document_model_get_rotation (ev_window->priv->model); + gint rotation; + + if (EV_WINDOW_IS_PRESENTATION (ev_window)) { + rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view)); + ev_view_presentation_set_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view), + rotation + 90); + } else { + rotation = ev_document_model_get_rotation (ev_window->priv->model); - ev_document_model_set_rotation (ev_window->priv->model, rotation + 90); + ev_document_model_set_rotation (ev_window->priv->model, rotation + 90); + } } static void @@ -4231,6 +4307,7 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar); egg_editable_toolbar_set_edit_mode (toolbar, FALSE); + ev_window_set_action_sensitive (ev_window, "ViewToolbar", TRUE); toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, TRUE), "evince_toolbar.xml", NULL); @@ -4268,9 +4345,10 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window) gtk_container_set_border_width (GTK_CONTAINER (editor), 5); gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5); - gtk_container_add (GTK_CONTAINER (content_area), editor); + gtk_box_pack_start (GTK_BOX (content_area), editor, TRUE, TRUE, 0); egg_editable_toolbar_set_edit_mode (toolbar, TRUE); + ev_window_set_action_sensitive (ev_window, "ViewToolbar", FALSE); g_signal_connect (dialog, "response", G_CALLBACK (ev_window_cmd_edit_toolbar_cb), @@ -4515,7 +4593,7 @@ ev_window_cmd_leave_fullscreen (GtkAction *action, EvWindow *window) static void ev_window_cmd_start_presentation (GtkAction *action, EvWindow *window) { - ev_window_run_presentation (window); + ev_window_run_presentation_wrapper (window); } static void @@ -4740,6 +4818,8 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window) const char *documenters[] = { "Nickolay V. Shmyrev ", + "Phil Bull ", + "Tiffany Antpolski ", NULL }; @@ -4847,6 +4927,8 @@ ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, if (ev_window->priv->metadata) ev_metadata_set_boolean (ev_window->priv->metadata, "sidebar_visibility", visible); + if (!visible) + gtk_widget_grab_focus (ev_window->priv->view); } } @@ -5134,30 +5216,23 @@ find_bar_close_cb (EggFindBar *find_bar, } static void -find_bar_search_changed_cb (EggFindBar *find_bar, - GParamSpec *param, - EvWindow *ev_window) +ev_window_search_start (EvWindow *ev_window) { - gboolean case_sensitive; + EggFindBar *find_bar = EGG_FIND_BAR (ev_window->priv->find_bar); const char *search_string; if (!ev_window->priv->document || !EV_IS_DOCUMENT_FIND (ev_window->priv->document)) return; - - /* Either the string or case sensitivity could have changed. */ - case_sensitive = egg_find_bar_get_case_sensitive (find_bar); - search_string = egg_find_bar_get_search_string (find_bar); - ev_view_find_search_changed (EV_VIEW (ev_window->priv->view)); + search_string = egg_find_bar_get_search_string (find_bar); ev_window_clear_find_job (ev_window); - if (search_string && search_string[0]) { ev_window->priv->find_job = ev_job_find_new (ev_window->priv->document, ev_document_model_get_page (ev_window->priv->model), ev_document_get_n_pages (ev_window->priv->document), search_string, - case_sensitive); + egg_find_bar_get_case_sensitive (find_bar)); g_signal_connect (ev_window->priv->find_job, "finished", G_CALLBACK (ev_window_find_job_finished_cb), ev_window); @@ -5167,12 +5242,21 @@ find_bar_search_changed_cb (EggFindBar *find_bar, ev_job_scheduler_push_job (ev_window->priv->find_job, EV_JOB_PRIORITY_NONE); } else { ev_window_update_actions (ev_window); - egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), - NULL); + egg_find_bar_set_status_text (find_bar, NULL); gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view)); } } +static void +find_bar_search_changed_cb (EggFindBar *find_bar, + GParamSpec *param, + EvWindow *ev_window) +{ + /* Either the string or case sensitivity could have changed. */ + ev_view_find_search_changed (EV_VIEW (ev_window->priv->view)); + ev_window_search_start (ev_window); +} + static void find_bar_visibility_changed_cb (EggFindBar *find_bar, GParamSpec *param, @@ -5185,11 +5269,10 @@ find_bar_visibility_changed_cb (EggFindBar *find_bar, if (ev_window->priv->document && EV_IS_DOCUMENT_FIND (ev_window->priv->document)) { ev_view_find_set_highlight_search (EV_VIEW (ev_window->priv->view), visible); - ev_view_find_search_changed (EV_VIEW (ev_window->priv->view)); ev_window_update_actions (ev_window); if (visible) - find_bar_search_changed_cb (find_bar, NULL, ev_window); + ev_window_search_start (ev_window); else egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar), NULL); } @@ -5990,7 +6073,8 @@ view_actions_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, EvWindow *win #endif /* ENABLE_DBUS */ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, FALSE); - ev_window_set_action_sensitive (window, "ViewToolbar", TRUE); + ev_window_set_action_sensitive (window, "ViewToolbar", + !ev_window_is_editing_toolbar (window)); ev_window_set_view_accels_sensitivity (window, TRUE); @@ -6700,11 +6784,17 @@ ev_window_media_player_key_pressed (EvWindow *window, * often seen keys */ if (strcmp (key, "Play") == 0) { - ev_window_run_presentation (window); + ev_window_run_presentation_wrapper (window); } else if (strcmp (key, "Previous") == 0) { - ev_window_cmd_go_previous_page (NULL, window); + if (EV_WINDOW_IS_PRESENTATION (window)) + ev_view_presentation_previous_page (EV_VIEW_PRESENTATION (window->priv->presentation_view)); + else + ev_window_cmd_go_previous_page (NULL, window); } else if (strcmp (key, "Next") == 0) { - ev_window_cmd_go_next_page (NULL, window); + if (EV_WINDOW_IS_PRESENTATION (window)) + ev_view_presentation_next_page (EV_VIEW_PRESENTATION (window->priv->presentation_view)); + else + ev_window_cmd_go_next_page (NULL, window); } else if (strcmp (key, "FastForward") == 0) { ev_window_cmd_go_last_page (NULL, window); } else if (strcmp (key, "Rewind") == 0) { @@ -7078,6 +7168,10 @@ ev_window_init (EvWindow *ev_window) NULL)); g_object_unref (toolbars_model); + gtk_style_context_add_class + (gtk_widget_get_style_context (GTK_WIDGET (ev_window->priv->toolbar)), + GTK_STYLE_CLASS_PRIMARY_TOOLBAR); + egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), "DefaultToolBar"); gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),