[Xfce4-commits] <ristretto:ristretto-0.0> Improve behaviour when in fullscreen mode

Stephan Arts noreply at xfce.org
Sun Oct 23 19:13:08 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to c75595516827f2c6fc5552e81335088a3af7da48 (commit)
       from 81c13825b177d82b6f72cb06b8e28cbae9fa8163 (commit)

commit c75595516827f2c6fc5552e81335088a3af7da48
Author: Stephan Arts <stephan at xfce.org>
Date:   Thu Apr 30 09:26:43 2009 +0200

    Improve behaviour when in fullscreen mode

 ChangeLog              |   13 ++++---
 src/main_window.c      |   95 ++++++++++++++++++++++++++++++++++++++++++++++--
 src/main_window_ui.xml |   11 ++++++
 src/picture_viewer.c   |    3 +-
 4 files changed, 112 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8f2b249..1f87082 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,23 +1,26 @@
 2009-04-30  Stephan Arts <stephan at xfce.org>
 
 	* src/main_window.c
-	  src/pictureviewer.c
-	  src/pictureviewer.h: Let the pictureviewer figure out the fullscreen-
+	  src/picture_viewer.c
+	  src/picture_viewer.h: Let the pictureviewer figure out the fullscreen-
 	  state of it's parent-window by itself
+	* src/main_window.c
+	  src/main_window_ui.xml: Add 'fullscreen-toolbar' with controls when in
+	  fullscreen-mode.
 
 2009-04-28  Stephan Arts <stephan at xfce.org>
 
 	* src/image.c
-	  src/pictureviewer.c: Emit 'prepared' signal when the size-prepared signal
+	  src/picture_viewer.c: Emit 'prepared' signal when the size-prepared signal
 	  is emitted, instead of waiting for the area-prepared signal. When the
 	  image is rendered at a different scale then 'maximum', the 
 	  'area-prepared', 'area-updated' and 'closed' signals are all emitted at 
 	  once. Then the thumbnail is not displayed when the image is not ready yet.
-	* src/pictureviewer.c: Do not repaint the image when the image is
+	* src/picture_viewer.c: Do not repaint the image when the image is
 	  'prepared' but there is no thumbnail available. This will prevent the
 	  image from flickering.
 	* src/image_cache.c: Implement 'enable'/'disable' of image-cache
 	* src/main_window_ui.xml
 	  src/main_window.c: Remove properties dialog menu item
-	* src/pictureviewer.c: Add a 'fullscreen' state, setting a different
+	* src/picture_viewer.c: Add a 'fullscreen' state, setting a different
 	  background-color if it is in fullscreen.
diff --git a/src/main_window.c b/src/main_window.c
index bc688da..a719125 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -57,6 +57,7 @@ struct _RsttoMainWindowPriv
         gboolean        toolbar_visible;
     } props;
 
+    guint show_fs_toolbar_timeout_id;
     gint window_save_geometry_timer_id;
 
     RsttoNavigatorIter *iter;
@@ -68,6 +69,7 @@ struct _RsttoMainWindowPriv
 
     GtkWidget *menubar;
     GtkWidget *toolbar;
+    GtkWidget *fs_toolbar;
     GtkWidget *picture_viewer;
     GtkWidget *p_viewer_s_window;
     GtkWidget *statusbar;
@@ -75,6 +77,8 @@ struct _RsttoMainWindowPriv
     guint      recent_merge_id;
     guint      play_merge_id;
     guint      pause_merge_id;
+    guint      fs_play_merge_id;
+    guint      fs_pause_merge_id;
 
     GtkAction *play_action;
     GtkAction *pause_action;
@@ -114,6 +118,8 @@ static gboolean
 cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event);
 static void
 cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data);
+static gboolean
+cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
 
 static void
 cb_rstto_main_window_navigator_new_image (RsttoNavigator *navigator, RsttoImage *image, RsttoMainWindow *window);
@@ -177,6 +183,11 @@ cb_rstto_main_window_contents (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_quit (GtkWidget *widget, RsttoMainWindow *window);
 
+static gboolean 
+cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
+                                             GdkEventMotion *event,
+                                             gpointer user_data);
+
 static void
 rstto_main_window_set_sensitive (RsttoMainWindow *window, gboolean sensitive);
 
@@ -290,6 +301,8 @@ rstto_main_window_init (RsttoMainWindow *window)
     window->priv->recent_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
     window->priv->play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
     window->priv->pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+    window->priv->fs_play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
