Gtk4 bug fixes and improvements

This commit is contained in:
Marvin W 2022-07-27 19:41:05 +02:00 committed by fiaxh
parent f44cbe02c1
commit e51b55432f
15 changed files with 69 additions and 42 deletions

View file

@ -465,8 +465,8 @@ namespace Dino {
call_state.cim_message_type = message_stanza.type_; 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? 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; if (conversation == null) return;
conversation.last_active = call_state.call.time;
if (call_state.call.direction == Call.DIRECTION_INCOMING) { if (call_state.call.direction == Call.DIRECTION_INCOMING) {
call_incoming(call_state.call, call_state, conversation, video_requested, multiparty); call_incoming(call_state.call, call_state, conversation, video_requested, multiparty);

View file

@ -205,7 +205,7 @@ OPTIONS
${MAIN_EXTRA_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_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET})
add_dependencies(dino ${GETTEXT_PACKAGE}-translations) add_dependencies(dino ${GETTEXT_PACKAGE}-translations)
target_include_directories(dino PRIVATE src) target_include_directories(dino PRIVATE src)

View file

@ -43,18 +43,13 @@ window.dino-main .dino-conversation .message-box.highlight {
} }
window.dino-main .dino-conversation .message-box { 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) { window.dino-main .dino-conversation .message-box:not(.has-skeleton) {
padding-left: 58px; 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 { window.dino-main .unread-count-notify {
background-color: alpha(@theme_fg_color, 0.8); background-color: alpha(@theme_fg_color, 0.8);
color: @theme_base_color; color: @theme_base_color;

View file

@ -34,7 +34,7 @@ public class ChatInputController : Object {
reset_input_field_status(); 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); 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); 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(); activate_last_message_correction();
return true; return true;
} else { } else {
chat_input.chat_text_view.text_view.grab_focus(); chat_input.do_focus();
} }
return false; return false;
} }

View file

