[nautilus] search-provider: don't own a separate bus name
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] search-provider: don't own a separate bus name
- Date: Wed, 30 Apr 2014 09:25:47 +0000 (UTC)
commit 39b4fc320b2a4ef6cfd36f7e2f74cc2cfcf60e9d
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Apr 29 18:25:09 2014 +0200
search-provider: don't own a separate bus name
This is not needed anymore, now what we're fully dbus activatable.
data/Makefile.am | 6 +-
data/nautilus-search-provider.ini | 2 +-
data/org.gnome.Nautilus.SearchProvider.service.in | 2 +-
src/nautilus-application.c | 13 ++-
src/nautilus-shell-search-provider.c | 95 ++++++--------------
src/nautilus-shell-search-provider.h | 5 +
6 files changed, 46 insertions(+), 77 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index cf71ffa..d1e1f22 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -31,8 +31,7 @@ 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.SearchProvider.service.in
+ org.gnome.Nautilus.service.in
org.gnome.Nautilus.service: org.gnome.Nautilus.service.in Makefile
$(AM_V_GEN) sed -e "s|\ bindir\@|$(bindir)|" $< > $@
@@ -40,9 +39,6 @@ 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|\ bindir\@|$(bindir)|" $< > $@
-
searchproviderdir = $(datadir)/gnome-shell/search-providers
searchprovider_DATA = nautilus-search-provider.ini
diff --git a/data/nautilus-search-provider.ini b/data/nautilus-search-provider.ini
index 2ff7e3a..20b6d12 100644
--- a/data/nautilus-search-provider.ini
+++ b/data/nautilus-search-provider.ini
@@ -1,5 +1,5 @@
[Shell Search Provider]
DesktopId=org.gnome.Nautilus.desktop
-BusName=org.gnome.Nautilus.SearchProvider
+BusName=org.gnome.Nautilus
ObjectPath=/org/gnome/Nautilus/SearchProvider
Version=2
diff --git a/data/org.gnome.Nautilus.SearchProvider.service.in
b/data/org.gnome.Nautilus.SearchProvider.service.in
index 1d10ad2..48fe6fc 100644
--- a/data/org.gnome.Nautilus.SearchProvider.service.in
+++ b/data/org.gnome.Nautilus.SearchProvider.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
-Name=org.gnome.Nautilus.SearchProvider
+Name=org.gnome.Nautilus
Exec= bindir@/nautilus --gapplication-service
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 2fb0297..f78fb46 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -1216,10 +1216,6 @@ nautilus_application_startup (GApplication *app)
notify_init (GETTEXT_PACKAGE);
self->priv->progress_handler = nautilus_progress_ui_handler_new ();
- /* Bookmarks and search */
- self->priv->bookmark_list = nautilus_bookmark_list_new ();
- self->priv->search_provider = nautilus_shell_search_provider_new ();
-
/* Check the user's .nautilus directories and post warnings
* if there are problems.
*/
@@ -1246,6 +1242,11 @@ nautilus_application_dbus_register (GApplication *app,
return FALSE;
}
+ self->priv->search_provider = nautilus_shell_search_provider_new ();
+ if (!nautilus_shell_search_provider_register (self->priv->search_provider, connection, error)) {
+ return FALSE;
+ }
+
return TRUE;
}
@@ -1259,6 +1260,10 @@ nautilus_application_dbus_unregister (GApplication *app,
if (self->priv->dbus_manager) {
nautilus_dbus_manager_unregister (self->priv->dbus_manager);
}
+
+ if (self->priv->search_provider) {
+ nautilus_shell_search_provider_unregister (self->priv->search_provider);
+ }
}
static void
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index f070a35..e3ecdda 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -54,8 +54,6 @@ typedef struct {
struct _NautilusShellSearchProvider {
GObject parent;
- guint name_owner_id;
- GDBusObjectManagerServer *object_manager;
NautilusShellSearchProvider2 *skeleton;
PendingSearch *current_search;
@@ -659,66 +657,11 @@ handle_launch_search (NautilusShellSearchProvider2 *skeleton,
}
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)
-{
- NautilusShellSearchProvider *self = user_data;
-
- self->object_manager = g_dbus_object_manager_server_new ("/org/gnome/Nautilus/SearchProvider");
- self->skeleton = nautilus_shell_search_provider2_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_signal_connect (self->skeleton, "handle-launch-search",
- G_CALLBACK (handle_launch_search), 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);
-
- g_application_release (g_application_get_default ());
-}
-
-static void
search_provider_dispose (GObject *obj)
{
NautilusShellSearchProvider *self = NAUTILUS_SHELL_SEARCH_PROVIDER (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_clear_object (&self->skeleton);
g_hash_table_destroy (self->metas_cache);
cancel_current_search (self);
@@ -735,14 +678,18 @@ nautilus_shell_search_provider_init (NautilusShellSearchProvider *self)
self->bookmarks = nautilus_application_get_bookmarks (NAUTILUS_APPLICATION (g_application_get_default ()));
self->volumes = g_volume_monitor_get ();
- g_application_hold (g_application_get_default ());
- 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,
- self, NULL);
+ self->skeleton = nautilus_shell_search_provider2_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_signal_connect (self->skeleton, "handle-launch-search",
+ G_CALLBACK (handle_launch_search), self);
}
static void
@@ -759,3 +706,19 @@ nautilus_shell_search_provider_new (void)
return g_object_new (nautilus_shell_search_provider_get_type (),
NULL);
}
+
+gboolean
+nautilus_shell_search_provider_register (NautilusShellSearchProvider *self,
+ GDBusConnection *connection,
+ GError **error)
+{
+ return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->skeleton),
+ connection,
+ "/org/gnome/Nautilus/SearchProvider", error);
+}
+
+void
+nautilus_shell_search_provider_unregister (NautilusShellSearchProvider *self)
+{
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->skeleton));
+}
diff --git a/src/nautilus-shell-search-provider.h b/src/nautilus-shell-search-provider.h
index 3818700..8216631 100644
--- a/src/nautilus-shell-search-provider.h
+++ b/src/nautilus-shell-search-provider.h
@@ -34,4 +34,9 @@ typedef GObjectClass NautilusShellSearchProviderClass;
GType nautilus_shell_search_provider_get_type (void);
NautilusShellSearchProvider * nautilus_shell_search_provider_new (void);
+gboolean nautilus_shell_search_provider_register (NautilusShellSearchProvider *self,
+ GDBusConnection *connection,
+ GError **error);
+void nautilus_shell_search_provider_unregister (NautilusShellSearchProvider *self);
+
#endif /* __NAUTILUS_SHELL_SEARCH_PROVIDER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]