#include "ev-utils.h"
#include "ev-keyring.h"
#include "ev-view.h"
+#include "ev-view-presentation.h"
#include "ev-view-type-builtins.h"
#include "ev-window.h"
#include "ev-window-title.h"
GtkWidget *find_bar;
GtkWidget *scrolled_window;
GtkWidget *view;
+ GtkWidget *presentation_view;
GtkWidget *message_area;
GtkWidget *password_view;
GtkWidget *sidebar_thumbs;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
- /* Presentation mode */
- guint presentation_timeout_id;
-
/* Popup view */
GtkWidget *view_popup;
EvLink *link;
#define EV_WINDOW_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
+#define EV_WINDOW_IS_PRESENTATION(w) (w->priv->presentation_view != NULL)
+
#define PAGE_SELECTOR_ACTION "PageSelector"
#define ZOOM_CONTROL_ACTION "ViewZoom"
#define NAVIGATION_ACTION "Navigation"
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
-#define PRESENTATION_TIMEOUT 5
-
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
ev_window_set_action_sensitive (ev_window, "F3",
has_pages && can_find_in_page);
- presentation_mode = ev_view_get_presentation (view);
+ presentation_mode = EV_WINDOW_IS_PRESENTATION (ev_window);
ev_window_set_action_sensitive (ev_window, "ViewZoomIn",
has_pages &&
gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
gboolean fullscreen_mode, presentation, fullscreen;
- presentation = ev_view_get_presentation (EV_VIEW (priv->view));
+ presentation = EV_WINDOW_IS_PRESENTATION (window);
fullscreen = ev_document_model_get_fullscreen (priv->model);
fullscreen_mode = fullscreen || presentation;
info = ev_document_get_info (document);
update_document_mode (ev_window, info->mode);
- gtk_widget_grab_focus (ev_window->priv->view);
+ if (EV_WINDOW_IS_PRESENTATION (ev_window))
+ gtk_widget_grab_focus (ev_window->priv->presentation_view);
+ else
+ gtk_widget_grab_focus (ev_window->priv->view);
return FALSE;
}
static void
ev_window_run_fullscreen (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
gboolean fullscreen_window = TRUE;
if (ev_document_model_get_fullscreen (window->priv->model))
window->priv->fullscreen_toolbar, 1);
}
- if (ev_view_get_presentation (view)) {
+ if (EV_WINDOW_IS_PRESENTATION (window)) {
ev_window_stop_presentation (window, FALSE);
fullscreen_window = FALSE;
}
}
}
-static gboolean
-presentation_timeout_cb (EvWindow *window)
-{
- EvView *view = EV_VIEW (window->priv->view);
-
- if (!view || !ev_view_get_presentation (EV_VIEW (view)))
- return FALSE;
-
- ev_view_hide_cursor (EV_VIEW (window->priv->view));
- window->priv->presentation_timeout_id = 0;
-
- return FALSE;
-}
-
-static void
-presentation_set_timeout (EvWindow *window)
-{
- if (window->priv->presentation_timeout_id > 0) {
- g_source_remove (window->priv->presentation_timeout_id);
- }
-
- window->priv->presentation_timeout_id =
- g_timeout_add_seconds (PRESENTATION_TIMEOUT,
- (GSourceFunc)presentation_timeout_cb, window);
-
- ev_view_show_cursor (EV_VIEW (window->priv->view));
-}
-
-static void
-presentation_clear_timeout (EvWindow *window)
-{
- if (window->priv->presentation_timeout_id > 0) {
- g_source_remove (window->priv->presentation_timeout_id);
- }
-
- window->priv->presentation_timeout_id = 0;
-
- ev_view_show_cursor (EV_VIEW (window->priv->view));
-}
-
-static gboolean
-presentation_motion_notify_cb (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- presentation_set_timeout (window);
-
- return FALSE;
-}
-
-static gboolean
-presentation_leave_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- EvWindow *window = EV_WINDOW (user_data);
-
- presentation_clear_timeout (window);
-
- return FALSE;
-}
-
static void
ev_window_update_presentation_action (EvWindow *window)
{
g_signal_handlers_block_by_func
(action, G_CALLBACK (ev_window_cmd_view_presentation), window);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- ev_view_get_presentation (EV_VIEW (window->priv->view)));
+ EV_WINDOW_IS_PRESENTATION (window));
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (ev_window_cmd_view_presentation), window);
}
static void
ev_window_run_presentation (EvWindow *window)
{
- EvView *view = EV_VIEW (window->priv->view);
gboolean fullscreen_window = TRUE;
+ guint current_page;
+ guint rotation;
- if (ev_view_get_presentation (view))
+ if (EV_WINDOW_IS_PRESENTATION (window))
return;
if (ev_document_model_get_fullscreen (window->priv->model)) {
ev_window_stop_fullscreen (window, FALSE);
fullscreen_window = FALSE;
}
-
- g_object_set (G_OBJECT (window->priv->scrolled_window),
- "shadow-type", GTK_SHADOW_NONE,
- NULL);
- ev_view_set_presentation (view, TRUE);
- ev_window_update_presentation_action (window);
+ current_page = ev_document_model_get_page (window->priv->model);
+ rotation = ev_document_model_get_rotation (window->priv->model);
+ window->priv->presentation_view =
+ ev_view_presentation_new (window->priv->document, current_page, rotation);
+ gtk_box_pack_start (GTK_BOX (window->priv->main_box),
+ window->priv->presentation_view,
+ FALSE, FALSE, 0);
+ gtk_widget_show (window->priv->presentation_view);
+
+ ev_window_update_presentation_action (window);
update_chrome_visibility (window);
-
- gtk_widget_grab_focus (window->priv->view);
+
+ gtk_widget_grab_focus (window->priv->presentation_view);
if (fullscreen_window)
gtk_window_fullscreen (GTK_WINDOW (window));
- g_signal_connect (window->priv->view,
- "motion-notify-event",
- G_CALLBACK (presentation_motion_notify_cb),
- window);
- g_signal_connect (window->priv->view,
- "leave-notify-event",
- G_CALLBACK (presentation_leave_notify_cb),
- window);
- presentation_set_timeout (window);
-
ev_application_screensaver_disable (EV_APP);
-
+
if (window->priv->metadata && !ev_window_is_empty (window))
ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE);
}
ev_window_stop_presentation (EvWindow *window,
gboolean unfullscreen_window)
{
- EvView *view = EV_VIEW (window->priv->view);
-
- if (!ev_view_get_presentation (view))
+ guint current_page;
+
+ if (!EV_WINDOW_IS_PRESENTATION (window))
return;
- g_object_set (G_OBJECT (window->priv->scrolled_window),
- "shadow-type", GTK_SHADOW_IN,
- NULL);
+ 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);
+
+ gtk_container_remove (GTK_CONTAINER (window->priv->main_box),
+ window->priv->presentation_view);
+ window->priv->presentation_view = NULL;
- ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
if (unfullscreen_window)
gtk_window_unfullscreen (GTK_WINDOW (window));
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) presentation_motion_notify_cb,
- window);
- g_signal_handlers_disconnect_by_func (window->priv->view,
- (gpointer) presentation_leave_notify_cb,
- window);
- presentation_clear_timeout (window);
+ gtk_widget_grab_focus (window->priv->view);
ev_application_screensaver_enable (EV_APP);
GdkEventWindowState *event)
{
EvWindow *window = EV_WINDOW (widget);
- EvView *view = EV_VIEW (window->priv->view);
if (GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event) {
GTK_WIDGET_CLASS (ev_window_parent_class)->window_state_event (widget, event);
return FALSE;
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) {
- if (ev_document_model_get_fullscreen (window->priv->model) || ev_view_get_presentation (view))
+ if (ev_document_model_get_fullscreen (window->priv->model) || EV_WINDOW_IS_PRESENTATION (window))
return FALSE;
ev_window_run_fullscreen (window);
} else {
if (ev_document_model_get_fullscreen (window->priv->model))
ev_window_stop_fullscreen (window, FALSE);
- else if (ev_view_get_presentation (view))
+ else if (EV_WINDOW_IS_PRESENTATION (window))
ev_window_stop_presentation (window, FALSE);
}
gtk_widget_grab_focus (window->priv->view);
} else {
gboolean fullscreen;
- gboolean presentation;
fullscreen = ev_document_model_get_fullscreen (window->priv->model);
- g_object_get (window->priv->view,
- "presentation", &presentation,
- NULL);
if (fullscreen) {
ev_window_stop_fullscreen (window, TRUE);
- } else if (presentation) {
+ } else if (EV_WINDOW_IS_PRESENTATION (window)) {
ev_window_stop_presentation (window, TRUE);
gtk_widget_grab_focus (window->priv->view);
} else {
gtk_widget_grab_focus (window->priv->view);
}
- if (fullscreen && presentation)
+ if (fullscreen && EV_WINDOW_IS_PRESENTATION (window))
g_warning ("Both fullscreen and presentation set somehow");
}
}
static void
ev_window_view_sidebar_cb (GtkAction *action, EvWindow *ev_window)
{
- if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
+ if (EV_WINDOW_IS_PRESENTATION (ev_window))
return;
update_chrome_flag (ev_window, EV_CHROME_SIDEBAR,
GParamSpec *pspec,
EvWindow *ev_window)
{
- EvView *view = EV_VIEW (ev_window->priv->view);
GtkAction *action;
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
- if (!ev_view_get_presentation (view)) {
+ if (!EV_WINDOW_IS_PRESENTATION (ev_window)) {
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
GTK_WIDGET_VISIBLE (ev_sidebar));
priv->history = NULL;
}
- if (priv->presentation_timeout_id > 0) {
- g_source_remove (priv->presentation_timeout_id);
- priv->presentation_timeout_id = 0;
- }
-
if (priv->print_queue) {
g_queue_free (priv->print_queue);
priv->print_queue = NULL;
g_object_unref (priv->view);
}
- if (!handled && !ev_view_get_presentation (EV_VIEW (priv->view))) {
+ if (!handled && !EV_WINDOW_IS_PRESENTATION (ev_window)) {
guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
if (priv->menubar_accel_keyval != 0 &&