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

Ali Abdallah aliov at xfce.org
Sun Jun 14 22:16:58 CEST 2009


Author: aliov
Date: 2009-06-14 20:16:58 +0000 (Sun, 14 Jun 2009)
New Revision: 7572

Added:
   parole/trunk/src/conf-dialog.c
   parole/trunk/src/conf-dialog.h
   parole/trunk/src/conf.c
   parole/trunk/src/conf.h
   parole/trunk/src/vis.c
   parole/trunk/src/vis.h
Modified:
   parole/trunk/ChangeLog
   parole/trunk/data/interfaces/Makefile.am
   parole/trunk/data/interfaces/parole.ui
   parole/trunk/src/Makefile.am
   parole/trunk/src/enum-glib.h
   parole/trunk/src/gst.c
   parole/trunk/src/player.c
   parole/trunk/src/utils.c
   parole/trunk/src/utils.h
Log:
	* Added code for configurations.
	* By default visualizations are disabled when playing audio files.
	* User now can select between multiple Gst visualizations plugins.

Modified: parole/trunk/ChangeLog
===================================================================
--- parole/trunk/ChangeLog	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/ChangeLog	2009-06-14 20:16:58 UTC (rev 7572)
@@ -1,3 +1,8 @@
+2009-06-14: Ali aliov at xfce.org
+	* Added code for configurations.
+	* By default visualizations are disabled when playing audio files.
+	* User now can select between multiple Gst visualizations plugins.
+
 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.

Modified: parole/trunk/data/interfaces/Makefile.am
===================================================================
--- parole/trunk/data/interfaces/Makefile.am	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/data/interfaces/Makefile.am	2009-06-14 20:16:58 UTC (rev 7572)
@@ -1,5 +1,6 @@
 interfaces =					\
 	parole.ui				\
+	parole-settings.ui			\
 	playlist.ui				\
 	mediachooser.ui				\
 	openlocation.ui

Modified: parole/trunk/data/interfaces/parole.ui
===================================================================
--- parole/trunk/data/interfaces/parole.ui	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/data/interfaces/parole.ui	2009-06-14 20:16:58 UTC (rev 7572)
@@ -74,6 +74,20 @@
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">_Edit</property>
                 <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu4">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="preferences">
+                        <property name="label">gtk-preferences</property>
+                        <property name="visible">True</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                        <signal name="activate" handler="parole_player_open_preferences_cb"/>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
             </child>
             <child>

Modified: parole/trunk/src/Makefile.am
===================================================================
--- parole/trunk/src/Makefile.am	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/Makefile.am	2009-06-14 20:16:58 UTC (rev 7572)
@@ -23,6 +23,8 @@
 	stream.h				\
 	gst.c					\
 	gst.h					\
+	vis.c					\
+	vis.h					\
 	statusbar.c				\
 	statusbar.h				\
 	builder.c				\
@@ -37,6 +39,10 @@
 	filters.h				\
 	screensaver.c				\
 	screensaver.h				\
+	conf.c					\
+	conf.h					\
+	conf-dialog.c				\
+	conf-dialog.h				\
 	rc-utils.c				\
 	rc-utils.h				\
 	utils.c					\

