[Goodies-commits] r7528 - in parole/trunk: . data/interfaces src

Ali Abdallah aliov at xfce.org
Thu Jun 11 17:33:49 CEST 2009


Author: aliov
Date: 2009-06-11 15:33:49 +0000 (Thu, 11 Jun 2009)
New Revision: 7528

Added:
   parole/trunk/src/utils.c
   parole/trunk/src/utils.h
Modified:
   parole/trunk/ChangeLog
   parole/trunk/data/interfaces/parole.ui
   parole/trunk/src/Makefile.am
   parole/trunk/src/gst.c
   parole/trunk/src/mediachooser.c
   parole/trunk/src/statusbar.c
Log:
	* Fix a bug in processing state change in Gst.
	* Added utils.{c,h} with window cursor functions.
	* Fix the date of the previous ChangeLog commit message.

Modified: parole/trunk/ChangeLog
===================================================================
--- parole/trunk/ChangeLog	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/ChangeLog	2009-06-11 15:33:49 UTC (rev 7528)
@@ -1,4 +1,9 @@
-2009-06-17: Ali aliov at xfce.org
+2009-06-11: Ali aliov at xfce.org
+	* Fix a bug in processing state change in Gst.
+	* Added utils.{c,h} with window cursor functions.
+	* Fix the date of the previous ChangeLog commit message.
+
+2009-06-10: Ali aliov at xfce.org
 	* Split the GtkBuilder interface files into multiple files.
 
 2009-06-07: Ali aliov at xfce.org

Modified: parole/trunk/data/interfaces/parole.ui
===================================================================
--- parole/trunk/data/interfaces/parole.ui	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/data/interfaces/parole.ui	2009-06-11 15:33:49 UTC (rev 7528)
@@ -12,7 +12,6 @@
       <object class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">4</property>
         <child>
           <object class="GtkMenuBar" id="menubar">
             <property name="visible">True</property>
@@ -817,6 +816,8 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="padding">2</property>
             <property name="position">2</property>
           </packing>
         </child>

Modified: parole/trunk/src/Makefile.am
===================================================================
--- parole/trunk/src/Makefile.am	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/src/Makefile.am	2009-06-11 15:33:49 UTC (rev 7528)
@@ -39,6 +39,8 @@
 	screensaver.h				\
 	rc-utils.c				\
 	rc-utils.h				\
+	utils.c					\
+	utils.h					\
 	debug.c					\
 	debug.h
 

Modified: parole/trunk/src/gst.c
===================================================================
--- parole/trunk/src/gst.c	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/src/gst.c	2009-06-11 15:33:49 UTC (rev 7528)
@@ -37,6 +37,7 @@
 #include <gdk/gdkx.h>
 
 #include "gst.h"
+#include "utils.h"
 #include "enum-gtypes.h"
 #include "gmarshal.h"
 
@@ -63,7 +64,6 @@
     gboolean      seeking;
     
     GdkPixbuf    *logo;
-    GdkCursor    *busy_cursor;
     GTimer	 *hidecursor_timer;
 };
 
@@ -95,7 +95,6 @@
     parole_stream_init_properties (gst->priv->stream);
     g_object_unref (gst->priv->stream);
     g_object_unref (gst->priv->playbin);
-    gdk_cursor_unref (gst->priv->busy_cursor);
     
     g_object_unref (gst->priv->logo);
     g_mutex_free (gst->priv->lock);
@@ -103,42 +102,16 @@
     G_OBJECT_CLASS (parole_gst_parent_class)->finalize (object);
 }
 
-static void
-parole_gst_set_invisible_cursor (GdkWindow *window)
-{
-    GdkBitmap *empty_bitmap;
-    GdkCursor *cursor;
-    GdkColor  color;
-    
-    char cursor_bits[] = { 0x0 }; 
-
-    color.red = color.green = color.blue = 0;
-    color.pixel = 0;
-
-    empty_bitmap = gdk_bitmap_create_from_data (window,
-		   cursor_bits,
-		   1, 1);
-
-    cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
-					 empty_bitmap,
-					 &color,
-					 &color, 0, 0);
-
-    gdk_window_set_cursor (window, cursor);
-
-    gdk_cursor_unref (cursor);
-
-    g_object_unref (empty_bitmap);
-}
-
 static void 
 parole_gst_set_cursor_visible (ParoleGst *gst, gboolean visible)
 {
     if ( visible )
-	gdk_window_set_cursor (GTK_WIDGET (gst)->window, 
-			       gst->priv->target == gst->priv->state ? NULL : gst->priv->busy_cursor);
+    {
+	gst->priv->target == gst->priv->state ? gdk_window_set_cursor (GTK_WIDGET (gst)->window, NULL):
+						parole_window_busy_cursor (GTK_WIDGET (gst)->window);
+    }
     else
-	parole_gst_set_invisible_cursor (GTK_WIDGET (gst)->window);
+	parole_window_invisible_cursor (GTK_WIDGET (gst)->window);
 }
 
 static void
