mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-02 14:03:39 +00:00
shell-provider: add a first skeleton of the shell search provider
It's not wired in yet.
This commit is contained in:
parent
c68654c1a0
commit
8e491b6492
|
@ -24,7 +24,8 @@ servicedir = $(datadir)/dbus-1/services
|
|||
service_DATA = $(service_in_files:.service.in=.service)
|
||||
service_in_files = \
|
||||
org.freedesktop.FileManager1.service.in \
|
||||
org.gnome.Nautilus.service.in
|
||||
org.gnome.Nautilus.service.in \
|
||||
org.gnome.Nautilus.SearchProvider.service.in
|
||||
|
||||
org.gnome.Nautilus.service: org.gnome.Nautilus.service.in Makefile
|
||||
$(AM_V_GEN) sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
@ -32,6 +33,12 @@ org.gnome.Nautilus.service: org.gnome.Nautilus.service.in Makefile
|
|||
org.freedesktop.FileManager1.service: org.freedesktop.FileManager1.service.in Makefile
|
||||
$(AM_V_GEN) sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
org.gnome.Nautilus.SearchProvider.service: org.gnome.Nautilus.SearchProvider.service.in Makefile
|
||||
$(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
|
||||
|
||||
searchproviderdir = $(datadir)/gnome-shell/search-providers
|
||||
searchprovider_DATA = nautilus-search-provider.ini
|
||||
|
||||
nautilusdatadir = $(datadir)/nautilus
|
||||
|
||||
nautilusdata_DATA = \
|
||||
|
@ -44,6 +51,7 @@ EXTRA_DIST = $(nautilusdata_DATA) \
|
|||
nautilus.desktop.in \
|
||||
dbus-interfaces.xml \
|
||||
freedesktop-dbus-interfaces.xml \
|
||||
shell-search-provider-dbus-interfaces.xml \
|
||||
$(xml_in_files) \
|
||||
$(desktop_in_files) \
|
||||
$(service_in_files) \
|
||||
|
|
4
data/nautilus-search-provider.ini
Normal file
4
data/nautilus-search-provider.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Shell Search Provider]
|
||||
DesktopId=nautilus.desktop
|
||||
BusName=org.gnome.Nautilus.SearchProvider
|
||||
ObjectPath=/org/gnome/Nautilus/SearchProvider
|
3
data/org.gnome.Nautilus.SearchProvider.service.in
Normal file
3
data/org.gnome.Nautilus.SearchProvider.service.in
Normal file
|
@ -0,0 +1,3 @@
|
|||
[D-BUS Service]
|
||||
Name=org.gnome.Nautilus.SearchProvider
|
||||
Exec=@libexecdir@/nautilus-shell-search-provider
|
|
@ -8,6 +8,7 @@ bin_PROGRAMS= \
|
|||
|
||||
libexec_PROGRAMS= \
|
||||
nautilus-convert-metadata \
|
||||
nautilus-shell-search-provider \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES = \
|
||||
|
@ -43,8 +44,11 @@ LDADD =\
|
|||
$(POPT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
dbus_built_sources = nautilus-freedesktop-generated.c nautilus-freedesktop-generated.h
|
||||
$(dbus_built_sources) : Makefile.am $(top_srcdir)/data/freedesktop-dbus-interfaces.xml
|
||||
dbus_freedesktop_built_sources = \
|
||||
nautilus-freedesktop-generated.c \
|
||||
nautilus-freedesktop-generated.h
|
||||
|
||||
$(dbus_freedesktop_built_sources) : Makefile.am $(top_srcdir)/data/freedesktop-dbus-interfaces.xml
|
||||
gdbus-codegen \
|
||||
--interface-prefix org.freedesktop. \
|
||||
--c-namespace NautilusFreedesktop \
|
||||
|
@ -113,8 +117,8 @@ nautilus-enum-types.c: $(headers) Makefile
|
|||
&& cp xgen-gtc $(@F) \
|
||||
&& rm -f xgen-gtc
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(dbus_built_sources) \
|
||||
nautilus_built_sources = \
|
||||
$(dbus_freedesktop_built_sources) \
|
||||
nautilus-resources.c \
|
||||
nautilus-resources.h \
|
||||
nautilus-enum-types.h \
|
||||
|
@ -209,7 +213,7 @@ nautilus_SOURCES = \
|
|||
$(NULL)
|
||||
|
||||
nodist_nautilus_SOURCES = \
|
||||
$(BUILT_SOURCES) \
|
||||
$(nautilus_built_sources) \
|
||||
$(NULL)
|
||||
|
||||
EMPTY_VIEW_SOURCES = \
|
||||
|
@ -234,6 +238,31 @@ nautilus_convert_metadata_SOURCES= \
|
|||
nautilus-convert-metadata.c \
|
||||
$(NULL)
|
||||
|
||||
dbus_shell_search_provider_built_sources = \
|
||||
nautilus-shell-search-provider-generated.c \
|
||||
nautilus-shell-search-provider-generated.h
|
||||
|
||||
$(dbus_shell_search_provider_built_sources) : Makefile.am $(top_srcdir)/data/shell-search-provider-dbus-interfaces.xml
|
||||
gdbus-codegen \
|
||||
--interface-prefix org.gnome. \
|
||||
--c-namespace Nautilus \
|
||||
--generate-c-code nautilus-shell-search-provider-generated \
|
||||
$(top_srcdir)/data/shell-search-provider-dbus-interfaces.xml \
|
||||
$(NULL)
|
||||
|
||||
nautilus_shell_search_provider_SOURCES = \
|
||||
nautilus-shell-search-provider.c \
|
||||
$(NULL)
|
||||
|
||||
nodist_nautilus_shell_search_provider_SOURCES = \
|
||||
$(dbus_shell_search_provider_built_sources) \
|
||||
$(NULL)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(nautilus_built_sources) \
|
||||
$(dbus_shell_search_provider_built_sources) \
|
||||
$(NULL)
|
||||
|
||||
TESTS=check-nautilus
|
||||
|
||||
@INTLTOOL_SERVER_RULE@
|
||||
|
|
204
src/nautilus-shell-search-provider.c
Normal file
204
src/nautilus-shell-search-provider.c
Normal file
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* nautilus-shell-search-provider.c - Implementation of a GNOME Shell
|
||||
* search provider
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* Nautilus 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 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Nautilus 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, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Authors: Cosimo Cecchi <cosimoc@gnome.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "nautilus-shell-search-provider-generated.h"
|
||||
|
||||
#define SEARCH_PROVIDER_INACTIVITY_TIMEOUT 12000 /* milliseconds */
|
||||
|
||||
typedef struct {
|
||||
GApplication parent;
|
||||
|
||||
guint name_owner_id;
|
||||
|
||||
GDBusObjectManagerServer *object_manager;
|
||||
NautilusShellSearchProvider *skeleton;
|
||||
} NautilusShellSearchProviderApp;
|
||||
|
||||
typedef GApplicationClass NautilusShellSearchProviderAppClass;
|
||||
|
||||
GType nautilus_shell_search_provider_app_get_type (void);
|
||||
|
||||
#define NAUTILUS_TYPE_SHELL_SEARCH_PROVIDER_APP nautilus_shell_search_provider_app_get_type()
|
||||
#define NAUTILUS_SHELL_SEARCH_PROVIDER_APP(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SHELL_SEARCH_PROVIDER_APP, NautilusShellSearchProviderApp))
|
||||
|
||||
G_DEFINE_TYPE (NautilusShellSearchProviderApp, nautilus_shell_search_provider_app, G_TYPE_APPLICATION)
|
||||
|
||||
static void
|
||||
handle_get_initial_result_set (GDBusMethodInvocation *invocation,
|
||||
gchar **terms)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
handle_get_subsearch_result_set (GDBusMethodInvocation *invocation,
|
||||
gchar **previous_results,
|
||||
gchar **terms)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
handle_get_result_metas (GDBusMethodInvocation *invocation,
|
||||
gchar **results)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
handle_activate_result (GDBusMethodInvocation *invocation,
|
||||
gchar *result)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
search_provider_name_acquired_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_debug ("Search provider name acquired: %s\n", name);
|
||||
}
|
||||
|
||||
static void
|
||||
search_provider_name_lost_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_debug ("Search provider name lost: %s\n", name);
|
||||
}
|
||||
|
||||
static void
|
||||
search_provider_bus_acquired_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusShellSearchProviderApp *self = user_data;
|
||||
|
||||
self->object_manager = g_dbus_object_manager_server_new ("/org/gnome/Nautilus/SearchProvider");
|
||||
self->skeleton = nautilus_shell_search_provider_skeleton_new ();
|
||||
|
||||
g_signal_connect (self->skeleton, "handle-get-initial-result-set",
|
||||
G_CALLBACK (handle_get_initial_result_set), self);
|
||||
g_signal_connect (self->skeleton, "handle-get-subsearch-result-set",
|
||||
G_CALLBACK (handle_get_subsearch_result_set), self);
|
||||
g_signal_connect (self->skeleton, "handle-get-result-metas",
|
||||
G_CALLBACK (handle_get_result_metas), self);
|
||||
g_signal_connect (self->skeleton, "handle-activate-result",
|
||||
G_CALLBACK (handle_activate_result), self);
|
||||
|
||||
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->skeleton),
|
||||
connection,
|
||||
"/org/gnome/Nautilus/SearchProvider", NULL);
|
||||
g_dbus_object_manager_server_set_connection (self->object_manager, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
search_provider_app_dispose (GObject *obj)
|
||||
{
|
||||
NautilusShellSearchProviderApp *self = NAUTILUS_SHELL_SEARCH_PROVIDER_APP (obj);
|
||||
|
||||
if (self->name_owner_id != 0) {
|
||||
g_bus_unown_name (self->name_owner_id);
|
||||
self->name_owner_id = 0;
|
||||
}
|
||||
|
||||
if (self->skeleton != NULL) {
|
||||
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->skeleton));
|
||||
g_clear_object (&self->skeleton);
|
||||
}
|
||||
|
||||
g_clear_object (&self->object_manager);
|
||||
|
||||
G_OBJECT_CLASS (nautilus_shell_search_provider_app_parent_class)->dispose (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
search_provider_app_startup (GApplication *app)
|
||||
{
|
||||
NautilusShellSearchProviderApp *self = NAUTILUS_SHELL_SEARCH_PROVIDER_APP (app);
|
||||
|
||||
G_APPLICATION_CLASS (nautilus_shell_search_provider_app_parent_class)->startup (app);
|
||||
|
||||
/* hold indefinitely if we're asked to persist */
|
||||
if (g_getenv ("NAUTILUS_SEARCH_PROVIDER_PERSIST") != NULL)
|
||||
g_application_hold (app);
|
||||
|
||||
self->name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
||||
"org.gnome.Nautilus.SearchProvider",
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
search_provider_bus_acquired_cb,
|
||||
search_provider_name_acquired_cb,
|
||||
search_provider_name_lost_cb,
|
||||
app, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_shell_search_provider_app_init (NautilusShellSearchProviderApp *self)
|
||||
{
|
||||
GApplication *app = G_APPLICATION (self);
|
||||
|
||||
g_application_set_inactivity_timeout (app, SEARCH_PROVIDER_INACTIVITY_TIMEOUT);
|
||||
g_application_set_application_id (app, "org.gnome.Nautilus.SearchProvider");
|
||||
g_application_set_flags (app, G_APPLICATION_IS_SERVICE);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_shell_search_provider_app_class_init (NautilusShellSearchProviderAppClass *klass)
|
||||
{
|
||||
GApplicationClass *aclass = G_APPLICATION_CLASS (klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS (klass);
|
||||
|
||||
aclass->startup = search_provider_app_startup;
|
||||
oclass->dispose = search_provider_app_dispose;
|
||||
}
|
||||
|
||||
static GApplication *
|
||||
nautilus_shell_search_provider_app_new (void)
|
||||
{
|
||||
g_type_init ();
|
||||
|
||||
return g_object_new (nautilus_shell_search_provider_app_get_type (),
|
||||
NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
GApplication *app;
|
||||
gint res;
|
||||
|
||||
app = nautilus_shell_search_provider_app_new ();
|
||||
res = g_application_run (app, argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in a new issue