]> spindle.queued.net Git - midori/commitdiff
Use ShellExecuteEx in sokoke_show_uri on Win32
authorPaweł Forysiuk <tuxator@o2.pl>
Fri, 6 Apr 2012 18:20:01 +0000 (20:20 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 6 Apr 2012 18:20:01 +0000 (20:20 +0200)
An 'Open With' dialog opens if needed.

midori/sokoke.c

index b25a3dd0f96e3d93cdd8f9ab5856eab52cb9fb73..fa8f9dfd9c23f466fb5c2d9c261063d7fe1f1304 100644 (file)
@@ -286,71 +286,12 @@ sokoke_show_uri (GdkScreen*   screen,
     return hildon_uri_open (uri, action, error);
 
     #elif defined (G_OS_WIN32)
+    CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
+    SHELLEXECUTEINFO info = { sizeof (info) };
+    info.nShow = SW_SHOWNORMAL;
+    info.lpFile = uri;
 
-    const gchar* fallbacks [] = { "explorer" };
-    gsize i;
-    GAppInfo *app_info;
-    GFile *file;
-    gchar *free_uri;
-
-    g_return_val_if_fail (GDK_IS_SCREEN (screen) || !screen, FALSE);
-    g_return_val_if_fail (uri != NULL, FALSE);
-    g_return_val_if_fail (!error || !*error, FALSE);
-
-    file = g_file_new_for_uri (uri);
-    app_info = g_file_query_default_handler (file, NULL, error);
-
-    if (app_info != NULL)
-    {
-        GdkAppLaunchContext *context;
-        gboolean result;
-        GList l;
-
-        context = gdk_app_launch_context_new ();
-        gdk_app_launch_context_set_screen (context, screen);
-        gdk_app_launch_context_set_timestamp (context, timestamp);
-
-        l.data = (char *)file;
-        l.next = l.prev = NULL;
-        result = g_app_info_launch (app_info, &l, (GAppLaunchContext*)context, error);
-
-        g_object_unref (context);
-        g_object_unref (app_info);
-        g_object_unref (file);
-
-        if (result)
-            return TRUE;
-    }
-    else
-        g_object_unref (file);
-
-    free_uri = g_filename_from_uri (uri, NULL, NULL);
-    if (free_uri)
-    {
-        gchar *quoted = g_shell_quote (free_uri);
-        uri = quoted;
-        g_free (free_uri);
-        free_uri = quoted;
-    }
-
-    for (i = 0; i < G_N_ELEMENTS (fallbacks); i++)
-    {
-        gchar* command = g_strconcat (fallbacks[i], " ", uri, NULL);
-        gboolean result = g_spawn_command_line_async (command, error);
-        g_free (command);
-        if (result)
-        {
-            g_free (free_uri);
-            return TRUE;
-        }
-        if (error)
-            *error = NULL;
-    }
-
-    g_free (free_uri);
-
-    return FALSE;
-
+    return ShellExecuteEx (&info);
     #else
 
     #if !GLIB_CHECK_VERSION (2, 28, 0)