search: Check for either tracker 2.x or 3.x schemas

The Tracker3 schema points to the same dconf path and is backwards
compatible with Tracker 2.x settings. Check for either here, with a
preference to Tracker 3.x.

Eventually, Tracker 2.x will be fully phased out, and this will not
be necessary.

Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1173
This commit is contained in:
Carlos Garnacho 2020-11-02 11:07:10 +01:00 committed by Robert Ancell
parent e522e5e732
commit 27e1140c9d

View file

@ -24,6 +24,7 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#define TRACKER_SCHEMA "org.freedesktop.Tracker.Miner.Files" #define TRACKER_SCHEMA "org.freedesktop.Tracker.Miner.Files"
#define TRACKER3_SCHEMA "org.freedesktop.Tracker3.Miner.Files"
#define TRACKER_KEY_RECURSIVE_DIRECTORIES "index-recursive-directories" #define TRACKER_KEY_RECURSIVE_DIRECTORIES "index-recursive-directories"
#define TRACKER_KEY_SINGLE_DIRECTORIES "index-single-directories" #define TRACKER_KEY_SINGLE_DIRECTORIES "index-single-directories"
@ -670,12 +671,20 @@ CcSearchLocationsDialog *
cc_search_locations_dialog_new (CcSearchPanel *panel) cc_search_locations_dialog_new (CcSearchPanel *panel)
{ {
CcSearchLocationsDialog *self; CcSearchLocationsDialog *self;
GSettingsSchemaSource *source;
g_autoptr(GSettingsSchema) schema = NULL;
self = g_object_new (CC_SEARCH_LOCATIONS_DIALOG_TYPE, self = g_object_new (CC_SEARCH_LOCATIONS_DIALOG_TYPE,
"use-header-bar", TRUE, "use-header-bar", TRUE,
NULL); NULL);
self->tracker_preferences = g_settings_new (TRACKER_SCHEMA); source = g_settings_schema_source_get_default ();
schema = g_settings_schema_source_lookup (source, TRACKER3_SCHEMA, TRUE);
if (schema)
self->tracker_preferences = g_settings_new (TRACKER3_SCHEMA);
else
self->tracker_preferences = g_settings_new (TRACKER_SCHEMA);
populate_list_boxes (self); populate_list_boxes (self);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->others_list), gtk_list_box_set_sort_func (GTK_LIST_BOX (self->others_list),
@ -702,8 +711,15 @@ cc_search_locations_dialog_is_available (void)
if (!source) if (!source)
return FALSE; return FALSE;
schema = g_settings_schema_source_lookup (source, TRACKER3_SCHEMA, TRUE);
if (schema)
return TRUE;
schema = g_settings_schema_source_lookup (source, TRACKER_SCHEMA, TRUE); schema = g_settings_schema_source_lookup (source, TRACKER_SCHEMA, TRUE);
return schema != NULL; if (schema)
return TRUE;
return FALSE;
} }
static void static void