From 057a72cd9fa3cbbf98894bea78323e7e542a2441 Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Sat, 2 May 2020 12:47:40 -0300 Subject: [PATCH] Windows compatibility Tweaks --- libdino/src/service/file_manager.vala | 4 ++-- libdino/src/service/util.vala | 21 ++++++++++++++++++++- main/src/ui/main_window.vala | 4 ++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala index 00abe517..34e88dcc 100644 --- a/libdino/src/service/file_manager.vala +++ b/libdino/src/service/file_manager.vala @@ -63,7 +63,7 @@ public class FileManager : StreamInteractionModule, Object { try { FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE); file_transfer.file_name = file_info.get_display_name(); - file_transfer.mime_type = file_info.get_content_type(); + file_transfer.mime_type = Util.get_content_type(file_info); file_transfer.size = (int)file_info.get_size(); file_transfer.input_stream = yield file.read_async(); @@ -285,7 +285,7 @@ public class FileManager : StreamInteractionModule, Object { file_transfer.input_stream = yield file.read_async(); FileInfo file_info = file_transfer.get_file().query_info("*", FileQueryInfoFlags.NONE); - file_transfer.mime_type = file_info.get_content_type(); + file_transfer.mime_type = Util.get_content_type(file_info); file_transfer.state = FileTransfer.State.COMPLETE; } catch (Error e) { diff --git a/libdino/src/service/util.vala b/libdino/src/service/util.vala index 4f9b94ce..9fe3029c 100644 --- a/libdino/src/service/util.vala +++ b/libdino/src/service/util.vala @@ -26,6 +26,25 @@ public class Util { } assert_not_reached(); } -} + + public static string get_content_type(FileInfo fileInfo) + { +//#if WIN32 + string fileName = fileInfo.get_name(); + int fileNameLength = fileName.length; + int extIndex = fileName.index_of("."); + if (extIndex < fileNameLength) + { + string extension = fileName.substring(extIndex, fileNameLength - extIndex); + string mime_type = ContentType.get_mime_type(extension); + if (mime_type != null && mime_type.length != 0) + { + return mime_type; + } + } +//#endif + return fileInfo.get_content_type(); + } +} } diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala index afa16645..eea3a945 100644 --- a/main/src/ui/main_window.vala +++ b/main/src/ui/main_window.vala @@ -55,6 +55,10 @@ public class MainWindow : Gtk.Window { } private void setup_unified() { + new Dino.Ui.ConversationSelector(); + new Dino.Ui.ConversationSummary.ConversationView(); + new Dino.Ui.ChatInput.View(); + new Dino.Ui.GlobalSearch(); Builder builder = new Builder.from_resource("/im/dino/Dino/unified_main_content.ui"); paned = (Paned) builder.get_object("paned"); box.add(paned);