Added: parole/trunk/src/conf-dialog.c
===================================================================
--- parole/trunk/src/conf-dialog.c	                        (rev 0)
+++ parole/trunk/src/conf-dialog.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -0,0 +1,243 @@
+/*
+ * * 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 "conf-dialog.h"
+#include "conf.h"
+#include "builder.h"
+#include "vis.h"
+
+/*
+ * GtkBuilder Callbacks
+ */
+
+void		parole_conf_dialog_response_cb		 (GtkDialog *dialog, 
+							  gint response_id, 
+							  ParoleConfDialog *self);
+							  
+void		parole_conf_dialog_enable_vis_changed_cb (GtkToggleButton *widget,
+							  ParoleConfDialog *self);
+
+void		parole_conf_dialog_vis_plugin_changed_cb (GtkComboBox *widget,
+							  ParoleConfDialog *self);
+/*
+ * End of GtkBuilder callbacks
+ */
+#define PAROLE_SETTINGS_DIALOG_FILE INTERFACES_DIR "/parole-settings.ui"
+
+#define PAROLE_CONF_DIALOG_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_CONF_DIALOG, ParoleConfDialogPrivate))
+
+struct ParoleConfDialogPrivate
+{
+    ParoleConf *conf;
+    
+    GHashTable *vis_plugins;
+    
+    GtkWidget  *vis_combox;
+    GtkWidget  *toggle_vis;
+};
+
+G_DEFINE_TYPE (ParoleConfDialog, parole_conf_dialog, G_TYPE_OBJECT)
+
+static void 
+parole_conf_dialog_destroy (GtkWidget *widget, ParoleConfDialog *self)
+{
+    gtk_widget_destroy (widget);
+    g_object_unref (self);
+}
+
+void parole_conf_dialog_response_cb (GtkDialog *dialog, gint response_id, ParoleConfDialog *self)
+{
+    switch (response_id)
+    {
+	case GTK_RESPONSE_HELP:
+	    break;
+	default:
+	    parole_conf_dialog_destroy (GTK_WIDGET (dialog), self);
+	    break;
+    }
+}
+
+void parole_conf_dialog_enable_vis_changed_cb (GtkToggleButton *widget, ParoleConfDialog *self)
+{
+    gboolean active;
+    
+    active = gtk_toggle_button_get_active (widget);
+    
+    g_object_set (G_OBJECT (self->priv->conf),
+		  "vis-enabled", active,
+		  NULL);
+    
+    gtk_widget_set_sensitive (self->priv->vis_combox, active);
+}
+
+void parole_conf_dialog_vis_plugin_changed_cb (GtkComboBox *widget,  ParoleConfDialog *self)
+{
+    gchar *active;
+    GstElementFactory *f;
+    
+    active = gtk_combo_box_get_active_text (widget);
+    
+    f = g_hash_table_lookup (self->priv->vis_plugins, active);
+    
+    if ( f )
+    {
+	g_object_set (G_OBJECT (self->priv->conf),
+		      "vis-name", GST_PLUGIN_FEATURE_NAME (f),
+		      NULL);
+    }
+    
+    g_free (active);
+}
+
+static void
+parole_conf_dialog_finalize (GObject *object)
+{
+    ParoleConfDialog *self;
+
+    self = PAROLE_CONF_DIALOG (object);
+    
+    g_object_unref (self->priv->conf);
+    g_hash_table_destroy (self->priv->vis_plugins);
+
+    G_OBJECT_CLASS (parole_conf_dialog_parent_class)->finalize (object);
+}
+
+static void
+parole_conf_dialog_class_init (ParoleConfDialogClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = parole_conf_dialog_finalize;
+
+    g_type_class_add_private (klass, sizeof (ParoleConfDialogPrivate));
+}
+
+static void
+parole_conf_dialog_init (ParoleConfDialog *self)
+{
+    self->priv = PAROLE_CONF_DIALOG_GET_PRIVATE (self);
+    self->priv->conf = parole_conf_new ();
+    
+    self->priv->vis_plugins = parole_vis_get_plugins ();
+}
+
+static void
+parole_conf_dialog_add_vis_plugins (gpointer key, gpointer value, GtkWidget *combox)
+{
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combox), (const gchar *) key);
+}
+
+static gboolean 
+parole_conf_dialog_set_default_vis_plugin (GtkTreeModel *model, GtkTreePath *path,
+					   GtkTreeIter *iter, ParoleConfDialog *self)
+{
+    GstElementFactory *f;
+    gchar *vis_name;
+    gchar *combox_text;
+    gboolean ret = FALSE;
+    
+    g_object_get (G_OBJECT (self->priv->conf),
+		  "vis-name", &vis_name,
+		  NULL);
+
+    gtk_tree_model_get (model, iter, 
+			0, &combox_text,
+			-1);
+
+    f = g_hash_table_lookup (self->priv->vis_plugins, combox_text);
+    
+    if ( !g_strcmp0 (vis_name, "none") )
+    {
+	if ( !g_strcmp0 (GST_PLUGIN_FEATURE_NAME (f), "Goom") )
+	    ret = TRUE;
+    }
+    else if ( !g_strcmp0 (GST_PLUGIN_FEATURE_NAME (f), vis_name) )
+    {
+	ret = TRUE;
+    }
+    
+    if ( ret == TRUE )
+	gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->vis_combox), iter);
+    
+    return ret;
+}
+
+static void
+parole_conf_dialog_set_defaults (ParoleConfDialog *self)
+{
+    GtkTreeModel *model;
+    gboolean vis_enabled;
+        
+    g_object_get (G_OBJECT (self->priv->conf),
+		  "vis-enabled", &vis_enabled,
+		  NULL);
+
+    gtk_widget_set_sensitive (self->priv->vis_combox, vis_enabled);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->priv->toggle_vis), vis_enabled);
+    
+    model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->priv->vis_combox));
+
+    gtk_tree_model_foreach (model, 
+			    (GtkTreeModelForeachFunc) parole_conf_dialog_set_default_vis_plugin,
+			    self);
+}
+
+ParoleConfDialog *
+parole_conf_dialog_new (void)
+{
+    ParoleConfDialog *parole_conf_dialog = NULL;
+    parole_conf_dialog = g_object_new (PAROLE_TYPE_CONF_DIALOG, NULL);
+    return parole_conf_dialog;
+}
+
+void parole_conf_dialog_open (ParoleConfDialog *self, GtkWidget *parent)
+{
+    GtkBuilder *builder;
+    GtkWidget  *dialog;
+    GtkWidget  *combox;
+    
+    builder = parole_builder_new_from_file (PAROLE_SETTINGS_DIALOG_FILE);
+    
+    dialog = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog"));
+    combox = GTK_WIDGET (gtk_builder_get_object (builder, "vis-combobox"));
+    self->priv->toggle_vis = GTK_WIDGET (gtk_builder_get_object (builder, "enable-vis"));
+    
+    g_hash_table_foreach (self->priv->vis_plugins, (GHFunc) parole_conf_dialog_add_vis_plugins, combox);
+    
+    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+    
+    self->priv->vis_combox = combox;
+
+    parole_conf_dialog_set_defaults (self);
+    
+    gtk_builder_connect_signals (builder, self);
+    
+    g_object_unref (builder);
+    gtk_widget_show_all (dialog);
+}

