[nautilus/wip/antoniof/gtk4-pre-switch-simplification: 3/4] shell-search-provider: Prepare for gtk_show_uri_full()
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-pre-switch-simplification: 3/4] shell-search-provider: Prepare for gtk_show_uri_full()
- Date: Fri, 24 Dec 2021 11:50:31 +0000 (UTC)
commit 9d07df3b816c2da4595600b14429fe081e19c512
Author: António Fernandes <antoniof gnome org>
Date: Thu Dec 23 00:32:17 2021 +0000
shell-search-provider: Prepare for gtk_show_uri_full()
gtk_show_uri_on_window() is gone in GTK 4. Instead, we are going to need
gtk_show_uri_full(), which uses an async result API.
Split the code in advance, to reduce the necessary changes at the time
of the GTK 3 to 4 switch.
src/nautilus-shell-search-provider.c | 39 ++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index b65f4bebe..657736d6a 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -731,6 +731,30 @@ handle_get_result_metas (NautilusShellSearchProvider2 *skeleton,
return TRUE;
}
+typedef struct
+{
+ GFile *file;
+ NautilusShellSearchProvider2 *skeleton;
+ GDBusMethodInvocation *invocation;
+} ShowURIData;
+
+static void
+show_uri_callback (gboolean res,
+ gpointer user_data)
+{
+ ShowURIData *data = user_data;
+
+ if (!res)
+ {
+ g_application_open (g_application_get_default (), &data->file, 1, "");
+ }
+
+ nautilus_shell_search_provider2_complete_activate_result (data->skeleton, data->invocation);
+
+ g_object_unref (data->file);
+ g_free (data);
+}
+
static gboolean
handle_activate_result (NautilusShellSearchProvider2 *skeleton,
GDBusMethodInvocation *invocation,
@@ -739,19 +763,18 @@ handle_activate_result (NautilusShellSearchProvider2 *skeleton,
guint32 timestamp,
gpointer user_data)
{
+ ShowURIData *data;
gboolean res;
- GFile *file;
+
+ data = g_new (ShowURIData, 1);
+ data->file = g_file_new_for_uri (result);
+ data->skeleton = skeleton;
+ data->invocation = invocation;
res = gtk_show_uri_on_window (NULL, result, timestamp, NULL);
- if (!res)
- {
- file = g_file_new_for_uri (result);
- g_application_open (g_application_get_default (), &file, 1, "");
- g_object_unref (file);
- }
+ show_uri_callback (res, data);
- nautilus_shell_search_provider2_complete_activate_result (skeleton, invocation);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]