From: Carlos Garcia Campos Date: Sun, 10 Dec 2006 20:49:12 +0000 (+0000) Subject: Blank screen in presentation mode when pressing 'b' (filling with black) X-Git-Tag: EVINCE_0_7_0~27 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=913ada1452d003b49919126cd4cb2c91842bfdcd;p=evince.git Blank screen in presentation mode when pressing 'b' (filling with black) 2006-12-10 Carlos Garcia Campos * shell/ev-view-private.h: * shell/ev-view.c: (draw_end_presentation_page), (ev_view_expose_event), (ev_view_key_press_event), (ev_view_class_init), (ev_view_init): Blank screen in presentation mode when pressing 'b' (filling with black) or 'w' (filling with white) keys. Fixes bug #358132. --- diff --git a/ChangeLog b/ChangeLog index dceee97e..59c8ef4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-12-10 Carlos Garcia Campos + + * shell/ev-view-private.h: + * shell/ev-view.c: (draw_end_presentation_page), + (ev_view_expose_event), (ev_view_key_press_event), + (ev_view_class_init), (ev_view_init): + + Blank screen in presentation mode when pressing 'b' (filling with + black) or 'w' (filling with white) keys. Fixes bug #358132. + 2006-12-09 Gabriel Felipe Cornejo * data/evince-toolbar.xml: diff --git a/shell/ev-view-private.h b/shell/ev-view-private.h index 7278a509..36053c31 100644 --- a/shell/ev-view-private.h +++ b/shell/ev-view-private.h @@ -57,6 +57,13 @@ typedef enum { EV_VIEW_CURSOR_DRAG } EvViewCursor; +typedef enum { + EV_PRESENTATION_NORMAL, + EV_PRESENTATION_BLACK, + EV_PRESENTATION_WHITE, + EV_PRESENTATION_END +} EvPresentationState; + struct _EvView { GtkWidget parent_instance; @@ -98,7 +105,7 @@ struct _EvView { gboolean dual_page; gboolean fullscreen; gboolean presentation; - gboolean end_presentation; + EvPresentationState presentation_state; EvSizingMode sizing_mode; /* Common for button press handling */ diff --git a/shell/ev-view.c b/shell/ev-view.c index 62940986..9a37136c 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -1795,7 +1795,7 @@ draw_end_presentation_page (EvView *view, gchar *markup; const gchar *text = _("End of presentation, press Escape to exit."); - if (!view->end_presentation) + if (view->presentation_state != EV_PRESENTATION_END) return; layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), NULL); @@ -1829,15 +1829,24 @@ ev_view_expose_event (GtkWidget *widget, EvView *view = EV_VIEW (widget); int i; - if (view->end_presentation) { - GdkRectangle area = {0}; - - area.width = widget->allocation.width; - area.height = widget->allocation.height; - - draw_end_presentation_page (view, &area); + if (view->presentation) { + switch (view->presentation_state) { + case EV_PRESENTATION_END: { + GdkRectangle area = {0}; - return FALSE; + area.width = widget->allocation.width; + area.height = widget->allocation.height; + + draw_end_presentation_page (view, &area); + } + return FALSE; + case EV_PRESENTATION_BLACK: + case EV_PRESENTATION_WHITE: + return FALSE; + case EV_PRESENTATION_NORMAL: + default: + break; + } } if (view->loading) { @@ -2167,6 +2176,60 @@ ev_view_button_release_event (GtkWidget *widget, return FALSE; } +static gboolean +ev_view_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + EvView *view = EV_VIEW (widget); + EvPresentationState current; + + if (!view->presentation || + view->presentation_state == EV_PRESENTATION_END) + return FALSE; + + current = view->presentation_state; + + switch (event->keyval) { + case GDK_b: + case GDK_B: + view->presentation_state = + (view->presentation_state == EV_PRESENTATION_BLACK) ? + EV_PRESENTATION_NORMAL : EV_PRESENTATION_BLACK; + break; + case GDK_w: + case GDK_W: + view->presentation_state = + (view->presentation_state == EV_PRESENTATION_WHITE) ? + EV_PRESENTATION_NORMAL : EV_PRESENTATION_WHITE; + break; + default: + if (view->presentation_state == EV_PRESENTATION_BLACK || + view->presentation_state == EV_PRESENTATION_WHITE) { + view->presentation_state = EV_PRESENTATION_NORMAL; + } + } + + if (current == view->presentation_state) + return FALSE; + + switch (view->presentation_state) { + case EV_PRESENTATION_NORMAL: + case EV_PRESENTATION_BLACK: + gdk_window_set_background (widget->window, + &widget->style->black); + break; + case EV_PRESENTATION_WHITE: + gdk_window_set_background (widget->window, + &widget->style->white); + break; + default: + return FALSE; + } + + gtk_widget_queue_draw (widget); + return TRUE; +} + static gint ev_view_focus_in (GtkWidget *widget, GdkEventFocus *event) @@ -2648,6 +2711,7 @@ ev_view_class_init (EvViewClass *class) widget_class->button_press_event = ev_view_button_press_event; widget_class->motion_notify_event = ev_view_motion_notify_event; widget_class->button_release_event = ev_view_button_release_event; + widget_class->key_press_event = ev_view_key_press_event; widget_class->focus_in_event = ev_view_focus_in; widget_class->focus_out_event = ev_view_focus_out; widget_class->get_accessible = ev_view_get_accessible; @@ -2821,7 +2885,7 @@ ev_view_init (EvView *view) view->continuous = TRUE; view->dual_page = FALSE; view->presentation = FALSE; - view->end_presentation = FALSE; + view->presentation_state = EV_PRESENTATION_NORMAL; view->fullscreen = FALSE; view->sizing_mode = EV_SIZING_FIT_WIDTH; view->pending_scroll = SCROLL_TO_KEEP_POSITION; @@ -3112,7 +3176,7 @@ ev_view_set_presentation (EvView *view, return; if (!presentation) - view->end_presentation = FALSE; + view->presentation_state = EV_PRESENTATION_NORMAL; view->presentation = presentation; view->pending_scroll = SCROLL_TO_PAGE_POSITION; @@ -4224,6 +4288,19 @@ ev_view_show_cursor (EvView *view) ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); } +static void +ev_view_reset_presentation_state (EvView *view) +{ + if (!view->presentation || + view->presentation_state == EV_PRESENTATION_NORMAL) + return; + + view->presentation_state = EV_PRESENTATION_NORMAL; + gdk_window_set_background (GTK_WIDGET (view)->window, + >K_WIDGET (view)->style->black); + gtk_widget_queue_draw (GTK_WIDGET (view)); +} + gboolean ev_view_next_page (EvView *view) { @@ -4234,6 +4311,8 @@ ev_view_next_page (EvView *view) if (!view->page_cache) return FALSE; + ev_view_reset_presentation_state (view); + page = ev_page_cache_get_current_page (view->page_cache); n_pages = ev_page_cache_get_n_pages (view->page_cache); @@ -4246,7 +4325,7 @@ ev_view_next_page (EvView *view) ev_page_cache_set_current_page (view->page_cache, page); return TRUE; } else if (view->presentation && page == n_pages) { - view->end_presentation = TRUE; + view->presentation_state = EV_PRESENTATION_END; gtk_widget_queue_draw (GTK_WIDGET (view)); return TRUE; } else if (view->dual_page && page == n_pages) { @@ -4267,12 +4346,14 @@ ev_view_previous_page (EvView *view) if (!view->page_cache) return FALSE; - if (view->end_presentation) { - view->end_presentation = FALSE; - gtk_widget_queue_draw (GTK_WIDGET (view)); + if (view->presentation && + view->presentation_state == EV_PRESENTATION_END) { + ev_view_reset_presentation_state (view); return TRUE; } + ev_view_reset_presentation_state (view); + page = ev_page_cache_get_current_page (view->page_cache); if (view->dual_page && !view->presentation)