[Xfce4-commits] [apps/parole] 02/02: Cleanup cursor code

noreply at xfce.org noreply at xfce.org
Wed Jun 18 06:37:36 CEST 2014


This is an automated email from the git hooks/post-receive script.

bluesabre pushed a commit to branch master
in repository apps/parole.

commit a7f4d0309e6c2d8a18918d2c3074beb8c91dfe1b
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Wed Jun 18 00:37:30 2014 -0400

    Cleanup cursor code
---
 src/common/parole-common.c |   37 +++++++++++++++++++++++++++----------
 src/common/parole-common.h |    2 ++
 src/gst/parole-gst.c       |   14 +++-----------
 src/parole-medialist.c     |    2 +-
 src/parole-player.c        |    5 ++---
 5 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/src/common/parole-common.c b/src/common/parole-common.c
index 857d1b3..822cd31 100644
--- a/src/common/parole-common.c
+++ b/src/common/parole-common.c
@@ -36,24 +36,24 @@
 
 
 static void
-parole_dialog_show (GtkWindow *parent, 
+parole_dialog_show (GtkWindow *parent,
                     GtkMessageType type,
                     const gchar *window_title,
-                    const gchar *title, 
+                    const gchar *title,
                     const gchar *msg)
 {
     GtkWidget *dialog;
-    
+
     dialog = gtk_message_dialog_new_with_markup (parent,
                         GTK_DIALOG_DESTROY_WITH_PARENT,
                         type,
                         GTK_BUTTONS_CLOSE,
                         "<span size='larger'><b>%s</b></span>",
                         title);
-                         
+
     gtk_window_set_title (GTK_WINDOW (dialog), window_title);
     gtk_window_set_icon_name (GTK_WINDOW (dialog), "parole");
-    
+
     gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", msg);
 
 
@@ -78,15 +78,17 @@ void parole_dialog_error (GtkWindow *parent, const gchar *title, const gchar *ms
 
 void parole_window_busy_cursor (GdkWindow *window)
 {
-    GdkCursor *cursor;
-    
+    GdkCursor *cursor = NULL;
+
     if ( G_UNLIKELY (window == NULL) )
         return;
-    
+
     cursor = gdk_cursor_new (GDK_WATCH);
+
     gdk_window_set_cursor (window, cursor);
-    
-    g_object_unref (cursor);
+
+    if (cursor)
+        g_object_unref (cursor);
 
     gdk_flush ();
 }
@@ -95,10 +97,25 @@ void parole_window_invisible_cursor (GdkWindow *window)
 {
     GdkCursor *cursor = NULL;
 
+    if ( G_UNLIKELY (window == NULL) )
+        return;
+
     cursor = gdk_cursor_new (GDK_BLANK_CURSOR);
 
     gdk_window_set_cursor (window, cursor);
 
     if (cursor)
         g_object_unref (cursor);
+
+    gdk_flush ();
+}
+
+void parole_window_normal_cursor (GdkWindow *window)
+{
+    if ( G_UNLIKELY (window == NULL) )
+        return;
+
+    gdk_window_set_cursor (window, NULL);
+
+    gdk_flush ();
 }
diff --git a/src/common/parole-common.h b/src/common/parole-common.h
index 1adf93f..d458874 100644
--- a/src/common/parole-common.h
+++ b/src/common/parole-common.h
@@ -39,6 +39,8 @@ void        parole_window_busy_cursor       (GdkWindow *window);
 
 void        parole_window_invisible_cursor  (GdkWindow *window);
 
+void        parole_window_normal_cursor     (GdkWindow *window);
+
 
 
 #endif /* __PAROLE_COMMON_ */
diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c
index bcea70b..9097058 100644
--- a/src/gst/parole-gst.c
+++ b/src/gst/parole-gst.c
@@ -207,14 +207,6 @@ parole_gst_finalize (GObject *object)
     G_OBJECT_CLASS (parole_gst_parent_class)->finalize (object);
 }
 
-static void
-parole_gst_set_window_cursor (GdkWindow *window, GdkCursor *cursor)
-{
-    TRACE ("start");
-    if ( window )
-        gdk_window_set_cursor (window, cursor);
-}
-
 static gboolean
 parole_gst_configure_event_cb (GtkWidget *widget, GdkEventConfigure *ev, ParoleGst *gst)
 {
@@ -951,7 +943,7 @@ parole_gst_evaluate_state (ParoleGst *gst, GstState old, GstState new, GstState
     if ( gst->priv->target == new )
     {
         gtk_widget_queue_draw (GTK_WIDGET (gst));
-        parole_gst_set_window_cursor ( gtk_widget_get_window(GTK_WIDGET (gst)), NULL);
+        parole_window_normal_cursor (gtk_widget_get_window(GTK_WIDGET (gst)));
         if ( gst->priv->state_change_id != 0 )
         {
             g_source_remove (gst->priv->state_change_id);
@@ -1647,7 +1639,7 @@ parole_gst_bus_event (GstBus *bus, GstMessage *msg, gpointer data)
     {
         GError *error = NULL;
         gchar *debug;
-        parole_gst_set_window_cursor (gtk_widget_get_window(GTK_WIDGET (gst)), NULL);
+        parole_window_normal_cursor (gtk_widget_get_window(GTK_WIDGET (gst)));
         gst->priv->target = GST_STATE_NULL;
         gst->priv->buffering = FALSE;
         parole_gst_change_state (gst, GST_STATE_NULL);
@@ -2866,7 +2858,7 @@ parole_gst_set_cursor_visible (ParoleGst *gst, gboolean visible)
     if ( visible )
     {
         if (gst->priv->target == gst->priv->state)
-            gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET (gst)), NULL);
+            parole_window_normal_cursor (gtk_widget_get_window(GTK_WIDGET (gst)));
         else
             parole_window_busy_cursor (gtk_widget_get_window(GTK_WIDGET (gst)));
     }
diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index 0d84355..1c00fde 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -564,7 +564,7 @@ void    parole_media_list_drag_data_received_cb (GtkWidget *widget,
 
     g_strfreev (uri_list);
 
-    gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET (list)), NULL);
+    parole_window_normal_cursor (gtk_widget_get_window(GTK_WIDGET (list)));
     gtk_drag_finish (drag_context, added == i ? TRUE : FALSE, FALSE, drag_time);
 }
 
diff --git a/src/parole-player.c b/src/parole-player.c
index 22fd430..7a80b38 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -2966,7 +2966,6 @@ parole_player_drag_data_received_cb (GtkWidget *widget,
                                      guint drag_time,
                                      ParolePlayer *player)
 {
-
     gchar **uri_list;
     guint added  = 0;
     guint i;
@@ -2985,7 +2984,7 @@ parole_player_drag_data_received_cb (GtkWidget *widget,
 
     g_strfreev (uri_list);
 
-    gdk_window_set_cursor (gtk_widget_get_window(widget), NULL);
+    parole_player_set_cursor_visible (player, TRUE);
     gtk_drag_finish (drag_context, added == i ? TRUE : FALSE, FALSE, drag_time);
 }
 
@@ -2998,7 +2997,7 @@ parole_player_set_cursor_visible (ParolePlayer *player, gboolean visible)
     if (visible)
     {
         parole_gst_set_cursor_visible (PAROLE_GST (player->priv->gst), TRUE);
-        gdk_window_set_cursor (gdkwindow, NULL);
+        parole_window_normal_cursor (gdkwindow);
     }
     else if (gtk_window_is_active (GTK_WINDOW (player->priv->window)))
     {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list