Added: parole/trunk/src/conf-dialog.h
===================================================================
--- parole/trunk/src/conf-dialog.h	                        (rev 0)
+++ parole/trunk/src/conf-dialog.h	2009-06-14 20:16:58 UTC (rev 7572)
@@ -0,0 +1,56 @@
+/*
+ * * 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_CONF_DIALOG_H
+#define __PAROLE_CONF_DIALOG_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PAROLE_TYPE_CONF_DIALOG        (parole_conf_dialog_get_type () )
+#define PAROLE_CONF_DIALOG(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_CONF_DIALOG, ParoleConfDialog))
+#define PAROLE_IS_CONF_DIALOG(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_CONF_DIALOG))
+
+typedef struct ParoleConfDialogPrivate ParoleConfDialogPrivate;
+
+typedef struct
+{
+    GObject         		 parent;
+    ParoleConfDialogPrivate     *priv;
+    
+} ParoleConfDialog;
+
+typedef struct
+{
+    GObjectClass 		 parent_class;
+    
+} ParoleConfDialogClass;
+
+GType        			 parole_conf_dialog_get_type        (void) G_GNUC_CONST;
+ParoleConfDialog       		*parole_conf_dialog_new             (void);
+
+void				 parole_conf_dialog_open	    (ParoleConfDialog *self,
+								     GtkWidget *parent);
+
+G_END_DECLS
+
+#endif /* __PAROLE_CONF_DIALOG_H */

Added: parole/trunk/src/conf.c
===================================================================
--- parole/trunk/src/conf.c	                        (rev 0)
+++ parole/trunk/src/conf.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -0,0 +1,164 @@
+/*
+ * * 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 "conf.h"
+#include "rc-utils.h"
+
+#define PAROLE_CONF_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_CONF, ParoleConfPrivate))
+
+struct ParoleConfPrivate
+{
+    gchar 	*vis_sink;
+    gboolean 	 enable_vis;
+};
+
+static gpointer parole_conf_object = NULL;
+
+G_DEFINE_TYPE (ParoleConf, parole_conf, G_TYPE_OBJECT)
+
+enum
+{
+    PROP_0,
+    PROP_VIS_ENABLED,
+    PROP_VIS_NAME
+};
+
+static void parole_conf_set_property (GObject *object,
+				      guint prop_id,
+				      const GValue *value,
+				      GParamSpec *pspec)
+{
+    ParoleConf *conf;
+    conf = PAROLE_CONF (object);
+
+    switch (prop_id)
+    {
+	case PROP_VIS_ENABLED:
+	    conf->priv->enable_vis = g_value_get_boolean (value);
+	    g_object_notify (G_OBJECT (conf), "vis-enabled");
+	    parole_rc_write_entry_bool ("VIS_ENABLED", conf->priv->enable_vis);
+	    break;
+	case PROP_VIS_NAME:
+	    conf->priv->vis_sink = g_strdup (g_value_get_string (value));
+	    g_object_notify (G_OBJECT (conf), "vis-name");
+	    parole_rc_write_entry_string ("VIS_NAME", conf->priv->vis_sink);
+	    break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void parole_conf_get_property (GObject *object,
+				      guint prop_id,
+				      GValue *value,
+				      GParamSpec *pspec)
+{
+    ParoleConf *conf;
+    conf = PAROLE_CONF (object);
+
+    switch (prop_id)
+    {
+	case PROP_VIS_ENABLED:
+	    g_value_set_boolean (value, conf->priv->enable_vis);
+	    break;
+	case PROP_VIS_NAME:
+	    g_value_set_string (value, conf->priv->vis_sink);
+	    break;
+	default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+parole_conf_finalize (GObject *object)
+{
+    ParoleConf *conf;
+
+    conf = PAROLE_CONF (object);
+    
+    g_free (conf->priv->vis_sink);
+
+    G_OBJECT_CLASS (parole_conf_parent_class)->finalize (object);
+}
+
+static void
+parole_conf_class_init (ParoleConfClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = parole_conf_finalize;
+
+    object_class->get_property = parole_conf_get_property;
+    object_class->set_property = parole_conf_set_property;
+
+    g_object_class_install_property (object_class,
+                                     PROP_VIS_ENABLED,
+                                     g_param_spec_boolean ("vis-enabled",
+                                                           NULL, NULL,
+                                                           FALSE,
+                                                           G_PARAM_READWRITE));
+
+    g_object_class_install_property (object_class,
+                                     PROP_VIS_NAME,
+                                     g_param_spec_string  ("vis-name",
+                                                           NULL, NULL,
+                                                           NULL,
+                                                           G_PARAM_READWRITE));
+
+    g_type_class_add_private (klass, sizeof (ParoleConfPrivate));
+}
+
+static void
+parole_conf_init (ParoleConf *conf)
+{
+    conf->priv = PAROLE_CONF_GET_PRIVATE (conf);
+    
+    conf->priv->enable_vis = parole_rc_read_entry_bool ("VIS_ENABLED", FALSE);
+    conf->priv->vis_sink   = g_strdup (parole_rc_read_entry_string ("VIS_NAME", "none"));
+}
+
+ParoleConf *
+parole_conf_new (void)
+{
+    if ( parole_conf_object != NULL )
+    {
+	g_object_ref (parole_conf_object);
+    }
+    else
+    {
+	parole_conf_object = g_object_new (PAROLE_TYPE_CONF, NULL);
+	g_object_add_weak_pointer (parole_conf_object, &parole_conf_object);
+    }
+
+    return PAROLE_CONF (parole_conf_object);
+}

Added: parole/trunk/src/conf.h
===================================================================
--- parole/trunk/src/conf.h	                        (rev 0)
+++ parole/trunk/src/conf.h	2009-06-14 20:16:58 UTC (rev 7572)
@@ -0,0 +1,52 @@
+/*
+ * * 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_CONF_H
+#define __PAROLE_CONF_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PAROLE_TYPE_CONF        (parole_conf_get_type () )
+#define PAROLE_CONF(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_CONF, ParoleConf))
+#define PAROLE_IS_CONF(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_CONF))
+
+typedef struct ParoleConfPrivate ParoleConfPrivate;
+
+typedef struct
+{
+    GObject         		 parent;
+    ParoleConfPrivate     	*priv;
+    
+} ParoleConf;
+
+typedef struct
+{
+    GObjectClass 		 parent_class;
+    
+} ParoleConfClass;
+
+GType        			 parole_conf_get_type        (void) G_GNUC_CONST;
+ParoleConf       		*parole_conf_new             (void);
+
+G_END_DECLS
+
+#endif /* __PAROLE_CONF_H */

