[nautilus] application: register NautilusDBusManager from dbus_register()
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] application: register NautilusDBusManager from dbus_register()
- Date: Wed, 30 Apr 2014 09:25:02 +0000 (UTC)
commit 89d04f6b542781b776dd7cf91fcfc996318fd261
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Apr 28 22:42:24 2014 -0700
application: register NautilusDBusManager from dbus_register()
libnautilus-private/nautilus-dbus-manager.c | 23 +++++++++++++-------
libnautilus-private/nautilus-dbus-manager.h | 5 ++++
src/nautilus-application.c | 31 ++++++++++++++++++++++++++-
3 files changed, 50 insertions(+), 9 deletions(-)
---
diff --git a/libnautilus-private/nautilus-dbus-manager.c b/libnautilus-private/nautilus-dbus-manager.c
index 6fa3f0d..847afb5 100644
--- a/libnautilus-private/nautilus-dbus-manager.c
+++ b/libnautilus-private/nautilus-dbus-manager.c
@@ -50,7 +50,6 @@ nautilus_dbus_manager_dispose (GObject *object)
NautilusDBusManager *self = (NautilusDBusManager *) object;
if (self->file_operations) {
- g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->file_operations));
g_object_unref (self->file_operations);
self->file_operations = NULL;
}
@@ -128,10 +127,6 @@ handle_empty_trash (NautilusDBusFileOperations *object,
static void
nautilus_dbus_manager_init (NautilusDBusManager *self)
{
- GDBusConnection *connection;
-
- connection = g_application_get_dbus_connection (g_application_get_default ());
-
self->file_operations = nautilus_dbus_file_operations_skeleton_new ();
g_signal_connect (self->file_operations,
@@ -146,9 +141,6 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
"handle-empty-trash",
G_CALLBACK (handle_empty_trash),
self);
- g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations), connection,
- "/org/gnome/Nautilus", NULL);
-
}
static void
@@ -165,3 +157,18 @@ nautilus_dbus_manager_new (void)
return g_object_new (nautilus_dbus_manager_get_type (),
NULL);
}
+
+gboolean
+nautilus_dbus_manager_register (NautilusDBusManager *self,
+ GDBusConnection *connection,
+ GError **error)
+{
+ return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations),
+ connection, "/org/gnome/Nautilus", error);
+}
+
+void
+nautilus_dbus_manager_unregister (NautilusDBusManager *self)
+{
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->file_operations));
+}
diff --git a/libnautilus-private/nautilus-dbus-manager.h b/libnautilus-private/nautilus-dbus-manager.h
index fb6ed5a..ce83979 100644
--- a/libnautilus-private/nautilus-dbus-manager.h
+++ b/libnautilus-private/nautilus-dbus-manager.h
@@ -32,4 +32,9 @@ typedef struct _NautilusDBusManagerClass NautilusDBusManagerClass;
GType nautilus_dbus_manager_get_type (void);
NautilusDBusManager * nautilus_dbus_manager_new (void);
+gboolean nautilus_dbus_manager_register (NautilusDBusManager *self,
+ GDBusConnection *connection,
+ GError **error);
+void nautilus_dbus_manager_unregister (NautilusDBusManager *self);
+
#endif /* __NAUTILUS_DBUS_MANAGER_H__ */
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 1ff62b3..73ce713 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -1221,7 +1221,6 @@ nautilus_application_startup (GApplication *app)
gtk_window_set_default_icon_name ("system-file-manager");
/* create DBus manager */
- self->priv->dbus_manager = nautilus_dbus_manager_new ();
self->priv->fdb_manager = nautilus_freedesktop_dbus_new ();
/* initialize preferences and create the global GSettings objects */
@@ -1263,6 +1262,34 @@ nautilus_application_startup (GApplication *app)
nautilus_profile_end (NULL);
}
+static gboolean
+nautilus_application_dbus_register (GApplication *app,
+ GDBusConnection *connection,
+ const gchar *object_path,
+ GError **error)
+{
+ NautilusApplication *self = NAUTILUS_APPLICATION (app);
+
+ self->priv->dbus_manager = nautilus_dbus_manager_new ();
+ if (!nautilus_dbus_manager_register (self->priv->dbus_manager, connection, error)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+nautilus_application_dbus_unregister (GApplication *app,
+ GDBusConnection *connection,
+ const gchar *object_path)
+{
+ NautilusApplication *self = NAUTILUS_APPLICATION (app);
+
+ if (self->priv->dbus_manager) {
+ nautilus_dbus_manager_unregister (self->priv->dbus_manager);
+ }
+}
+
static void
nautilus_application_quit_mainloop (GApplication *app)
{
@@ -1400,6 +1427,8 @@ nautilus_application_class_init (NautilusApplicationClass *class)
application_class->quit_mainloop = nautilus_application_quit_mainloop;
application_class->open = nautilus_application_open;
application_class->local_command_line = nautilus_application_local_command_line;
+ application_class->dbus_register = nautilus_application_dbus_register;
+ application_class->dbus_unregister = nautilus_application_dbus_unregister;
gtkapp_class = GTK_APPLICATION_CLASS (class);
gtkapp_class->window_added = nautilus_application_window_added;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]