diff --git a/libdino/src/service/util.vala b/libdino/src/service/util.vala index bb7198d3..6680cade 100644 --- a/libdino/src/service/util.vala +++ b/libdino/src/service/util.vala @@ -3,6 +3,15 @@ using Dino.Entities; namespace Dino { public class Util { + #if _WIN32 + [CCode (cname = "ShellExecuteA")] + private static extern int ShellExecuteA(int* hwnd, string operation, string file, string parameters, string directory, int showCmd); + + private static int ShellExecute(string file) { + return ShellExecuteA(null, null, file, null, null, 0); + } + #endif + public static Message.Type get_message_type_for_conversation(Conversation conversation) { switch (conversation.type_) { case Conversation.Type.CHAT: @@ -26,6 +35,15 @@ public class Util { } assert_not_reached(); } + + public static void launch_default_for_uri(string file_uri) + { +#if _WIN32 + Dino.Util.ShellExecute(file_uri); +#else + AppInfo.launch_default_for_uri(file_uri, null); +#endif + } public static string get_content_type(FileInfo fileInfo) { diff --git a/main/src/ui/conversation_content_view/file_widget.vala b/main/src/ui/conversation_content_view/file_widget.vala index 7d77ba11..92380c82 100644 --- a/main/src/ui/conversation_content_view/file_widget.vala +++ b/main/src/ui/conversation_content_view/file_widget.vala @@ -165,7 +165,7 @@ public class FileDefaultWidgetController : Object { case FileTransfer.State.COMPLETE: if (event_button.button == 1) { try{ - AppInfo.launch_default_for_uri(file_uri, null); + Dino.Util.launch_default_for_uri(file_uri); } catch (Error err) { warning("Failed to open %s - %s", file_uri, err.message); } diff --git a/main/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala index 2f2bcb43..33b7c129 100644 --- a/main/src/ui/manage_accounts/add_account_dialog.vala +++ b/main/src/ui/manage_accounts/add_account_dialog.vala @@ -368,7 +368,7 @@ public class AddAccountDialog : Gtk.Dialog { // Button is opening a registration website if (form.oob != null) { try { - AppInfo.launch_default_for_uri(form.oob, null); + Dino.Util.launch_default_for_uri(form.oob); } catch (Error e) { } show_sign_in_jid(); return;