Modified: parole/trunk/src/enum-glib.h
===================================================================
--- parole/trunk/src/enum-glib.h	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/enum-glib.h	2009-06-14 20:16:58 UTC (rev 7572)
@@ -26,7 +26,7 @@
     PAROLE_MEDIA_STATE_PAUSED,
     PAROLE_MEDIA_STATE_PLAYING,
     PAROLE_MEDIA_STATE_STOPPED,
-    PAROLE_MEDIA_STATE_FINISHED    
+    PAROLE_MEDIA_STATE_FINISHED
     
 } ParoleMediaState;
 

Modified: parole/trunk/src/gst.c
===================================================================
--- parole/trunk/src/gst.c	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/gst.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -38,6 +38,7 @@
 
 #include "gst.h"
 #include "utils.h"
+#include "conf.h"
 #include "enum-gtypes.h"
 #include "gmarshal.h"
 
@@ -65,6 +66,10 @@
     
     GdkPixbuf    *logo;
     GTimer	 *hidecursor_timer;
+    
+    ParoleConf   *conf;
+    gboolean	  update;
+    gboolean      with_vis;
 };
 
 enum
@@ -99,6 +104,8 @@
     g_object_unref (gst->priv->logo);
     g_mutex_free (gst->priv->lock);
 
+    g_object_unref (gst->priv->conf);
+
     G_OBJECT_CLASS (parole_gst_parent_class)->finalize (object);
 }
 
@@ -278,7 +285,7 @@
 
     parole_gst_set_x_overlay (gst);
 
-    if ( gst->priv->state < GST_STATE_PAUSED )
+    if ( gst->priv->state < GST_STATE_PAUSED || !gst->priv->with_vis)
 	parole_gst_draw_logo (gst);
     else 
     {
@@ -434,6 +441,37 @@
 }
 
 static void
+parole_gst_update_vis (ParoleGst *gst)
+{
+    gchar *vis_name;
+    
+    g_object_get (G_OBJECT (gst->priv->conf),
+		  "vis-enabled", &gst->priv->with_vis,
+		  "vis-name", &vis_name,
+		  NULL);
+
+    TRACE ("Vis name %s enabled %d\n", vis_name, gst->priv->with_vis);
+    
+    if ( gst->priv->with_vis )
+    {
+	gst->priv->vis_sink = gst_element_factory_make (vis_name, "vis");
+	g_object_set (G_OBJECT (gst->priv->playbin),
+		      "vis-plugin", gst->priv->vis_sink,
+		      NULL);
+    }
+    else
+    {
+	g_object_set (G_OBJECT (gst->priv->playbin),
+		      "vis-plugin", NULL,
+		      NULL);
+	gtk_widget_queue_draw (GTK_WIDGET (gst));
+    }
+
+    gst->priv->update = FALSE;
+    g_free (vis_name);
+}
+
+static void
 parole_gst_evaluate_state (ParoleGst *gst, GstState old, GstState new, GstState pending)
 {
     TRACE ("State change new %i old %i pending %i", new, old, pending);
@@ -441,6 +479,9 @@
     gst->priv->state = new;
 
     parole_gst_tick (gst);
+
+    if ( gst->priv->update && new == GST_STATE_NULL)
+	parole_gst_update_vis (gst);
     
     if ( gst->priv->target == new )
 	parole_gst_set_window_cursor (GTK_WIDGET (gst)->window, NULL);
@@ -455,12 +496,16 @@
 			   gst->priv->stream, PAROLE_MEDIA_STATE_PLAYING);
 	    break;
 	case GST_STATE_PAUSED:
