From: Sebastian Harl Date: Thu, 8 Dec 2011 07:10:58 +0000 (+0100) Subject: tpdfview: Let 'F' toggle fullscreen mode. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c3bb0049acc46995d2166022bdcf6cc3568f20b1;p=tpdfview.git tpdfview: Let 'F' toggle fullscreen mode. --- diff --git a/src/tpdfview.c b/src/tpdfview.c index 0d37559..b98332d 100644 --- a/src/tpdfview.c +++ b/src/tpdfview.c @@ -88,6 +88,22 @@ exit_version(void) exit(0); } /* exit_version */ +static void +toggle_fullscreen(GtkWindow *win) +{ + GdkWindowState state; + + if (! gtk_widget_get_realized(GTK_WIDGET(win))) + return; + + state = gdk_window_get_state(GTK_WIDGET(win)->window); + + if (state & GDK_WINDOW_STATE_FULLSCREEN) + gtk_window_unfullscreen(win); + else + gtk_window_fullscreen(win); +} /* toggle_fullscreen */ + static void on_destroy(GtkWidget __attribute__((unused)) *widget, gpointer __attribute__((unused)) data) @@ -96,8 +112,7 @@ on_destroy(GtkWidget __attribute__((unused)) *widget, } /* on_destroy */ static gboolean -key_press(GtkWidget __attribute__((unused)) *widget, - GdkEventKey *event, gpointer data) +key_press(GtkWidget *window, GdkEventKey *event, gpointer data) { GtkWidget *tpdfv; @@ -113,6 +128,10 @@ key_press(GtkWidget __attribute__((unused)) *widget, gtk_tpdfv_reload(tpdfv); break; + case GDK_F: + toggle_fullscreen(GTK_WINDOW(window)); + break; + /* navigation */ case GDK_Page_Up: gtk_tpdfv_page_up(tpdfv);