@@ -463,52 +436,49 @@
 static void
 parole_gst_evaluate_state (ParoleGst *gst, GstState old, GstState new, GstState pending)
 {
-    if ( gst->priv->state != new )
-    {
-	TRACE ("State change new %i old %i pending %i", new, old, pending);
-	
-	gst->priv->state = new;
+    TRACE ("State change new %i old %i pending %i", new, old, pending);
 
-	parole_gst_tick (gst);
-	
-	if ( gst->priv->target == new )
-	    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, NULL);
-	
-	switch (gst->priv->state)
+    gst->priv->state = new;
+
+    parole_gst_tick (gst);
+    
+    if ( gst->priv->target == new )
+	parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, NULL);
+    
+    switch (gst->priv->state)
+    {
+	case GST_STATE_PLAYING:
+	    parole_gst_query_capabilities (gst);
+	    parole_gst_query_duration (gst);
+	    parole_gst_query_info (gst);
+	    g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
+			   gst->priv->stream, PAROLE_MEDIA_STATE_PLAYING);
+	    break;
+	case GST_STATE_PAUSED:
+	    parole_gst_set_x_overlay (gst);
+	    g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
+			   gst->priv->stream, PAROLE_MEDIA_STATE_PAUSED);
+	    break;
+	default:
 	{
-	    case GST_STATE_PLAYING:
-		parole_gst_query_capabilities (gst);
-		parole_gst_query_duration (gst);
-		parole_gst_query_info (gst);
+	    if ( gst->priv->target == GST_STATE_PLAYING)
+	    {
+		parole_gst_play_file_internal (gst);
+	    }
+	    else if ( gst->priv->target == GST_STATE_PAUSED)
+	    {
+		parole_gst_change_state (gst, GST_STATE_PAUSED);
+	    }
+	    else if ( gst->priv->target == GST_STATE_READY)
+	    {
 		g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
-			       gst->priv->stream, PAROLE_MEDIA_STATE_PLAYING);
-		break;
-	    case GST_STATE_PAUSED:
-		parole_gst_set_x_overlay (gst);
-		g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
-			       gst->priv->stream, PAROLE_MEDIA_STATE_PAUSED);
-		break;
-	    default:
+			   gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
+		parole_gst_draw_logo (gst);
+	    }
+	    else if ( gst->priv->target == GST_STATE_NULL )
 	    {
-		if ( gst->priv->target == GST_STATE_PLAYING)
-		{
-		    parole_gst_play_file_internal (gst);
-		}
-		else if ( gst->priv->target == GST_STATE_PAUSED)
-		{
-		    parole_gst_change_state (gst, GST_STATE_PAUSED);
-		}
-		else if ( gst->priv->target == GST_STATE_READY)
-		{
-		    g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
-			       gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
-		    parole_gst_draw_logo (gst);
-		}
-		else if ( gst->priv->target == GST_STATE_NULL )
-		{
-		    g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
-			       gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
-		}
+		g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
+			   gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
 	    }
 	}
     }
@@ -629,14 +599,16 @@
     {
 	case GST_STATE_CHANGE_SUCCESS:
 	    parole_gst_evaluate_state (gst, 
-				     GST_STATE_RETURN (gst->priv->playbin),
-				     GST_STATE (gst->priv->playbin),
-				     GST_STATE_PENDING (gst->priv->playbin));
+				       GST_STATE_RETURN (gst->priv->playbin),
+				       GST_STATE (gst->priv->playbin),
+				       GST_STATE_PENDING (gst->priv->playbin));
 	    break;
 	case GST_STATE_CHANGE_ASYNC:
 	    TRACE ("State will change async");
 	    break;
 	case GST_STATE_CHANGE_FAILURE:
+	    gst->priv->target = GST_STATE_NULL;
+	    parole_gst_change_state (gst, GST_STATE_NULL);
 	    g_signal_emit (G_OBJECT (gst), signals [ERROR], 0, _("Error in changing state to ready"));
 	    break;
 	case GST_STATE_CHANGE_NO_PREROLL:
@@ -807,7 +779,6 @@
     gst->priv->lock = g_mutex_new ();
     gst->priv->stream = parole_stream_new ();
     gst->priv->tick_id = 0;
-    gst->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
     gst->priv->hidecursor_timer = g_timer_new ();
     
     GTK_WIDGET_SET_FLAGS (GTK_WIDGET (gst), GTK_CAN_FOCUS);
@@ -841,7 +812,7 @@
 
     g_mutex_unlock (gst->priv->lock);
     
