[brasero] Use our new BraseroSearchEngine in BraseroPlaylist object to abstract search completely in brasero



commit 13ff95210e5a1d8f1d6d90e4ff9300b55ff6c1e9
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sun Nov 8 14:23:24 2009 +0100

    Use our new BraseroSearchEngine in BraseroPlaylist object to abstract search completely in brasero

 configure.in                 |   21 +-
 libbrasero-media/Makefile.am |    3 +-
 src/Makefile.am              |   33 +-
 src/brasero-mime-filter.c    |    1 -
 src/brasero-playlist.c       |  947 ++++++++++++++++++------------------------
 src/brasero-search-beagle.c  |   58 +++-
 src/brasero-search-engine.c  |   58 ++-
 src/brasero-search-engine.h  |   24 +-
 src/brasero-search-entry.c   |   15 +-
 src/brasero-search-entry.h   |    4 -
 src/brasero-search.c         |    5 +-
 src/brasero-search.h         |    4 -
 12 files changed, 549 insertions(+), 624 deletions(-)
---
diff --git a/configure.in b/configure.in
index 4b9adfa..2e227b8 100644
--- a/configure.in
+++ b/configure.in
@@ -346,21 +346,20 @@ dnl ****************check for search (optional)**************
 BEAGLE_REQUIRED=0.3.0
 
 AC_ARG_ENABLE(search,
-			AS_HELP_STRING([--enable-search],[Build search pane (if beagle is available) [[default=yes]]]),
+			AS_HELP_STRING([--enable-search],[Build search pane (if a search backend is available) [[default=yes]]]),
 			[enable_search=$enableval],
 			[enable_search="yes"])
 
 if test x"$enable_search" = "xyes"; then
-	PKG_CHECK_MODULES(BRASERO_BEAGLE, libbeagle-1.0 >= $BEAGLE_REQUIRED, build_beagle=yes, build_beagle=no)
-else
-	build_beagle="no"
-fi
-
-if test x"$build_beagle" = "xyes"; then
-	AC_DEFINE(BUILD_SEARCH, 1, [define if you  want to use search pane])
+	PKG_CHECK_MODULES(BRASERO_SEARCH, libbeagle-1.0 >= $BEAGLE_REQUIRED, build_search=yes, build_search=no)
+	if test x"$build_search" = "xyes"; then
+		AC_DEFINE(BUILD_SEARCH, 1, [define if you  want to use search pane])
 	
-	AC_SUBST(BRASERO_BEAGLE_CFLAGS)
-	AC_SUBST(BRASERO_BEAGLE_LIBS)
+		AC_SUBST(BRASERO_SEARCH_CFLAGS)
+		AC_SUBST(BRASERO_SEARCH_LIBS)
+	fi
+else
+	build_search="no"
 fi
 
 AM_CONDITIONAL(BUILD_SEARCH, test x"$build_search" = "xyes")
@@ -584,7 +583,7 @@ echo "Version: $BRASERO_VERSION
 	Update caches: ${enable_caches}
 	Build Nautilus extension : ${build_nautilus}
 	Build inotify: ${enable_inotify}
-	Build search pane : ${build_beagle}
+	Build search pane : ${build_search}
 	Build playlist pane : ${build_totem}
 	Build Preview pane : ${enable_preview}
 	Build cdrtools plugins : ${build_cdrtools}
diff --git a/libbrasero-media/Makefile.am b/libbrasero-media/Makefile.am
index e31bd54..95ca6b2 100644
--- a/libbrasero-media/Makefile.am
+++ b/libbrasero-media/Makefile.am
@@ -127,8 +127,7 @@ libbrasero_media_la_SOURCES =		\
 	scsi-inquiry.c         \
 	scsi-prevent-allow-medium-removal.c         \
 	scsi-inquiry.h         \
-	brasero-drive-priv.h         \
-	../src/brasero-search-engine.c
+	brasero-drive-priv.h
 
 # FreeBSD's SCSI CAM interface
 if HAVE_CAM_LIB_H
diff --git a/src/Makefile.am b/src/Makefile.am
index 8804c53..b2a9f37 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,7 @@ INCLUDES = \
 	$(BRASERO_DBUS_CFLAGS)						\
 	$(BRASERO_LIBUNIQUE_CFLAGS)                                     \
 	$(BRASERO_LIBXML_CFLAGS)					\
-	$(BRASERO_BEAGLE_CFLAGS)					\
+	$(BRASERO_SEARCH_CFLAGS)					\
 	$(BRASERO_PL_PARSER_CFLAGS)					\
 	$(BRASERO_LIBUNIQUE_CFLAGS)					\
 	$(BRASERO_SM_CFLAGS)
@@ -44,12 +44,6 @@ brasero_SOURCES = \
 	main.c		\
 	brasero-utils.h		\
 	brasero-utils.c         \
-	brasero-search-entry.c         \
-	brasero-search-entry.h         \
-	brasero-mime-filter.c         \
-	brasero-mime-filter.h         \
-	brasero-playlist.c         \
-	brasero-playlist.h         \
 	brasero-player.c         \
 	brasero-player.h         \
 	brasero-eject-dialog.c		\
@@ -124,13 +118,28 @@ brasero_SOURCES = \
 	eggsmclient-xsmp.c        \
 	brasero-setting.h        \
 	brasero-setting.c        \
-	brasero-search.h        \
-	brasero-search.c        \
-	brasero-search-beagle.h        \
-	brasero-search-beagle.c        \
 	brasero-search-engine.h        \
 	brasero-search-engine.c
 
+if BUILD_PLAYLIST
+brasero_SOURCES += \
+	brasero-playlist.c         \
+	brasero-playlist.h
+
+endif
+
+if BUILD_SEARCH
+brasero_SOURCES += \
+		   brasero-mime-filter.c         \
+		   brasero-mime-filter.h         \
+		   brasero-search-entry.c         \
+		   brasero-search-entry.h         \
+		   brasero-search.h		\
+		   brasero-search.c		\
+		   brasero-search-beagle.h	\
+		   brasero-search-beagle.c
+endif
+
 brasero_LDADD =						\
 	$(top_builddir)/libbrasero-media/libbrasero-media.la	\
 	$(top_builddir)/libbrasero-burn/libbrasero-burn.la	\
@@ -146,7 +155,7 @@ brasero_LDADD =						\
 	$(BRASERO_DBUS_LIBS)		\
 	$(BRASERO_LIBUNIQUE_LIBS)	\
 	$(BRASERO_LIBXML_LIBS)		\
-	$(BRASERO_BEAGLE_LIBS)		\
+	$(BRASERO_SEARCH_LIBS)		\
 	$(BRASERO_PL_PARSER_LIBS)	\
 	$(BRASERO_LIBUNIQUE_LIBS)	\
 	$(BRASERO_SM_LIBS)
diff --git a/src/brasero-mime-filter.c b/src/brasero-mime-filter.c
index 1b2b16d..e7208bd 100644
--- a/src/brasero-mime-filter.c
+++ b/src/brasero-mime-filter.c
@@ -170,7 +170,6 @@ brasero_mime_filter_unref_mime (BraseroMimeFilter * filter, const char *mime)
 	GtkFileFilter *item;
 
 	item = g_hash_table_lookup (filter->priv->table, mime);
-	g_print ("IIII %p %s\n", item, mime);
 	if (item)
 		g_object_unref (item);
 }
