[gtk/wip/carlosg/tracker2-fallback] searchengine: Prepare for apps linking to Tracker 2.x
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/tracker2-fallback] searchengine: Prepare for apps linking to Tracker 2.x
- Date: Tue, 1 Sep 2020 11:23:57 +0000 (UTC)
commit e2d05f0625b5ab9114a0c2b998ad5963188fd5e9
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Sep 1 13:17:49 2020 +0200
searchengine: Prepare for apps linking to Tracker 2.x
Given it does seem likely Tracker is going to miss the goal to get all
applications ported to Tracker 3, the scenario where there's applications
linking to Tracker 2.x while GTK was built with Tracker 3 support becomes
more likely.
Avoid the upcoming GType clashes if that were the case, and resort to the
good (I lie) old Tracker 2 search engine.
gtk/gtksearchengine.c | 26 ++++++++++++++++----------
gtk/gtksearchenginetracker3.c | 16 ++++++++++++++++
2 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtksearchengine.c b/gtk/gtksearchengine.c
index 49ae39ce32..1910cc0ad3 100644
--- a/gtk/gtksearchengine.c
+++ b/gtk/gtksearchengine.c
@@ -28,7 +28,8 @@
#if defined(HAVE_TRACKER3)
#include "gtksearchenginetracker3.h"
-#elif !defined G_OS_WIN32 /* No tracker on windows */
+#endif
+#if !defined G_OS_WIN32 /* No tracker on windows */
#include "gtksearchenginetracker.h"
#define HAVE_TRACKER 1
#endif
@@ -385,16 +386,21 @@ _gtk_search_engine_new (void)
g_object_ref (engine->priv->native),
g_object_unref);
}
-#elif defined(HAVE_TRACKER)
- engine->priv->native = _gtk_search_engine_tracker_new ();
- if (engine->priv->native)
+#endif
+
+#ifdef HAVE_TRACKER
+ if (!engine->priv->native)
{
- g_debug ("Using Tracker search engine");
- connect_engine_signals (engine->priv->native, engine);
- _gtk_search_engine_simple_set_indexed_cb (GTK_SEARCH_ENGINE_SIMPLE (engine->priv->simple),
- _gtk_search_engine_tracker_is_indexed,
- g_object_ref (engine->priv->native),
- g_object_unref);
+ engine->priv->native = _gtk_search_engine_tracker_new ();
+ if (engine->priv->native)
+ {
+ g_debug ("Using Tracker search engine");
+ connect_engine_signals (engine->priv->native, engine);
+ _gtk_search_engine_simple_set_indexed_cb (GTK_SEARCH_ENGINE_SIMPLE (engine->priv->simple),
+ _gtk_search_engine_tracker_is_indexed,
+ g_object_ref (engine->priv->native),
+ g_object_unref);
+ }
}
#endif
diff --git a/gtk/gtksearchenginetracker3.c b/gtk/gtksearchenginetracker3.c
index bb47f030ad..bbc2a7752d 100644
--- a/gtk/gtksearchenginetracker3.c
+++ b/gtk/gtksearchenginetracker3.c
@@ -368,6 +368,22 @@ gtk_search_engine_tracker3_new (void)
{
GtkSearchEngineTracker3 *engine;
GError *error = NULL;
+ GModule *self;
+
+ self = g_module_open (NULL, G_MODULE_BIND_LAZY);
+
+ /* Avoid hell from breaking loose if the application links to Tracker 2.x */
+ if (self)
+ {
+ gpointer symbol;
+ gboolean found;
+
+ found = g_module_symbol (self, "tracker_sparql_builder_new", &symbol);
+ g_module_close (self);
+
+ if (found)
+ return NULL;
+ }
g_debug ("Creating GtkSearchEngineTracker3...");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]