[folks] inspect: Add search option to folks-inspect
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] inspect: Add search option to folks-inspect
- Date: Fri, 13 Feb 2015 10:06:47 +0000 (UTC)
commit b4c33754dc69b7f1b0d360346e4fe0c8e48284cc
Author: Alvaro Soliverez <alvaro soliverez collabora co uk>
Date: Wed Aug 28 16:50:35 2013 -0300
inspect: Add search option to folks-inspect
https://bugzilla.gnome.org/show_bug.cgi?id=646808
tools/inspect/Makefile.am | 1 +
tools/inspect/command-search.vala | 83 +++++++++++++++++++++++++++++++++++++
tools/inspect/inspect.vala | 1 +
3 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/tools/inspect/Makefile.am b/tools/inspect/Makefile.am
index d0103b1..20d9ae7 100644
--- a/tools/inspect/Makefile.am
+++ b/tools/inspect/Makefile.am
@@ -23,6 +23,7 @@ folks_inspect_SOURCES = \
command-persona-stores.vala \
command-personas.vala \
command-quit.vala \
+ command-search.vala \
command-set.vala \
command-signals.vala \
signal-manager.vala \
diff --git a/tools/inspect/command-search.vala b/tools/inspect/command-search.vala
new file mode 100644
index 0000000..a4c2612
--- /dev/null
+++ b/tools/inspect/command-search.vala
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alvaro Soliverez <alvaro soliverez collabora co uk>
+ */
+
+using Folks;
+using Gee;
+using GLib;
+
+private class Folks.Inspect.Commands.Search : Folks.Inspect.Command
+{
+ public override string name
+ {
+ get { return "search"; }
+ }
+
+ public override string description
+ {
+ get
+ {
+ return "Search the individuals currently present in the aggregator";
+ }
+ }
+
+ public override string help
+ {
+ get
+ {
+ return "search [string] Search the name fields of " +
+ "the known individuals for the given string";
+ }
+ }
+
+ public Search (Client client)
+ {
+ base (client);
+ }
+
+ public override async void run (string? command_string)
+ {
+ if (command_string == null)
+ {
+ /* A search string is required */
+ Utils.print_line ("Please enter a search string");
+ }
+ else
+ {
+ var query = new SimpleQuery (
+ command_string, Query.MATCH_FIELDS_NAMES);
+ var search_view = new SearchView (this.client.aggregator, query);
+
+ try
+ {
+ yield search_view.prepare ();
+ }
+ catch (GLib.Error e)
+ {
+ GLib.warning ("Error when calling prepare: %s", e.message);
+ }
+
+ foreach (var individual in search_view.individuals)
+ {
+ Utils.print_line ("%s %s", individual.id,
+ individual.display_name);
+ }
+ }
+ }
+}
diff --git a/tools/inspect/inspect.vala b/tools/inspect/inspect.vala
index 5778e2e..4209020 100644
--- a/tools/inspect/inspect.vala
+++ b/tools/inspect/inspect.vala
@@ -143,6 +143,7 @@ public class Folks.Inspect.Client : Object
this.commands.set ("set", new Commands.Set (this));
this.commands.set ("signals", new Commands.Signals (this));
this.commands.set ("debug", new Commands.Debug (this));
+ this.commands.set ("search", new Commands.Search (this));
/* Create various bits of folks machinery. */
this.main_loop = new MainLoop ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]