[gnome-characters/bilelmoussaoui/search-provider] Search Provider: fixup




commit 74b4486d5f8289fea105f6eb84f235858845316a
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Thu Jan 27 19:11:16 2022 +0100

    Search Provider: fixup
    
    - Fix the no longer working search provider
    - Drop the copy to clipboard call using GTK, it is handled by the shell nowadays
    - Replace the ActivateResult call to send a GNotification instead
    - Fix up broken search provider on devel builds
    
    Fixes #77
    Fixes #78
    Fixes #26
    Fixes #93

 data/meson.build                              |  2 ++
 data/org.gnome.Characters.search-provider.ini |  4 ++--
 data/org.gnome.Characters.service.in          |  2 +-
 meson.build                                   |  1 +
 src/searchProvider.js                         | 16 ++++++++++------
 src/service.js                                |  1 -
 src/window.js                                 |  5 +++++
 7 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index e5f7d95..d0de6a0 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -96,6 +96,8 @@ install_data(
 
 search_provider_conf = configuration_data()
 search_provider_conf.set('appid', application_id)
+search_provider_conf.set('background_service_id', background_service_id)
+search_provider_conf.set('background_service_path', background_service_path)
 
 configure_file(
   input: 'org.gnome.Characters.search-provider.ini',
diff --git a/data/org.gnome.Characters.search-provider.ini b/data/org.gnome.Characters.search-provider.ini
index 14a67a4..58ef6a1 100644
--- a/data/org.gnome.Characters.search-provider.ini
+++ b/data/org.gnome.Characters.search-provider.ini
@@ -1,6 +1,6 @@
 [Shell Search Provider]
 DesktopId=@appid@.desktop
-BusName=@appid@.BackgroundService
-ObjectPath=/org/gnome/Characters/BackgroundService
+BusName=@background_service_id@
+ObjectPath=@background_service_path@
 Version=2
 DefaultDisabled=false
diff --git a/data/org.gnome.Characters.service.in b/data/org.gnome.Characters.service.in
index 97514ac..43297d9 100644
--- a/data/org.gnome.Characters.service.in
+++ b/data/org.gnome.Characters.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=@appid@
-Exec=@bindir@/gnome-characters --gapplication-service
+Exec=@pkgdatadir@/@appid@.BackgroundService
diff --git a/meson.build b/meson.build
index c7334c2..6069a3d 100644
--- a/meson.build
+++ b/meson.build
@@ -19,6 +19,7 @@ else
   version_suffix = ''
 endif
 application_id = 'org.gnome.Characters@0@'.format(profile)
+background_service_path = '/org/gnome/Characters@0@/BackgroundService'.format(profile)
 background_service_id = application_id + '.BackgroundService'
 
 characters_version = meson.project_version()
diff --git a/src/searchProvider.js b/src/searchProvider.js
index a9baf02..f0e3956 100644
--- a/src/searchProvider.js
+++ b/src/searchProvider.js
@@ -32,6 +32,9 @@ var SearchProvider = GObject.registerClass({
 }, class SearchProvider extends GObject.Object {
     _init(application) {
         this._app = application;
+        const serviceId = application.get_application_id();
+        this._appId = serviceId.replace(".BackgroundService", "");
+        this._appObjectPath = `/${this._appId.split(".").join("/")}`
 
         this._impl = Gio.DBusExportedObject.wrapJSObject(SearchProviderInterface, this);
         this._cancellable = new Gio.Cancellable();
@@ -100,7 +103,6 @@ var SearchProvider = GObject.registerClass({
                 name: new GLib.Variant('s', name),
                 id: new GLib.Variant('s', identifiers[i]),
                 description: new GLib.Variant('s', summary),
-                icon: new Gio.ThemedIcon({ name: pkg.name }).serialize(),
                 clipboardText: new GLib.Variant('s', character),
             });
         }
@@ -111,8 +113,10 @@ var SearchProvider = GObject.registerClass({
     }
 
     ActivateResult(id, _terms, _timestamp) {
-        let clipboard = Gc.gtk_clipboard_get();
-        clipboard.set_text(id, -1);
+        log('activating result');
+        const notification = Gio.Notification.new(_("Character copied"));
+        notification.set_body(_("Character was copied successfully"));
+        this._app.send_notification(null, notification);
     }
 
     _getPlatformData(timestamp) {
@@ -120,7 +124,7 @@ var SearchProvider = GObject.registerClass({
         let context = display.get_app_launch_context();
         context.set_timestamp(timestamp);
 
-        let app = Gio.DesktopAppInfo.new('org.gnome.Characters.desktop');
+        let app = Gio.DesktopAppInfo.new(`${this._appId}.desktop`);
         let id = context.get_startup_notify_id(app, []);
         return { 'desktop-startup-id': new GLib.Variant('s', id) };
     }
@@ -132,8 +136,8 @@ var SearchProvider = GObject.registerClass({
         else
             wrappedParam = [];
 
-        Gio.DBus.session.call('org.gnome.Characters',
-            '/org/gnome/Characters',
+        Gio.DBus.session.call(this._appId,
+            this._appObjectPath,
             'org.freedesktop.Application',
             'ActivateAction',
             new GLib.Variant('(sava{sv})', [action, wrappedParam,
diff --git a/src/service.js b/src/service.js
index 3bcb40a..f067492 100644
--- a/src/service.js
+++ b/src/service.js
@@ -44,7 +44,6 @@ const BackgroundService = GObject.registerClass({
             inactivity_timeout: 30000,
         });
         GLib.set_application_name(_('Characters'));
-
         this._searchProvider = new SearchProvider.SearchProvider(this);
     }
 
diff --git a/src/window.js b/src/window.js
index d181aba..34cc01e 100644
--- a/src/window.js
+++ b/src/window.js
@@ -217,6 +217,11 @@ var MainWindow = GObject.registerClass({
             });
     }
 
+    setSearchKeywords(terms) {
+        this._searchEntry.set_text(terms.join(' '));
+        this._searchButton.set_active(true);
+    }
+
     setPage(pageRow) {
         if (pageRow.name === 'recent') {
             // always draw a baseline for recent view


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