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 {
|
namespace Dino {
|
||||||
|
|
||||||
public class Util {
|
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) {
|
public static Message.Type get_message_type_for_conversation(Conversation conversation) {
|
||||||
switch (conversation.type_) {
|
switch (conversation.type_) {
|
||||||
case Conversation.Type.CHAT:
|
case Conversation.Type.CHAT:
|
||||||
|
@ -27,6 +36,15 @@ public class Util {
|
||||||
assert_not_reached();
|
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)
|
public static string get_content_type(FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class FileDefaultWidgetController : Object {
|
||||||
case FileTransfer.State.COMPLETE:
|
case FileTransfer.State.COMPLETE:
|
||||||
if (event_button.button == 1) {
|
if (event_button.button == 1) {
|
||||||
try{
|
try{
|
||||||
AppInfo.launch_default_for_uri(file_uri, null);
|
Dino.Util.launch_default_for_uri(file_uri);
|
||||||
} catch (Error err) {
|
} catch (Error err) {
|
||||||
warning("Failed to open %s - %s", file_uri, err.message);
|
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
|
// Button is opening a registration website
|
||||||
if (form.oob != null) {
|
if (form.oob != null) {
|
||||||
try {
|
try {
|
||||||
AppInfo.launch_default_for_uri(form.oob, null);
|
Dino.Util.launch_default_for_uri(form.oob);
|
||||||
} catch (Error e) { }
|
} catch (Error e) { }
|
||||||
show_sign_in_jid();
|
show_sign_in_jid();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue