[gnome-boxes] Update to the new gnome-shell search interface



commit b9778a39ab12c4f9a3d3a9ced556d6bf027ed3bb
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jan 25 16:31:01 2013 +0100

    Update to the new gnome-shell search interface
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685229

 data/gnome-boxes-search-provider.ini.in |    1 +
 src/app.vala                            |   12 ++++++++++++
 src/collection.vala                     |    2 +-
 src/gnome-boxes-search-provider.vala    |   26 ++++++++++++++++++++++++--
 4 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-boxes-search-provider.ini.in b/data/gnome-boxes-search-provider.ini.in
index 607cf47..8d3d5f2 100644
--- a/data/gnome-boxes-search-provider.ini.in
+++ b/data/gnome-boxes-search-provider.ini.in
@@ -4,3 +4,4 @@ Icon=gnome-remote-desktop
 DesktopId=gnome-boxes.desktop
 BusName=org.gnome.Boxes.SearchProvider
 ObjectPath=/org/gnome/Boxes/SearchProvider
+Version=2
diff --git a/src/app.vala b/src/app.vala
index 07c07f8..5676688 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -195,12 +195,14 @@ private class Boxes.App: Boxes.UI {
     static bool opt_help;
     static string opt_open_uuid;
     static string[] opt_uris;
+    static string[] opt_search;
     static const OptionEntry[] options = {
         { "version", 0, 0, OptionArg.NONE, null, N_("Display version number"), null },
         { "help", 'h', OptionFlags.HIDDEN, OptionArg.NONE, ref opt_help, null, null },
         { "full-screen", 'f', 0, OptionArg.NONE, ref opt_fullscreen, N_("Open in full screen"), null },
         { "checks", 0, 0, OptionArg.NONE, null, N_("Check virtualization capabilities"), null },
         { "open-uuid", 0, 0, OptionArg.STRING, ref opt_open_uuid, N_("Open box with UUID"), null },
+        { "search", 0, 0, OptionArg.STRING_ARRAY, ref opt_search, N_("Search term"), null },
         // A 'broker' is a virtual-machine manager (could be local or remote). Currently libvirt is the only one supported.
         { "", 0, 0, OptionArg.STRING_ARRAY, ref opt_uris, N_("URI to display, broker or installer media"), null },
         { null }
@@ -211,6 +213,7 @@ private class Boxes.App: Boxes.UI {
         opt_help = false;
         opt_open_uuid = null;
         opt_uris = null;
+        opt_search = null;
 
         var parameter_string = _("- A simple application to access remote or virtual machines");
         var opt_context = new OptionContext (parameter_string);
@@ -262,6 +265,15 @@ private class Boxes.App: Boxes.UI {
             }
         }
 
+        if (opt_search != null) {
+            call_when_ready (() => {
+                searchbar.text = string.joinv (" ", opt_search);
+                searchbar.visible = true;
+                if (ui_state == UIState.COLLECTION) {
+                    searchbar_revealer.revealed = true;
+                }
+            });
+        }
 
         if (opt_fullscreen)
             app.fullscreen = true;
diff --git a/src/collection.vala b/src/collection.vala
index 2ce8b8e..7b5a4b1 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -29,7 +29,7 @@ private class Boxes.Collection: GLib.Object {
 }
 
 private class Boxes.CollectionFilter: GLib.Object {
-    string [] terms;
+    private string [] terms;
 
     public string text {
         set {
diff --git a/src/gnome-boxes-search-provider.vala b/src/gnome-boxes-search-provider.vala
index d1a28e5..bea7e09 100644
--- a/src/gnome-boxes-search-provider.vala
+++ b/src/gnome-boxes-search-provider.vala
@@ -1,6 +1,6 @@
 // This file is part of GNOME Boxes. License: LGPLv2+
 
-[DBus (name = "org.gnome.Shell.SearchProvider")]
+[DBus (name = "org.gnome.Shell.SearchProvider2")]
 public class Boxes.SearchProvider: Object {
     private SearchProviderApp app;
     private bool loading;
@@ -148,7 +148,7 @@ public class Boxes.SearchProvider: Object {
         return yield get_metas (ids);
     }
 
-    public void ActivateResult (string search_id) {
+    public void ActivateResult (string search_id, string[] terms, uint32 timestamp) {
         app.hold ();
 
         debug ("ActivateResult (%s)", search_id);
@@ -172,6 +172,28 @@ public class Boxes.SearchProvider: Object {
 
         app.release ();
     }
+
+    public void LaunchSearch (string[] terms, uint32 timestamp) {
+        app.hold ();
+
+        debug ("LaunchSearch (%s)", string.joinv (", ", terms));
+
+        try {
+            string[] args = {};
+            args += "gnome-boxes";
+            foreach (var term in terms) {
+                args += "--search";
+                args += term;
+            }
+            if (!Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH, null, null))
+                stderr.printf ("Failed to launch Boxes for search\n");
+        } catch (SpawnError error) {
+            stderr.printf ("Failed to launch Boxes for search\n");
+            warning (error.message);
+        }
+
+        app.release ();
+    }
 }
 
 public class Boxes.SearchProviderApp: GLib.Application {



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