diff --git a/src/brasero-playlist.c b/src/brasero-playlist.c
index 7cb10de..9276455 100644
--- a/src/brasero-playlist.c
+++ b/src/brasero-playlist.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 /***************************************************************************
 *            play-list.c
 *
@@ -29,8 +30,6 @@
 #  include <config.h>
 #endif
 
-#ifdef BUILD_PLAYLIST
-
 #include <string.h>
 
 #include <glib.h>
@@ -41,10 +40,6 @@
 
 #include <gtk/gtk.h>
 
-#ifdef BUILD_SEARCH
-#include <beagle/beagle.h>
-#endif
-
 #include <totem-pl-parser.h>
 
 #include "brasero-misc.h"
@@ -53,6 +48,7 @@
 
 #include "brasero-app.h"
 #include "brasero-playlist.h"
+#include "brasero-search-engine.h"
 #include "brasero-utils.h"
 #include "brasero-metadata.h"
 #include "brasero-io.h"
@@ -61,20 +57,10 @@
 #include "brasero-uri-container.h"
 #include "brasero-layout-object.h"
 
-static void brasero_playlist_class_init (BraseroPlaylistClass *klass);
-static void brasero_playlist_init (BraseroPlaylist *sp);
-static void brasero_playlist_iface_uri_container_init (BraseroURIContainerIFace *iface);
-static void brasero_playlist_iface_layout_object_init (BraseroLayoutObjectIFace *iface);
-static void brasero_playlist_finalize (GObject *object);
-static void brasero_playlist_destroy (GtkObject *object);
 
 struct BraseroPlaylistPrivate {
-
-#ifdef BUILD_SEARCH
-	BeagleClient *client;
-	BeagleQuery *query;
+	BraseroSearchEngine *engine;
 	int id;
-#endif
 
 	GtkWidget *tree;
 	GtkWidget *button_add;
@@ -96,56 +82,6 @@ enum {
 	BRASERO_PLAYLIST_NB_COL,
 };
 
-#ifdef BUILD_SEARCH
-
-static void brasero_playlist_beagle_hit_added_cb (BeagleQuery *query,
-						  BeagleHitsAddedResponse *response,
-						  BraseroPlaylist *playlist);
-static void brasero_playlist_beagle_hit_substracted_cb (BeagleQuery *query,
-							BeagleHitsSubtractedResponse *response,
-							BraseroPlaylist *playlist);
-static void brasero_playlist_beagle_finished_cb (BeagleQuery *query,
-						 BeagleFinishedResponse *response,
-						 BraseroPlaylist *playlist);
-#endif
-
-static void brasero_playlist_drag_data_get_cb (GtkTreeView *tree,
-					       GdkDragContext *drag_context,
-					       GtkSelectionData *selection_data,
-					       guint info,
-					       guint time,
-					       BraseroPlaylist *playlist);
-static void brasero_playlist_add_cb (GtkButton *button,
-				     BraseroPlaylist *playlist);
-static void brasero_playlist_remove_cb (GtkButton *button,
-					BraseroPlaylist *playlist);
-static void brasero_playlist_add_uri_playlist (BraseroPlaylist *playlist,
-					       const char *uri,
-					       gboolean quiet);
-static void brasero_playlist_search_playlists_rhythmbox (BraseroPlaylist *playlist);
-static void brasero_playlist_increase_activity_counter (BraseroPlaylist *playlist);
-static void brasero_playlist_decrease_activity_counter (BraseroPlaylist *playlist);
-static void brasero_playlist_row_activated_cb (GtkTreeView *tree,
-					       GtkTreeIter *row,
-					       GtkTreeViewColumn *column,
-					       BraseroPlaylist *playlist);
-static void brasero_playlist_selection_changed_cb (GtkTreeSelection *
-						   selection,
-						   BraseroPlaylist *
-						   playlist);
-static gchar **brasero_playlist_get_selected_uris_real (BraseroPlaylist *playlist);
-
-static gchar **
-brasero_playlist_get_selected_uris (BraseroURIContainer *container);
-static gchar *
-brasero_playlist_get_selected_uri (BraseroURIContainer *container);
-
-static void
-brasero_playlist_get_proportion (BraseroLayoutObject *object,
-				 gint *header,
-				 gint *center,
-				 gint *footer);
-
 enum {
 	TARGET_URIS_LIST,
 };
@@ -155,79 +91,18 @@ static GtkTargetEntry ntables[] = {
 };
 static guint nb_ntables = sizeof (ntables) / sizeof (ntables[0]);
 
-static GObjectClass *parent_class = NULL;
-
-#define BRASERO_PLAYLIST_SPACING 6
-
-GType
-brasero_playlist_get_type ()
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo our_info = {
-			sizeof (BraseroPlaylistClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) brasero_playlist_class_init,
-			NULL,
-			NULL,
-			sizeof (BraseroPlaylist),
-			0,
-			(GInstanceInitFunc) brasero_playlist_init,
-		};
-
-		static const GInterfaceInfo uri_container_info =
-		{
-			(GInterfaceInitFunc) brasero_playlist_iface_uri_container_init,
-			NULL,
-			NULL
-		};
-		static const GInterfaceInfo layout_object_info =
-		{
-			(GInterfaceInitFunc) brasero_playlist_iface_layout_object_init,
-			NULL,
-			NULL
-		};
-
-		type = g_type_register_static (GTK_TYPE_VBOX,
-					       "BraseroPlaylist",
-					       &our_info, 0);
-
-		g_type_add_interface_static (type,
-					     BRASERO_TYPE_URI_CONTAINER,
-					     &uri_container_info);
-		g_type_add_interface_static (type,
-					     BRASERO_TYPE_LAYOUT_OBJECT,
-					     &layout_object_info);
-	}
-
-	return type;
-}
-
-static void
-brasero_playlist_class_init (BraseroPlaylistClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
-
-	parent_class = g_type_class_peek_parent (klass);
-	object_class->finalize = brasero_playlist_finalize;
-	gtkobject_class->destroy = brasero_playlist_destroy;
-}
+static void brasero_playlist_iface_uri_container_init (BraseroURIContainerIFace *iface);
+static void brasero_playlist_iface_layout_object_init (BraseroLayoutObjectIFace *iface);
 
-static void
-brasero_playlist_iface_uri_container_init (BraseroURIContainerIFace *iface)
-{
-	iface->get_selected_uri = brasero_playlist_get_selected_uri;
-	iface->get_selected_uris = brasero_playlist_get_selected_uris;
-}
+G_DEFINE_TYPE_WITH_CODE (BraseroPlaylist,
+			 brasero_playlist,
+			 GTK_TYPE_VBOX,
+			 G_IMPLEMENT_INTERFACE (BRASERO_TYPE_URI_CONTAINER,
+					        brasero_playlist_iface_uri_container_init)
+			 G_IMPLEMENT_INTERFACE (BRASERO_TYPE_LAYOUT_OBJECT,
+					        brasero_playlist_iface_layout_object_init));
 
-static void
-brasero_playlist_iface_layout_object_init (BraseroLayoutObjectIFace *iface)
-{
-	iface->get_proportion = brasero_playlist_get_proportion;
-}
+#define BRASERO_PLAYLIST_SPACING 6
 
 static void
 brasero_playlist_get_proportion (BraseroLayoutObject *object,
@@ -243,141 +118,6 @@ brasero_playlist_get_proportion (BraseroLayoutObject *object,
 }
 
 static void
-brasero_playlist_init (BraseroPlaylist *obj)
-{
-	GtkWidget *hbox, *scroll;
-	GtkTreeStore *store = NULL;
-	GtkCellRenderer *renderer;
-	GtkTreeViewColumn *column;
-
-	obj->priv = g_new0 (BraseroPlaylistPrivate, 1);
-	gtk_box_set_spacing (GTK_BOX (obj), BRASERO_PLAYLIST_SPACING);
-
-	hbox = gtk_hbox_new (FALSE, 8);
-	gtk_widget_show (hbox);
-
-	obj->priv->button_add = gtk_button_new_from_stock (GTK_STOCK_ADD);
-	gtk_widget_show (obj->priv->button_add);
-	gtk_box_pack_end (GTK_BOX (hbox),
-			  obj->priv->button_add,
-			  FALSE,
-			  FALSE,
-			  0);
-	g_signal_connect (G_OBJECT (obj->priv->button_add),
-			  "clicked",
-			  G_CALLBACK (brasero_playlist_add_cb),
-			  obj);
-
-	obj->priv->button_remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
-	gtk_widget_show (obj->priv->button_remove);
-	gtk_box_pack_end (GTK_BOX (hbox),
-			  obj->priv->button_remove,
-			  FALSE,
-			  FALSE,
-			  0);
-	g_signal_connect (G_OBJECT (obj->priv->button_remove),
-			  "clicked",
-			  G_CALLBACK (brasero_playlist_remove_cb),
-			  obj);
-
-	gtk_box_pack_end (GTK_BOX (obj), hbox, FALSE, FALSE, 0);
-
-	store = gtk_tree_store_new (BRASERO_PLAYLIST_NB_COL,
-				    G_TYPE_STRING,
-				    G_TYPE_STRING,
-				    G_TYPE_STRING,
-				    G_TYPE_STRING, 
-				    G_TYPE_STRING,
-				    G_TYPE_INT64);
-
-	obj->priv->tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
-	egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (obj->priv->tree));
-
-	gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (obj->priv->tree), TRUE);
-	gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (obj->priv->tree), TRUE);
-	gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (obj->priv->tree), TRUE);
-	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (obj->priv->tree), TRUE);
-	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (obj->priv->tree), TRUE);
-	gtk_tree_view_set_expander_column (GTK_TREE_VIEW (obj->priv->tree),
-					   BRASERO_PLAYLIST_DISPLAY_COL);
-
-	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Playlists"),
-							   renderer, "text",
-							   BRASERO_PLAYLIST_DISPLAY_COL,
-							   NULL);
-	gtk_tree_view_column_set_sort_column_id (column,
-						 BRASERO_PLAYLIST_DISPLAY_COL);
-	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
-				     column);
-	gtk_tree_view_column_set_expand (column, TRUE);
-
-	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Number of Songs"),
-							   renderer, "text",
-							   BRASERO_PLAYLIST_NB_SONGS_COL,
-							   NULL);
-	gtk_tree_view_column_set_sort_column_id (column,
-						 BRASERO_PLAYLIST_NB_SONGS_COL);
-	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
-				     column);
-
-	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Length"),
-							   renderer, "text",
-							   BRASERO_PLAYLIST_LEN_COL,
-							   NULL);
-	gtk_tree_view_column_set_sort_column_id (column,
-						 BRASERO_PLAYLIST_LEN_COL);
-	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
-				     column);
-
-	renderer = gtk_cell_renderer_text_new ();
-	column = gtk_tree_view_column_new_with_attributes (_("Genre"), renderer,
-							   "text",
-							   BRASERO_PLAYLIST_GENRE_COL,
-							   NULL);
-	gtk_tree_view_column_set_sort_column_id (column,
-						 BRASERO_PLAYLIST_GENRE_COL);
-	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
-				     column);
-
-	gtk_tree_view_set_search_column (GTK_TREE_VIEW (obj->priv->tree),
-					 BRASERO_PLAYLIST_DISPLAY_COL);
-	gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (obj->priv->tree),
-						GDK_BUTTON1_MASK, ntables,
-						nb_ntables,
-						GDK_ACTION_COPY |
-						GDK_ACTION_MOVE);
-
-	g_signal_connect (G_OBJECT (obj->priv->tree), "drag_data_get",
-			  G_CALLBACK (brasero_playlist_drag_data_get_cb),
-			  obj);
-
-	g_signal_connect (G_OBJECT (obj->priv->tree), "row_activated",
-			  G_CALLBACK (brasero_playlist_row_activated_cb),
-			  obj);
-
-	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->tree))),
-			  "changed",
-			  G_CALLBACK (brasero_playlist_selection_changed_cb),
-			  obj);
-
-	gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->tree)),
-				     GTK_SELECTION_MULTIPLE);
-
-	scroll = gtk_scrolled_window_new (NULL, NULL);
-	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
-					GTK_POLICY_AUTOMATIC,
-					GTK_POLICY_AUTOMATIC);
-	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
-					     GTK_SHADOW_IN);
-
-	gtk_container_add (GTK_CONTAINER (scroll), obj->priv->tree);
-	gtk_box_pack_start (GTK_BOX (obj), scroll, TRUE, TRUE, 0);
-}
-
-static void
 brasero_playlist_increase_activity_counter (BraseroPlaylist *playlist)
 {
 	if (!GTK_WIDGET (playlist->priv->tree)->window)
@@ -409,149 +149,59 @@ brasero_playlist_decrease_activity_counter (BraseroPlaylist *playlist)
 }
 
 static void
-brasero_playlist_destroy (GtkObject *object)
+brasero_playlist_search_playlists_rhythmbox (BraseroPlaylist *playlist)
 {
-	BraseroPlaylist *playlist = BRASERO_PLAYLIST (object);
-
-#ifdef BUILD_SEARCH
-
-	if (playlist->priv->id) {
-		g_source_remove (playlist->priv->id);
-		playlist->priv->id = 0;
-	}
-
-	if (playlist->priv->client) {
-		g_object_unref (playlist->priv->client);
-		playlist->priv->client = NULL;
-	}
-
-	if (playlist->priv->query) {
-		g_object_unref (playlist->priv->query);
-		playlist->priv->query = NULL;
-	}
-
-#endif
-
-	/* NOTE: we must do it here since cancel could call brasero_playlist_end
-	 * itself calling decrease_activity_counter. In finalize the latter will
-	 * raise problems since the GdkWindow has been destroyed */
-	if (playlist->priv->parse_type) {
-		brasero_io_cancel_by_base (playlist->priv->parse_type);
-		brasero_io_job_base_free (playlist->priv->parse_type);
-		playlist->priv->parse_type = NULL;
-	}
+/*	RBSource *source;
 
-	if (GTK_OBJECT_CLASS (parent_class)->destroy)
-		GTK_OBJECT_CLASS (parent_class)->destroy (object);
+	manager = rb_playlist_manager_new ();
+	lists = rb_playlist_manager_get_playlists (manager);
+*/
 }
 
 static void
