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

View file

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

View file

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

View file

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

View file

@ -21,12 +21,11 @@
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkLabel" id="name_label"> <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="expand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="visible">True</property> <property name="visible">True</property>
<style>
<class name="name"/>
</style>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>

View file

@ -8,14 +8,16 @@ using Xmpp;
namespace Dino.Ui { namespace Dino.Ui {
[GtkTemplate (ui = "/org/dino-im/chat_input.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; [GtkChild] private TextView text_input;
private Conversation? conversation; private Conversation? conversation;
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private HashMap<Conversation, string> entry_cache = new HashMap<Conversation, string>(Conversation.hash_func, Conversation.equals_func); 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 static HashMap<string, string> smiley_translations = new HashMap<string, string>();
private int vscrollbar_min_height;
static construct { static construct {
smiley_translations[":)"] = "🙂"; smiley_translations[":)"] = "🙂";
@ -34,6 +36,8 @@ public class ChatInput : Grid {
public ChatInput(StreamInteractor stream_interactor) { public ChatInput(StreamInteractor stream_interactor) {
this.stream_interactor = 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) { public void initialize_for_conversation(Conversation conversation) {
@ -93,6 +97,13 @@ public class ChatInput : Grid {
return false; 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() { private void check_convert_smiley() {
if (Dino.Settings.instance().convert_utf8_smileys) { if (Dino.Settings.instance().convert_utf8_smileys) {
foreach (string smiley in smiley_translations.keys) { foreach (string smiley in smiley_translations.keys) {

View file

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

View file

@ -35,7 +35,7 @@ public class MessageTextView : TextView {
} }
private void format_suffix_urls(string text) { 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`!()\[\]{};:'".,<>?«»]))"""); 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; 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, ""); list_store.set(iter, 0, build_markup_string("Key publishing disabled", "Select key"), 1, "");
for (int i = 0; i < keys.size; i++) { for (int i = 0; i < keys.size; i++) {
list_store.append(out iter); 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); list_store.set(iter, 1, keys[i].fpr);
if (keys[i].fpr == plugin.db.get_account_key(current_account)) { if (keys[i].fpr == plugin.db.get_account_key(current_account)) {
set_label_active(iter, i + 1); set_label_active(iter, i + 1);