aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2022-07-27 19:41:05 +0200
committerfiaxh <git@lightrise.org>2022-07-27 20:55:54 +0200
commite51b55432fe98e0fbc036fe785ef50fbf1589034 (patch)
tree3f4737de32d1c9ef4f68b397394a0d7ac1f89d2a /main/src/ui
parentf44cbe02c17df1f02ad49c63cd784fec0ea02d85 (diff)
downloaddino-e51b55432fe98e0fbc036fe785ef50fbf1589034.tar.gz
dino-e51b55432fe98e0fbc036fe785ef50fbf1589034.zip
Gtk4 bug fixes and improvements
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala4
-rw-r--r--main/src/ui/chat_input/chat_text_view.vala38
-rw-r--r--main/src/ui/chat_input/smiley_converter.vala2
-rw-r--r--main/src/ui/contact_details/dialog.vala2
-rw-r--r--main/src/ui/conversation_content_view/conversation_item_skeleton.vala6
-rw-r--r--main/src/ui/conversation_content_view/conversation_view.vala3
-rw-r--r--main/src/ui/conversation_content_view/message_widget.vala4
-rw-r--r--main/src/ui/conversation_view_controller.vala26
-rw-r--r--main/src/ui/global_search.vala2
9 files changed, 54 insertions, 33 deletions
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);