-brasero_playlist_finalize (GObject *object)
+brasero_playlist_search (BraseroPlaylist *playlist)
 {
-	BraseroPlaylist *cobj;
-
-	cobj = BRASERO_PLAYLIST (object);
+	const gchar* mimes [] = {"audio/x-ms-asx",
+		"audio/x-mpegurl",
+		"audio/x-scpls",
+		"audio/x-mp3-playlist",
+		NULL};
 
-	g_free (cobj->priv);
-
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	brasero_search_engine_new_query (playlist->priv->engine, NULL);
+	brasero_search_engine_set_query_mime (playlist->priv->engine, mimes);
+	brasero_search_engine_start_query (playlist->priv->engine);
+	brasero_playlist_increase_activity_counter (playlist);
 }
 
-#ifdef BUILD_SEARCH
-
 static gboolean
 brasero_playlist_try_again (BraseroPlaylist *playlist)
 {
-	playlist->priv->client = beagle_client_new (NULL);
-	if (!playlist->priv->client)
+	if (!brasero_search_engine_is_available (playlist->priv->engine))
 		return TRUE;
 
+	brasero_playlist_search (playlist);
+
 	playlist->priv->id = 0;
 	return FALSE;
 }
 
 static void
-brasero_playlist_start_beagle_search (BraseroPlaylist *playlist)
+brasero_playlist_start_search (BraseroPlaylist *playlist)
 {
-	playlist->priv->client = beagle_client_new (NULL);
-	if(playlist->priv->client) {
-		GError *error = NULL;
-		BeagleQueryPartOr *or_part;
-		BeagleQueryPartHuman *type;
-		BeagleQueryPartProperty *filetype;
-
-		playlist->priv->query = beagle_query_new ();
-
-		g_signal_connect (G_OBJECT (playlist->priv->query), "hits-added",
-				  G_CALLBACK (brasero_playlist_beagle_hit_added_cb),
-				  playlist);
-		g_signal_connect (G_OBJECT (playlist->priv->query), "hits-subtracted",
-				  G_CALLBACK (brasero_playlist_beagle_hit_substracted_cb),
-				  playlist);
-		g_signal_connect (G_OBJECT (playlist->priv->query), "finished",
-				  G_CALLBACK (brasero_playlist_beagle_finished_cb),
-				  playlist);
-	
-		type = beagle_query_part_human_new ();
-		beagle_query_part_human_set_string (type, "type:File");
-		beagle_query_add_part (playlist->priv->query, BEAGLE_QUERY_PART (type));
-
-		or_part = beagle_query_part_or_new ();
-
-		filetype = beagle_query_part_property_new ();
-		beagle_query_part_property_set_property_type (filetype, BEAGLE_PROPERTY_TYPE_KEYWORD);
-		beagle_query_part_property_set_key (filetype, "beagle:MimeType");
-		beagle_query_part_property_set_value (filetype, "audio/x-ms-asx");
-		beagle_query_part_or_add_subpart (or_part, BEAGLE_QUERY_PART (filetype));
-
-		filetype = beagle_query_part_property_new ();
-		beagle_query_part_property_set_property_type (filetype, BEAGLE_PROPERTY_TYPE_KEYWORD);
-		beagle_query_part_property_set_key (filetype, "beagle:MimeType");
-		beagle_query_part_property_set_value (filetype, "audio/x-mpegurl");
-		beagle_query_part_or_add_subpart (or_part, BEAGLE_QUERY_PART (filetype));
-
-		filetype = beagle_query_part_property_new ();
-		beagle_query_part_property_set_property_type (filetype, BEAGLE_PROPERTY_TYPE_KEYWORD);
-		beagle_query_part_property_set_key (filetype, "beagle:MimeType");
-		beagle_query_part_property_set_value (filetype, "audio/x-scpls");
-		beagle_query_part_or_add_subpart (or_part, BEAGLE_QUERY_PART (filetype));
-
-		filetype = beagle_query_part_property_new ();
-		beagle_query_part_property_set_property_type (filetype, BEAGLE_PROPERTY_TYPE_KEYWORD);
-		beagle_query_part_property_set_key (filetype, "beagle:FileType");
-		beagle_query_part_property_set_value (filetype, "audio/x-mp3-playlist");
-		beagle_query_part_or_add_subpart (or_part, BEAGLE_QUERY_PART (filetype));
-
-		beagle_query_add_part (playlist->priv->query, BEAGLE_QUERY_PART (or_part));
-
-		brasero_playlist_increase_activity_counter (playlist);
-		beagle_client_send_request_async (playlist->priv->client,
-						  BEAGLE_REQUEST (playlist->priv->query),
-						  &error);
-		if (error) {
-			g_warning ("Could not connect to beagle : %s\n",
-				   error->message);
-			g_error_free (error);
-		}
-	}
-	else {
+	if (!playlist->priv->engine)
+		return;
+
+	if (!brasero_search_engine_is_available (playlist->priv->engine)) {
 		/* we will retry in 10 seconds */
 		playlist->priv->id = g_timeout_add_seconds (10,
 							    (GSourceFunc) brasero_playlist_try_again,
 							    playlist);
+		return;
 	}
-}
-
-#else
 
-static void
-brasero_playlist_start_beagle_search (BraseroPlaylist *playlist)
-{
-	
+	brasero_playlist_search (playlist);
 }
 
-#endif /* BUILD_SEARCH */
-
 static gboolean
 brasero_playlist_expose_event_cb (GtkWidget *widget,
 				  gpointer event,
@@ -563,26 +213,74 @@ brasero_playlist_expose_event_cb (GtkWidget *widget,
 	 * is if they become apparent. That will avoid overhead */
 	if (!playlist->priv->searched) {
 		playlist->priv->searched = 1;
-		brasero_playlist_start_beagle_search (playlist);
+		brasero_playlist_start_search (playlist);
 		brasero_playlist_search_playlists_rhythmbox (playlist);
 	}
 
 	return FALSE;
 }
 
-GtkWidget *
-brasero_playlist_new ()
+static gchar **
+brasero_playlist_get_selected_uris_real (BraseroPlaylist *playlist)
 {
-	BraseroPlaylist *obj;
+	GtkTreeSelection *selection;
+	GtkTreeModel *model;
+	GtkTreePath *path;
+	GList *rows, *iter;
+	GtkTreeIter row;
+	gchar **uris = NULL, *uri;
+	GPtrArray *array;
+	gboolean valid;
 
-	obj = BRASERO_PLAYLIST (g_object_new (BRASERO_TYPE_PLAYLIST, NULL));
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (playlist->priv->tree));
+	rows = gtk_tree_selection_get_selected_rows (selection, &model);
 
-	g_signal_connect (obj,
-			  "expose-event",
-			  G_CALLBACK (brasero_playlist_expose_event_cb),
-			  NULL);
+	if (rows == NULL)
+		return NULL;
 
-	return GTK_WIDGET (obj);
+	array = g_ptr_array_sized_new (g_list_length (rows) + 1);
+	for (iter = rows; iter; iter = iter->next) {
+		path = iter->data;
+		valid = gtk_tree_model_get_iter (model, &row, path);
+		gtk_tree_path_free (path);
+
+		if (valid == FALSE)
+			continue;
+
+		/* FIXME : we must find a way to reverse the list */
+		/* check if it is a list or not */
+		if (gtk_tree_model_iter_has_child (model, &row)) {
+			GtkTreeIter child;
+
+			if (gtk_tree_model_iter_children (model, &child, &row) == FALSE)
+				continue;
+
+			do {
+				/* first check if the row is selected to prevent to put it in the list twice */
+				if (gtk_tree_selection_iter_is_selected (selection, &child) == TRUE)
+					continue;
+
+				gtk_tree_model_get (model, &child,
+						    BRASERO_PLAYLIST_URI_COL, &uri,
+						    -1);
+				g_ptr_array_add (array, uri);
+			} while (gtk_tree_model_iter_next (model, &child));
+
+			continue;
+		}
+
+		gtk_tree_model_get (model, &row,
+				    BRASERO_PLAYLIST_URI_COL, &uri,
+				    -1);
+		g_ptr_array_add (array, uri);
+	}
+
+	g_list_free (rows);
+
+	g_ptr_array_set_size (array, array->len + 1);
+	uris = (gchar **) array->pdata;
+	g_ptr_array_free (array, FALSE);
+	return uris;
 }
 
 static gchar **
@@ -614,50 +312,6 @@ brasero_playlist_get_selected_uri (BraseroURIContainer *container)
 }
 
 static void