@ -34,16 +34,18 @@ public class ChatTextView : Box {
public signal void send_text(); public signal void send_text();
public signal void cancel_input(); 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 }; 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 int vscrollbar_min_height;
private uint wait_queue_resize;
private SmileyConverter smiley_converter; private SmileyConverter smiley_converter;
construct { construct {
valign = Align.CENTER;
scrolled_window.set_child(text_view); scrolled_window.set_child(text_view);
this.append(scrolled_window); 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_input_key_events.key_pressed.connect(on_text_input_key_press);
text_view.add_controller(text_input_key_events); text_view.add_controller(text_input_key_events);
@ -52,20 +54,44 @@ public class ChatTextView : Box {
scrolled_window.vadjustment.changed.connect(on_upper_notify); scrolled_window.vadjustment.changed.connect(on_upper_notify);
text_view.realize.connect(() => { text_view.realize.connect(() => {
var minimum_size = new Requisition(); var minimum_size = Requisition();
scrolled_window.get_preferred_size(out minimum_size, null); scrolled_window.get_preferred_size(out minimum_size, null);
vscrollbar_min_height = minimum_size.height; 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() { private void on_upper_notify() {
// hack. otherwise the textview would only show the last row(s) when entering a new row on some systems. // 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.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 = scrolled_window.vadjustment.upper; 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 // 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); 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) { private bool on_text_input_key_press(uint keyval, uint keycode, Gdk.ModifierType state) {

View file

@ -33,7 +33,7 @@ class SmileyConverter {
public SmileyConverter(TextView text_input) { public SmileyConverter(TextView text_input) {
this.text_input = 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_key_events.key_pressed.connect(on_text_input_key_press);
text_input.add_controller(text_input_key_events); text_input.add_controller(text_input_key_events);
} }

View file

@ -131,7 +131,7 @@ public class Dialog : Gtk.Dialog {
int width = get_content_area().get_width(); int width = get_content_area().get_width();
int pref_height, pref_width; int pref_height, pref_width;
get_content_area().measure(Orientation.VERTICAL, width, null, out pref_height, null, null); 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) { private void add_category(string category) {

View file

@ -24,7 +24,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
set { set {
show_skeleton_ = value && content_meta_item != null && content_meta_item.requires_header && content_meta_item.requires_avatar; } 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 StreamInteractor stream_interactor;
public Conversation conversation { get; set; } public Conversation conversation { get; set; }
@ -63,7 +62,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
} }
this.notify["show-skeleton"].connect(update_margin); this.notify["show-skeleton"].connect(update_margin);
this.notify["last-group-item"].connect(update_margin);
this.notify["show-skeleton"].connect(set_header); this.notify["show-skeleton"].connect(set_header);
update_margin(); update_margin();
@ -110,10 +108,6 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
if (show_skeleton || content_meta_item == null) { if (show_skeleton || content_meta_item == null) {
main_grid.add_css_class("has-skeleton"); main_grid.add_css_class("has-skeleton");
} }
if (last_group_item) {
main_grid.add_css_class("last-group-item");
}
} }
private void update_edit_mode() { private void update_edit_mode() {

View file

@ -51,6 +51,7 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug
public ConversationView init(StreamInteractor stream_interactor) { public ConversationView init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify); 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); scrolled.vadjustment.notify["value"].connect(on_value_notify);
content_populator = new ContentProvider(stream_interactor); content_populator = new ContentProvider(stream_interactor);
@ -363,7 +364,6 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug
if (can_merge(item, lower_item)) { if (can_merge(item, lower_item)) {
ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item]; ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
item_skeleton.show_skeleton = false; item_skeleton.show_skeleton = false;
lower_skeleton.last_group_item = false;
} else { } else {
item_skeleton.show_skeleton = true; 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) { } 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 scrolled.vadjustment.value = scrolled.vadjustment.upper - was_upper + scrolled.vadjustment.value; // stay at same content
} }
was_upper = scrolled.vadjustment.upper; was_upper = scrolled.vadjustment.upper;

View file

@ -163,7 +163,6 @@ public class MessageMetaItem : ContentMetaItem {
edit_mode.cancelled.connect(() => { edit_mode.cancelled.connect(() => {
in_edit_mode = false; in_edit_mode = false;
outer.set_widget(label, Plugins.WidgetType.GTK4); outer.set_widget(label, Plugins.WidgetType.GTK4);
label.grab_focus();
}); });
edit_mode.send.connect(() => { edit_mode.send.connect(() => {
if (((MessageItem) content_item).message.body != edit_mode.chat_text_view.text_view.buffer.text) { 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; in_edit_mode = false;
outer.set_widget(label, Plugins.WidgetType.GTK4); outer.set_widget(label, Plugins.WidgetType.GTK4);
label.grab_focus();
}); });
edit_mode.chat_text_view.text_view.buffer.text = message.body; edit_mode.chat_text_view.text_view.buffer.text = message.body;
@ -239,7 +237,7 @@ public class MessageItemEditMode : Box {
[GtkChild] public unowned Frame frame; [GtkChild] public unowned Frame frame;
construct { 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(); EmojiChooser chooser = new EmojiChooser();
chooser.emoji_picked.connect((emoji) => { chooser.emoji_picked.connect((emoji) => {

View file

@ -40,16 +40,16 @@ public class ConversationViewController : Object {
drop_event_controller.on_drop.connect(this.on_drag_data_received); drop_event_controller.on_drop.connect(this.on_drag_data_received);
// forward key presses // forward key presses
var key_controller = new EventControllerKey(); var key_controller = new EventControllerKey() { name = "dino-forward-to-input-key-events-1" };
key_controller.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller, v, c, s)); key_controller.key_pressed.connect(forward_key_press_to_chat_input);
view.conversation_frame.add_controller(key_controller); view.conversation_frame.add_controller(key_controller);
var key_controller2 = new EventControllerKey(); var key_controller2 = new EventControllerKey() { name = "dino-forward-to-input-key-events-2" };
key_controller2.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller2, v, c, s)); key_controller2.key_pressed.connect(forward_key_press_to_chat_input);
view.chat_input.add_controller(key_controller2); view.chat_input.add_controller(key_controller2);
var key_controller3 = new EventControllerKey(); var key_controller3 = new EventControllerKey() { name = "dino-forward-to-input-key-events-3" };
key_controller3.key_pressed.connect((v, c, s) => forward_key_press_to_chat_input(key_controller3, v, c, s)); key_controller3.key_pressed.connect(forward_key_press_to_chat_input);
titlebar.get_widget().add_controller(key_controller3); titlebar.get_widget().add_controller(key_controller3);
// goto-end floating button // goto-end floating button
@ -190,11 +190,15 @@ public class ConversationViewController : Object {
} }
private async void on_clipboard_paste() { private async void on_clipboard_paste() {
Clipboard clipboard = view.get_clipboard(); try {
Gdk.Texture? texture = yield clipboard.read_texture_async(null); // TODO critical Clipboard clipboard = view.get_clipboard();
var file_name = Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png"); Gdk.Texture? texture = yield clipboard.read_texture_async(null); // TODO critical
texture.save_to_png(file_name); var file_name = Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png");
open_send_file_overlay(File.new_for_path(file_name)); 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) { private bool on_drag_data_received(DropTarget target, Value val, double x, double y) {

View file

@ -47,7 +47,7 @@ public class GlobalSearch {
results_scrolled.vadjustment.notify["value"].connect(on_scrolled_window_vadjustment_value); results_scrolled.vadjustment.notify["value"].connect(on_scrolled_window_vadjustment_value);
results_scrolled.vadjustment.notify["upper"].connect_after(on_scrolled_window_vadjustment_upper); 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_pressed.connect(on_key_pressed);
overlay_key_events.key_released.connect(on_key_released); overlay_key_events.key_released.connect(on_key_released);
overlay.add_controller(overlay_key_events); overlay.add_controller(overlay_key_events);

View file

@ -28,6 +28,10 @@ if(GstRtp_VERSION VERSION_GREATER "1.20")
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_20) set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_20)
endif() 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") set(RTP_ENABLE_VP9 "no" CACHE BOOL "Enable VP9 support")
if(RTP_ENABLE_VP9) if(RTP_ENABLE_VP9)
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VP9) set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_VP9)

View file

@ -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) { 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 }"); Gst.Caps caps = Gst.Caps.from_string("video/x-raw, format={ BGRA, ARGB, RGBA, ABGR, RGB, BGR }");
if (filter != null) { if (filter != null) {

View file

@ -186,7 +186,7 @@ namespace Xmpp.Xep.Pubsub {
string node = items_node.get_attribute("node", NS_URI_EVENT); string node = items_node.get_attribute("node", NS_URI_EVENT);
if (!message.from.is_bare() && pep_subset_listeners.contains(node)) { 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; return;
} }