Commit 13ff9521 authored by Philippe Rouquier's avatar Philippe Rouquier

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

parent 551f9348
......@@ -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}
......
......@@ -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
......
......@@ -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)
......
......@@ -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);
}
......
This diff is collapsed.
......@@ -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;
......
......@@ -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
......@@ -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,10 +105,17 @@ 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);
......
......@@ -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*/
......@@ -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
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment