aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/chat_input.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-15 22:01:32 +0100
committerfiaxh <git@mx.ax.lt>2017-03-16 17:56:38 +0100
commitaf49a47cf6c5933a9bcc21f2b7bb20d85be37483 (patch)
tree6f1c993fea5f238a1131d23586d9b8095553dc5b /main/src/ui/chat_input.vala
parentf277db6cb459c6e7456fb75722b9d57f734c4db6 (diff)
downloaddino-af49a47cf6c5933a9bcc21f2b7bb20d85be37483.tar.gz
dino-af49a47cf6c5933a9bcc21f2b7bb20d85be37483.zip
Fix ChatInput for many lines + small UI changes
Diffstat (limited to 'main/src/ui/chat_input.vala')
-rw-r--r--main/src/ui/chat_input.vala13
1 files changed, 12 insertions, 1 deletions
diff --git a/main/src/ui/chat_input.vala b/main/src/ui/chat_input.vala
index 5030fcea..209869a8 100644
--- a/main/src/ui/chat_input.vala
+++ b/main/src/ui/chat_input.vala
@@ -8,14 +8,16 @@ using Xmpp;
namespace Dino.Ui {
[GtkTemplate (ui = "/org/dino-im/chat_input.ui")]
-public class ChatInput : Grid {
+public class ChatInput : Box {
+ [GtkChild] private ScrolledWindow scrolled;
[GtkChild] private TextView text_input;
private Conversation? conversation;
private StreamInteractor stream_interactor;
private HashMap<Conversation, string> entry_cache = new HashMap<Conversation, string>(Conversation.hash_func, Conversation.equals_func);
private static HashMap<string, string> smiley_translations = new HashMap<string, string>();
+ private int vscrollbar_min_height;
static construct {
smiley_translations[":)"] = "🙂";
@@ -34,6 +36,8 @@ public class ChatInput : Grid {
public ChatInput(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
+ scrolled.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null);
+ scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
}
public void initialize_for_conversation(Conversation conversation) {
@@ -93,6 +97,13 @@ public class ChatInput : Grid {
return false;
}
+ private void on_upper_notify() {
+ scrolled.vadjustment.value = scrolled.vadjustment.upper - scrolled.vadjustment.page_size;
+
+ // hack for vscrollbar not requiring space and making textview higher //TODO doesn't resize immediately
+ scrolled.get_vscrollbar().visible = (scrolled.vadjustment.upper > scrolled.max_content_height - 2 * vscrollbar_min_height);
+ }
+
private void check_convert_smiley() {
if (Dino.Settings.instance().convert_utf8_smileys) {
foreach (string smiley in smiley_translations.keys) {