|
|
1fbf07 |
From 1fa3039c67671fe53416b2575f3c305029ef4854 Mon Sep 17 00:00:00 2001
|
|
|
1fbf07 |
From: Ondrej Holy <oholy@redhat.com>
|
|
|
1fbf07 |
Date: Wed, 11 Jan 2023 09:55:41 +0100
|
|
|
1fbf07 |
Subject: [PATCH] application: Export FileManager1 iface from dbus_register
|
|
|
1fbf07 |
vfunc
|
|
|
1fbf07 |
|
|
|
1fbf07 |
The `org/freedesktop/FileManager1` interface is not currently exported
|
|
|
1fbf07 |
from the `dbus_register` vfunc. This causes issues for projects (e.g.
|
|
|
1fbf07 |
desktop-icons extension) that want to use all the Nautilus intefaces
|
|
|
1fbf07 |
over the `org.gnome.Nautilus` connection. Let's use the already established
|
|
|
1fbf07 |
connection and export the `FileManager1` interface from the `dbus_register`
|
|
|
1fbf07 |
vfunc.
|
|
|
1fbf07 |
|
|
|
1fbf07 |
https://bugzilla.redhat.com/show_bug.cgi?id=2150894
|
|
|
1fbf07 |
---
|
|
|
1fbf07 |
src/nautilus-application.c | 17 ++--
|
|
|
1fbf07 |
src/nautilus-freedesktop-dbus.c | 150 +++++++++++++++++++++++++-------
|
|
|
1fbf07 |
src/nautilus-freedesktop-dbus.h | 6 +-
|
|
|
1fbf07 |
3 files changed, 136 insertions(+), 37 deletions(-)
|
|
|
1fbf07 |
|
|
|
1fbf07 |
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
|
|
|
1fbf07 |
index 829faa3..3bb3da1 100644
|
|
|
1fbf07 |
--- a/src/nautilus-application.c
|
|
|
1fbf07 |
+++ b/src/nautilus-application.c
|
|
|
1fbf07 |
@@ -608,8 +608,6 @@ nautilus_application_finalize (GObject *object)
|
|
|
1fbf07 |
g_clear_object (&priv->progress_handler);
|
|
|
1fbf07 |
g_clear_object (&priv->bookmark_list);
|
|
|
1fbf07 |
|
|
|
1fbf07 |
- g_clear_object (&priv->fdb_manager);
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
g_list_free (priv->windows);
|
|
|
1fbf07 |
|
|
|
1fbf07 |
g_hash_table_destroy (priv->notifications);
|
|
|
1fbf07 |
@@ -1270,9 +1268,6 @@ nautilus_application_startup (GApplication *app)
|
|
|
1fbf07 |
|
|
|
1fbf07 |
setup_theme_extensions ();
|
|
|
1fbf07 |
|
|
|
1fbf07 |
- /* create DBus manager */
|
|
|
1fbf07 |
- priv->fdb_manager = nautilus_freedesktop_dbus_new ();
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
/* initialize preferences and create the global GSettings objects */
|
|
|
1fbf07 |
nautilus_global_preferences_init ();
|
|
|
1fbf07 |
|
|
|
1fbf07 |
@@ -1315,6 +1310,12 @@ nautilus_application_dbus_register (GApplication *app,
|
|
|
1fbf07 |
return FALSE;
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
+ priv->fdb_manager = nautilus_freedesktop_dbus_new (connection);
|
|
|
1fbf07 |
+ if (!nautilus_freedesktop_dbus_register (priv->fdb_manager, error))
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ return FALSE;
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
priv->search_provider = nautilus_shell_search_provider_new ();
|
|
|
1fbf07 |
if (!nautilus_shell_search_provider_register (priv->search_provider, connection, error))
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
@@ -1339,6 +1340,12 @@ nautilus_application_dbus_unregister (GApplication *app,
|
|
|
1fbf07 |
g_clear_object (&priv->dbus_manager);
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
+ if (priv->fdb_manager)
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ nautilus_freedesktop_dbus_unregister (priv->fdb_manager);
|
|
|
1fbf07 |
+ g_clear_object (&priv->fdb_manager);
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
if (priv->search_provider)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
nautilus_shell_search_provider_unregister (priv->search_provider);
|
|
|
1fbf07 |
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
|
|
|
1fbf07 |
index b888099..d013e20 100644
|
|
|
1fbf07 |
--- a/src/nautilus-freedesktop-dbus.c
|
|
|
1fbf07 |
+++ b/src/nautilus-freedesktop-dbus.c
|
|
|
1fbf07 |
@@ -41,6 +41,14 @@ struct _NautilusFreedesktopDBus
|
|
|
1fbf07 |
|
|
|
1fbf07 |
/* Our DBus implementation skeleton */
|
|
|
1fbf07 |
NautilusFreedesktopFileManager1 *skeleton;
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ GDBusConnection *connection;
|
|
|
1fbf07 |
+};
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+enum
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ PROP_0,
|
|
|
1fbf07 |
+ PROP_CONNECTION,
|
|
|
1fbf07 |
};
|
|
|
1fbf07 |
|
|
|
1fbf07 |
struct _NautilusFreedesktopDBusClass
|
|
|
1fbf07 |
@@ -149,27 +157,6 @@ skeleton_handle_show_item_properties_cb (NautilusFreedesktopFileManager1 *object
|
|
|
1fbf07 |
return TRUE;
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
-static void
|
|
|
1fbf07 |
-bus_acquired_cb (GDBusConnection *conn,
|
|
|
1fbf07 |
- const gchar *name,
|
|
|
1fbf07 |
- gpointer user_data)
|
|
|
1fbf07 |
-{
|
|
|
1fbf07 |
- NautilusFreedesktopDBus *fdb = user_data;
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
- DEBUG ("Bus acquired at %s", name);
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
- fdb->skeleton = nautilus_freedesktop_file_manager1_skeleton_new ();
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
- g_signal_connect (fdb->skeleton, "handle-show-items",
|
|
|
1fbf07 |
- G_CALLBACK (skeleton_handle_show_items_cb), fdb);
|
|
|
1fbf07 |
- g_signal_connect (fdb->skeleton, "handle-show-folders",
|
|
|
1fbf07 |
- G_CALLBACK (skeleton_handle_show_folders_cb), fdb);
|
|
|
1fbf07 |
- g_signal_connect (fdb->skeleton, "handle-show-item-properties",
|
|
|
1fbf07 |
- G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
- g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fdb->skeleton), conn, NAUTILUS_FDO_DBUS_PATH, NULL);
|
|
|
1fbf07 |
-}
|
|
|
1fbf07 |
-
|
|
|
1fbf07 |
static void
|
|
|
1fbf07 |
name_acquired_cb (GDBusConnection *connection,
|
|
|
1fbf07 |
const gchar *name,
|
|
|
1fbf07 |
@@ -186,6 +173,20 @@ name_lost_cb (GDBusConnection *connection,
|
|
|
1fbf07 |
DEBUG ("Lost (or failed to acquire) the name %s on the session message bus\n", name);
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
+static void
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_constructed (GObject *object)
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ fdb->owner_id = g_bus_own_name_on_connection (fdb->connection,
|
|
|
1fbf07 |
+ NAUTILUS_FDO_DBUS_NAME,
|
|
|
1fbf07 |
+ G_BUS_NAME_OWNER_FLAGS_NONE,
|
|
|
1fbf07 |
+ name_acquired_cb,
|
|
|
1fbf07 |
+ name_lost_cb,
|
|
|
1fbf07 |
+ fdb,
|
|
|
1fbf07 |
+ NULL);
|
|
|
1fbf07 |
+}
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
static void
|
|
|
1fbf07 |
nautilus_freedesktop_dbus_dispose (GObject *object)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
@@ -199,33 +200,87 @@ nautilus_freedesktop_dbus_dispose (GObject *object)
|
|
|
1fbf07 |
|
|
|
1fbf07 |
if (fdb->skeleton != NULL)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
- g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (fdb->skeleton));
|
|
|
1fbf07 |
g_object_unref (fdb->skeleton);
|
|
|
1fbf07 |
fdb->skeleton = NULL;
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
+ g_clear_object (&fdb->connection);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
G_OBJECT_CLASS (nautilus_freedesktop_dbus_parent_class)->dispose (object);
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
+static void
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_set_property (GObject *object,
|
|
|
1fbf07 |
+ guint prop_id,
|
|
|
1fbf07 |
+ const GValue *value,
|
|
|
1fbf07 |
+ GParamSpec *pspec)
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ switch (prop_id)
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ case PROP_CONNECTION:
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ g_set_object (&fdb->connection, g_value_get_object (value));
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+ break;
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ default:
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+ break;
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+}
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+static void
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_get_property (GObject *object,
|
|
|
1fbf07 |
+ guint prop_id,
|
|
|
1fbf07 |
+ GValue *value,
|
|
|
1fbf07 |
+ GParamSpec *pspec)
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ switch (prop_id)
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ case PROP_CONNECTION:
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ g_value_set_object (value, fdb->connection);
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+ break;
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ default:
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+ break;
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+}
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
static void
|
|
|
1fbf07 |
nautilus_freedesktop_dbus_class_init (NautilusFreedesktopDBusClass *klass)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
1fbf07 |
|
|
|
1fbf07 |
object_class->dispose = nautilus_freedesktop_dbus_dispose;
|
|
|
1fbf07 |
+ object_class->constructed = nautilus_freedesktop_dbus_constructed;
|
|
|
1fbf07 |
+ object_class->get_property = nautilus_freedesktop_dbus_get_property;
|
|
|
1fbf07 |
+ object_class->set_property = nautilus_freedesktop_dbus_set_property;
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ g_object_class_install_property (object_class,
|
|
|
1fbf07 |
+ PROP_CONNECTION,
|
|
|
1fbf07 |
+ g_param_spec_object ("connection",
|
|
|
1fbf07 |
+ "Connection",
|
|
|
1fbf07 |
+ "GDBus connection property",
|
|
|
1fbf07 |
+ G_TYPE_DBUS_CONNECTION,
|
|
|
1fbf07 |
+ G_PARAM_CONSTRUCT_ONLY |
|
|
|
1fbf07 |
+ G_PARAM_READWRITE));
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
static void
|
|
|
1fbf07 |
nautilus_freedesktop_dbus_init (NautilusFreedesktopDBus *fdb)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
- fdb->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
|
|
1fbf07 |
- NAUTILUS_FDO_DBUS_NAME,
|
|
|
1fbf07 |
- G_BUS_NAME_OWNER_FLAGS_NONE,
|
|
|
1fbf07 |
- bus_acquired_cb,
|
|
|
1fbf07 |
- name_acquired_cb,
|
|
|
1fbf07 |
- name_lost_cb,
|
|
|
1fbf07 |
- fdb,
|
|
|
1fbf07 |
- NULL);
|
|
|
1fbf07 |
+ fdb->skeleton = nautilus_freedesktop_file_manager1_skeleton_new ();
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
|
|
|
1fbf07 |
void
|
|
|
1fbf07 |
@@ -239,8 +294,41 @@ nautilus_freedesktop_dbus_set_open_locations (NautilusFreedesktopDBus *fdb,
|
|
|
1fbf07 |
|
|
|
1fbf07 |
/* Tries to own the org.freedesktop.FileManager1 service name */
|
|
|
1fbf07 |
NautilusFreedesktopDBus *
|
|
|
1fbf07 |
-nautilus_freedesktop_dbus_new (void)
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_new (GDBusConnection *connection)
|
|
|
1fbf07 |
{
|
|
|
1fbf07 |
return g_object_new (nautilus_freedesktop_dbus_get_type (),
|
|
|
1fbf07 |
+ "connection", connection,
|
|
|
1fbf07 |
NULL);
|
|
|
1fbf07 |
}
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+gboolean
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb,
|
|
|
1fbf07 |
+ GError **error)
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ gboolean success;
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ success = g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fdb->skeleton),
|
|
|
1fbf07 |
+ fdb->connection,
|
|
|
1fbf07 |
+ NAUTILUS_FDO_DBUS_PATH,
|
|
|
1fbf07 |
+ error);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ if (success)
|
|
|
1fbf07 |
+ {
|
|
|
1fbf07 |
+ g_signal_connect (fdb->skeleton, "handle-show-items",
|
|
|
1fbf07 |
+ G_CALLBACK (skeleton_handle_show_items_cb), fdb);
|
|
|
1fbf07 |
+ g_signal_connect (fdb->skeleton, "handle-show-folders",
|
|
|
1fbf07 |
+ G_CALLBACK (skeleton_handle_show_folders_cb), fdb);
|
|
|
1fbf07 |
+ g_signal_connect (fdb->skeleton, "handle-show-item-properties",
|
|
|
1fbf07 |
+ G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
|
|
1fbf07 |
+ }
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ return success;
|
|
|
1fbf07 |
+}
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+void
|
|
|
1fbf07 |
+nautilus_freedesktop_dbus_unregister (NautilusFreedesktopDBus *fdb)
|
|
|
1fbf07 |
+{
|
|
|
1fbf07 |
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (fdb->skeleton));
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+ g_signal_handlers_disconnect_by_data (fdb->skeleton, fdb);
|
|
|
1fbf07 |
+}
|
|
|
1fbf07 |
diff --git a/src/nautilus-freedesktop-dbus.h b/src/nautilus-freedesktop-dbus.h
|
|
|
1fbf07 |
index 410c420..ee2ced5 100644
|
|
|
1fbf07 |
--- a/src/nautilus-freedesktop-dbus.h
|
|
|
1fbf07 |
+++ b/src/nautilus-freedesktop-dbus.h
|
|
|
1fbf07 |
@@ -23,6 +23,7 @@
|
|
|
1fbf07 |
#define __NAUTILUS_FREEDESKTOP_DBUS_H__
|
|
|
1fbf07 |
|
|
|
1fbf07 |
#include <glib-object.h>
|
|
|
1fbf07 |
+#include <gio/gio.h>
|
|
|
1fbf07 |
|
|
|
1fbf07 |
#define NAUTILUS_FDO_DBUS_IFACE "org.freedesktop.FileManager1"
|
|
|
1fbf07 |
#define NAUTILUS_FDO_DBUS_NAME "org.freedesktop.FileManager1"
|
|
|
1fbf07 |
@@ -44,7 +45,10 @@ typedef struct _NautilusFreedesktopDBus NautilusFreedesktopDBus;
|
|
|
1fbf07 |
typedef struct _NautilusFreedesktopDBusClass NautilusFreedesktopDBusClass;
|
|
|
1fbf07 |
|
|
|
1fbf07 |
GType nautilus_freedesktop_dbus_get_type (void);
|
|
|
1fbf07 |
-NautilusFreedesktopDBus * nautilus_freedesktop_dbus_new (void);
|
|
|
1fbf07 |
+NautilusFreedesktopDBus * nautilus_freedesktop_dbus_new (GDBusConnection *connection);
|
|
|
1fbf07 |
+
|
|
|
1fbf07 |
+gboolean nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb, GError **error);
|
|
|
1fbf07 |
+void nautilus_freedesktop_dbus_unregister (NautilusFreedesktopDBus *fdb);
|
|
|
1fbf07 |
|
|
|
1fbf07 |
void nautilus_freedesktop_dbus_set_open_locations (NautilusFreedesktopDBus *fdb, const gchar **locations);
|
|
|
1fbf07 |
|
|
|
1fbf07 |
--
|
|
|
1fbf07 |
2.38.1
|
|
|
1fbf07 |
|