-brasero_playlist_add_cb (GtkButton *button, BraseroPlaylist *playlist)
-{
-	GtkWidget *dialog, *toplevel;
-	gchar *uri;
-	GSList *uris, *iter;
-	gint result;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (playlist));
-	if (!GTK_WIDGET_TOPLEVEL (toplevel))
-		return;
-
-	dialog = gtk_file_chooser_dialog_new (_("Select Playlist"),
-					      GTK_WINDOW (toplevel),
-					      GTK_FILE_CHOOSER_ACTION_OPEN,
-					      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					      GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-					      NULL);
-
-	gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-					 GTK_RESPONSE_ACCEPT);
-	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
-	gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
-	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
-						 g_get_home_dir ());
-
-	gtk_widget_show_all (dialog);
-	result = gtk_dialog_run (GTK_DIALOG (dialog));
-	if (result == GTK_RESPONSE_CANCEL) {
-		gtk_widget_destroy (dialog);
-		return;
-	}
-
-	uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
-	gtk_widget_destroy (dialog);
-
-	for (iter = uris; iter; iter = iter->next) {
-		uri = iter->data;
-		brasero_playlist_add_uri_playlist (playlist, uri, FALSE);
-		g_free (uri);
-	}
-	g_slist_free (uris);
-}
-
-static void
 brasero_playlist_remove_cb (GtkButton *button, BraseroPlaylist *playlist)
 {
 	GtkTreeSelection *selection;
@@ -697,69 +351,6 @@ brasero_playlist_remove_cb (GtkButton *button, BraseroPlaylist *playlist)
 	g_list_free (rows);
 }
 