-    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, gst->priv->busy_cursor);
+    parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     
     if ( gst->priv->state < GST_STATE_PAUSED )
 	parole_gst_play_file_internal (gst);
@@ -857,7 +828,7 @@
     
     g_mutex_unlock (gst->priv->lock);
 
-    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, gst->priv->busy_cursor);
+    parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     parole_gst_change_state (gst, GST_STATE_PAUSED);
 }
 
@@ -869,7 +840,7 @@
     
     g_mutex_unlock (gst->priv->lock);
 
-    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, gst->priv->busy_cursor);
+    parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     parole_gst_change_state (gst, GST_STATE_PLAYING);
 }
 
@@ -882,7 +853,7 @@
     
     g_mutex_unlock (gst->priv->lock);
 
-    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, gst->priv->busy_cursor);
+    parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     
     parole_gst_change_state (gst, GST_STATE_READY);
 }
@@ -895,9 +866,9 @@
     gst->priv->target = GST_STATE_NULL;
     
     g_mutex_unlock (gst->priv->lock);
+
+    parole_window_busy_cursor (GTK_WIDGET (gst)->window);
     
-    parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, gst->priv->busy_cursor);
-    
     parole_gst_change_state (gst, GST_STATE_NULL);
 }
 

Modified: parole/trunk/src/mediachooser.c
===================================================================
--- parole/trunk/src/mediachooser.c	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/src/mediachooser.c	2009-06-11 15:33:49 UTC (rev 7528)
@@ -37,6 +37,7 @@
 #include "mediafile.h"
 #include "filters.h"
 #include "rc-utils.h"
+#include "utils.h"
 
 /*
  * GtkBuilder Callbacks
@@ -384,6 +385,7 @@
     }
     else
     {
+	parole_window_busy_cursor (GTK_WIDGET (chooser)->window);
 	parole_media_chooser_add_many (chooser, file_chooser);
 	parole_media_chooser_close (NULL, chooser);
     }

Modified: parole/trunk/src/statusbar.c
===================================================================
--- parole/trunk/src/statusbar.c	2009-06-11 08:37:41 UTC (rev 7527)
+++ parole/trunk/src/statusbar.c	2009-06-11 15:33:49 UTC (rev 7528)
@@ -83,7 +83,11 @@
     statusbar->priv->progress = gtk_progress_bar_new ();
     gtk_widget_hide (statusbar->priv->progress);
     statusbar->priv->label = gtk_label_new (NULL);
-    
+
+    gtk_misc_set_alignment (GTK_MISC (statusbar->priv->label), 0.0, 0.5);
+
+    gtk_widget_set_size_request (statusbar->priv->progress, 180, 20);
+
     gtk_box_pack_start (GTK_BOX (box), statusbar->priv->label, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (box), statusbar->priv->progress, FALSE, FALSE, 0);
 

Added: parole/trunk/src/utils.c
===================================================================
--- parole/trunk/src/utils.c	                        (rev 0)
+++ parole/trunk/src/utils.c	2009-06-11 15:33:49 UTC (rev 7528)
@@ -0,0 +1,75 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "utils.h"
+
+void parole_window_busy_cursor		(GdkWindow *window)
+{
+    GdkCursor *cursor;
+    
+    if ( G_UNLIKELY (window == NULL) )
+	return;
+	
+    cursor = gdk_cursor_new (GDK_WATCH);
+    gdk_window_set_cursor (window, cursor);
+    gdk_cursor_unref (cursor);
+
+    gdk_flush ();
+}
+
+void parole_window_invisible_cursor		(GdkWindow *window)
+{
+    GdkBitmap *empty_bitmap;
+    GdkCursor *cursor;
+    GdkColor  color;
+
+    char cursor_bits[] = { 0x0 }; 
+    
+    if ( G_UNLIKELY (window == NULL) )
+	return;
+	
+    color.red = color.green = color.blue = 0;
+    color.pixel = 0;
+
+    empty_bitmap = gdk_bitmap_create_from_data (window,
+		   cursor_bits,
+		   1, 1);
+
+    cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
+					 empty_bitmap,
+					 &color,
+					 &color, 0, 0);
+
+    gdk_window_set_cursor (window, cursor);
+
+    gdk_cursor_unref (cursor);
+
+    g_object_unref (empty_bitmap);
+}

Added: parole/trunk/src/utils.h
===================================================================
--- parole/trunk/src/utils.h	                        (rev 0)
+++ parole/trunk/src/utils.h	2009-06-11 15:33:49 UTC (rev 7528)
@@ -0,0 +1,31 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __PAROLE_UTILS_
+#define __PAROLE_UTILS_
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+void		parole_window_busy_cursor		(GdkWindow *window);
+
+void		parole_window_invisible_cursor		(GdkWindow *window);
+
+#endif /* __PAROLE_UTILS_ */




More information about the Goodies-commits mailing list