From 7e7dcedaf31ee35499875491c9f569c575d28435 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 14 Feb 2022 14:55:59 +0100 Subject: Port from GTK3 to GTK4 --- cmake/FindGDK4.cmake | 38 + cmake/FindGTK4.cmake | 30 + cmake/FindGspell.cmake | 2 +- libdino/src/entity/encryption.vala | 10 +- libdino/src/plugin/interfaces.vala | 25 +- libdino/src/service/content_item_store.vala | 89 +- .../service/counterpart_interaction_manager.vala | 2 +- libdino/src/service/message_correction.vala | 2 +- main/CMakeLists.txt | 104 ++- main/data/add_conversation/add_contact_dialog.ui | 112 +-- main/data/add_conversation/add_groupchat_dialog.ui | 198 ++--- .../conference_details_fragment.ui | 301 +++---- main/data/add_conversation/list_row.ui | 89 +- main/data/add_conversation/select_jid_fragment.ui | 80 +- main/data/call_widget.ui | 11 +- main/data/chat_input.ui | 57 +- main/data/contact_details_dialog.ui | 103 +-- main/data/conversation_content_view/view.ui | 175 ++-- main/data/conversation_item_widget.ui | 73 ++ main/data/conversation_list_titlebar_csd.ui | 25 +- main/data/conversation_row.ui | 14 +- main/data/conversation_view.ui | 105 +-- main/data/emojichooser.ui | 410 ---------- main/data/file_default_widget.ui | 191 ++--- main/data/file_send_overlay.ui | 56 +- main/data/global_search.ui | 246 +++--- main/data/icons/dino-changes-allowed-symbolic.svg | 10 - main/data/icons/dino-changes-prevent-symbolic.svg | 67 -- main/data/icons/dino-device-desktop-symbolic.svg | 5 - main/data/icons/dino-device-phone-symbolic.svg | 6 - main/data/icons/dino-double-tick-symbolic.svg | 7 - main/data/icons/dino-emoticon-symbolic.svg | 4 - main/data/icons/dino-file-document-symbolic.svg | 6 - main/data/icons/dino-file-download-symbolic.svg | 5 - main/data/icons/dino-file-image-symbolic.svg | 6 - main/data/icons/dino-file-music-symbolic.svg | 7 - main/data/icons/dino-file-symbolic.svg | 4 - main/data/icons/dino-file-table-symbolic.svg | 10 - main/data/icons/dino-file-video-symbolic.svg | 5 - main/data/icons/dino-microphone-off-symbolic.svg | 1 - main/data/icons/dino-microphone-symbolic.svg | 1 - main/data/icons/dino-phone-hangup-symbolic.svg | 1 - main/data/icons/dino-phone-in-talk-symbolic.svg | 1 - main/data/icons/dino-phone-missed-symbolic.svg | 1 - main/data/icons/dino-phone-ring-symbolic.svg | 1 - main/data/icons/dino-phone-symbolic.svg | 1 - main/data/icons/dino-security-high-symbolic.svg | 5 - main/data/icons/dino-tick-symbolic.svg | 6 - main/data/icons/dino-video-off-symbolic.svg | 1 - main/data/icons/dino-video-symbolic.svg | 1 - main/data/icons/im.dino.Dino-symbolic.svg | 6 - .../icons/scalable/apps/im.dino.Dino-symbolic.svg | 6 + .../devices/dino-device-desktop-symbolic.svg | 5 + .../devices/dino-device-phone-symbolic.svg | 6 + .../devices/dino-phone-hangup-symbolic.svg | 1 + .../devices/dino-phone-in-talk-symbolic.svg | 1 + .../devices/dino-phone-missed-symbolic.svg | 1 + .../scalable/devices/dino-phone-ring-symbolic.svg | 1 + .../icons/scalable/devices/dino-phone-symbolic.svg | 1 + .../scalable/emotes/dino-emoticon-symbolic.svg | 4 + .../mimetypes/dino-file-document-symbolic.svg | 6 + .../mimetypes/dino-file-download-symbolic.svg | 5 + .../mimetypes/dino-file-image-symbolic.svg | 6 + .../mimetypes/dino-file-music-symbolic.svg | 7 + .../scalable/mimetypes/dino-file-symbolic.svg | 4 + .../mimetypes/dino-file-table-symbolic.svg | 10 + .../mimetypes/dino-file-video-symbolic.svg | 5 + .../status/dino-changes-allowed-symbolic.svg | 10 + .../status/dino-changes-prevent-symbolic.svg | 67 ++ .../scalable/status/dino-double-tick-symbolic.svg | 7 + .../status/dino-microphone-off-symbolic.svg | 1 + .../scalable/status/dino-microphone-symbolic.svg | 1 + .../status/dino-security-high-symbolic.svg | 5 + .../icons/scalable/status/dino-tick-symbolic.svg | 6 + .../scalable/status/dino-video-off-symbolic.svg | 1 + .../icons/scalable/status/dino-video-symbolic.svg | 1 + main/data/manage_accounts/account_row.ui | 14 +- main/data/manage_accounts/add_account_dialog.ui | 906 +++++++++------------ main/data/manage_accounts/dialog.ui | 212 ++--- main/data/menu_encryption.ui | 33 +- main/data/message_item_widget_edit_mode.ui | 14 +- main/data/occupant_list.ui | 17 +- main/data/occupant_list_item.ui | 64 +- main/data/search_autocomplete.ui | 5 +- main/data/settings_dialog.ui | 70 +- main/data/theme.css | 47 +- main/data/unified_main_content.ui | 189 ++--- main/data/unified_window_placeholder.ui | 22 +- main/src/emojichooser.c | 823 ------------------- main/src/emojichooser.h | 36 - main/src/main.vala | 2 +- .../ui/add_conversation/add_conference_dialog.vala | 71 +- .../ui/add_conversation/add_groupchat_dialog.vala | 11 +- .../conference_details_fragment.vala | 48 +- main/src/ui/add_conversation/conference_list.vala | 37 +- main/src/ui/add_conversation/list_row.vala | 21 +- main/src/ui/add_conversation/roster_list.vala | 40 +- .../ui/add_conversation/select_contact_dialog.vala | 20 +- .../ui/add_conversation/select_jid_fragment.vala | 74 +- main/src/ui/application.vala | 24 +- main/src/ui/avatar_image.vala | 23 +- .../src/ui/call_window/audio_settings_popover.vala | 56 +- main/src/ui/call_window/call_bottom_bar.vala | 64 +- .../call_connection_details_window.vala | 8 +- .../src/ui/call_window/call_encryption_button.vala | 50 +- main/src/ui/call_window/call_window.vala | 58 +- .../src/ui/call_window/call_window_controller.vala | 43 +- main/src/ui/call_window/participant_widget.vala | 71 +- .../src/ui/call_window/video_settings_popover.vala | 30 +- main/src/ui/chat_input/chat_input_controller.vala | 15 +- main/src/ui/chat_input/chat_text_view.vala | 55 +- main/src/ui/chat_input/edit_history.vala | 77 -- main/src/ui/chat_input/encryption_button.vala | 43 +- .../src/ui/chat_input/occupants_tab_completer.vala | 14 +- main/src/ui/chat_input/smiley_converter.vala | 8 +- main/src/ui/chat_input/view.vala | 30 +- main/src/ui/contact_details/blocking_provider.vala | 2 +- main/src/ui/contact_details/dialog.vala | 43 +- .../contact_details/muc_config_form_provider.vala | 2 +- .../ui/contact_details/permissions_provider.vala | 4 +- main/src/ui/contact_details/settings_provider.vala | 2 +- .../conversation_item_factory.vala | 36 + .../ui/conversation_content_view/call_widget.vala | 37 +- .../chat_state_populator.vala | 6 +- .../conversation_item_skeleton.vala | 265 +++--- .../conversation_view.vala | 133 ++- .../date_separator_populator.vala | 8 +- .../file_default_widget.vala | 78 +- .../file_image_widget.vala | 25 +- .../ui/conversation_content_view/file_widget.vala | 45 +- .../message_item_widget.vala | 229 ++++++ .../conversation_content_view/message_widget.vala | 217 ++--- .../subscription_notification.vala | 10 +- .../conversation_list_item_factory.vala | 245 ++++++ .../conversation_list/conversation_list_model.vala | 141 ++++ .../conversation_list/conversation_list_row.vala | 41 + main/src/ui/conversation_list_titlebar.vala | 18 +- .../conversation_selector.vala | 54 +- .../conversation_selector_row.vala | 6 +- main/src/ui/conversation_titlebar/call_entry.vala | 69 +- .../conversation_titlebar.vala | 69 +- main/src/ui/conversation_titlebar/menu_entry.vala | 44 +- .../ui/conversation_titlebar/occupants_entry.vala | 42 +- .../src/ui/conversation_titlebar/search_entry.vala | 20 +- main/src/ui/conversation_view.vala | 37 +- main/src/ui/conversation_view_controller.vala | 184 +++-- main/src/ui/file_send_overlay.vala | 46 +- main/src/ui/global_search.vala | 140 ++-- main/src/ui/main_window.vala | 107 ++- main/src/ui/main_window_controller.vala | 97 ++- .../src/ui/manage_accounts/add_account_dialog.vala | 65 +- main/src/ui/manage_accounts/dialog.vala | 48 +- main/src/ui/occupant_menu/list.vala | 53 +- main/src/ui/occupant_menu/list_row.vala | 19 +- main/src/ui/occupant_menu/view.vala | 44 +- main/src/ui/util/data_forms.vala | 10 +- main/src/ui/util/helper.vala | 45 +- main/src/ui/util/label_hybrid.vala | 66 +- main/src/ui/util/scaling_image.vala | 89 +- main/src/ui/util/size_request_box.vala | 6 +- main/src/ui/util/sizing_bin.vala | 38 +- main/vapi/emojichooser.vapi | 7 - plugins/http-files/CMakeLists.txt | 2 +- plugins/ice/CMakeLists.txt | 3 +- plugins/omemo/CMakeLists.txt | 3 +- plugins/omemo/data/contact_details_dialog.ui | 161 ++-- plugins/omemo/data/manage_key_dialog.ui | 223 +++-- plugins/omemo/src/logic/trust_manager.vala | 2 +- plugins/omemo/src/ui/account_settings_entry.vala | 54 +- plugins/omemo/src/ui/account_settings_widget.vala | 54 -- plugins/omemo/src/ui/bad_messages_populator.vala | 6 +- plugins/omemo/src/ui/contact_details_dialog.vala | 57 +- plugins/omemo/src/ui/contact_details_provider.vala | 6 +- .../src/ui/device_notification_populator.vala | 8 +- plugins/omemo/src/ui/encryption_list_entry.vala | 8 +- plugins/omemo/src/ui/manage_key_dialog.vala | 28 +- plugins/openpgp/CMakeLists.txt | 3 +- plugins/openpgp/data/account_settings_item.ui | 44 +- plugins/openpgp/src/account_settings_entry.vala | 156 +++- plugins/openpgp/src/account_settings_widget.vala | 149 ---- plugins/openpgp/src/contact_details_provider.vala | 2 +- plugins/openpgp/src/encryption_list_entry.vala | 6 +- plugins/rtp/CMakeLists.txt | 2 +- plugins/rtp/src/plugin.vala | 2 +- plugins/rtp/src/video_widget.vala | 12 +- 185 files changed, 4694 insertions(+), 5618 deletions(-) create mode 100644 cmake/FindGDK4.cmake create mode 100644 cmake/FindGTK4.cmake create mode 100644 main/data/conversation_item_widget.ui delete mode 100644 main/data/emojichooser.ui delete mode 100644 main/data/icons/dino-changes-allowed-symbolic.svg delete mode 100644 main/data/icons/dino-changes-prevent-symbolic.svg delete mode 100644 main/data/icons/dino-device-desktop-symbolic.svg delete mode 100644 main/data/icons/dino-device-phone-symbolic.svg delete mode 100644 main/data/icons/dino-double-tick-symbolic.svg delete mode 100644 main/data/icons/dino-emoticon-symbolic.svg delete mode 100644 main/data/icons/dino-file-document-symbolic.svg delete mode 100644 main/data/icons/dino-file-download-symbolic.svg delete mode 100644 main/data/icons/dino-file-image-symbolic.svg delete mode 100644 main/data/icons/dino-file-music-symbolic.svg delete mode 100644 main/data/icons/dino-file-symbolic.svg delete mode 100644 main/data/icons/dino-file-table-symbolic.svg delete mode 100644 main/data/icons/dino-file-video-symbolic.svg delete mode 100644 main/data/icons/dino-microphone-off-symbolic.svg delete mode 100644 main/data/icons/dino-microphone-symbolic.svg delete mode 100644 main/data/icons/dino-phone-hangup-symbolic.svg delete mode 100644 main/data/icons/dino-phone-in-talk-symbolic.svg delete mode 100644 main/data/icons/dino-phone-missed-symbolic.svg delete mode 100644 main/data/icons/dino-phone-ring-symbolic.svg delete mode 100644 main/data/icons/dino-phone-symbolic.svg delete mode 100644 main/data/icons/dino-security-high-symbolic.svg delete mode 100644 main/data/icons/dino-tick-symbolic.svg delete mode 100644 main/data/icons/dino-video-off-symbolic.svg delete mode 100644 main/data/icons/dino-video-symbolic.svg delete mode 100644 main/data/icons/im.dino.Dino-symbolic.svg create mode 100644 main/data/icons/scalable/apps/im.dino.Dino-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-device-desktop-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-device-phone-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-phone-hangup-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-phone-in-talk-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-phone-missed-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-phone-ring-symbolic.svg create mode 100644 main/data/icons/scalable/devices/dino-phone-symbolic.svg create mode 100644 main/data/icons/scalable/emotes/dino-emoticon-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-document-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-download-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-image-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-music-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-table-symbolic.svg create mode 100644 main/data/icons/scalable/mimetypes/dino-file-video-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-changes-allowed-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-changes-prevent-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-double-tick-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-microphone-off-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-microphone-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-security-high-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-tick-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-video-off-symbolic.svg create mode 100644 main/data/icons/scalable/status/dino-video-symbolic.svg delete mode 100644 main/src/emojichooser.c delete mode 100644 main/src/emojichooser.h delete mode 100644 main/src/ui/chat_input/edit_history.vala create mode 100644 main/src/ui/conversation_content/conversation_item_factory.vala create mode 100644 main/src/ui/conversation_content_view/message_item_widget.vala create mode 100644 main/src/ui/conversation_list/conversation_list_item_factory.vala create mode 100644 main/src/ui/conversation_list/conversation_list_model.vala create mode 100644 main/src/ui/conversation_list/conversation_list_row.vala delete mode 100644 main/vapi/emojichooser.vapi delete mode 100644 plugins/omemo/src/ui/account_settings_widget.vala delete mode 100644 plugins/openpgp/src/account_settings_widget.vala diff --git a/cmake/FindGDK4.cmake b/cmake/FindGDK4.cmake new file mode 100644 index 00000000..74ef583e --- /dev/null +++ b/cmake/FindGDK4.cmake @@ -0,0 +1,38 @@ +include(PkgConfigWithFallback) +find_pkg_config_with_fallback(GDK4 + PKG_CONFIG_NAME gdk-4.0 + LIB_NAMES gdk-4 + INCLUDE_NAMES gdk/gdk.h + INCLUDE_DIR_SUFFIXES gtk-4.0 gtk-4.0/include gtk+-4.0 gtk+-4.0/include + DEPENDS Pango Cairo GDKPixbuf2 +) + +if(GDK4_FOUND AND NOT GDK4_VERSION) + find_file(GDK4_VERSION_HEADER "gdk/gdkversionmacros.h" HINTS ${GDK4_INCLUDE_DIRS}) + mark_as_advanced(GDK4_VERSION_HEADER) + + if(GDK4_VERSION_HEADER) + file(STRINGS "${GDK4_VERSION_HEADER}" GDK4_MAJOR_VERSION REGEX "^#define GDK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MAJOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK4_MAJOR_VERSION "${GDK4_MAJOR_VERSION}") + file(STRINGS "${GDK4_VERSION_HEADER}" GDK4_MINOR_VERSION REGEX "^#define GDK_MINOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MINOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK4_MINOR_VERSION "${GDK4_MINOR_VERSION}") + file(STRINGS "${GDK4_VERSION_HEADER}" GDK4_MICRO_VERSION REGEX "^#define GDK_MICRO_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MICRO_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK4_MICRO_VERSION "${GDK4_MICRO_VERSION}") + set(GDK4_VERSION "${GDK4_MAJOR_VERSION}.${GDK4_MINOR_VERSION}.${GDK4_MICRO_VERSION}") + unset(GDK4_MAJOR_VERSION) + unset(GDK4_MINOR_VERSION) + unset(GDK4_MICRO_VERSION) + endif() +endif() + +if (GDK4_FOUND) + find_file(GDK4_WITH_X11 "gdk/gdkx.h" HINTS ${GDK4_INCLUDE_DIRS}) + if (GDK4_WITH_X11) + set(GDK4_WITH_X11 yes CACHE INTERNAL "Does GDK4 support X11") + endif (GDK4_WITH_X11) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GDK4 + REQUIRED_VARS GDK4_LIBRARY + VERSION_VAR GDK4_VERSION) \ No newline at end of file diff --git a/cmake/FindGTK4.cmake b/cmake/FindGTK4.cmake new file mode 100644 index 00000000..23819bca --- /dev/null +++ b/cmake/FindGTK4.cmake @@ -0,0 +1,30 @@ +include(PkgConfigWithFallback) +find_pkg_config_with_fallback(GTK4 + PKG_CONFIG_NAME gtk4 + LIB_NAMES gtk-4 + INCLUDE_NAMES gtk/gtk.h + INCLUDE_DIR_SUFFIXES gtk-4.0 gtk-4.0/include gtk+-4.0 gtk+-4.0/include gtk4 gtk4/include +) + +if(GTK4_FOUND AND NOT GTK4_VERSION) + find_file(GTK4_VERSION_HEADER "gtk/gtkversion.h" HINTS ${GTK4_INCLUDE_DIRS}) + mark_as_advanced(GTK4_VERSION_HEADER) + + if(GTK4_VERSION_HEADER) + file(STRINGS "${GTK4_VERSION_HEADER}" GTK4_MAJOR_VERSION REGEX "^#define GTK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MAJOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK4_MAJOR_VERSION "${GTK4_MAJOR_VERSION}") + file(STRINGS "${GTK4_VERSION_HEADER}" GTK4_MINOR_VERSION REGEX "^#define GTK_MINOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MINOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK4_MINOR_VERSION "${GTK4_MINOR_VERSION}") + file(STRINGS "${GTK4_VERSION_HEADER}" GTK4_MICRO_VERSION REGEX "^#define GTK_MICRO_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MICRO_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK4_MICRO_VERSION "${GTK4_MICRO_VERSION}") + set(GTK4_VERSION "${GTK4_MAJOR_VERSION}.${GTK4_MINOR_VERSION}.${GTK4_MICRO_VERSION}") + unset(GTK4_MAJOR_VERSION) + unset(GTK4_MINOR_VERSION) + unset(GTK4_MICRO_VERSION) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GTK4 + REQUIRED_VARS GTK4_LIBRARY + VERSION_VAR GTK4_VERSION) diff --git a/cmake/FindGspell.cmake b/cmake/FindGspell.cmake index 51c33c7e..de29ed1d 100644 --- a/cmake/FindGspell.cmake +++ b/cmake/FindGspell.cmake @@ -4,7 +4,7 @@ find_pkg_config_with_fallback(Gspell LIB_NAMES gspell-1 INCLUDE_NAMES gspell.h INCLUDE_DIR_SUFFIXES gspell-1 gspell-1/gspell - DEPENDS Gtk + DEPENDS GTK3 ) include(FindPackageHandleStandardArgs) diff --git a/libdino/src/entity/encryption.vala b/libdino/src/entity/encryption.vala index 193d741b..ab5a0ae0 100644 --- a/libdino/src/entity/encryption.vala +++ b/libdino/src/entity/encryption.vala @@ -1,12 +1,16 @@ namespace Dino.Entities { -public enum Encryption { + public enum Encryption { NONE, PGP, OMEMO, DTLS_SRTP, SRTP, - UNKNOWN, -} + UNKNOWN; + + public bool is_some() { + return this != NONE; + } + } } \ No newline at end of file diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index c7c2c375..e4710732 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -12,7 +12,8 @@ public enum Priority { } public enum WidgetType { - GTK + GTK3, + GTK4 } public interface RootInterface : Object { @@ -27,6 +28,8 @@ public interface EncryptionListEntry : Object { public abstract void encryption_activated(Entities.Conversation conversation, Plugins.SetInputFieldStatus callback); public abstract Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item); + public abstract string? get_encryption_icon_name(Entities.Conversation conversation, ContentItem content_item); + } public interface CallEncryptionEntry : Object { @@ -45,15 +48,11 @@ public abstract class AccountSettingsEntry : Object { public abstract string name { get; } public virtual int16 label_top_padding { get { return -1; } } - public abstract AccountSettingsWidget? get_widget(WidgetType type); -} - -public interface AccountSettingsWidget : Object { - public abstract void set_account(Account account); - public abstract signal void activated(); - public abstract void deactivate(); + + public abstract void set_account(Account account); + public abstract Object? get_widget(WidgetType type); } public interface ContactDetailsProvider : Object { @@ -76,10 +75,8 @@ public interface TextCommand : Object { public interface ConversationTitlebarEntry : Object { public abstract string id { get; } public abstract double order { get; } - public abstract ConversationTitlebarWidget? get_widget(WidgetType type); -} + public abstract Object? get_widget(WidgetType type); -public interface ConversationTitlebarWidget : Object { public abstract void set_conversation(Conversation conversation); public abstract void unset_conversation(); } @@ -146,10 +143,14 @@ public abstract class MetaConversationItem : Object { public bool requires_header { get; set; default=false; } public bool in_edit_mode { get; set; default=false; } - public abstract Object? get_widget(WidgetType type); + public abstract Object? get_widget(ConversationItemWidgetInterface outer, WidgetType type); public abstract Gee.List? get_item_actions(WidgetType type); } +public interface ConversationItemWidgetInterface: Object { + public abstract void set_widget(Object object, WidgetType type); +} + public delegate void MessageActionEvoked(Object button, Plugins.MetaConversationItem evoked_on, Object widget); public class MessageAction : Object { public string icon_name; diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala index c6c47af4..6371e00b 100644 --- a/libdino/src/service/content_item_store.vala +++ b/libdino/src/service/content_item_store.vala @@ -44,37 +44,11 @@ public class ContentItemStore : StreamInteractionModule, Object { Gee.TreeSet items = new Gee.TreeSet(ContentItem.compare_func); foreach (var row in select) { - int provider = row[db.content_item.content_type]; + int id = row[db.content_item.id]; + int content_type = row[db.content_item.content_type]; int foreign_id = row[db.content_item.foreign_id]; DateTime time = new DateTime.from_unix_utc(row[db.content_item.time]); - switch (provider) { - case 1: - Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation); - if (message != null) { - var message_item = new MessageItem(message, conversation, row[db.content_item.id]); - message_item.time = time; // In case of message corrections, the original time should be used - items.add(message_item); - } - break; - case 2: - FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_file_by_id(foreign_id, conversation); - if (file_transfer != null) { - Message? message = null; - if (file_transfer.provider == 0 && file_transfer.info != null) { - message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(int.parse(file_transfer.info), conversation); - } - var file_item = new FileItem(file_transfer, conversation, row[db.content_item.id], message); - items.add(file_item); - } - break; - case 3: - Call? call = stream_interactor.get_module(CallStore.IDENTITY).get_call_by_id(foreign_id, conversation); - if (call != null) { - var call_item = new CallItem(call, conversation, row[db.content_item.id]); - items.add(call_item); - } - break; - } + items.add(get_item(conversation, id, content_type, foreign_id, time)); } Gee.List ret = new ArrayList(); @@ -84,7 +58,42 @@ public class ContentItemStore : StreamInteractionModule, Object { return ret; } - public ContentItem? get_item(Conversation conversation, int type, int foreign_id) { + public ContentItem get_item(Conversation conversation, int id, int content_type, int foreign_id, DateTime time) throws Error { + switch (content_type) { + case 1: + Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(foreign_id, conversation); + if (message != null) { + var message_item = new MessageItem(message, conversation, id); + message_item.time = time; // In case of message corrections, the original time should be used + return message_item; + } + break; + case 2: + FileTransfer? file_transfer = stream_interactor.get_module(FileTransferStorage.IDENTITY).get_file_by_id(foreign_id, conversation); + if (file_transfer != null) { + Message? message = null; + if (file_transfer.provider == 0 && file_transfer.info != null) { + message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_id(int.parse(file_transfer.info), conversation); + } + var file_item = new FileItem(file_transfer, conversation, id, message); + return file_item; + } + break; + case 3: + Call? call = stream_interactor.get_module(CallStore.IDENTITY).get_call_by_id(foreign_id, conversation); + if (call != null) { + var call_item = new CallItem(call, conversation, id); + return call_item; + } + break; + default: + warning("Unknown content item type: %i", content_type); + break; + } + throw new Error(-1, 0, "Bad content type %i or non existing content item %i", content_type, foreign_id); + } + + public ContentItem? get_item_by_foreign(Conversation conversation, int type, int foreign_id) { QueryBuilder select = db.content_item.select() .with(db.content_item.content_type, "=", type) .with(db.content_item.foreign_id, "=", foreign_id); @@ -122,6 +131,26 @@ public class ContentItemStore : StreamInteractionModule, Object { return get_items_from_query(select, conversation); } +// public Gee.List get_latest_meta(Conversation conversation, int count) { +// QueryBuilder select = db.content_item.select() +// .with(db.content_item.conversation_id, "=", conversation.id) +// .with(db.content_item.hide, "=", false) +// .order_by(db.content_item.time, "DESC") +// .order_by(db.content_item.id, "DESC") +// .limit(count); +// +// var ret = new ArrayList(); +// foreach (var row in select) { +// var item_meta = new ContentItemMeta() { +// id = row[db.content_item.id], +// content_type = row[db.content_item.content_type], +// foreign_id = row[db.content_item.foreign_id], +// time = new DateTime.from_unix_utc(row[db.content_item.time]) +// }; +// } +// return ret; +// } + public Gee.List get_before(Conversation conversation, ContentItem item, int count) { long time = (long) item.time.to_unix(); QueryBuilder select = db.content_item.select() diff --git a/libdino/src/service/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala index cc5489c3..23db5762 100644 --- a/libdino/src/service/counterpart_interaction_manager.vala +++ b/libdino/src/service/counterpart_interaction_manager.vala @@ -154,7 +154,7 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object { conversation.read_up_to = message; // TODO: This only marks messages as read, not http file transfers. - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message.id); if (content_item == null) return; ContentItem? read_up_to_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_id(conversation, conversation.read_up_to_item); if (read_up_to_item != null && read_up_to_item.compare(content_item) > 0) return; diff --git a/libdino/src/service/message_correction.vala b/libdino/src/service/message_correction.vala index 322fa1c1..d5d15578 100644 --- a/libdino/src/service/message_correction.vala +++ b/libdino/src/service/message_correction.vala @@ -144,7 +144,7 @@ public class MessageCorrection : StreamInteractionModule, MessageListener { } private void on_received_correction(Conversation conversation, int message_id) { - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message_id); + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message_id); if (content_item != null) { received_correction(content_item); } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 2326253c..4a952396 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -8,48 +8,50 @@ find_packages(MAIN_PACKAGES REQUIRED GLib GModule GObject - GTK3 + GTK4 ICU - Gspell ) set(RESOURCE_LIST icons/dino-account-plus-symbolic.svg - icons/dino-changes-allowed-symbolic.svg - icons/dino-changes-prevent-symbolic.svg icons/dino-conversation-list-placeholder-arrow.svg - icons/dino-double-tick-symbolic.svg - icons/dino-emoticon-symbolic.svg icons/dino-qr-code-symbolic.svg - icons/dino-security-high-symbolic.svg - icons/dino-microphone-off-symbolic.svg - icons/dino-microphone-symbolic.svg icons/dino-party-popper-symbolic.svg - icons/dino-phone-hangup-symbolic.svg - icons/dino-phone-in-talk-symbolic.svg - icons/dino-phone-missed-symbolic.svg - icons/dino-phone-ring-symbolic.svg - icons/dino-phone-symbolic.svg icons/dino-status-away.svg icons/dino-status-chat.svg icons/dino-status-dnd.svg icons/dino-status-online.svg icons/im.dino.Dino.svg - icons/im.dino.Dino-symbolic.svg - icons/dino-tick-symbolic.svg - icons/dino-video-off-symbolic.svg - icons/dino-video-symbolic.svg - - icons/dino-device-desktop-symbolic.svg - icons/dino-device-phone-symbolic.svg - - icons/dino-file-document-symbolic.svg - icons/dino-file-download-symbolic.svg - icons/dino-file-image-symbolic.svg - icons/dino-file-music-symbolic.svg - icons/dino-file-symbolic.svg - icons/dino-file-table-symbolic.svg - icons/dino-file-video-symbolic.svg + + icons/scalable/apps/im.dino.Dino-symbolic.svg + + icons/scalable/devices/dino-device-desktop-symbolic.svg + icons/scalable/devices/dino-device-phone-symbolic.svg + icons/scalable/devices/dino-phone-hangup-symbolic.svg + icons/scalable/devices/dino-phone-in-talk-symbolic.svg + icons/scalable/devices/dino-phone-missed-symbolic.svg + icons/scalable/devices/dino-phone-ring-symbolic.svg + icons/scalable/devices/dino-phone-symbolic.svg + + icons/scalable/emotes/dino-emoticon-symbolic.svg + + icons/scalable/mimetypes/dino-file-document-symbolic.svg + icons/scalable/mimetypes/dino-file-download-symbolic.svg + icons/scalable/mimetypes/dino-file-image-symbolic.svg + icons/scalable/mimetypes/dino-file-music-symbolic.svg + icons/scalable/mimetypes/dino-file-symbolic.svg + icons/scalable/mimetypes/dino-file-table-symbolic.svg + icons/scalable/mimetypes/dino-file-video-symbolic.svg + + icons/scalable/status/dino-changes-allowed-symbolic.svg + icons/scalable/status/dino-changes-prevent-symbolic.svg + icons/scalable/status/dino-double-tick-symbolic.svg + icons/scalable/status/dino-microphone-off-symbolic.svg + icons/scalable/status/dino-microphone-symbolic.svg + icons/scalable/status/dino-security-high-symbolic.svg + icons/scalable/status/dino-tick-symbolic.svg + icons/scalable/status/dino-video-off-symbolic.svg + icons/scalable/status/dino-video-symbolic.svg add_conversation/add_contact_dialog.ui add_conversation/add_groupchat_dialog.ui @@ -60,13 +62,13 @@ set(RESOURCE_LIST call_widget.ui chat_input.ui contact_details_dialog.ui + conversation_item_widget.ui conversation_list_titlebar.ui conversation_list_titlebar_csd.ui conversation_row.ui conversation_view.ui file_default_widget.ui file_send_overlay.ui - emojichooser.ui global_search.ui conversation_content_view/item_metadata_header.ui conversation_content_view/view.ui @@ -101,11 +103,11 @@ compile_gresources( unset(MAIN_EXTRA_OPTIONS) unset(MAIN_EXTRA_PACKAGES) -find_package(GDK3) -if(GDK3_WITH_X11) - set(MAIN_EXTRA_OPTIONS ${MAIN_EXTRA_OPTIONS} -D GDK3_WITH_X11) - set(MAIN_EXTRA_PACKAGES ${MAIN_EXTRA_PACKAGES} gdk-x11-3.0) -endif(GDK3_WITH_X11) +# find_package(GDK3) +# if(GDK3_WITH_X11) +# set(MAIN_EXTRA_OPTIONS ${MAIN_EXTRA_OPTIONS} -D GDK3_WITH_X11) +# set(MAIN_EXTRA_PACKAGES ${MAIN_EXTRA_PACKAGES} gdk-x11-3.0) +# endif(GDK3_WITH_X11) set(MAIN_EXTRA_OPTIONS ${MAIN_EXTRA_OPTIONS} --vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi) vala_precompile(MAIN_VALA_C @@ -145,13 +147,23 @@ SOURCES src/ui/call_window/participant_widget.vala src/ui/call_window/video_settings_popover.vala + src/ui/conversation_content_view/call_widget.vala + src/ui/conversation_content_view/chat_state_populator.vala + src/ui/conversation_content_view/content_populator.vala + src/ui/conversation_content_view/conversation_item_skeleton.vala + src/ui/conversation_content_view/conversation_view.vala + src/ui/conversation_content_view/date_separator_populator.vala + src/ui/conversation_content_view/file_default_widget.vala + src/ui/conversation_content_view/file_image_widget.vala + src/ui/conversation_content_view/file_widget.vala + src/ui/conversation_content_view/message_widget.vala + src/ui/conversation_content_view/subscription_notification.vala + src/ui/chat_input/chat_input_controller.vala src/ui/chat_input/chat_text_view.vala - src/ui/chat_input/edit_history.vala src/ui/chat_input/encryption_button.vala src/ui/chat_input/occupants_tab_completer.vala src/ui/chat_input/smiley_converter.vala - src/ui/chat_input/spell_checker.vala src/ui/chat_input/view.vala src/ui/contact_details/blocking_provider.vala @@ -160,20 +172,8 @@ SOURCES src/ui/contact_details/dialog.vala src/ui/contact_details/muc_config_form_provider.vala - src/ui/conversation_selector/conversation_selector_row.vala src/ui/conversation_selector/conversation_selector.vala - - src/ui/conversation_content_view/call_widget.vala - src/ui/conversation_content_view/chat_state_populator.vala - src/ui/conversation_content_view/content_populator.vala - src/ui/conversation_content_view/conversation_item_skeleton.vala - src/ui/conversation_content_view/conversation_view.vala - src/ui/conversation_content_view/date_separator_populator.vala - src/ui/conversation_content_view/file_default_widget.vala - src/ui/conversation_content_view/file_image_widget.vala - src/ui/conversation_content_view/file_widget.vala - src/ui/conversation_content_view/message_widget.vala - src/ui/conversation_content_view/subscription_notification.vala + src/ui/conversation_selector/conversation_selector_row.vala src/ui/conversation_titlebar/call_entry.vala src/ui/conversation_titlebar/menu_entry.vala @@ -197,12 +197,10 @@ SOURCES src/ui/util/sizing_bin.vala src/ui/util/size_request_box.vala src/ui/util/scaling_image.vala - src/ui/util/preview_file_chooser_native.vala CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/dino_internal.vapi - vapi/emojichooser.vapi PACKAGES ${MAIN_PACKAGES} ${MAIN_EXTRA_PACKAGES} @@ -213,7 +211,7 @@ OPTIONS ) add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\") -add_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET} src/emojichooser.c) +add_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET}) add_dependencies(dino ${GETTEXT_PACKAGE}-translations) target_include_directories(dino PRIVATE src) target_link_libraries(dino libdino ${MAIN_PACKAGES}) diff --git a/main/data/add_conversation/add_contact_dialog.ui b/main/data/add_conversation/add_contact_dialog.ui index 6185c5ba..1abc9a7a 100644 --- a/main/data/add_conversation/add_contact_dialog.ui +++ b/main/data/add_conversation/add_contact_dialog.ui @@ -1,128 +1,102 @@ + - + \ No newline at end of file diff --git a/main/data/add_conversation/add_groupchat_dialog.ui b/main/data/add_conversation/add_groupchat_dialog.ui index 29638f53..5acd6891 100644 --- a/main/data/add_conversation/add_groupchat_dialog.ui +++ b/main/data/add_conversation/add_groupchat_dialog.ui @@ -1,201 +1,165 @@ + - + \ No newline at end of file diff --git a/main/data/add_conversation/conference_details_fragment.ui b/main/data/add_conversation/conference_details_fragment.ui index a4f6f5d3..0fdf2b8e 100644 --- a/main/data/add_conversation/conference_details_fragment.ui +++ b/main/data/add_conversation/conference_details_fragment.ui @@ -1,272 +1,238 @@ +