[glib: 3/9] GWin32AppInfo: Add g_win32_app_info_launch_uris_impl utility function




commit f0ff6a6af0efd6d5d35c0acf264da81d2035d56c
Author: Luca Bacci <luca bacci982 gmail com>
Date:   Thu Jul 21 15:57:15 2022 +0200

    GWin32AppInfo: Add g_win32_app_info_launch_uris_impl utility function
    
    This utility function will be called by both launch_uris and
    launch_uris_async, passing a from_task parameter respectively
    as NULL and non-NULL. The from_task parameter will be needed
    to know whether GAppLaunchContext signals should be emitted
    directly (from_task == NULL) or scheduled for emission on the
    main thread (from_task != NULL).

 gio/gwin32appinfo.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
index 27d779085f..3ce417868d 100644
--- a/gio/gwin32appinfo.c
+++ b/gio/gwin32appinfo.c
@@ -4776,6 +4776,7 @@ g_win32_app_info_launch_internal (GWin32AppInfo      *info,
                                   IShellItemArray    *items, /* UWP only */
                                   GAppLaunchContext  *launch_context,
                                   GSpawnFlags         spawn_flags,
+                                  GTask              *from_task,
                                   GError            **error)
 {
   gboolean completed = FALSE;
@@ -5070,10 +5071,11 @@ make_item_array (gboolean   for_files,
 
 
 static gboolean
-g_win32_app_info_launch_uris (GAppInfo           *appinfo,
-                              GList              *uris,
-                              GAppLaunchContext  *launch_context,
-                              GError            **error)
+g_win32_app_info_launch_uris_impl (GAppInfo           *appinfo,
+                                   GList              *uris,
+                                   GAppLaunchContext  *launch_context,
+                                   GTask              *from_task,
+                                   GError            **error)
 {
   gboolean res = FALSE;
   gboolean do_files;
@@ -5091,7 +5093,7 @@ g_win32_app_info_launch_uris (GAppInfo           *appinfo,
             return res;
         }
 
-      res = g_win32_app_info_launch_internal (info, NULL, FALSE, items, launch_context, 0, error);
+      res = g_win32_app_info_launch_internal (info, NULL, FALSE, items, launch_context, 0, from_task, error);
 
       if (items != NULL)
         IShellItemArray_Release (items);
@@ -5132,6 +5134,7 @@ g_win32_app_info_launch_uris (GAppInfo           *appinfo,
                                           NULL,
                                           launch_context,
                                           G_SPAWN_SEARCH_PATH,
+                                          from_task,
                                           error);
 
   g_list_free_full (objs, free_file_or_uri);
@@ -5139,6 +5142,15 @@ g_win32_app_info_launch_uris (GAppInfo           *appinfo,
   return res;
 }
 
+static gboolean
+g_win32_app_info_launch_uris (GAppInfo           *appinfo,
+                              GList              *uris,
+                              GAppLaunchContext  *launch_context,
+                              GError            **error)
+{
+  return g_win32_app_info_launch_uris_impl (appinfo, uris, launch_context, NULL, error);
+}
+
 typedef struct
 {
   GList *uris;  /* (element-type utf8) (owned) (nullable) */
@@ -5164,7 +5176,7 @@ launch_uris_async_thread (GTask         *task,
   GError *local_error = NULL;
   gboolean succeeded;
 
-  succeeded = g_app_info_launch_uris (appinfo, data->uris, data->context, &local_error);
+  succeeded = g_win32_app_info_launch_uris_impl (appinfo, data->uris, data->context, task, &local_error);
   if (succeeded)
     g_task_return_boolean (task, TRUE);
   else
@@ -5235,7 +5247,7 @@ g_win32_app_info_launch (GAppInfo           *appinfo,
             return res;
         }
 
-      res = g_win32_app_info_launch_internal (info, NULL, TRUE, items, launch_context, 0, error);
+      res = g_win32_app_info_launch_internal (info, NULL, TRUE, items, launch_context, 0, NULL, error);
 
       if (items != NULL)
         IShellItemArray_Release (items);
@@ -5267,6 +5279,7 @@ g_win32_app_info_launch (GAppInfo           *appinfo,
                                           NULL,
                                           launch_context,
                                           G_SPAWN_SEARCH_PATH,
+                                          NULL,
                                           error);
 
   g_list_free_full (objs, free_file_or_uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]