Fix ChatInput for many lines + small UI changes

This commit is contained in:
fiaxh 2017-03-15 22:01:32 +01:00
parent f277db6cb4
commit af49a47cf6
9 changed files with 25 additions and 16 deletions

View file

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="DinoUiChatInput" parent="GtkGrid"> <!-- TODO -->
<requires lib="gtk+" version="3.22"/>
<template class="DinoUiChatInput">
<property name="hexpand">True</property>
<property name="orientation">horizontal</property>
<property name="visible">True</property>
<property name="margin">5</property>
<property name="column-spacing">5</property>
<property name="visible">True</property>
<child>
<object class="GtkFrame">
<object class="GtkScrolledWindow" id="scrolled">
<property name="max_content_height">300</property>
<property name="propagate_natural_height">True</property>
<child>
<object class="GtkTextView" id="text_input">
<property name="border-width">5</property>
<property name="wrap-mode">GTK_WRAP_WORD_CHAR</property>
<property name="border-width">5</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visible">True</property>

View file

@ -2,9 +2,6 @@
<interface>
<template class="DinoUiConversationSelectorConversationRow">
<property name="visible">True</property>
<style>
<class name="no_padding"/>
</style>
<child>
<object class="GtkRevealer" id="main_revealer">
<property name="transition-type">slide-down</property>

View file

@ -2,7 +2,6 @@
<interface>
<template class="DinoUiConversationSelectorView">
<property name="can_focus">True</property>
<property name="width_request">40</property>
<property name="expand">True</property>
<property name="orientation">vertical</property>
<property name="visible">True</property>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.22"/>
<template class="DinoUiOccupantList">
<property name="visible">True</property>
<child>

View file

@ -21,12 +21,11 @@
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="name_label">
<property name="max_width_chars">1</property>
<property name="ellipsize">end</property>
<property name="expand">True</property>
<property name="xalign">0</property>
<property name="visible">True</property>
<style>
<class name="name"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>

View file

@ -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) {

View file

@ -7,7 +7,7 @@ using Dino.Entities;
namespace Dino.Ui.ConversationSelector {
[GtkTemplate (ui = "/org/dino-im/conversation_selector/view.ui")]
public class View : Grid {
public class View : Box {
public List conversation_list;
[GtkChild] public SearchEntry search_entry;

View file

@ -35,7 +35,7 @@ public class MessageTextView : TextView {
}
private void format_suffix_urls(string text) {
int absolute_start = buffer.text.length - text.length;
int absolute_start = buffer.text.char_count() - text.char_count();
Regex url_regex = new Regex("""(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»]))""");
MatchInfo match_info;

View file

@ -80,7 +80,7 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget {
list_store.set(iter, 0, build_markup_string("Key publishing disabled", "Select key"), 1, "");
for (int i = 0; i < keys.size; i++) {
list_store.append(out iter);
list_store.set(iter, 0, build_markup_string(keys[i].uids[0].uid, keys[i].fpr[0:16]));
list_store.set(iter, 0, build_markup_string(keys[i].uids[0].uid, "0x" + keys[i].fpr[0:16]));
list_store.set(iter, 1, keys[i].fpr);
if (keys[i].fpr == plugin.db.get_account_key(current_account)) {
set_label_active(iter, i + 1);