[gnome-terminal] server: Add a search provider
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] server: Add a search provider
- Date: Mon, 27 Jan 2014 14:27:36 +0000 (UTC)
commit 04654feabfe1582c4c526dd157a0b70a588bd9b5
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Jan 22 16:18:07 2014 +0100
server: Add a search provider
https://bugzilla.gnome.org/show_bug.cgi?id=711075
configure.ac | 24 ++
src/Makefile.am | 26 ++
src/gnome-terminal-search-provider.ini | 20 ++
src/terminal-app.c | 28 ++
src/terminal-debug.c | 1 +
src/terminal-debug.h | 3 +-
src/terminal-defines.h | 2 +
src/terminal-search-provider.c | 446 ++++++++++++++++++++++++++++++++
src/terminal-search-provider.h | 51 ++++
9 files changed, 600 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6809a88..cc90d83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,12 @@ PKG_CHECK_MODULES([TERM],
# DBus
# ****
+AC_ARG_WITH([dbus-interface-dir],
+ [AS_HELP_STRING([--with-dbus-interface-dir=PATH],[dbus interace file directory])],
+ [dbusinterfacedir="$withval"],
+ [dbusinterfacedir='${datadir}/dbus-1/interfaces'])
+AC_SUBST([dbusinterfacedir])
+
AC_ARG_WITH([dbus-service-dir],
[AS_HELP_STRING([--with-dbus-service-dir=PATH],[dbus service file directory])],
[dbusservicedir="$withval"],
@@ -155,6 +161,22 @@ if test -z "$XMLLINT"; then
AC_MSG_ERROR([xmllint not found])
fi
+# ***************************
+# GNOME Shell search provider
+# ***************************
+
+AC_MSG_CHECKING([whether to build the gnome-shell search provider])
+AC_ARG_ENABLE([search-provider],
+ [AS_HELP_STRING([--disable-search-provider],[Disable gnome-shell search provider])],
+ [],[enable_search_provider=yes])
+AC_MSG_RESULT([$enable_search_provider])
+
+if test "$enable_search_provider" = "yes"; then
+ AC_DEFINE([ENABLE_SEARCH_PROVIDER],[1],[Define to enable gnome-shell search provider])
+fi
+
+AM_CONDITIONAL([ENABLE_SEARCH_PROVIDER],[test "$enable_search_provider" = "yes"])
+
# ******************
# Nautilus extension
# ******************
@@ -292,8 +314,10 @@ gnome-terminal-$VERSION:
prefix: ${prefix}
source code location: ${srcdir}
compiler: ${CC}
+ DBus interface dir: ${dbusinterfacedir}
DBus service dir: ${dbusservicedir}
Prefs migration: ${enable_migration}
+ Search provider: ${enable_search_provider}
Nautilus extension: ${with_nautilus_extension}
Nautilus extension dir: ${nautilusextensiondir}
"
diff --git a/src/Makefile.am b/src/Makefile.am
index 48c3ad3..29a0aad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -307,6 +307,32 @@ gnome_terminal_migration_LDADD = \
endif # ENABLE_MIGRATION
+# GNOME Shell search provider
+
+if ENABLE_SEARCH_PROVIDER
+
+searchproviderdir = $(datadir)/gnome-shell/search-providers
+dist_searchprovider_DATA = gnome-terminal-search-provider.ini
+
+BUILT_SOURCES += \
+ terminal-search-provider-gdbus-generated.c \
+ terminal-search-provider-gdbus-generated.h \
+ $(NULL)
+
+gnome_terminal_server_SOURCES += \
+ terminal-search-provider.c \
+ terminal-search-provider.h \
+ $(NULL)
+
+endif # ENABLE_SEARCH_PROVIDER
+
+terminal-search-provider-gdbus-generated.c terminal-search-provider-gdbus-generated.h:
$(dbusinterfacedir)/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 \
+ $<
+
gsettings_SCHEMAS = \
org.gnome.Terminal.gschema.xml \
$(NULL)
diff --git a/src/gnome-terminal-search-provider.ini b/src/gnome-terminal-search-provider.ini
new file mode 100644
index 0000000..b6506f2
--- /dev/null
+++ b/src/gnome-terminal-search-provider.ini
@@ -0,0 +1,20 @@
+# 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/>.
+
+[Shell Search Provider]
+DesktopId=gnome-terminal.desktop
+BusName=org.gnome.Terminal
+ObjectPath=/org/gnome/Terminal/SearchProvider
+Version=2
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 5834a18..f98a802 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -42,6 +42,10 @@
#include "terminal-prefs.h"
#include "terminal-libgsystem.h"
+#ifdef ENABLE_SEARCH_PROVIDER
+#include "terminal-search-provider.h"
+#endif /* ENABLE_SEARCH_PROVIDER */
+
#include <sys/wait.h>
#include <errno.h>
#include <string.h>
@@ -83,6 +87,10 @@ struct _TerminalApp
GSettings *global_settings;
GSettings *desktop_interface_settings;
GSettings *system_proxy_settings;
+
+#ifdef ENABLE_SEARCH_PROVIDER
+ TerminalSearchProvider *search_provider;
+#endif /* ENABLE_SEARCH_PROVIDER */
};
enum
@@ -347,6 +355,10 @@ terminal_app_init (TerminalApp *app)
gtk_window_set_default_icon_name (GNOME_TERMINAL_ICON_NAME);
+#ifdef ENABLE_SEARCH_PROVIDER
+ app->search_provider = terminal_search_provider_new ();
+#endif /* ENABLE_SEARCH_PROVIDER */
+
/* Desktop proxy settings */
app->system_proxy_settings = g_settings_new (SYSTEM_PROXY_SETTINGS_SCHEMA);
@@ -395,6 +407,10 @@ terminal_app_finalize (GObject *object)
g_object_unref (app->desktop_interface_settings);
g_object_unref (app->system_proxy_settings);
+#ifdef ENABLE_SEARCH_PROVIDER
+ g_object_unref (app->search_provider);
+#endif /* ENABLE_SEARCH_PROVIDER */
+
terminal_accels_shutdown ();
G_OBJECT_CLASS (terminal_app_parent_class)->finalize (object);
@@ -416,6 +432,14 @@ terminal_app_dbus_register (GApplication *application,
error))
return FALSE;
+#ifdef ENABLE_SEARCH_PROVIDER
+ if (!terminal_search_provider_dbus_register (app->search_provider,
+ connection,
+ TERMINAL_SEARCH_PROVIDER_PATH,
+ error))
+ return FALSE;
+#endif /* ENABLE_SEARCH_PROVIDER */
+
object = terminal_object_skeleton_new (TERMINAL_FACTORY_OBJECT_PATH);
factory = terminal_factory_impl_new ();
terminal_object_skeleton_set_factory (object, factory);
@@ -441,6 +465,10 @@ terminal_app_dbus_unregister (GApplication *application,
app->object_manager = NULL;
}
+#ifdef ENABLE_SEARCH_PROVIDER
+ terminal_search_provider_dbus_unregister (app->search_provider, connection, TERMINAL_SEARCH_PROVIDER_PATH);
+#endif /* ENABLE_SEARCH_PROVIDER */
+
G_APPLICATION_CLASS (terminal_app_parent_class)->dbus_unregister (application,
connection,
object_path);
diff --git a/src/terminal-debug.c b/src/terminal-debug.c
index c525cdf..9325c88 100644
--- a/src/terminal-debug.c
+++ b/src/terminal-debug.c
@@ -37,6 +37,7 @@ _terminal_debug_init(void)
{ "profile", TERMINAL_DEBUG_PROFILE },
{ "settings-list", TERMINAL_DEBUG_SETTINGS_LIST },
{ "appmenu", TERMINAL_DEBUG_APPMENU },
+ { "search", TERMINAL_DEBUG_SEARCH },
};
_terminal_debug_flags = g_parse_debug_string (g_getenv ("GNOME_TERMINAL_DEBUG"),
diff --git a/src/terminal-debug.h b/src/terminal-debug.h
index aec9c54..ab47975 100644
--- a/src/terminal-debug.h
+++ b/src/terminal-debug.h
@@ -33,7 +33,8 @@ typedef enum {
TERMINAL_DEBUG_PROCESSES = 1 << 5,
TERMINAL_DEBUG_PROFILE = 1 << 6,
TERMINAL_DEBUG_SETTINGS_LIST = 1 << 7,
- TERMINAL_DEBUG_APPMENU = 1 << 8
+ TERMINAL_DEBUG_APPMENU = 1 << 8,
+ TERMINAL_DEBUG_SEARCH = 1 << 9
} TerminalDebugFlags;
void _terminal_debug_init(void);
diff --git a/src/terminal-defines.h b/src/terminal-defines.h
index 03b2da1..6d1c8e8 100644
--- a/src/terminal-defines.h
+++ b/src/terminal-defines.h
@@ -31,6 +31,8 @@ G_BEGIN_DECLS
#define TERMINAL_RECEIVER_OBJECT_PATH_FORMAT TERMINAL_OBJECT_PATH_PREFIX "/window/%u/terminal/%s"
#define TEMRINAL_RECEIVER_INTERFACE_NAME TERMINAL_OBJECT_INTERFACE_PREFIX ".Terminal0"
+#define TERMINAL_SEARCH_PROVIDER_PATH TERMINAL_OBJECT_PATH_PREFIX "/SearchProvider"
+
G_END_DECLS
#endif /* !TERMINAL_DEFINES_H */
diff --git a/src/terminal-search-provider.c b/src/terminal-search-provider.c
new file mode 100644
index 0000000..457afb4
--- /dev/null
+++ b/src/terminal-search-provider.c
@@ -0,0 +1,446 @@
+/*
+ * Copyright © 2013, 2014 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 <string.h>
+
+#include "terminal-app.h"
+#include "terminal-debug.h"
+#include "terminal-libgsystem.h"
+#include "terminal-screen-container.h"
+#include "terminal-search-provider.h"
+#include "terminal-search-provider-gdbus-generated.h"
+#include "terminal-window.h"
+
+struct _TerminalSearchProvider
+{
+ GObject parent;
+
+ TerminalSearchProvider2 *skeleton;
+};
+
+struct _TerminalSearchProviderClass
+{
+ GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE (TerminalSearchProvider, terminal_search_provider, G_TYPE_OBJECT)
+
+/* Copied from tracker/src/libtracker-fts/tracker-parser-glib.c under LGPLv2+
+ * And then from gnome-shell/src/shell-util.c under GPLv2+
+ *
+ * Originally written by Aleksander Morgado <aleksander gnu org>
+ */
+
+/* Combining diacritical mark?
+ * Basic range: [0x0300,0x036F]
+ * Supplement: [0x1DC0,0x1DFF]
+ * For Symbols: [0x20D0,0x20FF]
+ * Half marks: [0xFE20,0xFE2F]
+ */
+#define IS_CDM_UCS4(c) (((c) >= 0x0300 && (c) <= 0x036F) || \
+ ((c) >= 0x1DC0 && (c) <= 0x1DFF) || \
+ ((c) >= 0x20D0 && (c) <= 0x20FF) || \
+ ((c) >= 0xFE20 && (c) <= 0xFE2F))
+
+static char *
+normalize_casefold_and_unaccent (const char *str)
+{
+ gs_free char *normalized = NULL;
+ char *tmp;
+ int i = 0, j = 0, ilen;
+
+ if (str == NULL)
+ return NULL;
+
+ /* NOTE: 'ALL' is equivalent to 'NFKD'. If this is ever updated, please
+ * update the unaccenting mechanism as well. */
+ normalized = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
+ tmp = g_utf8_casefold (normalized, -1);
+
+ ilen = strlen (tmp);
+
+ while (i < ilen)
+ {
+ gunichar unichar;
+ char *next_utf8;
+ gint utf8_len;
+
+ /* Get next character of the word as UCS4 */
+ unichar = g_utf8_get_char_validated (&tmp[i], -1);
+
+ /* Invalid UTF-8 character or end of original string. */
+ if (unichar == (gunichar) -1 ||
+ unichar == (gunichar) -2)
+ {
+ break;
+ }
+
+ /* Find next UTF-8 character */
+ next_utf8 = g_utf8_next_char (&tmp[i]);
+ utf8_len = next_utf8 - &tmp[i];
+
+ if (IS_CDM_UCS4 ((guint32) unichar))
+ {
+ /* If the given unichar is a combining diacritical mark,
+ * just update the original index, not the output one */
+ i += utf8_len;
+ continue;
+ }
+
+ /* If already found a previous combining
+ * diacritical mark, indexes are different so
+ * need to copy characters. As output and input
+ * buffers may overlap, need to use memmove
+ * instead of memcpy */
+ if (i != j)
+ {
+ memmove (&tmp[j], &tmp[i], utf8_len);
+ }
+
+ /* Update both indexes */
+ i += utf8_len;
+ j += utf8_len;
+ }
+
+ /* Force proper string end */
+ tmp[j] = '\0';
+
+ return tmp;
+}
+
+static char **
+normalize_casefold_and_unaccent_terms (const char* const *terms)
+{
+ char **casefolded_terms;
+ guint i, n;
+
+ n = g_strv_length ((char **) terms);
+ casefolded_terms = g_new (char *, n + 1);
+
+ for (i = 0; i < n; i++)
+ casefolded_terms[i] = normalize_casefold_and_unaccent (terms[i]);
+ casefolded_terms[n] = NULL;
+
+ return casefolded_terms;
+}
+
+static gboolean
+match_terms (const char *str,
+ const char* const *terms)
+{
+ gs_free char *casefolded_str = NULL;
+ gboolean matches = TRUE;
+ guint i;
+
+ if (str == NULL)
+ {
+ matches = FALSE;
+ goto out;
+ }
+
+ casefolded_str = normalize_casefold_and_unaccent (str);
+ for (i = 0; terms[i] != NULL; i++)
+ {
+ if (strstr (casefolded_str, terms[i]) == NULL)
+ {
+ matches = FALSE;
+ break;
+ }
+ }
+
+ out:
+ return matches;
+}
+
+static gboolean
+handle_get_initial_result_set_cb (TerminalSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *const *terms,
+ gpointer user_data)
+{
+ GList *l, *screens = NULL, *windows;
+ gs_unref_ptrarray GPtrArray *results;
+ TerminalApp *app;
+ gs_strfreev char **casefolded_terms = NULL;
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetInitialResultSet started\n");
+
+ app = terminal_app_get ();
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ for (l = windows; l != NULL; l = l->next)
+ {
+ TerminalWindow *window = TERMINAL_WINDOW (l->data);
+ GList *c, *containers;
+
+ containers = terminal_window_list_screen_containers (window);
+ for (c = containers; c != NULL; c = c->next)
+ {
+ TerminalScreenContainer *container = TERMINAL_SCREEN_CONTAINER (c->data);
+ TerminalScreen *screen;
+
+ screen = terminal_screen_container_get_screen (container);
+ screens = g_list_prepend (screens, screen);
+ }
+ }
+
+ casefolded_terms = normalize_casefold_and_unaccent_terms (terms);
+ results = g_ptr_array_new_with_free_func (g_free);
+
+ for (l = screens; l != NULL; l = l->next)
+ {
+ TerminalScreen *screen = TERMINAL_SCREEN (l->data);
+ gs_free char *cmdline = NULL, *process = NULL;
+ const char *cwd, *title;
+
+ cwd = vte_terminal_get_current_directory_uri (VTE_TERMINAL (screen));
+ title = terminal_screen_get_title (screen);
+ terminal_screen_has_foreground_process (screen, &process, &cmdline);
+ if (match_terms (cwd, (const char *const *) casefolded_terms) ||
+ match_terms (title, (const char *const *) casefolded_terms) ||
+ match_terms (process, (const char *const *) casefolded_terms) ||
+ match_terms (cmdline, (const char *const *) casefolded_terms))
+ {
+ const char *uuid;
+
+ uuid = terminal_screen_get_uuid (screen);
+ g_ptr_array_add (results, g_strdup (uuid));
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "Search hit: %s\n", uuid);
+ }
+ }
+
+ g_ptr_array_add (results, NULL);
+ terminal_search_provider2_complete_get_initial_result_set (skeleton,
+ invocation,
+ (const char *const *) results->pdata);
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetInitialResultSet completed\n");
+ return TRUE;
+}
+
+static gboolean
+handle_get_subsearch_result_set_cb (TerminalSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *const *previous_results,
+ const char *const *terms,
+ gpointer user_data)
+{
+ gs_unref_ptrarray GPtrArray *results;
+ TerminalApp *app;
+ gs_strfreev char **casefolded_terms = NULL;
+ guint i;
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetSubsearchResultSet started\n");
+
+ app = terminal_app_get ();
+ casefolded_terms = normalize_casefold_and_unaccent_terms (terms);
+ results = g_ptr_array_new_with_free_func (g_free);
+
+ for (i = 0; previous_results[i] != NULL; i++)
+ {
+ TerminalScreen *screen;
+ gs_free char *cmdline = NULL, *process = NULL;
+ const char *cwd, *title;
+
+ screen = terminal_app_get_screen_by_uuid (app, previous_results[i]);
+ if (screen == NULL)
+ {
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "Not a screen: %s\n", previous_results[i]);
+ continue;
+ }
+
+ cwd = vte_terminal_get_current_directory_uri (VTE_TERMINAL (screen));
+ title = terminal_screen_get_title (screen);
+ terminal_screen_has_foreground_process (screen, &process, &cmdline);
+ if (match_terms (cwd, (const char *const *) casefolded_terms) ||
+ match_terms (title, (const char *const *) casefolded_terms) ||
+ match_terms (process, (const char *const *) casefolded_terms) ||
+ match_terms (cmdline, (const char *const *) casefolded_terms))
+ {
+ g_ptr_array_add (results, g_strdup (previous_results[i]));
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "Search hit: %s\n", previous_results[i]);
+ }
+ }
+
+ g_ptr_array_add (results, NULL);
+ terminal_search_provider2_complete_get_subsearch_result_set (skeleton,
+ invocation,
+ (const char *const *) results->pdata);
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetSubsearchResultSet completed\n");
+ return TRUE;
+}
+
+static gboolean
+text_is_selected_cb (VteTerminal *terminal,
+ glong column,
+ glong row,
+ gpointer user_data)
+{
+ glong cursor_row;
+
+ vte_terminal_get_cursor_position (terminal, NULL, &cursor_row);
+ if (cursor_row - 1 <= row && row <= cursor_row + 1)
+ return TRUE;
+ return FALSE;
+}
+
+static gboolean
+handle_get_result_metas_cb (TerminalSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *const *results,
+ gpointer user_data)
+{
+ GVariantBuilder builder;
+ TerminalApp *app;
+ guint i;
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetResultMetas started\n");
+
+ app = terminal_app_get ();
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
+
+ for (i = 0; results[i] != NULL; i++)
+ {
+ TerminalScreen *screen;
+ const char *title;
+ gs_free char *escaped_text = NULL;
+ gs_free char *text = NULL;
+
+ screen = terminal_app_get_screen_by_uuid (app, results[i]);
+ if (screen == NULL)
+ {
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "Not a screen: %s\n", results[i]);
+ continue;
+ }
+
+ title = terminal_screen_get_title (screen);
+ if (terminal_screen_has_foreground_process (screen, NULL, NULL))
+ text = vte_terminal_get_text (VTE_TERMINAL (screen), text_is_selected_cb, NULL, NULL);
+
+ g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&builder, "{sv}", "id", g_variant_new_string (results[i]));
+ g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (title));
+ if (text != NULL)
+ {
+ escaped_text = g_markup_escape_text (text, -1);
+ g_variant_builder_add (&builder, "{sv}", "description", g_variant_new_string (escaped_text));
+ }
+ g_variant_builder_close (&builder);
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "Meta for %s: %s\n", results[i], title);
+ }
+
+ terminal_search_provider2_complete_get_result_metas (skeleton, invocation, g_variant_builder_end
(&builder));
+
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "GetResultMetas completed\n");
+
+ return TRUE;
+}
+
+static gboolean
+handle_activate_result_cb (TerminalSearchProvider2 *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *identifier,
+ const char* const *terms,
+ guint timestamp,
+ gpointer user_data)
+{
+ GtkWidget *toplevel;
+ TerminalApp *app;
+ TerminalScreen *screen;
+
+ app = terminal_app_get ();
+ screen = terminal_app_get_screen_by_uuid (app, identifier);
+ if (screen == NULL)
+ goto out;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
+ if (!gtk_widget_is_toplevel (toplevel))
+ goto out;
+
+ terminal_window_switch_screen (TERMINAL_WINDOW (toplevel), screen);
+ gtk_window_present_with_time (GTK_WINDOW (toplevel), timestamp);
+ _terminal_debug_print (TERMINAL_DEBUG_SEARCH, "ActivateResult: %s\n", identifier);
+
+ out:
+ terminal_search_provider2_complete_activate_result (skeleton, invocation);
+ return TRUE;
+}
+
+static void
+terminal_search_provider_init (TerminalSearchProvider *provider)
+{
+ provider->skeleton = terminal_search_provider2_skeleton_new ();
+
+ g_signal_connect (provider->skeleton, "handle-get-initial-result-set",
+ G_CALLBACK (handle_get_initial_result_set_cb), provider);
+ g_signal_connect (provider->skeleton, "handle-get-subsearch-result-set",
+ G_CALLBACK (handle_get_subsearch_result_set_cb), provider);
+ g_signal_connect (provider->skeleton, "handle-get-result-metas",
+ G_CALLBACK (handle_get_result_metas_cb), provider);
+ g_signal_connect (provider->skeleton, "handle-activate-result",
+ G_CALLBACK (handle_activate_result_cb), provider);
+}
+
+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);
+}
+
+gboolean
+terminal_search_provider_dbus_register (TerminalSearchProvider *provider,
+ GDBusConnection *connection,
+ const char *object_path,
+ GError **error)
+{
+ return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (provider->skeleton),
+ connection,
+ object_path,
+ error);
+}
+
+void
+terminal_search_provider_dbus_unregister (TerminalSearchProvider *provider,
+ GDBusConnection *connection,
+ const char *object_path)
+{
+ if (g_dbus_interface_skeleton_has_connection (G_DBUS_INTERFACE_SKELETON (provider->skeleton), connection))
+ g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (provider->skeleton),
+ connection);
+}
diff --git a/src/terminal-search-provider.h b/src/terminal-search-provider.h
new file mode 100644
index 0000000..719bd3e
--- /dev/null
+++ b/src/terminal-search-provider.h
@@ -0,0 +1,51 @@
+/*
+ * 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>
+#include <gio/gio.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);
+
+gboolean terminal_search_provider_dbus_register (TerminalSearchProvider *provider,
+ GDBusConnection *connection,
+ const char *object_path,
+ GError **error);
+
+void terminal_search_provider_dbus_unregister (TerminalSearchProvider *provider,
+ GDBusConnection *connection,
+ const char *object_path);
+
+G_END_DECLS
+
+#endif /* !TERMINAL_SEARCH_PROVIDER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]