[Xfce4-commits] <parole:master> Added an option in the media chooser to clean the current playlist before adding new files.
Ali Abdallah
noreply at xfce.org
Tue Nov 17 22:06:02 CET 2009
Updating branch refs/heads/master
to 61df0aef193f67047bf130e4adb13bff32eab4d9 (commit)
from 9c42f6a3d139fa5f926f8037c899a29a1280b1b4 (commit)
commit 61df0aef193f67047bf130e4adb13bff32eab4d9
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Tue Nov 17 22:01:22 2009 +0100
Added an option in the media chooser to
clean the current playlist before adding
new files.
data/interfaces/mediachooser.ui | 19 +++++++++++++++++--
parole/gmarshal.list | 1 +
parole/parole-gst.c | 2 --
parole/parole-mediachooser.c | 34 ++++++++++++++++++++++++++++++----
parole/parole-mediachooser.h | 3 ++-
parole/parole-medialist.c | 11 ++++++++---
6 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/data/interfaces/mediachooser.ui b/data/interfaces/mediachooser.ui
index b5023cd..95a1d19 100644
--- a/data/interfaces/mediachooser.ui
+++ b/data/interfaces/mediachooser.ui
@@ -5,7 +5,7 @@
<object class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
- <property name="spacing">10</property>
+ <property name="spacing">4</property>
<child>
<object class="GtkFileChooserWidget" id="filechooserwidget">
<property name="visible">True</property>
@@ -35,6 +35,21 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="replace">
+ <property name="label" translatable="yes">Replace playlist with opened files</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="parole_media_chooser_replace_toggled_cb"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="border_width">5</property>
@@ -72,7 +87,7 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/parole/gmarshal.list b/parole/gmarshal.list
index 05faeae..002d61d 100644
--- a/parole/gmarshal.list
+++ b/parole/gmarshal.list
@@ -2,3 +2,4 @@ VOID:OBJECT,ENUM
VOID:OBJECT,DOUBLE
VOID:OBJECT,INT
VOID:STRING,STRING
+VOID:BOOL,POINTER
diff --git a/parole/parole-gst.c b/parole/parole-gst.c
index d255b05..bc418c4 100644
--- a/parole/parole-gst.c
+++ b/parole/parole-gst.c
@@ -123,8 +123,6 @@ parole_gst_finalize (GObject *object)
if ( gst->priv->tick_id != 0)
g_source_remove (gst->priv->tick_id);
- g_object_unref (gst->priv->playbin);
-
parole_stream_init_properties (gst->priv->stream);
g_object_unref (gst->priv->stream);
diff --git a/parole/parole-mediachooser.c b/parole/parole-mediachooser.c
index 55464b8..c17c4e7 100644
--- a/parole/parole-mediachooser.c
+++ b/parole/parole-mediachooser.c
@@ -41,6 +41,8 @@
#include "parole-rc-utils.h"
#include "parole-utils.h"
+#include "gmarshal.h"
+
/*
* GtkBuilder Callbacks
*/
@@ -59,7 +61,8 @@ void media_chooser_file_activate_cb (GtkFileChooser *filechooser,
void parole_media_chooser_recursive_toggled_cb (GtkToggleButton *recursive,
gpointer data);
-
+void parole_media_chooser_replace_toggled_cb (GtkToggleButton *button,
+ gpointer data);
enum
{
@@ -96,7 +99,9 @@ parole_media_chooser_add (ParoleMediaChooser *chooser, GtkWidget *file_chooser)
GSList *files;
GtkFileFilter *filter;
GtkWidget *recursive;
+ GtkWidget *replace;
gboolean scan_recursive;
+ gboolean replace_playlist;
gchar *file;
guint i;
guint len;
@@ -108,8 +113,10 @@ parole_media_chooser_add (ParoleMediaChooser *chooser, GtkWidget *file_chooser)
return;
recursive = g_object_get_data (G_OBJECT (chooser), "recursive");
+ replace = g_object_get_data (G_OBJECT (chooser), "replace-playlist");
scan_recursive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (recursive));
+ replace_playlist = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (replace));
len = g_slist_length (files);
@@ -119,7 +126,7 @@ parole_media_chooser_add (ParoleMediaChooser *chooser, GtkWidget *file_chooser)
parole_get_media_files (filter, file, scan_recursive, &media_files);
}
- g_signal_emit (G_OBJECT (chooser), signals [MEDIA_FILES_OPENED], 0, media_files);
+ g_signal_emit (G_OBJECT (chooser), signals [MEDIA_FILES_OPENED], 0, replace_playlist, media_files);
g_slist_free (media_files);
g_slist_foreach (files, (GFunc) g_free, NULL);
@@ -151,6 +158,14 @@ void parole_media_chooser_recursive_toggled_cb (GtkToggleButton *recursive,
gtk_toggle_button_get_active (recursive));
}
+void parole_media_chooser_replace_toggled_cb (GtkToggleButton *button,
+ gpointer data)
+{
+ parole_rc_write_entry_bool ("replace-playlist",
+ PAROLE_RC_GROUP_GENERAL,
+ gtk_toggle_button_get_active (button));
+}
+
static void
parole_media_chooser_open_internal (GtkWidget *chooser)
{
@@ -161,7 +176,9 @@ parole_media_chooser_open_internal (GtkWidget *chooser)
GtkWidget *open;
GtkWidget *img;
GtkWidget *recursive;
+ GtkWidget *replace;
gboolean scan_recursive;
+ gboolean replace_playlist;
const gchar *folder;
media_chooser = PAROLE_MEDIA_CHOOSER (chooser);
@@ -191,7 +208,13 @@ parole_media_chooser_open_internal (GtkWidget *chooser)
scan_recursive = parole_rc_read_entry_bool ("scan-recursive", PAROLE_RC_GROUP_GENERAL, TRUE);
recursive = GTK_WIDGET (gtk_builder_get_object (builder, "recursive"));
+ replace = GTK_WIDGET (gtk_builder_get_object (builder, "replace"));
+
+ scan_recursive = parole_rc_read_entry_bool ("scan-recursive", PAROLE_RC_GROUP_GENERAL, TRUE);
+ replace_playlist = parole_rc_read_entry_bool ("replace-playlist", PAROLE_RC_GROUP_GENERAL, FALSE);
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (recursive), scan_recursive);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (replace), replace_playlist);
img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
@@ -202,6 +225,7 @@ parole_media_chooser_open_internal (GtkWidget *chooser)
g_object_set_data (G_OBJECT (chooser), "file-chooser", file_chooser);
g_object_set_data (G_OBJECT (chooser), "recursive", recursive);
+ g_object_set_data (G_OBJECT (chooser), "replace-playlist", replace);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (media_chooser)->vbox), vbox);
gtk_builder_connect_signals (builder, chooser);
@@ -228,8 +252,10 @@ parole_media_chooser_class_init (ParoleMediaChooserClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ParoleMediaChooserClass, media_files_opened),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ _gmarshal_VOID__BOOLEAN_POINTER,
+ G_TYPE_NONE, 2,
+ G_TYPE_BOOLEAN,
+ G_TYPE_POINTER);
object_class->finalize = parole_media_chooser_finalize;
}
diff --git a/parole/parole-mediachooser.h b/parole/parole-mediachooser.h
index 1ce16cc..da57a88 100644
--- a/parole/parole-mediachooser.h
+++ b/parole/parole-mediachooser.h
@@ -43,7 +43,8 @@ typedef struct
GtkDialogClass parent_class;
void (*media_files_opened) (ParoleMediaChooser *chooser,
- GPtrArray *array);
+ gboolean replace,
+ GSList *list);
} ParoleMediaChooserClass;
diff --git a/parole/parole-medialist.c b/parole/parole-medialist.c
index 1bda5e6..91dd34f 100644
--- a/parole/parole-medialist.c
+++ b/parole/parole-medialist.c
@@ -89,6 +89,8 @@ static GtkTreeRowReference *
static void parole_media_list_select_path (ParoleMediaList *list,
GtkTreePath *path);
+static void parole_media_list_clear_list (ParoleMediaList *list);
+
/*
* Callbacks for GtkBuilder
*/
@@ -234,7 +236,8 @@ parole_media_list_add (ParoleMediaList *list, ParoleFile *file, gboolean emit, g
}
static void
-parole_media_list_files_opened_cb (ParoleMediaChooser *chooser, GSList *files, ParoleMediaList *list)
+parole_media_list_files_opened_cb (ParoleMediaChooser *chooser, gboolean replace,
+ GSList *files, ParoleMediaList *list)
{
ParoleFile *file;
guint len;
@@ -242,8 +245,10 @@ parole_media_list_files_opened_cb (ParoleMediaChooser *chooser, GSList *files, P
len = g_slist_length (files);
TRACE ("Adding files");
+
if ( len != 0 )
{
+ parole_media_list_clear_list (list);
file = g_slist_nth_data (files, 0);
parole_media_list_add (list, file, TRUE, TRUE);
}
@@ -1075,7 +1080,7 @@ void parole_media_list_load (ParoleMediaList *list)
fileslist = parole_pl_parser_load_file (playlist_file);
g_free (playlist_file);
- parole_media_list_files_opened_cb (NULL, fileslist, list);
+ parole_media_list_files_opened_cb (NULL, FALSE, fileslist, list);
g_slist_free (fileslist);
}
}
@@ -1095,7 +1100,7 @@ parole_media_list_add_by_path (ParoleMediaList *list, const gchar *path, gboolea
parole_get_media_files (filter, path, TRUE, &file_list);
- parole_media_list_files_opened_cb (NULL, file_list, list);
+ parole_media_list_files_opened_cb (NULL, FALSE, file_list, list);
len = g_slist_length (file_list);
ret = len == 0 ? FALSE : TRUE;
More information about the Xfce4-commits
mailing list