-static gchar **
-brasero_playlist_get_selected_uris_real (BraseroPlaylist *playlist)
-{
-	GtkTreeSelection *selection;
-	GtkTreeModel *model;
-	GtkTreePath *path;
-	GList *rows, *iter;
-	GtkTreeIter row;
-	gchar **uris = NULL, *uri;
-	GPtrArray *array;
-	gboolean valid;
-
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (playlist->priv->tree));
-	rows = gtk_tree_selection_get_selected_rows (selection, &model);
-
-	if (rows == NULL)
-		return NULL;
-
-	array = g_ptr_array_sized_new (g_list_length (rows) + 1);
-	for (iter = rows; iter; iter = iter->next) {
-		path = iter->data;
-		valid = gtk_tree_model_get_iter (model, &row, path);
-		gtk_tree_path_free (path);
-
-		if (valid == FALSE)
-			continue;
-
-		/* FIXME : we must find a way to reverse the list */
-		/* check if it is a list or not */
-		if (gtk_tree_model_iter_has_child (model, &row)) {
-			GtkTreeIter child;
-
-			if (gtk_tree_model_iter_children (model, &child, &row) == FALSE)
-				continue;
-
-			do {
-				/* first check if the row is selected to prevent to put it in the list twice */
-				if (gtk_tree_selection_iter_is_selected (selection, &child) == TRUE)
-					continue;
-
-				gtk_tree_model_get (model, &child,
-						    BRASERO_PLAYLIST_URI_COL, &uri,
-						    -1);
-				g_ptr_array_add (array, uri);
-			} while (gtk_tree_model_iter_next (model, &child));
-
-			continue;
-		}
-
-		gtk_tree_model_get (model, &row,
-				    BRASERO_PLAYLIST_URI_COL, &uri,
-				    -1);
-		g_ptr_array_add (array, uri);
-	}
-
-	g_list_free (rows);
-
-	g_ptr_array_set_size (array, array->len + 1);
-	uris = (gchar **) array->pdata;
-	g_ptr_array_free (array, FALSE);
-	return uris;
-}
-
 static void
 brasero_playlist_drag_data_get_cb (GtkTreeView *tree,
 				   GdkDragContext *drag_context,
@@ -974,80 +565,106 @@ brasero_playlist_add_uri_playlist (BraseroPlaylist *playlist,
 }
 
 static void
-brasero_playlist_search_playlists_rhythmbox (BraseroPlaylist *playlist)
+brasero_playlist_add_cb (GtkButton *button, BraseroPlaylist *playlist)
 {
-/*	RBSource *source;
+	GtkWidget *dialog, *toplevel;
+	gchar *uri;
+	GSList *uris, *iter;
+	gint result;
 
-	manager = rb_playlist_manager_new ();
-	lists = rb_playlist_manager_get_playlists (manager);
-*/
-}
+	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (playlist));
+	if (!GTK_WIDGET_TOPLEVEL (toplevel))
+		return;
+
+	dialog = gtk_file_chooser_dialog_new (_("Select Playlist"),
+					      GTK_WINDOW (toplevel),
+					      GTK_FILE_CHOOSER_ACTION_OPEN,
+					      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+					      GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+					      NULL);
+
+	gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+					 GTK_RESPONSE_ACCEPT);
+	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
+	gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
+	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
+						 g_get_home_dir ());
+
+	gtk_widget_show_all (dialog);
+	result = gtk_dialog_run (GTK_DIALOG (dialog));
+	if (result == GTK_RESPONSE_CANCEL) {
+		gtk_widget_destroy (dialog);
+		return;
+	}
 
-#ifdef BUILD_SEARCH
+	uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
+	gtk_widget_destroy (dialog);
+
+	for (iter = uris; iter; iter = iter->next) {
+		uri = iter->data;
+		brasero_playlist_add_uri_playlist (playlist, uri, FALSE);
+		g_free (uri);
+	}
+	g_slist_free (uris);
+}
 
 static void
-brasero_playlist_beagle_hit_added_cb (BeagleQuery *query,
-				      BeagleHitsAddedResponse *response,
-				      BraseroPlaylist *playlist)
+brasero_playlist_search_hit_added_cb (BraseroSearchEngine *engine,
+                                      gpointer hit,
+                                      BraseroPlaylist *playlist)
 {
-	GSList *list, *iter;
-	BeagleHit *hit;
 	const char *uri;
 
-	list = beagle_hits_added_response_get_hits (response);
-	for (iter = list; iter; iter = iter->next) {
-		hit = iter->data;
-		uri = beagle_hit_get_uri (hit);
-		brasero_playlist_add_uri_playlist (playlist, uri, TRUE);
-	}
+	uri = brasero_search_engine_uri_from_hit (engine, hit);
+	brasero_playlist_add_uri_playlist (playlist, uri, TRUE);
 	brasero_playlist_decrease_activity_counter (playlist);
 }
 
 static void
-brasero_playlist_beagle_hit_substracted_cb (BeagleQuery *query,
-					    BeagleHitsSubtractedResponse *response,
-					    BraseroPlaylist *playlist)
+brasero_playlist_search_hit_substracted_cb (BraseroSearchEngine *engine,
+                                            gpointer hit,
+                                            BraseroPlaylist *playlist)
 {
-	GSList *list, *iter;
-	const char *uri;
-	char *row_uri;
-
 	GtkTreeModel *model;
 	GtkTreeIter row;
+	const gchar *uri;
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (playlist->priv->tree));
+	uri = brasero_search_engine_uri_from_hit (engine, hit);
 
-	list = beagle_hits_subtracted_response_get_uris (response);
-	for (iter = list; iter; iter = iter->next) {
-		uri = iter->data;
+	if (!gtk_tree_model_get_iter_first (model, &row))
+		return;
 
-		if (!gtk_tree_model_get_iter_first (model, &row))
-			continue;
+	do {
+		char *row_uri;
 
-		do {
-			gtk_tree_model_get (model, &row,
-					    BRASERO_PLAYLIST_URI_COL, &row_uri,
-					    -1);
+		gtk_tree_model_get (model, &row,
+				    BRASERO_PLAYLIST_URI_COL, &row_uri,
+				    -1);
 
-			if (!strcmp (row_uri, uri)) {
-				gtk_tree_store_remove (GTK_TREE_STORE (model), &row);
-				g_free (row_uri);
-				break;
-			}
+		if (!strcmp (row_uri, uri)) {
+			gtk_tree_store_remove (GTK_TREE_STORE (model), &row);
 			g_free (row_uri);
-		} while (gtk_tree_model_iter_next (model, &row));
-	}
+			return;
+		}
+
+		g_free (row_uri);
+	} while (gtk_tree_model_iter_next (model, &row));
 }
 
 static void