+    window->priv->fs_pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
 
 
     window->priv->play_action = gtk_action_new ("play", "_Play", "Play slideshow", GTK_STOCK_MEDIA_PLAY);
@@ -329,6 +342,7 @@ rstto_main_window_init (RsttoMainWindow *window)
     gtk_ui_manager_add_ui_from_string (window->priv->ui_manager,main_window_ui, main_window_ui_length, NULL);
     window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
     window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");
+    window->priv->fs_toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/fullscreen-toolbar");
 
     /**
      * Get the separator toolitem and tell it to expand
@@ -337,6 +351,10 @@ rstto_main_window_init (RsttoMainWindow *window)
     gtk_tool_item_set_expand (GTK_TOOL_ITEM (separator), TRUE);
     gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separator), FALSE);
 
+    separator = gtk_ui_manager_get_widget (window->priv->ui_manager, "/fullscreen-toolbar/separator-1");
+    gtk_tool_item_set_expand (GTK_TOOL_ITEM (separator), TRUE);
+    gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separator), FALSE);
+
     /**
      * Make the back and forward toolitems important,
      * when they are, the labels are shown when the toolbar style is 'both-horizontal'
@@ -359,10 +377,12 @@ rstto_main_window_init (RsttoMainWindow *window)
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menubar, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->toolbar, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->p_viewer_s_window, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->fs_toolbar, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->statusbar, FALSE, FALSE, 0);
 
     rstto_main_window_set_sensitive (window, FALSE);
     gtk_widget_set_no_show_all (window->priv->toolbar, TRUE);
+    gtk_widget_set_no_show_all (window->priv->fs_toolbar, TRUE);
 
     /**
      * Add missing pieces to the UI
@@ -375,6 +395,13 @@ rstto_main_window_init (RsttoMainWindow *window)
                            GTK_UI_MANAGER_MENUITEM,
                            FALSE);
     gtk_ui_manager_add_ui (window->priv->ui_manager,
+                           window->priv->fs_play_merge_id,
+                           "/fullscreen-toolbar/placeholder-slideshow",
+                           "play",
+                           "play",
+                           GTK_UI_MANAGER_TOOLITEM,
+                           FALSE);
+    gtk_ui_manager_add_ui (window->priv->ui_manager,
                            window->priv->recent_merge_id,
                            "/main-menu/file-menu/placeholder-open-recent",
                            "recent",
@@ -414,6 +441,9 @@ rstto_main_window_init (RsttoMainWindow *window)
         gtk_widget_hide (window->priv->toolbar);
     }
 
+    gtk_widget_hide (window->priv->fs_toolbar);
+
+    g_signal_connect(G_OBJECT(window->priv->picture_viewer), "motion-notify-event", G_CALLBACK(cb_rstto_main_window_picture_viewer_motion_notify_event), window);
     g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(cb_rstto_main_window_configure_event), NULL);
     g_signal_connect(G_OBJECT(window), "window-state-event", G_CALLBACK(cb_rstto_main_window_state_event), NULL);
 }
@@ -589,6 +619,10 @@ rstto_main_window_set_sensitive (RsttoMainWindow *window, gboolean sensitive)
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/zoom-out"), sensitive);
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/zoom-fit"), sensitive);
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar/zoom-100"), sensitive);
+
+    /* FS Toolbar */
+    gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/fullscreen-toolbar/forward"), sensitive);
+    gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/fullscreen-toolbar/back"), sensitive);
 }
 
 /**
@@ -1047,8 +1081,6 @@ cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *win
 static void
 cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window)
 {
-    g_debug ("%s", __FUNCTION__);
-
     GValue timeout = {0, };
 
     gtk_ui_manager_add_ui (window->priv->ui_manager,
@@ -1061,6 +1093,16 @@ cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window)
     gtk_ui_manager_remove_ui (window->priv->ui_manager,
                               window->priv->play_merge_id);
 
+    gtk_ui_manager_add_ui (window->priv->ui_manager,
+                           window->priv->fs_pause_merge_id,
+                           "/fullscreen-toolbar/placeholder-slideshow",
+                           "pause",
+                           "pause",
+                           GTK_UI_MANAGER_TOOLITEM,
+                           FALSE);
+    gtk_ui_manager_remove_ui (window->priv->ui_manager,
+                              window->priv->fs_play_merge_id);
+
     g_value_init (&timeout, G_TYPE_UINT);
     g_object_get_property (G_OBJECT(window->priv->settings_manager), "slideshow-timeout", &timeout);
 
@@ -1079,7 +1121,6 @@ cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window)
 static void
 cb_rstto_main_window_pause (GtkWidget *widget, RsttoMainWindow *window)
 {
-    g_debug ("%s", __FUNCTION__);
     gtk_ui_manager_add_ui (window->priv->ui_manager,
                            window->priv->play_merge_id,
                            "/main-menu/go-menu/placeholder-slideshow",
@@ -1090,6 +1131,16 @@ cb_rstto_main_window_pause (GtkWidget *widget, RsttoMainWindow *window)
     gtk_ui_manager_remove_ui (window->priv->ui_manager,
                               window->priv->pause_merge_id);
 
+    gtk_ui_manager_add_ui (window->priv->ui_manager,
+                           window->priv->fs_play_merge_id,
+                           "/fullscreen-toolbar/placeholder-slideshow",
+                           "play",
+                           "play",
+                           GTK_UI_MANAGER_TOOLITEM,
+                           FALSE);
+    gtk_ui_manager_remove_ui (window->priv->ui_manager,
+                              window->priv->fs_pause_merge_id);
+
     window->priv->playing = FALSE;
 }
 
@@ -1429,7 +1480,14 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
             gtk_widget_hide (window->priv->statusbar);
         }
         else
-       {
+        {
+            if (window->priv->show_fs_toolbar_timeout_id > 0)
+            {
+                g_source_remove (window->priv->show_fs_toolbar_timeout_id);
+                window->priv->show_fs_toolbar_timeout_id = 0;
+            }
+            gtk_widget_hide (window->priv->fs_toolbar);
+
             g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
             g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
 
@@ -1446,3 +1504,32 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
     {
     }
 }
+
+static gboolean 
+cb_rstto_main_window_picture_viewer_motion_notify_event (RsttoPictureViewer *viewer,
+                                             GdkEventMotion *event,
+                                             gpointer user_data)
+{
+    RsttoMainWindow *window = RSTTO_MAIN_WINDOW (user_data);
+    if(gdk_window_get_state(GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_FULLSCREEN)
+    {
+        if (event->state == 0)
+        {
+            /* TODO: implement timer to hide it again */
+            gtk_widget_show (window->priv->fs_toolbar);
+            if (window->priv->show_fs_toolbar_timeout_id > 0)
+            {
+                g_source_remove (window->priv->show_fs_toolbar_timeout_id);
+                window->priv->show_fs_toolbar_timeout_id = 0;
+            }
+            window->priv->show_fs_toolbar_timeout_id = g_timeout_add (3000, (GSourceFunc)cb_rstto_main_window_show_fs_toolbar_timeout, window);
+        }
+    }
+}
+
+static gboolean
+cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window)
+{
+    gtk_widget_hide (window->priv->fs_toolbar);
+    return FALSE;
+}
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index a03bf31..af1d990 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -67,4 +67,15 @@
         <toolitem action="zoom-100"/>
         <toolitem action="zoom-fit"/>
     </toolbar>
+
+    <!--
+
+    -->
+    <toolbar name="fullscreen-toolbar">
+        <toolitem action="back"/>
+        <placeholder name="placeholder-slideshow" />
+        <toolitem action="forward"/>
+        <separator name="separator-1"/>
+        <toolitem action="fullscreen"/>
+    </toolbar>
 </ui>
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index e64e4cf..85c5eb8 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -186,7 +186,8 @@ rstto_picture_viewer_init(RsttoPictureViewer *viewer)
     gtk_widget_set_events (GTK_WIDGET(viewer),
                            GDK_BUTTON_PRESS_MASK |
                            GDK_BUTTON_RELEASE_MASK |
-                           GDK_BUTTON1_MOTION_MASK);
+                           GDK_BUTTON1_MOTION_MASK |
+                           GDK_POINTER_MOTION_MASK);
 
     g_signal_connect(G_OBJECT(viewer), "button_press_event", G_CALLBACK(cb_rstto_picture_viewer_button_press_event), NULL);
     g_signal_connect(G_OBJECT(viewer), "button_release_event", G_CALLBACK(cb_rstto_picture_viewer_button_release_event), NULL);


More information about the Xfce4-commits mailing list