PROP_FIND_STATUS,
PROP_CONTINUOUS,
PROP_DUAL_PAGE,
- PROP_FULL_SCREEN,
+ PROP_FULLSCREEN,
PROP_PRESENTATION,
PROP_SIZING_MODE,
};
double scale;
GtkBorder border;
- gboolean show_border;
gboolean continuous;
gboolean dual_page;
- gboolean full_screen;
+ gboolean fullscreen;
gboolean presentation;
EvSizingMode sizing_mode;
};
static void
compute_border (EvView *view, int width, int height, GtkBorder *border)
{
- if (view->show_border) {
- ev_document_misc_get_page_border_size (width, height, border);
- } else {
+ if (view->presentation) {
border->left = 0;
border->right = 0;
border->top = 0;
border->bottom = 0;
+ } else {
+ ev_document_misc_get_page_border_size (width, height, border);
}
}
gdk_window_show (view->bin_window);
widget->style = gtk_style_attach (widget->style, view->bin_window);
- gdk_window_set_background (view->bin_window, &widget->style->mid[widget->state]);
+ if (view->presentation)
+ gdk_window_set_background (view->bin_window, &widget->style->black);
+ else
+ gdk_window_set_background (view->bin_window, &widget->style->mid [GTK_STATE_NORMAL]);
if (view->document) {
/* We can't get page size without a target, so we have to
page, view->scale,
&width, &height);
- if (view->show_border)
- ev_document_misc_paint_one_page (view->bin_window,
- GTK_WIDGET (view),
- page_area, border);
+ ev_document_misc_paint_one_page (view->bin_window,
+ GTK_WIDGET (view),
+ page_area, border);
/* Render the document itself */
real_page_area = *page_area;
scaled_image = gdk_pixbuf_scale_simple (current_pixbuf,
width, height,
GDK_INTERP_NEAREST);
-
if (scaled_image) {
gdk_draw_pixbuf (view->bin_window,
GTK_WIDGET (view)->style->fg_gc[GTK_STATE_NORMAL],
case PROP_DUAL_PAGE:
ev_view_set_dual_page (view, g_value_get_boolean (value));
break;
- case PROP_FULL_SCREEN:
- ev_view_set_full_screen (view, g_value_get_boolean (value));
+ case PROP_FULLSCREEN:
+ ev_view_set_fullscreen (view, g_value_get_boolean (value));
break;
case PROP_PRESENTATION:
ev_view_set_presentation (view, g_value_get_boolean (value));
case PROP_DUAL_PAGE:
g_value_set_boolean (value, view->dual_page);
break;
- case PROP_FULL_SCREEN:
- g_value_set_boolean (value, view->full_screen);
+ case PROP_FULLSCREEN:
+ g_value_set_boolean (value, view->fullscreen);
break;
case PROP_PRESENTATION:
g_value_set_boolean (value, view->presentation);
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
- PROP_FULL_SCREEN,
- g_param_spec_boolean ("full-screen",
+ PROP_FULLSCREEN,
+ g_param_spec_boolean ("fullscreen",
"Full Screen",
- "Draw page in a full-screen fashion",
+ "Draw page in a fullscreen fashion",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
view->current_page = 0;
view->pressed_button = -1;
view->cursor = EV_VIEW_CURSOR_NORMAL;
- view->show_border = TRUE;
view->continuous = TRUE;
view->dual_page = FALSE;
view->presentation = FALSE;
- view->full_screen = FALSE;
+ view->fullscreen = FALSE;
view->sizing_mode = EV_SIZING_FIT_WIDTH;
}
}
void
-ev_view_set_full_screen (EvView *view,
- gboolean full_screen)
+ev_view_set_fullscreen (EvView *view,
+ gboolean fullscreen)
{
g_return_if_fail (EV_IS_VIEW (view));
- full_screen = full_screen != FALSE;
+ fullscreen = fullscreen != FALSE;
- if (view->full_screen != full_screen) {
- view->full_screen = full_screen;
+ if (view->fullscreen != fullscreen) {
+ view->fullscreen = fullscreen;
gtk_widget_queue_resize (GTK_WIDGET (view));
}
- g_object_notify (G_OBJECT (view), "full-screen");
+ g_object_notify (G_OBJECT (view), "fullscreen");
+}
+
+gboolean
+ev_view_get_fullscreen (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
+
+ return view->fullscreen;
}
void
presentation = presentation != FALSE;
- if (view->presentation != presentation) {
- view->presentation = presentation;
- gtk_widget_queue_resize (GTK_WIDGET (view));
+ if (view->presentation == presentation)
+ return;
+
+ view->presentation = presentation;
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+ if (GTK_WIDGET_REALIZED (view)) {
+ if (view->presentation)
+ gdk_window_set_background (view->bin_window,
+ >K_WIDGET (view)->style->black);
+ else
+ gdk_window_set_background (view->bin_window,
+ >K_WIDGET (view)->style->mid [GTK_STATE_NORMAL]);
}
+
g_object_notify (G_OBJECT (view), "presentation");
}
+gboolean
+ev_view_get_presentation (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
+
+ return view->presentation;
+}
+
void
ev_view_set_sizing_mode (EvView *view,
EvSizingMode sizing_mode)
{
g_return_if_fail (EV_IS_VIEW (view));
- if (view->sizing_mode != sizing_mode) {
- view->sizing_mode = sizing_mode;
- gtk_widget_queue_resize (GTK_WIDGET (view));
- }
+ if (view->sizing_mode == sizing_mode)
+ return;
+
+ view->sizing_mode = sizing_mode;
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+
g_object_notify (G_OBJECT (view), "sizing-mode");
}
return MIN (w_scale, h_scale);
}
+
+static void
+ev_view_zoom_for_size_presentation (EvView *view,
+ int width,
+ int height)
+{
+ int doc_width, doc_height;
+ gdouble scale;
+
+ ev_page_cache_get_size (view->page_cache,
+ view->current_page,
+ 1.0,
+ &doc_width,
+ &doc_height);
+ scale = zoom_for_size_best_fit (doc_width, doc_height, width, height, 0, 0);
+ ev_view_zoom (view, scale, FALSE);
+}
+
static void
ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
int width,
if (view->document == NULL)
return;
- if (view->continuous && view->dual_page)
+ if (view->presentation)
+ ev_view_zoom_for_size_presentation (view, width, height);
+ else if (view->continuous && view->dual_page)
ev_view_zoom_for_size_continuous_and_dual_page (view, width, height, vsb_width, hsb_height);
else if (view->continuous)
ev_view_zoom_for_size_continuous (view, width, height, vsb_width, hsb_height);
char *password_uri;
EvChrome chrome;
- gboolean fullscreen_mode;
GSource *fullscreen_timeout_source;
/* recent file stuff */
#define SIDEBAR_DEFAULT_SIZE 132
-static void ev_window_update_fullscreen_popup (EvWindow *window);
-static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
- EvWindow *ev_window);
-static void ev_window_set_page_mode (EvWindow *window,
- EvWindowPageMode page_mode);
-static gboolean start_loading_document (EvWindow *ev_window,
- EvDocument *document,
- const char *uri);
-static void ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
- EvWindow *ev_window);
-static void ev_window_add_recent (EvWindow *window, const char *filename);
-static void ev_window_fullscreen (EvWindow *window);
+static void ev_window_update_fullscreen_popup (EvWindow *window);
+static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar,
+ GParamSpec *pspec,
+ EvWindow *ev_window);
+static void ev_window_set_page_mode (EvWindow *window,
+ EvWindowPageMode page_mode);
+static gboolean start_loading_document (EvWindow *ev_window,
+ EvDocument *document,
+ const char *uri);
+static void ev_window_sizing_mode_changed_cb (EvView *view,
+ GParamSpec *pspec,
+ EvWindow *ev_window);
+static void ev_window_add_recent (EvWindow *window,
+ const char *filename);
+static void ev_window_fullscreen (EvWindow *window);
+static void ev_window_unfullscreen (EvWindow *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);
+static void ev_window_cmd_view_presentation (GtkAction *action,
+ EvWindow *window);
+
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
{
EvWindowPrivate *priv = window->priv;
gboolean menubar, toolbar, sidebar, findbar, statusbar, fullscreen_toolbar;
+ gboolean fullscreen_mode, presentation, fullscreen;
+
+ presentation = ev_view_get_presentation (EV_VIEW (priv->view));
+ fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
+ fullscreen_mode = fullscreen || presentation;
- menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !priv->fullscreen_mode;
- toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !priv->fullscreen_mode;
- sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !priv->fullscreen_mode;
+ menubar = (priv->chrome & EV_CHROME_MENUBAR) != 0 && !fullscreen_mode;
+ toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0 && !fullscreen_mode;
+ sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !fullscreen_mode;
fullscreen_toolbar = (priv->chrome & EV_CHROME_TOOLBAR) != 0;
- statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !priv->fullscreen_mode;
+ statusbar = (priv->chrome & EV_CHROME_STATUSBAR) != 0 && !fullscreen_mode;
findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
set_widget_visibility (priv->menubar, menubar);
set_widget_visibility (priv->fullscreen_toolbar, fullscreen_toolbar);
if (priv->fullscreen_popup != NULL) {
- set_widget_visibility (priv->fullscreen_popup, priv->fullscreen_mode);
+ set_widget_visibility (priv->fullscreen_popup, fullscreen);
}
}
{
gboolean continuous;
+ ev_window_stop_presentation (ev_window);
continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"continuous", continuous,
{
gboolean dual_page;
+ ev_window_stop_presentation (ev_window);
dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_object_set (G_OBJECT (ev_window->priv->view),
"dual-page", dual_page,
static void
ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
{
+ ev_window_stop_presentation (ev_window);
+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
} else {
static void
ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
{
+ ev_window_stop_presentation (ev_window);
+
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
} else {
update_document_mode (EvWindow *window, EvDocumentMode mode)
{
if (mode == EV_DOCUMENT_MODE_FULL_SCREEN) {
- gtk_window_fullscreen (GTK_WINDOW (window));
+ ev_window_fullscreen (window);
+ } else if (mode == EV_DOCUMENT_MODE_PRESENTATION) {
+ ev_window_run_presentation (window);
}
}
return popup;
}
+
static void
-ev_window_fullscreen (EvWindow *window)
+ev_window_update_fullscreen_action (EvWindow *window)
{
- window->priv->fullscreen_mode = TRUE;
+ GtkAction *action;
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewFullscreen");
+ g_signal_handlers_block_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ ev_view_get_fullscreen (EV_VIEW (window->priv->view)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
+}
+
+static void
+ev_window_fullscreen (EvWindow *window)
+{
+ ev_view_set_fullscreen (EV_VIEW (window->priv->view), TRUE);
if (window->priv->fullscreen_popup == NULL)
window->priv->fullscreen_popup
= ev_window_create_fullscreen_popup (window);
fullscreen_set_timeout (window);
gtk_widget_grab_focus (window->priv->view);
-
+ ev_window_update_fullscreen_action (window);
+ gtk_window_fullscreen (GTK_WINDOW (window));
ev_window_update_fullscreen_popup (window);
}
{
EvView *view = EV_VIEW (window->priv->view);
- window->priv->fullscreen_mode = FALSE;
-
+ ev_view_set_fullscreen (view, FALSE);
g_object_set (G_OBJECT (window->priv->scrolled_window),
"shadow-type", GTK_SHADOW_IN,
NULL);
g_signal_handlers_disconnect_by_func (view,
(gpointer) fullscreen_motion_notify_cb,
window);
-
- g_object_set (G_OBJECT (view),
- "full-screen", FALSE,
- NULL);
+ g_signal_handlers_disconnect_by_func (view,
+ (gpointer) fullscreen_leave_notify_cb,
+ window);
+ ev_window_update_fullscreen_action (window);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
update_chrome_visibility (window);
}
static void
ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
{
- EvView *view;
gboolean fullscreen;
g_return_if_fail (EV_IS_WINDOW (window));
+ ev_window_stop_presentation (window);
- view = EV_VIEW (window->priv->view);
fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-
if (fullscreen) {
- gtk_window_fullscreen (GTK_WINDOW (window));
+ ev_window_fullscreen (window);
} else {
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ ev_window_unfullscreen (window);
}
+}
+
+static void
+ev_window_update_presentation_action (EvWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->priv->action_group, "ViewPresentation");
+ 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)));
+ g_signal_handlers_unblock_by_func
+ (action, G_CALLBACK (ev_window_cmd_view_presentation), window);
+}
- g_object_set (G_OBJECT (view),
- "full-screen", TRUE,
+static void
+ev_window_run_presentation (EvWindow *window)
+{
+ g_object_set (G_OBJECT (window->priv->scrolled_window),
+ "shadow-type", GTK_SHADOW_NONE,
NULL);
+
+ gtk_widget_grab_focus (window->priv->view);
+ ev_view_set_presentation (EV_VIEW (window->priv->view), TRUE);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
+}
+
+static void
+ev_window_stop_presentation (EvWindow *window)
+{
+ if (! ev_view_get_presentation (EV_VIEW (window->priv->view)))
+ return;
+
+ g_object_set (G_OBJECT (window->priv->scrolled_window),
+ "shadow-type", GTK_SHADOW_IN,
+ NULL);
+ ev_view_set_presentation (EV_VIEW (window->priv->view), FALSE);
+ gtk_window_unfullscreen (GTK_WINDOW (window));
+ ev_window_update_presentation_action (window);
+ update_chrome_visibility (window);
+}
+
+static void
+ev_window_cmd_view_presentation (GtkAction *action, EvWindow *window)
+{
+ gboolean presentation;
+
+ g_return_if_fail (EV_IS_WINDOW (window));
+
+ presentation = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (presentation) {
+ ev_window_run_presentation (window);
+ } else {
+ ev_window_stop_presentation (window);
+ }
}
static gboolean
show);
}
- if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
- GtkActionGroup *action_group;
- GtkAction *action;
- gboolean fullscreen;
-
- fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
-
- if (fullscreen) {
- ev_window_fullscreen (window);
- } else {
- ev_window_unfullscreen (window);
- }
-
- action_group = window->priv->action_group;
-
- action = gtk_action_group_get_action (action_group, "ViewFullscreen");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (ev_window_cmd_view_fullscreen), window);
- }
-
return FALSE;
}
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
+ gboolean fullscreen;
- if (priv->fullscreen_mode)
- {
+ g_object_get (priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
+
+ if (fullscreen)
gtk_widget_show (priv->fullscreen_popup);
- }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_in_event (widget, event);
}
{
EvWindow *window = EV_WINDOW (widget);
EvWindowPrivate *priv = window->priv;
+ gboolean fullscreen;
- if (priv->fullscreen_mode)
- {
+ g_object_get (priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
+
+ if (fullscreen)
gtk_widget_hide (priv->fullscreen_popup);
- }
return GTK_WIDGET_CLASS (ev_window_parent_class)->focus_out_event (widget, event);
}
if (widget && gtk_widget_get_ancestor (widget, EGG_TYPE_FIND_BAR)) {
update_chrome_flag (window, EV_CHROME_FINDBAR, NULL, FALSE);
} else {
- gtk_window_unfullscreen (GTK_WINDOW (window));
+ gboolean fullscreen;
+ gboolean presentation;
+
+ g_object_get (window->priv->view,
+ "fullscreen", &fullscreen,
+ "presentation", &presentation,
+ NULL);
+
+ if (fullscreen)
+ ev_window_unfullscreen (window);
+ if (presentation)
+ ev_window_stop_presentation (window);
+
+ if (fullscreen && presentation)
+ g_warning ("Both fullscreen and presentation set somehow");
}
}
EvWindow *ev_window)
{
GtkAction *action;
- gboolean visible;
+ gboolean visible, fullscreen;
+ g_object_get (ev_window->priv->view,
+ "fullscreen", &fullscreen,
+ NULL);
visible = GTK_WIDGET_VISIBLE (ev_sidebar);
/* In fullscreen mode the sidebar is not visible,
* but we don't want to update the chrome
*/
- if (ev_window->priv->fullscreen_mode)
+ if (fullscreen)
return;
action = gtk_action_group_get_action (ev_window->priv->action_group, "ViewSidebar");
{ "ViewFullscreen", NULL, N_("_Fullscreen"), "F11",
N_("Expand the window to fill the screen"),
G_CALLBACK (ev_window_cmd_view_fullscreen) },
+ { "ViewPresentation", NULL, N_("_Presentation"), "F12",
+ N_("Run document as a presentation"),
+ G_CALLBACK (ev_window_cmd_view_presentation) },
{ "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
N_("Make the current document fill the window"),
G_CALLBACK (ev_window_cmd_view_best_fit) },