[gnome-terminal/wip/search: 2/2] server: Add a search provider
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/wip/search: 2/2] server: Add a search provider
- Date: Wed, 4 Dec 2013 17:13:32 +0000 (UTC)
commit fd10825d86b7d276c265f8c2fd2fdfcedc774e6b
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Dec 4 17:05:05 2013 +0100
server: Add a search provider
https://bugzilla.gnome.org/show_bug.cgi?id=711075
src/Makefile.am | 11 ++++
src/org.gnome.ShellSearchProvider2.xml | 87 ++++++++++++++++++++++++++++++++
src/terminal-search-provider.c | 65 ++++++++++++++++++++++++
src/terminal-search-provider.h | 41 +++++++++++++++
4 files changed, 204 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 48c3ad3..290ed09 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,8 @@ BUILT_SOURCES = \
terminal-type-builtins.h \
terminal-gdbus-generated.c \
terminal-gdbus-generated.h \
+ terminal-search-provider-gdbus-generated.c \
+ terminal-search-provider-gdbus-generated.h \
terminal-resources.c \
terminal-resources.h \
$(NULL)
@@ -66,6 +68,8 @@ gnome_terminal_server_SOURCES = \
terminal-screen-container.h \
terminal-search-dialog.c \
terminal-search-dialog.h \
+ terminal-search-provider.c \
+ terminal-search-provider.h \
terminal-tab-label.c \
terminal-tab-label.h \
terminal-tabs-menu.c \
@@ -143,6 +147,13 @@ terminal-gdbus-generated.c terminal-gdbus-generated.h: org.gnome.Terminal.xml Ma
--generate-c-code terminal-gdbus-generated \
$<
+terminal-search-provider-gdbus-generated.c terminal-search-provider-gdbus-generated.h:
org.gnome.ShellSearchProvider2.xml Makefile
+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
+ --interface-prefix=org.gnome.Shell \
+ --c-namespace=Terminal \
+ --generate-c-code terminal-search-provider-gdbus-generated \
+ $<
+
terminal-resources.h terminal-resources.c: terminal.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES)
--generate-dependencies --sourcedir $(srcdir) $(srcdir)/terminal.gresource.xml)
$(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate
--c-name terminal $<
diff --git a/src/org.gnome.ShellSearchProvider2.xml b/src/org.gnome.ShellSearchProvider2.xml
new file mode 100644
index 0000000..9502340
--- /dev/null
+++ b/src/org.gnome.ShellSearchProvider2.xml
@@ -0,0 +1,87 @@
+<!DOCTYPE node PUBLIC
+'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
+'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
+<node>
+
+ <!--
+ org.gnome.Shell.SearchProvider2:
+ @short_description: Search provider interface
+
+ The interface used for integrating into GNOME Shell's search
+ interface (version 2).
+ -->
+ <interface name="org.gnome.Shell.SearchProvider2">
+
+ <!--
+ GetInitialResultSet:
+ @terms: Array of search terms, which the provider should treat as logical AND.
+ @results: An array of result identifier strings representing items which match the given search
terms. Identifiers must be unique within the provider's domain, but other than that may be chosen freely by
the provider.
+
+ Called when the user first begins a search.
+ -->
+ <method name="GetInitialResultSet">
+ <arg type="as" name="terms" direction="in" />
+ <arg type="as" name="results" direction="out" />
+ </method>
+
+ <!--
+ GetSubsearchResultSet:
+ @previous_results: Array of results previously returned by GetInitialResultSet().
+ @terms: Array of updated search terms, which the provider should treat as logical AND.
+ @results: An array of result identifier strings representing items which match the given search
terms. Identifiers must be unique within the provider's domain, but other than that may be chosen freely by
the provider.
+
+ Called when a search is performed which is a "subsearch" of
+ the previous search, e.g. the method may return less results, but
+ not more or different results.
+
+ This allows search providers to only search through the previous
+ result set, rather than possibly performing a full re-query.
+ -->
+ <method name="GetSubsearchResultSet">
+ <arg type="as" name="previous_results" direction="in" />
+ <arg type="as" name="terms" direction="in" />
+ <arg type="as" name="results" direction="out" />
+ </method>
+
+ <!--
+ GetResultMetas:
+ @identifiers: An array of result identifiers as returned by GetInitialResultSet() or
GetSubsearchResultSet()
+ @metas: A dictionary describing the given search result, containing a human-readable 'name'
(string), along with the result identifier this meta is for, 'id' (string). Optionally, 'icon' (a serialized
GIcon as obtained by g_icon_serialize) can be specified if the result can be better served with a thumbnail
of the content (such as with images). 'gicon' (a serialized GIcon as obtained by g_icon_to_string) or
'icon-data' (raw image data as (iiibiiay) - width, height, rowstride, has-alpha, bits per sample, channels,
data) are deprecated values that can also be used for that purpose. A 'description' field (string) may also
be specified if more context would help the user find the desired result.
+
+ Return an array of meta data used to display each given result
+ -->
+ <method name="GetResultMetas">
+ <arg type="as" name="identifiers" direction="in" />
+ <arg type="aa{sv}" name="metas" direction="out" />
+ </method>
+
+ <!--
+ ActivateResult:
+ @identifier: A result identifier as returned by GetInitialResultSet() or GetSubsearchResultSet()
+ @terms: Array of search terms, which the provider should treat as logical AND.
+ @timestamp: A timestamp of the user interaction that triggered this call
+
+ Called when the users chooses a given result. The result should
+ be displayed in the application associated with the corresponding
+ provider. The provided search terms can be used to allow launching a full search in
+ the application.
+ -->
+ <method name="ActivateResult">
+ <arg type="s" name="identifier" direction="in" />
+ <arg type="as" name="terms" direction="in" />
+ <arg type="u" name="timestamp" direction="in" />
+ </method>
+
+ <!--
+ LaunchSearch:
+ @terms: Array of search terms, which the provider should treat as logical AND.
+ @timestamp: A timestamp of the user interaction that triggered this call
+
+ Asks the search provider to launch a full search in the application for the provided terms.
+ -->
+ <method name="LaunchSearch">
+ <arg type="as" name="terms" direction="in" />
+ <arg type="u" name="timestamp" direction="in" />
+ </method>
+ </interface>
+</node>
diff --git a/src/terminal-search-provider.c b/src/terminal-search-provider.c
new file mode 100644
index 0000000..0b60572
--- /dev/null
+++ b/src/terminal-search-provider.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2013 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "terminal-search-provider.h"
+#include "terminal-search-provider-gdbus-generated.h"
+
+struct _TerminalSearchProvider
+{
+ GObject parent;
+
+ TerminalSearchProvider2 *skeleton;
+};
+
+struct _TerminalSearchProviderClass
+{
+ GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE (TerminalSearchProvider, terminal_search_provider, G_TYPE_OBJECT)
+
+static void
+terminal_search_provider_init (TerminalSearchProvider *provider)
+{
+ provider->skeleton = terminal_search_provider2_skeleton_new ();
+}
+
+static void
+terminal_search_provider_dispose (GObject *object)
+{
+ TerminalSearchProvider *provider = TERMINAL_SEARCH_PROVIDER (object);
+
+ g_clear_object (&provider->skeleton);
+
+ G_OBJECT_CLASS (terminal_search_provider_parent_class)->dispose (object);
+}
+
+static void
+terminal_search_provider_class_init (TerminalSearchProviderClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->dispose = terminal_search_provider_dispose;
+}
+
+TerminalSearchProvider *
+terminal_search_provider_new (void)
+{
+ return g_object_new (TERMINAL_TYPE_SEARCH_PROVIDER, NULL);
+}
diff --git a/src/terminal-search-provider.h b/src/terminal-search-provider.h
new file mode 100644
index 0000000..e9f0c2b
--- /dev/null
+++ b/src/terminal-search-provider.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2013 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TERMINAL_SEARCH_PROVIDER_H
+#define TERMINAL_SEARCH_PROVIDER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TERMINAL_TYPE_SEARCH_PROVIDER (terminal_search_provider_get_type ())
+#define TERMINAL_SEARCH_PROVIDER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
TERMINAL_TYPE_SEARCH_PROVIDER, TerminalSearchProvider))
+#define TERMINAL_SEARCH_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
TERMINAL_TYPE_SEARCH_PROVIDER, TerminalSearchProviderClass))
+#define TERMINAL_IS_SEARCH_PROVIDER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object),
TERMINAL_TYPE_SEARCH_PROVIDER))
+#define TERMINAL_IS_SEARCH_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
TERMINAL_TYPE_SEARCH_PROVIDER))
+#define TERMINAL_SEARCH_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
TERMINAL_TYPE_SEARCH_PROVIDER, TerminalSearchProviderClass))
+
+typedef struct _TerminalSearchProvider TerminalSearchProvider;
+typedef struct _TerminalSearchProviderClass TerminalSearchProviderClass;
+
+GType terminal_search_provider_get_type (void);
+
+TerminalSearchProvider *terminal_search_provider_new (void);
+
+G_END_DECLS
+
+#endif /* !TERMINAL_SEARCH_PROVIDER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]