-brasero_playlist_beagle_finished_cb (BeagleQuery *query,
-				     BeagleFinishedResponse *response,
-				     BraseroPlaylist *playlist)
+brasero_playlist_search_finished_cb (BraseroSearchEngine *engine,
+                                     BraseroPlaylist *playlist)
 {
 	brasero_playlist_decrease_activity_counter (playlist);
 }
 
-#endif /* BUILD_SEARCH */
+static void
+brasero_playlist_search_error_cb (BraseroSearchEngine *engine,
+                                  BraseroPlaylist *playlist)
+{
+
+}
 
 static void
 brasero_playlist_row_activated_cb (GtkTreeView *tree,
@@ -1065,4 +682,232 @@ brasero_playlist_selection_changed_cb (GtkTreeSelection *selection,
 	brasero_uri_container_uri_selected (BRASERO_URI_CONTAINER (playlist));
 }
 
-#endif /* BUILD_PLAYLIST */
+static void
+brasero_playlist_init (BraseroPlaylist *obj)
+{
+	GtkWidget *hbox, *scroll;
+	GtkTreeStore *store = NULL;
+	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
+
+	obj->priv = g_new0 (BraseroPlaylistPrivate, 1);
+	gtk_box_set_spacing (GTK_BOX (obj), BRASERO_PLAYLIST_SPACING);
+
+	hbox = gtk_hbox_new (FALSE, 8);
+	gtk_widget_show (hbox);
+
+	obj->priv->button_add = gtk_button_new_from_stock (GTK_STOCK_ADD);
+	gtk_widget_show (obj->priv->button_add);
+	gtk_box_pack_end (GTK_BOX (hbox),
+			  obj->priv->button_add,
+			  FALSE,
+			  FALSE,
+			  0);
+	g_signal_connect (G_OBJECT (obj->priv->button_add),
+			  "clicked",
+			  G_CALLBACK (brasero_playlist_add_cb),
+			  obj);
+
+	obj->priv->button_remove = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+	gtk_widget_show (obj->priv->button_remove);
+	gtk_box_pack_end (GTK_BOX (hbox),
+			  obj->priv->button_remove,
+			  FALSE,
+			  FALSE,
+			  0);
+	g_signal_connect (G_OBJECT (obj->priv->button_remove),
+			  "clicked",
+			  G_CALLBACK (brasero_playlist_remove_cb),
+			  obj);
+
+	gtk_box_pack_end (GTK_BOX (obj), hbox, FALSE, FALSE, 0);
+
+	store = gtk_tree_store_new (BRASERO_PLAYLIST_NB_COL,
+				    G_TYPE_STRING,
+				    G_TYPE_STRING,
+				    G_TYPE_STRING,
+				    G_TYPE_STRING, 
+				    G_TYPE_STRING,
+				    G_TYPE_INT64);
+
+	obj->priv->tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+	egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (obj->priv->tree));
+
+	gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (obj->priv->tree), TRUE);
+	gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (obj->priv->tree), TRUE);
+	gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (obj->priv->tree), TRUE);
+	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (obj->priv->tree), TRUE);
+	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (obj->priv->tree), TRUE);
+	gtk_tree_view_set_expander_column (GTK_TREE_VIEW (obj->priv->tree),
+					   BRASERO_PLAYLIST_DISPLAY_COL);
+
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Playlists"),
+							   renderer, "text",
+							   BRASERO_PLAYLIST_DISPLAY_COL,
+							   NULL);
+	gtk_tree_view_column_set_sort_column_id (column,
+						 BRASERO_PLAYLIST_DISPLAY_COL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
+				     column);
+	gtk_tree_view_column_set_expand (column, TRUE);
+
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Number of Songs"),
+							   renderer, "text",
+							   BRASERO_PLAYLIST_NB_SONGS_COL,
+							   NULL);
+	gtk_tree_view_column_set_sort_column_id (column,
+						 BRASERO_PLAYLIST_NB_SONGS_COL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
+				     column);
+
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Length"),
+							   renderer, "text",
+							   BRASERO_PLAYLIST_LEN_COL,
+							   NULL);
+	gtk_tree_view_column_set_sort_column_id (column,
+						 BRASERO_PLAYLIST_LEN_COL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
+				     column);
+
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Genre"), renderer,
+							   "text",
+							   BRASERO_PLAYLIST_GENRE_COL,
+							   NULL);
+	gtk_tree_view_column_set_sort_column_id (column,
+						 BRASERO_PLAYLIST_GENRE_COL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (obj->priv->tree),
+				     column);
+
+	gtk_tree_view_set_search_column (GTK_TREE_VIEW (obj->priv->tree),
+					 BRASERO_PLAYLIST_DISPLAY_COL);
+	gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (obj->priv->tree),
+						GDK_BUTTON1_MASK, ntables,
+						nb_ntables,
+						GDK_ACTION_COPY |
+						GDK_ACTION_MOVE);
+
+	g_signal_connect (G_OBJECT (obj->priv->tree), "drag_data_get",
+			  G_CALLBACK (brasero_playlist_drag_data_get_cb),
+			  obj);
+
+	g_signal_connect (G_OBJECT (obj->priv->tree), "row_activated",
+			  G_CALLBACK (brasero_playlist_row_activated_cb),
+			  obj);
+
+	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->tree))),
+			  "changed",
+			  G_CALLBACK (brasero_playlist_selection_changed_cb),
+			  obj);
+
+	gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->tree)),
+				     GTK_SELECTION_MULTIPLE);
+
+	scroll = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+					GTK_POLICY_AUTOMATIC,
+					GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+					     GTK_SHADOW_IN);
+
+	gtk_container_add (GTK_CONTAINER (scroll), obj->priv->tree);
+	gtk_box_pack_start (GTK_BOX (obj), scroll, TRUE, TRUE, 0);
+
+	obj->priv->engine = brasero_search_engine_new_default ();
+	if (!obj->priv->engine)
+		return;
+
+	g_signal_connect (G_OBJECT (obj->priv->engine), "hit-added",
+			  G_CALLBACK (brasero_playlist_search_hit_added_cb),
+			  obj);
+	g_signal_connect (G_OBJECT (obj->priv->engine), "hit-removed",
+			  G_CALLBACK (brasero_playlist_search_hit_substracted_cb),
+			  obj);
+	g_signal_connect (G_OBJECT (obj->priv->engine), "search-finished",
+			  G_CALLBACK (brasero_playlist_search_finished_cb),
+			  obj);
+	g_signal_connect (G_OBJECT (obj->priv->engine), "search-error",
+			  G_CALLBACK (brasero_playlist_search_error_cb),
+			  obj);
+}
+
+static void
+brasero_playlist_destroy (GtkObject *object)
+{
+	BraseroPlaylist *playlist = BRASERO_PLAYLIST (object);
+
+	if (playlist->priv->id) {
+		g_source_remove (playlist->priv->id);
+		playlist->priv->id = 0;
+	}
+
+	if (playlist->priv->engine) {
+		g_object_unref (playlist->priv->engine);
+		playlist->priv->engine = NULL;
+	}
+
+	/* NOTE: we must do it here since cancel could call brasero_playlist_end
+	 * itself calling decrease_activity_counter. In finalize the latter will
+	 * raise problems since the GdkWindow has been destroyed */
+	if (playlist->priv->parse_type) {
+		brasero_io_cancel_by_base (playlist->priv->parse_type);
+		brasero_io_job_base_free (playlist->priv->parse_type);
+		playlist->priv->parse_type = NULL;
+	}
+
+	if (GTK_OBJECT_CLASS (brasero_playlist_parent_class)->destroy)
+		GTK_OBJECT_CLASS (brasero_playlist_parent_class)->destroy (object);
+}
+
+static void
+brasero_playlist_finalize (GObject *object)
+{
+	BraseroPlaylist *cobj;
+
+	cobj = BRASERO_PLAYLIST (object);
+
+	g_free (cobj->priv);
+
+	G_OBJECT_CLASS (brasero_playlist_parent_class)->finalize (object);
+}
+
+static void
+brasero_playlist_class_init (BraseroPlaylistClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
+
+	object_class->finalize = brasero_playlist_finalize;
+	gtkobject_class->destroy = brasero_playlist_destroy;
+}
+
+static void
+brasero_playlist_iface_uri_container_init (BraseroURIContainerIFace *iface)
+{
+	iface->get_selected_uri = brasero_playlist_get_selected_uri;
+	iface->get_selected_uris = brasero_playlist_get_selected_uris;
+}
+
+static void
+brasero_playlist_iface_layout_object_init (BraseroLayoutObjectIFace *iface)
+{
+	iface->get_proportion = brasero_playlist_get_proportion;
+}
+
+GtkWidget *
+brasero_playlist_new ()
+{
+	BraseroPlaylist *obj;
+
+	obj = BRASERO_PLAYLIST (g_object_new (BRASERO_TYPE_PLAYLIST, NULL));
+
+	g_signal_connect (obj,
+			  "expose-event",
+			  G_CALLBACK (brasero_playlist_expose_event_cb),
+			  NULL);
+
+	return GTK_WIDGET (obj);
+}
diff --git a/src/brasero-search-beagle.c b/src/brasero-search-beagle.c
index 00bf6ae..40d3f43 100644
--- a/src/brasero-search-beagle.c
+++ b/src/brasero-search-beagle.c
@@ -325,20 +325,18 @@ brasero_search_beagle_clean (BraseroSearchBeagle *beagle)
 }
 
 static gboolean
