Use ShellExecute instead of AppInfo to open files on Windows
This commit is contained in:
parent
281a84a14c
commit
8cb15fc325
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue