[nautilus/gtk4-preparation-trunk: 49/50] shell-search-provider: Prepare for gtk_show_uri_full()




commit 29e5572a3bb0e75cf2f534ea4bd9c6ce26eb504c
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 94d0790a3..82850dafc 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]