[gnome-maps/wip/mlundblad/maps-uri: 3/5] application: Add action to perform search




commit c2351cbf1f2e62f2eb90c1fe66597eb541262cf2
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Nov 17 22:38:25 2021 +0100

    application: Add action to perform search
    
    Adds an action to initiate search so that
    a search query can be iniated via the
    "ActivateAction" DBus message.

 src/application.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/src/application.js b/src/application.js
index 07fbb6a1..0e2e65e5 100644
--- a/src/application.js
+++ b/src/application.js
@@ -189,6 +189,20 @@ var Application = GObject.registerClass({
         dialog.connect('response', () => dialog.destroy());
     }
 
+    _onSearchActivate(action, parameter) {
+        this._createWindow();
+        this._mainWindow.present();
+
+        let query = parameter.deep_unpack();
+        let mapView = this._mainWindow.mapView;
+
+        if (mapView.view.realized)
+            this._openSearchQuery(query);
+        else
+            mapView.view.connect('notify::realized',
+                                 this._openSearchQuery.bind(this, query));
+    }
+
     _addContacts() {
         let contacts = contactStore.get_contacts();
 
@@ -256,6 +270,10 @@ var Application = GObject.registerClass({
             'osm-account-setup': {
                 onActivate: this._onOsmAccountSetupActivate.bind(this)
             },
+            'search': {
+                paramType: 's',
+                onActivate: this._onSearchActivate.bind(this)
+            },
             'quit': {
                 onActivate: () => this.quit(),
                 accels: ['<Primary>Q']


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