Code

tpdfview: Let 'F' toggle fullscreen mode.
authorSebastian Harl <sh@tokkee.org>
Thu, 8 Dec 2011 07:10:58 +0000 (08:10 +0100)
committerSebastian Harl <sh@tokkee.org>
Thu, 8 Dec 2011 07:10:58 +0000 (08:10 +0100)
src/tpdfview.c

index 0d3755958a800a9bb511ccacde5ef3e02678a2e2..b98332d178032382ac7bfb9fccf30ab9cb474073 100644 (file)
@@ -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);