parent
22e2073e63
commit
bc4c5bc637
@ -0,0 +1,92 @@
|
||||
From 5b40335c34a3b920348633274a03d073d1338a09 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Mon, 9 Jan 2023 13:12:17 +0100
|
||||
Subject: [PATCH] Revert "application: add common startup code"
|
||||
|
||||
This reverts commit 23ae53870a39afe43548111b6432db39511a6e97. This
|
||||
change was needed for split of desktop-related functionality, but it
|
||||
seems no more needed to me. Let's revert those changes to make the
|
||||
code a bit easier as a preparation for the next commits.
|
||||
---
|
||||
src/nautilus-application.c | 32 ++++++--------------------------
|
||||
src/nautilus-application.h | 1 -
|
||||
2 files changed, 6 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
|
||||
index 5deae5cc9..9cc435ec3 100644
|
||||
--- a/src/nautilus-application.c
|
||||
+++ b/src/nautilus-application.c
|
||||
@@ -1298,9 +1298,10 @@ icon_theme_changed_callback (GtkIconTheme *icon_theme,
|
||||
emit_change_signals_for_all_files_in_all_directories ();
|
||||
}
|
||||
|
||||
-void
|
||||
-nautilus_application_startup_common (NautilusApplication *self)
|
||||
+static void
|
||||
+nautilus_application_startup (GApplication *app)
|
||||
{
|
||||
+ NautilusApplication *self = NAUTILUS_APPLICATION (app);
|
||||
NautilusApplicationPrivate *priv;
|
||||
|
||||
nautilus_profile_start (NULL);
|
||||
@@ -1319,6 +1320,9 @@ nautilus_application_startup_common (NautilusApplication *self)
|
||||
|
||||
setup_theme_extensions ();
|
||||
|
||||
+ /* create DBus manager */
|
||||
+ priv->fdb_manager = nautilus_freedesktop_dbus_new ();
|
||||
+
|
||||
/* initialize preferences and create the global GSettings objects */
|
||||
nautilus_global_preferences_init ();
|
||||
|
||||
@@ -1352,22 +1356,6 @@ nautilus_application_startup_common (NautilusApplication *self)
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
-static void
|
||||
-nautilus_application_startup (GApplication *app)
|
||||
-{
|
||||
- NautilusApplication *self = NAUTILUS_APPLICATION (app);
|
||||
- NautilusApplicationPrivate *priv;
|
||||
-
|
||||
- nautilus_profile_start (NULL);
|
||||
- priv = nautilus_application_get_instance_private (self);
|
||||
-
|
||||
- /* create DBus manager */
|
||||
- priv->fdb_manager = nautilus_freedesktop_dbus_new ();
|
||||
- nautilus_application_startup_common (self);
|
||||
-
|
||||
- nautilus_profile_end (NULL);
|
||||
-}
|
||||
-
|
||||
static gboolean
|
||||
nautilus_application_dbus_register (GApplication *app,
|
||||
GDBusConnection *connection,
|
||||
@@ -1443,14 +1431,6 @@ update_dbus_opened_locations (NautilusApplication *self)
|
||||
g_return_if_fail (NAUTILUS_IS_APPLICATION (self));
|
||||
|
||||
priv = nautilus_application_get_instance_private (self);
|
||||
-
|
||||
- /* Children of nautilus application could not handle the dbus, so don't
|
||||
- * do anything in that case */
|
||||
- if (!priv->fdb_manager)
|
||||
- {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
dbus_object_path = g_application_get_dbus_object_path (G_APPLICATION (self));
|
||||
|
||||
g_return_if_fail (dbus_object_path);
|
||||
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
|
||||
index f915b0d4d..d5cfc11b3 100644
|
||||
--- a/src/nautilus-application.h
|
||||
+++ b/src/nautilus-application.h
|
||||
@@ -85,5 +85,4 @@ GtkWidget * nautilus_application_connect_server (NautilusApplication *applicatio
|
||||
|
||||
void nautilus_application_search (NautilusApplication *application,
|
||||
NautilusQuery *query);
|
||||
-void nautilus_application_startup_common (NautilusApplication *application);
|
||||
G_END_DECLS
|
||||
--
|
||||
2.38.1
|
||||
|
@ -0,0 +1,160 @@
|
||||
From 7de08188d8d012d9aa8f49fe27b7992d081a7307 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Wed, 11 Jan 2023 09:44:25 +0100
|
||||
Subject: [PATCH] Revert "freedesktop-dbus: Defer D-Bus property setting"
|
||||
|
||||
This reverts commit 3014f69485a120bedf0eec5af441346a95fe27f7 and part of
|
||||
the commit a1751d3d870c6cdc092f893755623c4ff20e1ef3. This extra handling
|
||||
was needed because `NautilusFreedesktopDBus` methods might be called before
|
||||
establishing its own D-Bus connection. The follow-up commit is going to use
|
||||
the already established connection from the `dbus_register` vfunc. It
|
||||
should be ensured that the `dbus_register` vfunc is called before the
|
||||
`window_added`, `window_removed`, or `startup` vfunc. Consequently, this
|
||||
extra handling is going to be redundant. Let's remove it as a preparation
|
||||
for the next commit.
|
||||
---
|
||||
src/nautilus-freedesktop-dbus.c | 79 ++-------------------------------
|
||||
1 file changed, 3 insertions(+), 76 deletions(-)
|
||||
|
||||
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
|
||||
index 5cbbbad01..c75678399 100644
|
||||
--- a/src/nautilus-freedesktop-dbus.c
|
||||
+++ b/src/nautilus-freedesktop-dbus.c
|
||||
@@ -40,11 +40,6 @@ struct _NautilusFreedesktopDBus
|
||||
|
||||
/* Our DBus implementation skeleton */
|
||||
NautilusFreedesktopFileManager1 *skeleton;
|
||||
-
|
||||
- GStrv pending_open_locations;
|
||||
- GVariant *pending_open_windows_with_locations;
|
||||
-
|
||||
- gboolean name_lost;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NautilusFreedesktopDBus, nautilus_freedesktop_dbus, G_TYPE_OBJECT);
|
||||
@@ -162,24 +157,6 @@ bus_acquired_cb (GDBusConnection *conn,
|
||||
G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
||||
|
||||
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fdb->skeleton), conn, NAUTILUS_FDO_DBUS_PATH, NULL);
|
||||
-
|
||||
- if (G_UNLIKELY (fdb->pending_open_locations != NULL))
|
||||
- {
|
||||
- g_auto (GStrv) locations = NULL;
|
||||
-
|
||||
- locations = g_steal_pointer (&fdb->pending_open_locations);
|
||||
-
|
||||
- nautilus_freedesktop_dbus_set_open_locations (fdb, (const gchar **) locations);
|
||||
- }
|
||||
-
|
||||
- if (G_UNLIKELY (fdb->pending_open_windows_with_locations != NULL))
|
||||
- {
|
||||
- g_autoptr (GVariant) locations = NULL;
|
||||
-
|
||||
- locations = g_steal_pointer (&fdb->pending_open_windows_with_locations);
|
||||
-
|
||||
- nautilus_freedesktop_dbus_set_open_windows_with_locations (fdb, locations);
|
||||
- }
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -195,13 +172,7 @@ name_lost_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
- NautilusFreedesktopDBus *fdb;
|
||||
-
|
||||
DEBUG ("Lost (or failed to acquire) the name %s on the session message bus\n", name);
|
||||
-
|
||||
- fdb = NAUTILUS_FREEDESKTOP_DBUS (user_data);
|
||||
-
|
||||
- fdb->name_lost = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -225,24 +196,12 @@ nautilus_freedesktop_dbus_dispose (GObject *object)
|
||||
G_OBJECT_CLASS (nautilus_freedesktop_dbus_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
-static void
|
||||
-nautilus_freedesktop_dbus_finalize (GObject *object)
|
||||
-{
|
||||
- NautilusFreedesktopDBus *fdb;
|
||||
-
|
||||
- fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
||||
-
|
||||
- g_clear_pointer (&fdb->pending_open_locations, g_strfreev);
|
||||
- g_clear_pointer (&fdb->pending_open_windows_with_locations, g_variant_unref);
|
||||
-}
|
||||
-
|
||||
static void
|
||||
nautilus_freedesktop_dbus_class_init (NautilusFreedesktopDBusClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = nautilus_freedesktop_dbus_dispose;
|
||||
- object_class->finalize = nautilus_freedesktop_dbus_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -256,10 +215,6 @@ nautilus_freedesktop_dbus_init (NautilusFreedesktopDBus *fdb)
|
||||
name_lost_cb,
|
||||
fdb,
|
||||
NULL);
|
||||
- fdb->skeleton = NULL;
|
||||
- fdb->pending_open_locations = NULL;
|
||||
- fdb->pending_open_windows_with_locations = NULL;
|
||||
- fdb->name_lost = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -268,21 +223,7 @@ nautilus_freedesktop_dbus_set_open_locations (NautilusFreedesktopDBus *fdb,
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_FREEDESKTOP_DBUS (fdb));
|
||||
|
||||
- if (G_UNLIKELY (fdb->skeleton == NULL))
|
||||
- {
|
||||
- if (G_LIKELY (fdb->name_lost))
|
||||
- {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- g_clear_pointer (&fdb->pending_open_locations, g_strfreev);
|
||||
-
|
||||
- fdb->pending_open_locations = g_strdupv ((gchar **) locations);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- nautilus_freedesktop_file_manager1_set_open_locations (fdb->skeleton, locations);
|
||||
- }
|
||||
+ nautilus_freedesktop_file_manager1_set_open_locations (fdb->skeleton, locations);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,22 +242,8 @@ nautilus_freedesktop_dbus_set_open_windows_with_locations (NautilusFreedesktopDB
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_FREEDESKTOP_DBUS (fdb));
|
||||
|
||||
- if (G_UNLIKELY (fdb->skeleton == NULL))
|
||||
- {
|
||||
- if (G_LIKELY (fdb->name_lost))
|
||||
- {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- g_clear_pointer (&fdb->pending_open_windows_with_locations, g_variant_unref);
|
||||
-
|
||||
- fdb->pending_open_windows_with_locations = g_variant_ref (locations);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- nautilus_freedesktop_file_manager1_set_open_windows_with_locations (fdb->skeleton,
|
||||
- locations);
|
||||
- }
|
||||
+ nautilus_freedesktop_file_manager1_set_open_windows_with_locations (fdb->skeleton,
|
||||
+ locations);
|
||||
}
|
||||
|
||||
/* Tries to own the org.freedesktop.FileManager1 service name */
|
||||
--
|
||||
2.38.1
|
||||
|
@ -0,0 +1,305 @@
|
||||
From 1fa3039c67671fe53416b2575f3c305029ef4854 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Wed, 11 Jan 2023 09:55:41 +0100
|
||||
Subject: [PATCH] application: Export FileManager1 iface from dbus_register
|
||||
vfunc
|
||||
|
||||
The `org/freedesktop/FileManager1` interface is not currently exported
|
||||
from the `dbus_register` vfunc. This causes issues for projects (e.g.
|
||||
desktop-icons extension) that want to use all the Nautilus intefaces
|
||||
over the `org.gnome.Nautilus` connection. Let's use the already established
|
||||
connection and export the `FileManager1` interface from the `dbus_register`
|
||||
vfunc.
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=2150894
|
||||
---
|
||||
src/nautilus-application.c | 17 ++--
|
||||
src/nautilus-freedesktop-dbus.c | 153 +++++++++++++++++++++++++-------
|
||||
src/nautilus-freedesktop-dbus.h | 6 +-
|
||||
3 files changed, 138 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
|
||||
index 9cc435ec3..16725932d 100644
|
||||
--- a/src/nautilus-application.c
|
||||
+++ b/src/nautilus-application.c
|
||||
@@ -578,8 +578,6 @@ nautilus_application_finalize (GObject *object)
|
||||
g_clear_object (&priv->progress_handler);
|
||||
g_clear_object (&priv->bookmark_list);
|
||||
|
||||
- g_clear_object (&priv->fdb_manager);
|
||||
-
|
||||
g_list_free (priv->windows);
|
||||
|
||||
g_hash_table_destroy (priv->notifications);
|
||||
@@ -1320,9 +1318,6 @@ nautilus_application_startup (GApplication *app)
|
||||
|
||||
setup_theme_extensions ();
|
||||
|
||||
- /* create DBus manager */
|
||||
- priv->fdb_manager = nautilus_freedesktop_dbus_new ();
|
||||
-
|
||||
/* initialize preferences and create the global GSettings objects */
|
||||
nautilus_global_preferences_init ();
|
||||
|
||||
@@ -1372,6 +1367,12 @@ nautilus_application_dbus_register (GApplication *app,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+ priv->fdb_manager = nautilus_freedesktop_dbus_new (connection);
|
||||
+ if (!nautilus_freedesktop_dbus_register (priv->fdb_manager, error))
|
||||
+ {
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
priv->search_provider = nautilus_shell_search_provider_new ();
|
||||
if (!nautilus_shell_search_provider_register (priv->search_provider, connection, error))
|
||||
{
|
||||
@@ -1398,6 +1399,12 @@ nautilus_application_dbus_unregister (GApplication *app,
|
||||
g_clear_object (&priv->dbus_manager);
|
||||
}
|
||||
|
||||
+ if (priv->fdb_manager)
|
||||
+ {
|
||||
+ nautilus_freedesktop_dbus_unregister (priv->fdb_manager);
|
||||
+ g_clear_object (&priv->fdb_manager);
|
||||
+ }
|
||||
+
|
||||
if (priv->search_provider)
|
||||
{
|
||||
nautilus_shell_search_provider_unregister (priv->search_provider);
|
||||
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
|
||||
index c75678399..c253cfaba 100644
|
||||
--- a/src/nautilus-freedesktop-dbus.c
|
||||
+++ b/src/nautilus-freedesktop-dbus.c
|
||||
@@ -40,6 +40,14 @@ struct _NautilusFreedesktopDBus
|
||||
|
||||
/* Our DBus implementation skeleton */
|
||||
NautilusFreedesktopFileManager1 *skeleton;
|
||||
+
|
||||
+ GDBusConnection *connection;
|
||||
+};
|
||||
+
|
||||
+enum
|
||||
+{
|
||||
+ PROP_0,
|
||||
+ PROP_CONNECTION,
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NautilusFreedesktopDBus, nautilus_freedesktop_dbus, G_TYPE_OBJECT);
|
||||
@@ -138,27 +146,6 @@ skeleton_handle_show_item_properties_cb (NautilusFreedesktopFileManager1 *object
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
-static void
|
||||
-bus_acquired_cb (GDBusConnection *conn,
|
||||
- const gchar *name,
|
||||
- gpointer user_data)
|
||||
-{
|
||||
- NautilusFreedesktopDBus *fdb = user_data;
|
||||
-
|
||||
- DEBUG ("Bus acquired at %s", name);
|
||||
-
|
||||
- fdb->skeleton = nautilus_freedesktop_file_manager1_skeleton_new ();
|
||||
-
|
||||
- g_signal_connect (fdb->skeleton, "handle-show-items",
|
||||
- G_CALLBACK (skeleton_handle_show_items_cb), fdb);
|
||||
- g_signal_connect (fdb->skeleton, "handle-show-folders",
|
||||
- G_CALLBACK (skeleton_handle_show_folders_cb), fdb);
|
||||
- g_signal_connect (fdb->skeleton, "handle-show-item-properties",
|
||||
- G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
||||
-
|
||||
- g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fdb->skeleton), conn, NAUTILUS_FDO_DBUS_PATH, NULL);
|
||||
-}
|
||||
-
|
||||
static void
|
||||
name_acquired_cb (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
@@ -175,6 +162,20 @@ name_lost_cb (GDBusConnection *connection,
|
||||
DEBUG ("Lost (or failed to acquire) the name %s on the session message bus\n", name);
|
||||
}
|
||||
|
||||
+static void
|
||||
+nautilus_freedesktop_dbus_constructed (GObject *object)
|
||||
+{
|
||||
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
||||
+
|
||||
+ fdb->owner_id = g_bus_own_name_on_connection (fdb->connection,
|
||||
+ NAUTILUS_FDO_DBUS_NAME,
|
||||
+ G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
+ name_acquired_cb,
|
||||
+ name_lost_cb,
|
||||
+ fdb,
|
||||
+ NULL);
|
||||
+}
|
||||
+
|
||||
static void
|
||||
nautilus_freedesktop_dbus_dispose (GObject *object)
|
||||
{
|
||||
@@ -188,33 +189,87 @@ nautilus_freedesktop_dbus_dispose (GObject *object)
|
||||
|
||||
if (fdb->skeleton != NULL)
|
||||
{
|
||||
- g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (fdb->skeleton));
|
||||
g_object_unref (fdb->skeleton);
|
||||
fdb->skeleton = NULL;
|
||||
}
|
||||
|
||||
+ g_clear_object (&fdb->connection);
|
||||
+
|
||||
G_OBJECT_CLASS (nautilus_freedesktop_dbus_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
+static void
|
||||
+nautilus_freedesktop_dbus_set_property (GObject *object,
|
||||
+ guint prop_id,
|
||||
+ const GValue *value,
|
||||
+ GParamSpec *pspec)
|
||||
+{
|
||||
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
||||
+
|
||||
+ switch (prop_id)
|
||||
+ {
|
||||
+ case PROP_CONNECTION:
|
||||
+ {
|
||||
+ g_set_object (&fdb->connection, g_value_get_object (value));
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ {
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+nautilus_freedesktop_dbus_get_property (GObject *object,
|
||||
+ guint prop_id,
|
||||
+ GValue *value,
|
||||
+ GParamSpec *pspec)
|
||||
+{
|
||||
+ NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
||||
+
|
||||
+ switch (prop_id)
|
||||
+ {
|
||||
+ case PROP_CONNECTION:
|
||||
+ {
|
||||
+ g_value_set_object (value, fdb->connection);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ {
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void
|
||||
nautilus_freedesktop_dbus_class_init (NautilusFreedesktopDBusClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = nautilus_freedesktop_dbus_dispose;
|
||||
+ object_class->constructed = nautilus_freedesktop_dbus_constructed;
|
||||
+ object_class->get_property = nautilus_freedesktop_dbus_get_property;
|
||||
+ object_class->set_property = nautilus_freedesktop_dbus_set_property;
|
||||
+
|
||||
+ g_object_class_install_property (object_class,
|
||||
+ PROP_CONNECTION,
|
||||
+ g_param_spec_object ("connection",
|
||||
+ "Connection",
|
||||
+ "GDBus connection property",
|
||||
+ G_TYPE_DBUS_CONNECTION,
|
||||
+ G_PARAM_CONSTRUCT_ONLY |
|
||||
+ G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_freedesktop_dbus_init (NautilusFreedesktopDBus *fdb)
|
||||
{
|
||||
- fdb->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
|
||||
- NAUTILUS_FDO_DBUS_NAME,
|
||||
- G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
- bus_acquired_cb,
|
||||
- name_acquired_cb,
|
||||
- name_lost_cb,
|
||||
- fdb,
|
||||
- NULL);
|
||||
+ fdb->skeleton = nautilus_freedesktop_file_manager1_skeleton_new ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -248,7 +303,41 @@ nautilus_freedesktop_dbus_set_open_windows_with_locations (NautilusFreedesktopDB
|
||||
|
||||
/* Tries to own the org.freedesktop.FileManager1 service name */
|
||||
NautilusFreedesktopDBus *
|
||||
-nautilus_freedesktop_dbus_new (void)
|
||||
+nautilus_freedesktop_dbus_new (GDBusConnection *connection)
|
||||
+{
|
||||
+ return g_object_new (NAUTILUS_TYPE_FREEDESKTOP_DBUS,
|
||||
+ "connection", connection,
|
||||
+ NULL);
|
||||
+}
|
||||
+
|
||||
+gboolean
|
||||
+nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ gboolean success;
|
||||
+
|
||||
+ success = g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fdb->skeleton),
|
||||
+ fdb->connection,
|
||||
+ NAUTILUS_FDO_DBUS_PATH,
|
||||
+ error);
|
||||
+
|
||||
+ if (success)
|
||||
+ {
|
||||
+ g_signal_connect (fdb->skeleton, "handle-show-items",
|
||||
+ G_CALLBACK (skeleton_handle_show_items_cb), fdb);
|
||||
+ g_signal_connect (fdb->skeleton, "handle-show-folders",
|
||||
+ G_CALLBACK (skeleton_handle_show_folders_cb), fdb);
|
||||
+ g_signal_connect (fdb->skeleton, "handle-show-item-properties",
|
||||
+ G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
||||
+ }
|
||||
+
|
||||
+ return success;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+nautilus_freedesktop_dbus_unregister (NautilusFreedesktopDBus *fdb)
|
||||
{
|
||||
- return g_object_new (NAUTILUS_TYPE_FREEDESKTOP_DBUS, NULL);
|
||||
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (fdb->skeleton));
|
||||
+
|
||||
+ g_signal_handlers_disconnect_by_data (fdb->skeleton, fdb);
|
||||
}
|
||||
diff --git a/src/nautilus-freedesktop-dbus.h b/src/nautilus-freedesktop-dbus.h
|
||||
index 416900eb9..8fb09e498 100644
|
||||
--- a/src/nautilus-freedesktop-dbus.h
|
||||
+++ b/src/nautilus-freedesktop-dbus.h
|
||||
@@ -21,6 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
+#include <gio/gio.h>
|
||||
|
||||
#define NAUTILUS_FDO_DBUS_IFACE "org.freedesktop.FileManager1"
|
||||
#define NAUTILUS_FDO_DBUS_NAME "org.freedesktop.FileManager1"
|
||||
@@ -30,7 +31,10 @@
|
||||
|
||||
G_DECLARE_FINAL_TYPE (NautilusFreedesktopDBus, nautilus_freedesktop_dbus, NAUTILUS, FREEDESKTOP_DBUS, GObject);
|
||||
|
||||
-NautilusFreedesktopDBus * nautilus_freedesktop_dbus_new (void);
|
||||
+NautilusFreedesktopDBus * nautilus_freedesktop_dbus_new (GDBusConnection *connection);
|
||||
+
|
||||
+gboolean nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb, GError **error);
|
||||
+void nautilus_freedesktop_dbus_unregister (NautilusFreedesktopDBus *fdb);
|
||||
|
||||
void nautilus_freedesktop_dbus_set_open_locations (NautilusFreedesktopDBus *fdb, const gchar **locations);
|
||||
|
||||
--
|
||||
2.38.1
|
||||
|
@ -0,0 +1,96 @@
|
||||
From ba878013689114bf199ba2260f9282ae82b352c4 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Wed, 22 Feb 2023 16:22:43 +0100
|
||||
Subject: [PATCH] freedesktop-dbus: Try to own the name until after exporting
|
||||
skeleton
|
||||
|
||||
Currently, the `g_bus_own_name_on_connection` function is called for the
|
||||
`org.freedesktop.FileManager1` name before exporting the
|
||||
`/org/freedesktop/FileManager1` skeleton. This seemingly works fine in most
|
||||
cases, but occasionally the name is acquired too early and D-Bus clients
|
||||
can get `No such interface` error. This is regression caused by the commit
|
||||
2293e813d3cd1cc47b2b8750f7140647aa066fc8. Let's try to own the nam until
|
||||
after exporting the skeleton to avoid this error.
|
||||
---
|
||||
src/nautilus-freedesktop-dbus.c | 31 +++++++++++++++----------------
|
||||
1 file changed, 15 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
|
||||
index c253cfaba..c20166abb 100644
|
||||
--- a/src/nautilus-freedesktop-dbus.c
|
||||
+++ b/src/nautilus-freedesktop-dbus.c
|
||||
@@ -162,20 +162,6 @@ name_lost_cb (GDBusConnection *connection,
|
||||
DEBUG ("Lost (or failed to acquire) the name %s on the session message bus\n", name);
|
||||
}
|
||||
|
||||
-static void
|
||||
-nautilus_freedesktop_dbus_constructed (GObject *object)
|
||||
-{
|
||||
- NautilusFreedesktopDBus *fdb = NAUTILUS_FREEDESKTOP_DBUS (object);
|
||||
-
|
||||
- fdb->owner_id = g_bus_own_name_on_connection (fdb->connection,
|
||||
- NAUTILUS_FDO_DBUS_NAME,
|
||||
- G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
- name_acquired_cb,
|
||||
- name_lost_cb,
|
||||
- fdb,
|
||||
- NULL);
|
||||
-}
|
||||
-
|
||||
static void
|
||||
nautilus_freedesktop_dbus_dispose (GObject *object)
|
||||
{
|
||||
@@ -252,7 +238,6 @@ nautilus_freedesktop_dbus_class_init (NautilusFreedesktopDBusClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = nautilus_freedesktop_dbus_dispose;
|
||||
- object_class->constructed = nautilus_freedesktop_dbus_constructed;
|
||||
object_class->get_property = nautilus_freedesktop_dbus_get_property;
|
||||
object_class->set_property = nautilus_freedesktop_dbus_set_property;
|
||||
|
||||
@@ -301,7 +286,6 @@ nautilus_freedesktop_dbus_set_open_windows_with_locations (NautilusFreedesktopDB
|
||||
locations);
|
||||
}
|
||||
|
||||
-/* Tries to own the org.freedesktop.FileManager1 service name */
|
||||
NautilusFreedesktopDBus *
|
||||
nautilus_freedesktop_dbus_new (GDBusConnection *connection)
|
||||
{
|
||||
@@ -310,6 +294,7 @@ nautilus_freedesktop_dbus_new (GDBusConnection *connection)
|
||||
NULL);
|
||||
}
|
||||
|
||||
+/* Tries to own the org.freedesktop.FileManager1 service name */
|
||||
gboolean
|
||||
nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb,
|
||||
GError **error)
|
||||
@@ -331,12 +316,26 @@ nautilus_freedesktop_dbus_register (NautilusFreedesktopDBus *fdb,
|
||||
G_CALLBACK (skeleton_handle_show_item_properties_cb), fdb);
|
||||
}
|
||||
|
||||
+ fdb->owner_id = g_bus_own_name_on_connection (fdb->connection,
|
||||
+ NAUTILUS_FDO_DBUS_NAME,
|
||||
+ G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
+ name_acquired_cb,
|
||||
+ name_lost_cb,
|
||||
+ fdb,
|
||||
+ NULL);
|
||||
+
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_freedesktop_dbus_unregister (NautilusFreedesktopDBus *fdb)
|
||||
{
|
||||
+ if (fdb->owner_id != 0)
|
||||
+ {
|
||||
+ g_bus_unown_name (fdb->owner_id);
|
||||
+ fdb->owner_id = 0;
|
||||
+ }
|
||||
+
|
||||
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (fdb->skeleton));
|
||||
|
||||
g_signal_handlers_disconnect_by_data (fdb->skeleton, fdb);
|
||||
--
|
||||
2.39.1
|
||||
|
Loading…
Reference in new issue