-	    parole_gst_set_x_overlay (gst);
+	    if ( gst->priv->target == GST_STATE_PLAYING )
+		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:
 	{
+	    g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0, 
+			   gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
+
 	    if ( gst->priv->target == GST_STATE_PLAYING)
 	    {
 		parole_gst_play_file_internal (gst);
@@ -471,15 +516,8 @@
 	    }
 	    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);
-	    }
 	}
     }
 }
@@ -677,11 +715,10 @@
 	}
     }
     
-    gst->priv->vis_sink = gst_element_factory_make ("goom", "vis");
+    parole_gst_update_vis (gst);
     
     g_object_set (G_OBJECT (gst->priv->playbin),
 		  "video-sink", gst->priv->video_sink,
-		  "vis-plugin", gst->priv->vis_sink,
 		  NULL);
 
     /*
@@ -712,6 +749,15 @@
 }
 
 static void
+parole_gst_conf_notify_cb (GObject *object, GParamSpec *spec, ParoleGst *gst)
+{
+    if ( !g_strcmp0 ("vis-enabled", spec->name) || !g_strcmp0 ("vis-name", spec->name))
+    {
+	gst->priv->update = TRUE;
+    }
+}
+
+static void
 parole_gst_class_init (ParoleGstClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -780,7 +826,14 @@
     gst->priv->stream = parole_stream_new ();
     gst->priv->tick_id = 0;
     gst->priv->hidecursor_timer = g_timer_new ();
+    gst->priv->update = FALSE;
+    gst->priv->vis_sink = NULL;
     
+    gst->priv->conf = parole_conf_new ();
+    
+    g_signal_connect (G_OBJECT (gst->priv->conf), "notify",
+		      G_CALLBACK (parole_gst_conf_notify_cb), gst);
+    
     GTK_WIDGET_SET_FLAGS (GTK_WIDGET (gst), GTK_CAN_FOCUS);
     
     /*
@@ -816,7 +869,9 @@
     
     if ( gst->priv->state < GST_STATE_PAUSED )
 	parole_gst_play_file_internal (gst);
-    else
+    else if ( gst->priv->update )
+	parole_gst_change_state (gst, GST_STATE_NULL);
+    else 
 	parole_gst_change_state (gst, GST_STATE_READY);
 }
 

Modified: parole/trunk/src/player.c
===================================================================
--- parole/trunk/src/player.c	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/player.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -41,7 +41,10 @@
 #include "sidebar.h"
 #include "statusbar.h"
 #include "screensaver.h"
+#include "conf-dialog.h"
+#include "conf.h"
 #include "rc-utils.h"
+#include "utils.h"
 #include "enum-glib.h"
 #include "enum-gtypes.h"
 #include "debug.h"
@@ -85,6 +88,8 @@
 void            parole_player_menu_exit_cb              (GtkWidget *widget,
 							 ParolePlayer *player);
 
+void		parole_player_open_preferences_cb	(GtkWidget *widget,
+							 ParolePlayer *player);
 
 void            parole_player_volume_value_changed_cb   (GtkRange *range, 
 							 ParolePlayer *player);
@@ -92,6 +97,8 @@
 void		parole_player_full_screen_activated_cb  (GtkWidget *widget,
 							 ParolePlayer *player);
 
+
+
 gboolean	parole_player_key_press 		(GtkWidget *widget, 
 							 GdkEventKey *ev, 
 							 ParolePlayer *player);
@@ -349,8 +356,8 @@
     gtk_widget_set_sensitive (player->priv->play_pause, FALSE);
     gtk_widget_set_sensitive (player->priv->stop, FALSE);
 
+    parole_player_change_range_value (player, 0);
     gtk_widget_set_sensitive (player->priv->range, FALSE);
-    parole_player_change_range_value (player, 0);
 
     parole_player_set_playpause_widget_image (player->priv->play_pause, GTK_STOCK_MEDIA_PLAY);
     
@@ -387,7 +394,7 @@
 	if ( row )
 	{
 	    parole_player_media_activated_cb (player->priv->list, row, player);
-	    goto out;
+	    return;
 	}
 	else
 	{
@@ -396,9 +403,7 @@
 	}
     }
 
-    parole_gst_stop (PAROLE_GST (player->priv->gst));
-out:
-    ;
+    parole_player_stopped (player);
 }
 
 static void
@@ -425,16 +430,15 @@
     {
 	parole_player_paused (player);
     }
+    else if ( state == PAROLE_MEDIA_STATE_STOPPED )
+    {
+	parole_player_stopped (player);
+    }
     else if ( state == PAROLE_MEDIA_STATE_FINISHED )
     {
 	TRACE ("***Playback finished***");
-	parole_player_stopped (player);
 	parole_player_play_next (player);
     }
-    else
-    {
-	parole_player_stopped (player);
-    }  
 }
 
 void
@@ -522,6 +526,8 @@
 void
 parole_player_destroy_cb (GtkObject *window, ParolePlayer *player)
 {
+    parole_window_busy_cursor (GTK_WIDGET (window)->window);
+    
     player->priv->exit = TRUE;
     parole_gst_null_state (PAROLE_GST (player->priv->gst));
 }
@@ -706,6 +712,15 @@
     parole_media_list_open (player->priv->list, TRUE);
 }
 
+void parole_player_open_preferences_cb	(GtkWidget *widget, ParolePlayer *player)
+{
+    ParoleConfDialog *dialog;
+    
+    dialog = parole_conf_dialog_new ();
+    
+    parole_conf_dialog_open (dialog, player->priv->window);
+}
+
 void
 parole_player_menu_exit_cb (GtkWidget *widget, ParolePlayer *player)
 {

Modified: parole/trunk/src/utils.c
===================================================================
--- parole/trunk/src/utils.c	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/utils.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <gst/gst.h>
 #include <glib.h>
 
 #include "utils.h"

Modified: parole/trunk/src/utils.h
===================================================================
--- parole/trunk/src/utils.h	2009-06-14 14:38:09 UTC (rev 7571)
+++ parole/trunk/src/utils.h	2009-06-14 20:16:58 UTC (rev 7572)
@@ -18,8 +18,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef __PAROLE_UTILS_
-#define __PAROLE_UTILS_
+#ifndef __PAROLE_UTILS_H_
+#define __PAROLE_UTILS_H_
 
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>

Added: parole/trunk/src/vis.c
===================================================================
--- parole/trunk/src/vis.c	                        (rev 0)
+++ parole/trunk/src/vis.c	2009-06-14 20:16:58 UTC (rev 7572)
@@ -0,0 +1,73 @@
+/*
+ * * 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 <gst/gst.h>
+#include <glib.h>
+
+#include "vis.h"
+
+static gboolean
+parole_vis_filter (GstPluginFeature *feature, gpointer data)
+{
+    GstElementFactory *factory;
+    
+    if ( !GST_IS_ELEMENT_FACTORY (feature) )
+	return FALSE;
+	
+    factory = GST_ELEMENT_FACTORY (feature);
+    
+    if ( !g_strrstr (gst_element_factory_get_klass (factory), "Visualization"))
+	return FALSE;
+	
+    return TRUE;
+}
+
+static void
+parole_vis_get_name (GstElementFactory *factory, GHashTable **hash)
+{
+    g_hash_table_insert (*hash, g_strdup (gst_element_factory_get_longname (factory)), factory);
+}
+
+GHashTable *parole_vis_get_plugins (void)
+{
+    GList *plugins = NULL;
+    GHashTable *hash;
+    
+    hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+    
+    plugins = gst_registry_feature_filter (gst_registry_get_default (),
+					   parole_vis_filter,
+					   FALSE,
+					   NULL);
+					   
+    g_list_foreach (plugins, (GFunc) parole_vis_get_name, &hash);
+    
+    gst_plugin_feature_list_free (plugins);
+    
+    return hash;
+}

Added: parole/trunk/src/vis.h
===================================================================
--- parole/trunk/src/vis.h	                        (rev 0)
+++ parole/trunk/src/vis.h	2009-06-14 20:16:58 UTC (rev 7572)
@@ -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_VIS_H_
+#define __PAROLE_VIS_H_
+
+#include <gst/gst.h>
+#include <glib.h>
+
+GHashTable        *parole_vis_get_plugins			(void);
+
+//GstElement	*parole_vis_get_for_name		(void)
+
+#endif /* __PAROLE_VIS_H_ */




More information about the Goodies-commits mailing list