-brasero_search_beagle_query_set (BraseroSearchEngine *search,
-                                 BraseroSearchScope scope,
-                                 const gchar *keywords)
+brasero_search_beagle_query_new (BraseroSearchEngine *search,
+                                  const gchar *keywords)
 {
-	BeagleQueryPartHuman *text;
-	BeagleQueryPartOr *or_part = NULL;
 	BraseroSearchBeaglePrivate *priv;
+	BeagleQueryPartHuman *text;
 
 	priv = BRASERO_SEARCH_BEAGLE_PRIVATE (search);
 
 	brasero_search_beagle_clean (BRASERO_SEARCH_BEAGLE (search));
 	priv->query = beagle_query_new ();
 
-	if ((scope & BRASERO_SEARCH_SCOPE_WILDCARD) == 0) {
+	if (keywords) {
 		BeagleQueryPartHuman *text;
 
 		text = beagle_query_part_human_new ();
@@ -353,6 +351,21 @@ brasero_search_beagle_query_set (BraseroSearchEngine *search,
 	beagle_query_part_human_set_string (text, "type:File");
 	beagle_query_add_part (priv->query, BEAGLE_QUERY_PART (text));
 
+	return TRUE;
+}
+
+static gboolean
+brasero_search_beagle_query_set_scope (BraseroSearchEngine *search,
+                                       BraseroSearchScope scope)
+{
+	BeagleQueryPartOr *or_part = NULL;
+	BraseroSearchBeaglePrivate *priv;
+
+	priv = BRASERO_SEARCH_BEAGLE_PRIVATE (search);
+
+	if (!priv->query)
+		return FALSE;
+
 	if (scope & BRASERO_SEARCH_SCOPE_DOCUMENTS) {
 		BeagleQueryPartProperty *filetype;
 
@@ -412,6 +425,35 @@ brasero_search_beagle_query_set (BraseroSearchEngine *search,
 	return TRUE;
 }
 
+static gboolean
+brasero_search_beagle_set_query_mime (BraseroSearchEngine *search,
+                                      const gchar **mimes)
+{
+	int i;
+	BeagleQueryPartOr *or_part;
+	BraseroSearchBeaglePrivate *priv;
+
+	priv = BRASERO_SEARCH_BEAGLE_PRIVATE (search);
+
+	if (!priv->query)
+		return FALSE;
+
+	or_part = beagle_query_part_or_new ();
+	for (i = 0; mimes [i]; i ++) {
+		BeagleQueryPartProperty *filetype;
+
+		filetype = beagle_query_part_property_new ();
+		beagle_query_part_property_set_property_type (filetype, BEAGLE_PROPERTY_TYPE_KEYWORD);
+		beagle_query_part_property_set_key (filetype, "beagle:MimeType");
+		beagle_query_part_property_set_value (filetype, mimes [i]);
+		beagle_query_part_or_add_subpart (or_part, BEAGLE_QUERY_PART (filetype));
+	}
+
+	beagle_query_add_part (priv->query, BEAGLE_QUERY_PART (or_part));
+
+	return TRUE;
+}
+
 static void
 brasero_search_beagle_init_engine (BraseroSearchEngineIface *iface)
 {
@@ -422,7 +464,9 @@ brasero_search_beagle_init_engine (BraseroSearchEngineIface *iface)
 	iface->score_from_hit = brasero_search_beagle_score_from_hit;
 	iface->mime_from_hit = brasero_search_beagle_mime_from_hit;
 	iface->description_from_hit = brasero_search_beagle_description_from_hit;
-	iface->query_set = brasero_search_beagle_query_set;
+	iface->query_new = brasero_search_beagle_query_new;
+	iface->query_set_scope = brasero_search_beagle_query_set_scope;
+	iface->query_set_mime = brasero_search_beagle_set_query_mime;
 	iface->query_start = brasero_search_beagle_query_start;
 	iface->add_hits = brasero_search_beagle_add_hit_to_tree;
 	iface->num_hits = brasero_search_beagle_num_hits;
diff --git a/src/brasero-search-engine.c b/src/brasero-search-engine.c
index 9d1b7ce..2f49b57 100644
--- a/src/brasero-search-engine.c
+++ b/src/brasero-search-engine.c
@@ -70,19 +70,48 @@ brasero_search_engine_start_query (BraseroSearchEngine *search)
 }
 
 gboolean
-brasero_search_engine_set_query (BraseroSearchEngine *search,
-                                   BraseroSearchScope scope,
-                                   const gchar *keywords)
+brasero_search_engine_new_query (BraseroSearchEngine *search,
+                                 const gchar *keywords)
 {
 	BraseroSearchEngineIface *iface;
 
 	g_return_val_if_fail (BRASERO_IS_SEARCH_ENGINE (search), FALSE);
 
 	iface = BRASERO_SEARCH_ENGINE_GET_IFACE (search);
-	if (!iface->query_set)
+	if (!iface->query_new)
 		return FALSE;
 
-	return (* iface->query_set) (search, scope, keywords);
+	return (* iface->query_new) (search, keywords);
+}
+
+gboolean
+brasero_search_engine_set_query_scope (BraseroSearchEngine *search,
+                                       BraseroSearchScope scope)
+{
+	BraseroSearchEngineIface *iface;
+
+	g_return_val_if_fail (BRASERO_IS_SEARCH_ENGINE (search), FALSE);
+
+	iface = BRASERO_SEARCH_ENGINE_GET_IFACE (search);
+	if (!iface->query_set_scope)
+		return FALSE;
+
+	return (* iface->query_set_scope) (search, scope);
+}
+
+gboolean
+brasero_search_engine_set_query_mime (BraseroSearchEngine *search,
+                                      const gchar **mimes)
+{
+	BraseroSearchEngineIface *iface;
+
+	g_return_val_if_fail (BRASERO_IS_SEARCH_ENGINE (search), FALSE);
+
+	iface = BRASERO_SEARCH_ENGINE_GET_IFACE (search);
+	if (!iface->query_set_mime)
+		return FALSE;
+
+	return (* iface->query_set_mime) (search, mimes);
 }
 
 gboolean
@@ -344,17 +373,24 @@ brasero_search_engine_base_init (gpointer g_class)
 	initialized = TRUE;
 }
 
+#ifdef BUILD_SEARCH
+
 #include "brasero-search-beagle.h"
 
 BraseroSearchEngine *search_engine = NULL;
 
 BraseroSearchEngine *
-brasero_search_engine_get_default (void)
+brasero_search_engine_new_default (void)
 {
-	if (!search_engine)
-		search_engine = g_object_new (BRASERO_TYPE_SEARCH_BEAGLE, NULL);
-	else
-		g_object_ref (search_engine);
+	return g_object_new (BRASERO_TYPE_SEARCH_BEAGLE, NULL);
+}
 
-	return search_engine;
+#else
+
+BraseroSearchEngine *
+brasero_search_engine_new_default (void)
+{
+	return NULL;
 }
+
+#endif
diff --git a/src/brasero-search-engine.h b/src/brasero-search-engine.h
index 9f7659f..27a3145 100644
--- a/src/brasero-search-engine.h
+++ b/src/brasero-search-engine.h
@@ -36,12 +36,11 @@ enum {
 };
 
 typedef enum {
-	BRASERO_SEARCH_SCOPE_NONE		= 0,
+	BRASERO_SEARCH_SCOPE_ANY		= 0,
 	BRASERO_SEARCH_SCOPE_VIDEO		= 1,
 	BRASERO_SEARCH_SCOPE_MUSIC		= 1 << 1,
 	BRASERO_SEARCH_SCOPE_PICTURES	= 1 << 2,
 	BRASERO_SEARCH_SCOPE_DOCUMENTS	= 1 << 3,
-	BRASERO_SEARCH_SCOPE_WILDCARD	= 1 << 4
 } BraseroSearchScope;
 
 #define BRASERO_TYPE_SEARCH_ENGINE         (brasero_search_engine_get_type ())
@@ -65,10 +64,12 @@ struct _BraseroSearchEngineIface {
 
 	/* <Virtual functions> */
 	gboolean	(*is_available)			(BraseroSearchEngine *search);
-	gboolean	(*query_set)			(BraseroSearchEngine *search,
-					                     BraseroSearchScope scope,
+	gboolean	(*query_new)			(BraseroSearchEngine *search,
 					                     const gchar *keywords);
-
+	gboolean	(*query_set_scope)	(BraseroSearchEngine *search,
+					                     BraseroSearchScope scope);
+	gboolean	(*query_set_mime)		(BraseroSearchEngine *search,
+					                     const gchar **mimes);
 	gboolean	(*query_start)		(BraseroSearchEngine *search);
 
 	gboolean	(*add_hits)			(BraseroSearchEngine *search,
@@ -95,7 +96,7 @@ struct _BraseroSearchEngineIface {
 GType brasero_search_engine_get_type (void);
 
 BraseroSearchEngine *
-brasero_search_engine_get_default (void);
+brasero_search_engine_new_default (void);
 
 gboolean
 brasero_search_engine_is_available (BraseroSearchEngine *search);
@@ -104,11 +105,18 @@ gint
 brasero_search_engine_num_hits (BraseroSearchEngine *search);
 
 gboolean
-brasero_search_engine_set_query (BraseroSearchEngine *search,
-                                 BraseroSearchScope scope,
+brasero_search_engine_new_query (BraseroSearchEngine *search,
                                  const gchar *keywords);
 
 gboolean
+brasero_search_engine_set_query_scope (BraseroSearchEngine *search,
+                                       BraseroSearchScope scope);
+
+gboolean
+brasero_search_engine_set_query_mime (BraseroSearchEngine *search,
+                                      const gchar **mimes);
+
+gboolean
 brasero_search_engine_start_query (BraseroSearchEngine *search);
 
 void
diff --git a/src/brasero-search-entry.c b/src/brasero-search-entry.c
index 86598c6..58fed04 100644
--- a/src/brasero-search-entry.c
+++ b/src/brasero-search-entry.c
@@ -28,8 +28,6 @@
 #  include <config.h>
 #endif
 
-#ifdef BUILD_SEARCH
-
 #include <string.h>
 
 #include <glib.h>
@@ -623,10 +621,11 @@ gboolean
 brasero_search_entry_set_query (BraseroSearchEntry *entry,
                                 BraseroSearchEngine *search)
 {
-	BraseroSearchScope scope;
+	BraseroSearchScope scope = BRASERO_SEARCH_SCOPE_ANY;
+	const gchar *keywords = NULL;
 
-	if (!strcmp (entry->priv->keywords, _("All files")))
-		scope = BRASERO_SEARCH_SCOPE_WILDCARD;
+	if (strcmp (entry->priv->keywords, _("All files")))
+		keywords = entry->priv->keywords;
 
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry->priv->documents)))
 		scope |= BRASERO_SEARCH_SCOPE_DOCUMENTS;
@@ -640,9 +639,8 @@ brasero_search_entry_set_query (BraseroSearchEntry *entry,
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry->priv->video)))
 		scope |= BRASERO_SEARCH_SCOPE_VIDEO;
 
-	brasero_search_engine_set_query (search,
-	                                 scope,
-	                                 entry->priv->keywords);
+	brasero_search_engine_new_query (search, keywords);
+	brasero_search_engine_set_query_scope (search, scope);
 
 	return TRUE;
 }
@@ -669,4 +667,3 @@ brasero_search_entry_set_context (BraseroSearchEntry *self,
 	}
 }
 
-#endif /*BUILD_SEARCH*/
diff --git a/src/brasero-search-entry.h b/src/brasero-search-entry.h
index b2d4a3d..873a8fe 100644
--- a/src/brasero-search-entry.h
+++ b/src/brasero-search-entry.h
@@ -28,8 +28,6 @@
 #  include <config.h>
 #endif
 
-#ifdef BUILD_SEARCH
-
 #ifndef SEARCH_ENTRY_H
 #define SEARCH_ENTRY_H
 
@@ -74,6 +72,4 @@ void
 brasero_search_entry_set_context (BraseroSearchEntry *entry,
 				  BraseroLayoutType type);
 
-#endif				/* SEARCH_ENTRY_H */
-
 #endif
diff --git a/src/brasero-search.c b/src/brasero-search.c
index c4cf895..655f43b 100644
--- a/src/brasero-search.c
+++ b/src/brasero-search.c
@@ -31,8 +31,6 @@
 #  include <config.h>
 #endif
 
-#ifdef BUILD_SEARCH
-
 #include <string.h>
 
 #include <glib.h>
@@ -780,7 +778,7 @@ brasero_search_init (BraseroSearch *obj)
 	gtk_box_set_spacing (GTK_BOX (obj), BRASERO_SEARCH_SPACING);
 	obj->priv = g_new0 (BraseroSearchPrivate, 1);
 
-	obj->priv->engine = brasero_search_engine_get_default ();
+	obj->priv->engine = brasero_search_engine_new_default ();
 	g_signal_connect (obj->priv->engine,
 	                  "search-finished",
 	                  G_CALLBACK (brasero_search_finished_cb),
@@ -1098,4 +1096,3 @@ brasero_search_new ()
 	return g_object_new (BRASERO_TYPE_SEARCH, NULL);
 }
 
-#endif
diff --git a/src/brasero-search.h b/src/brasero-search.h
index 88168c6..3df7f07 100644
--- a/src/brasero-search.h
+++ b/src/brasero-search.h
@@ -30,8 +30,6 @@
 #  include <config.h>
 #endif
 
-#ifdef BUILD_SEARCH
-
 #ifndef SEARCH_H
 #define SEARCH_H
 
@@ -64,5 +62,3 @@ GtkWidget *brasero_search_new (void);
 G_END_DECLS
 
 #endif
-
-#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]