diff options
author | Marvin W <git@larma.de> | 2022-07-27 19:41:05 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2022-07-27 20:55:54 +0200 |
commit | e51b55432fe98e0fbc036fe785ef50fbf1589034 (patch) | |
tree | 3f4737de32d1c9ef4f68b397394a0d7ac1f89d2a | |
parent | f44cbe02c17df1f02ad49c63cd784fec0ea02d85 (diff) | |
download | dino-e51b55432fe98e0fbc036fe785ef50fbf1589034.tar.gz dino-e51b55432fe98e0fbc036fe785ef50fbf1589034.zip |
Gtk4 bug fixes and improvements
-rw-r--r-- | libdino/src/service/calls.vala | 2 | ||||
-rw-r--r-- | main/CMakeLists.txt | 2 | ||||
-rw-r--r-- | main/data/theme.css | 7 | ||||
-rw-r--r-- | main/src/ui/chat_input/chat_input_controller.vala | 4 | ||||
-rw-r--r-- | main/src/ui/chat_input/chat_text_view.vala | 38 | ||||
-rw-r--r-- | main/src/ui/chat_input/smiley_converter.vala | 2 | ||||
-rw-r--r-- | main/src/ui/contact_details/dialog.vala | 2 | ||||
-rw-r--r-- | main/src/ui/conversation_content_view/conversation_item_skeleton.vala | 6 | ||||
-rw-r--r-- | main/src/ui/conversation_content_view/conversation_view.vala | 3 | ||||
-rw-r--r-- | main/src/ui/conversation_content_view/message_widget.vala | 4 | ||||
-rw-r--r-- | main/src/ui/conversation_view_controller.vala | 26 | ||||
-rw-r--r-- | main/src/ui/global_search.vala | 2 | ||||
-rw-r--r-- | plugins/rtp/CMakeLists.txt | 4 | ||||
-rw-r--r-- | plugins/rtp/src/video_widget.vala | 7 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0060_pubsub.vala | 2 |
15 files changed, 69 insertions, 42 deletions
diff --git a/libdino/src/service/calls.vala b/libdino/src/service/calls.vala index 094a45c9..35b88866 100644 --- a/libdino/src/service/calls.vala +++ b/libdino/src/service/calls.vala @@ -465,8 +465,8 @@ namespace Dino { call_state.cim_message_type = message_stanza.type_; Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(from_jid, to_jid, account, message_stanza.type_); - conversation.last_active = call_state.call.time; if (conversation == null) return; + conversation.last_active = call_state.call.time; if (call_state.call.direction == Call.DIRECTION_INCOMING) { call_incoming(call_state.call, call_state, conversation, video_requested, multiparty); diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index dd12e120..af007935 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -205,7 +205,7 @@ OPTIONS ${MAIN_EXTRA_OPTIONS} ) -add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\") +add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\" -DG_LOG_DOMAIN="dino") add_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET}) add_dependencies(dino ${GETTEXT_PACKAGE}-translations) target_include_directories(dino PRIVATE src) diff --git a/main/data/theme.css b/main/data/theme.css index 78d8862f..8c1a826b 100644 --- a/main/data/theme.css +++ b/main/data/theme.css @@ -43,18 +43,13 @@ window.dino-main .dino-conversation .message-box.highlight { } window.dino-main .dino-conversation .message-box { - padding: 4px 15px 4px 15px; + padding: 6px 15px 6px 15px; } window.dino-main .dino-conversation .message-box:not(.has-skeleton) { padding-left: 58px; } -window.dino-main .dino-conversation .message-box.has-skeleton.last-group-item { - padding-top: 8px; - padding-bottom: 8px; -} - window.dino-main .unread-count-notify { background-color: alpha(@theme_fg_color, 0.8); color: @theme_base_color; diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala index 41891519..b60a17d4 100644 --- a/main/src/ui/chat_input/chat_input_controller.vala +++ b/main/src/ui/chat_input/chat_input_controller.vala @@ -34,7 +34,7 @@ public class ChatInputController : Object { reset_input_field_status(); - var text_input_key_events = new EventControllerKey(); + var text_input_key_events = new EventControllerKey() { name = "dino-text-input-controller-key-events" }; text_input_key_events.key_pressed.connect(on_text_input_key_press); chat_input.chat_text_view.text_view.add_controller(text_input_key_events); @@ -192,7 +192,7 @@ public class ChatInputController : Object { activate_last_message_correction(); return true; } else { - chat_input.chat_text_view.text_view.grab_focus(); + chat_input.do_focus(); } return false; } diff --git a/main/src/ui/chat_input/chat_text_view.vala b/main/src/ui/chat_input/chat_text_view.vala index 437950ea..3752a1cf 100644 --- a/main/src/ui/chat_input/chat_text_view.vala +++ b/main/src/ui/chat_input/chat_text_view.vala @@ -34,16 +34,18 @@ public class ChatTextView : Box { public signal void send_text(); public signal void cancel_input(); - public ScrolledWindow scrolled_window = new ScrolledWindow() { propagate_natural_height=true, max_content_height=300 }; + public ScrolledWindow scrolled_window = new ScrolledWindow() { propagate_natural_height=true, max_content_height=300, hexpand=true }; public TextView text_view = new TextView() { hexpand=true, wrap_mode=Gtk.WrapMode.WORD_CHAR, valign=Align.CENTER, margin_top=7, margin_bottom=7 }; private int vscrollbar_min_height; + private uint wait_queue_resize; private SmileyConverter smiley_converter; construct { + valign = Align.CENTER; scrolled_window.set_child(text_view); this.append(scrolled_window); - var text_input_key_events = new EventControllerKey(); + var text_input_key_events = new EventControllerKey() { name = "dino-text-input-view-key-events" }; text_input_key_events.key_pressed.connect(on_text_input_key_press); text_view.add_controller(text_input_key_events); @@ -52,20 +54,44 @@ public class ChatTextView : Box { scrolled_window.vadjustment.changed.connect(on_upper_notify); text_view.realize.connect(() => { - var minimum_size = new Requisition(); + var minimum_size = Requisition(); scrolled_window.get_preferred_size(out minimum_size, null); vscrollbar_min_height = minimum_size.height; }); } + public override void dispose() { + base.dispose(); + if (wait_queue_resize != 0) { + Source.remove(wait_queue_resize); + wait_queue_resize = 0; + } + } + private void on_upper_notify() { // hack. otherwise the textview would only show the last row(s) when entering a new row on some systems. - if (text_view.get_height() < scrolled_window.max_content_height - 20) { - scrolled_window.vadjustment.page_size = scrolled_window.vadjustment.upper; - } + scrolled_window.height_request = int.min(scrolled_window.max_content_height, (int) scrolled_window.vadjustment.upper + text_view.margin_top + text_view.margin_bottom); + scrolled_window.vadjustment.page_size = double.min(scrolled_window.height_request - (text_view.margin_top + text_view.margin_bottom), scrolled_window.vadjustment.upper); // hack for vscrollbar not requiring space and making textview higher //TODO doesn't resize immediately scrolled_window.get_vscrollbar().visible = (scrolled_window.vadjustment.upper > scrolled_window.max_content_height - 2 * this.vscrollbar_min_height); + start_queue_resize_if_needed(); + } + + private void start_queue_resize_if_needed() { + if (wait_queue_resize == 0) { + wait_queue_resize = Timeout.add(100, queue_resize_if_needed); + } + } + + private bool queue_resize_if_needed() { + if (scrolled_window.get_height() == scrolled_window.height_request) { + wait_queue_resize = 0; + return false; + } else { + queue_resize(); + return true; + } } private bool on_text_input_key_press(uint keyval, uint keycode, Gdk.ModifierType state) { diff --git a/main/src/ui/chat_input/smiley_converter.vala b/main/src/ui/chat_input/smiley_converter.vala index fe280d99..ea0483e9 100644 --- a/main/src/ui/chat_input/smiley_converter.vala +++ b/main/src/ui/chat_input/smiley_converter.vala @@ -33,7 +33,7 @@ class SmileyConverter { public SmileyConverter(TextView text_input) { this.text_input = text_input; - var text_input_key_events = new EventControllerKey(); + var text_input_key_events = new EventControllerKey() { name = "dino-smiley-converter-key-events" }; text_input_key_events.key_pressed.connect(on_text_input_key_press); text_input.add_controller(text_input_key_events); } diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala index 36bef391..134bb559 100644 --- a/main/src/ui/contact_details/dialog.vala +++ b/main/src/ui/contact_details/dialog.vala @@ -131,7 +131,7 @@ public class Dialog : Gtk.Dialog { int width = get_content_area().get_width(); int pref_height, pref_width; get_content_area().measure(Orientation.VERTICAL, width, null, out pref_height, null, null); - default_height = pref_height; + default_height = pref_height + 48; } private void add_category(string category) { diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala index ae2d835f..b4b99a77 100644 --- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala @@ -24,7 +24,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, set { show_skeleton_ = value && content_meta_item != null && content_meta_item.requires_header && content_meta_item.requires_avatar; } } - public bool last_group_item { get; set; default=true; } public StreamInteractor stream_interactor; public Conversation conversation { get; set; } @@ -63,7 +62,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, } this.notify["show-skeleton"].connect(update_margin); - this.notify["last-group-item"].connect(update_margin); this.notify["show-skeleton"].connect(set_header); update_margin(); @@ -110,10 +108,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, if (show_skeleton || content_meta_item == null) { main_grid.add_css_class("has-skeleton"); } - - if (last_group_item) { - main_grid.add_css_class("last-group-item"); - } } private void update_edit_mode() { diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala index bfee3cbb..4babbdb4 100644 --- a/main/src/ui/conversation_content_view/conversation_view.vala +++ b/main/src/ui/conversation_content_view/conversation_view.vala @@ -51,6 +51,7 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug public ConversationView init(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify); + scrolled.vadjustment.notify["page-size"].connect(on_upper_notify); scrolled.vadjustment.notify["value"].connect(on_value_notify); content_populator = new ContentProvider(stream_interactor); @@ -363,7 +364,6 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug if (can_merge(item, lower_item)) { ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item]; item_skeleton.show_skeleton = false; - lower_skeleton.last_group_item = false; } else { item_skeleton.show_skeleton = true; } @@ -414,7 +414,6 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug }); } } else if (scrolled.vadjustment.value < scrolled.vadjustment.upper - scrolled.vadjustment.page_size - 1) { - print("move!\n"); scrolled.vadjustment.value = scrolled.vadjustment.upper - was_upper + scrolled.vadjustment.value; // stay at same content } was_upper = scrolled.vadjustment.upper; diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala index 346a6f71..3da76226 100644 --- a/main/src/ui/conversation_content_view/message_widget.vala +++ b/main/src/ui/conversation_content_view/message_widget.vala @@ -163,7 +163,6 @@ public class MessageMetaItem : ContentMetaItem { edit_mode.cancelled.connect(() => { in_edit_mode = false; outer.set_widget(label, Plugins.WidgetType.GTK4); - label.grab_focus(); }); edit_mode.send.connect(() => { if (((MessageItem) content_item).message.body != edit_mode.chat_text_view.text_view.buffer.text) { @@ -173,7 +172,6 @@ public class MessageMetaItem : ContentMetaItem { } in_edit_mode = false; outer.set_widget(label, Plugins.WidgetType.GTK4); - label.grab_focus(); }); edit_mode.chat_text_view.text_view.buffer.text = message.body; @@ -239,7 +237,7 @@ public class MessageItemEditMode : Box { [GtkChild] public unowned Frame frame; construct { - Util.force_css(frame, "* { border-radius: 3px; padding: 5px 7px; }"); + Util.force_css(frame, "* { border-radius: 3px; padding: 0px 7px; }"); EmojiChooser chooser = new EmojiChooser(); chooser.emoji_picked.connect((emoji) => { diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala index 6786117c..a2ac2655 100644 --- a/main/src/ui/conversation_view_controller.vala +++ b/main/src/ui/conversation_view_controller.vala @@ -40,16 +40,16 @@ public class ConversationViewController : Object { drop_event_controller.on_drop.connect(this.on_drag_data_received); // forward key presses - var key_controller = new EventControllerKey(); - key_controller.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller, v, c, s)); + var key_controller = new EventControllerKey() { name = "dino-forward-to-input-key-events-1" }; + key_controller.key_pressed.connect(forward_key_press_to_chat_input); view.conversation_frame.add_controller(key_controller); - var key_controller2 = new EventControllerKey(); - key_controller2.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller2, v, c, s)); + var key_controller2 = new EventControllerKey() { name = "dino-forward-to-input-key-events-2" }; + key_controller2.key_pressed.connect(forward_key_press_to_chat_input); view.chat_input.add_controller(key_controller2); - var key_controller3 = new EventControllerKey(); - key_controller3.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller3, v, c, s)); + var key_controller3 = new EventControllerKey() { name = "dino-forward-to-input-key-events-3" }; + key_controller3.key_pressed.connect(forward_key_press_to_chat_input); titlebar.get_widget().add_controller(key_controller3); // goto-end floating button @@ -190,11 +190,15 @@ public class ConversationViewController : Object { } private async void on_clipboard_paste() { - Clipboard clipboard = view.get_clipboard(); - Gdk.Texture? texture = yield clipboard.read_texture_async(null); // TODO critical - var file_name = Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png"); - texture.save_to_png(file_name); - open_send_file_overlay(File.new_for_path(file_name)); + try { + Clipboard clipboard = view.get_clipboard(); + Gdk.Texture? texture = yield clipboard.read_texture_async(null); // TODO critical + var file_name = Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png"); + texture.save_to_png(file_name); + open_send_file_overlay(File.new_for_path(file_name)); + } catch (IOError.NOT_SUPPORTED e) { + // Format not supported, ignore + } } private bool on_drag_data_received(DropTarget target, Value val, double x, double y) { diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala index 5a02aa28..aaf41b08 100644 --- a/main/src/ui/global_search.vala +++ b/main/src/ui/global_search.vala @@ -47,7 +47,7 @@ public class GlobalSearch { results_scrolled.vadjustment.notify["value"].connect(on_scrolled_window_vadjustment_value); results_scrolled.vadjustment.notify["upper"].connect_after(on_scrolled_window_vadjustment_upper); - var overlay_key_events = new EventControllerKey(); + var overlay_key_events = new EventControllerKey() { name = "dino-search-overlay-key-events" }; overlay_key_events.key_pressed.connect(on_key_pressed); overlay_key_events.key_released.connect(on_key_released); overlay.add_controller(overlay_key_events); diff --git a/plugins/rtp/CMakeLists.txt b/plugins/rtp/CMakeLists.txt index 33903d88..3a24c31c 100644 --- a/plugins/rtp/CMakeLists.txt +++ b/plugins/rtp/CMakeLists.txt @@ -28,6 +28,10 @@ if(GstRtp_VERSION VERSION_GREATER "1.20") set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_20) endif() +if(VALA_VERSION VERSION_GREATER "0.56.1") + set(RTP_DEFINITIONS ${RTP_DEFINITIONS} VALA_0_56_1) +endif() + set(RTP_ENABLE_VP9 "no" CACHE BOOL "Enable VP9 support") if(RTP_ENABLE_VP9) set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VP9) diff --git a/plugins/rtp/src/video_widget.vala b/plugins/rtp/src/video_widget.vala index 6afa0c03..c22e8440 100644 --- a/plugins/rtp/src/video_widget.vala +++ b/plugins/rtp/src/video_widget.vala @@ -97,7 +97,14 @@ public class Dino.Plugins.Rtp.Sink : Gst.Video.Sink { } } +#if VALA_0_56_1 public override Gst.Caps get_caps(Gst.Caps? filter) { +#if 0 + } +#endif +#else + public override Gst.Caps get_caps(Gst.Caps filter) { +#endif Gst.Caps caps = Gst.Caps.from_string("video/x-raw, format={ BGRA, ARGB, RGBA, ABGR, RGB, BGR }"); if (filter != null) { diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala index 95eee020..77f9aee6 100644 --- a/xmpp-vala/src/module/xep/0060_pubsub.vala +++ b/xmpp-vala/src/module/xep/0060_pubsub.vala @@ -186,7 +186,7 @@ namespace Xmpp.Xep.Pubsub { string node = items_node.get_attribute("node", NS_URI_EVENT); if (!message.from.is_bare() && pep_subset_listeners.contains(node)) { - warning("Got a PEP message from a full JID (%s), ignoring:\n%s", message.from.to_string(), message.stanza.to_string()); + warning("Got a PEP message from a full JID (%s), ignoring.", message.from.to_string()); return; } |