aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-09-09 19:47:11 +0200
committerfiaxh <git@lightrise.org>2019-09-09 19:47:11 +0200
commit9950742bf1903291c271619aea101b0e2f81d19c (patch)
tree49550030dd678a52adce9a0de81688cf95b4dfcb /main/src/ui
parentecb3e783b9fde0fc6164a8058531b0be54eb7ef0 (diff)
downloaddino-9950742bf1903291c271619aea101b0e2f81d19c.tar.gz
dino-9950742bf1903291c271619aea101b0e2f81d19c.zip
Add emoji button to chat input
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/chat_input/encryption_button.vala1
-rw-r--r--main/src/ui/chat_input/view.vala15
-rw-r--r--main/src/ui/conversation_summary/conversation_item_skeleton.vala1
-rw-r--r--main/src/ui/unified_window.vala32
4 files changed, 33 insertions, 16 deletions
diff --git a/main/src/ui/chat_input/encryption_button.vala b/main/src/ui/chat_input/encryption_button.vala
index d80fa18f..3544c252 100644
--- a/main/src/ui/chat_input/encryption_button.vala
+++ b/main/src/ui/chat_input/encryption_button.vala
@@ -18,7 +18,6 @@ public class EncryptionButton : MenuButton {
public EncryptionButton(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- relief = ReliefStyle.NONE;
use_popover = true;
image = new Image.from_icon_name("changes-allow-symbolic", IconSize.BUTTON);
get_style_context().add_class("flat");
diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala
index c40152a2..b1f37e90 100644
--- a/main/src/ui/chat_input/view.vala
+++ b/main/src/ui/chat_input/view.vala
@@ -42,7 +42,7 @@ public class View : Box {
occupants_tab_completor = new OccupantsTabCompletor(stream_interactor, text_input);
smiley_converter = new SmileyConverter(text_input);
edit_history = new EditHistory(text_input, GLib.Application.get_default());
- encryption_widget = new EncryptionButton(stream_interactor) { margin_top=3, valign=Align.START, visible=true };
+ encryption_widget = new EncryptionButton(stream_interactor) { relief=ReliefStyle.NONE, margin_top=3, valign=Align.START, visible=true };
file_button.clicked.connect(() => {
PreviewFileChooserNative chooser = new PreviewFileChooserNative("Select file", get_toplevel() as Gtk.Window, FileChooserAction.OPEN, "Select", "Cancel");
@@ -57,6 +57,19 @@ public class View : Box {
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
encryption_widget.get_style_context().add_class("dino-chatinput-button");
+
+ MenuButton emoji_button = new MenuButton() { relief=ReliefStyle.NONE, margin_top=3, valign=Align.START, visible=true };
+ emoji_button.get_style_context().add_class("flat");
+ emoji_button.get_style_context().add_class("dino-chatinput-button");
+ emoji_button.image = new Image.from_icon_name("dino-emoticon-symbolic", IconSize.BUTTON) { visible=true };
+
+ EmojiChooser chooser = new EmojiChooser();
+ chooser.emoji_picked.connect((emoji) => {
+ text_input.buffer.insert_at_cursor(emoji, emoji.data.length);
+ });
+ emoji_button.set_popover(chooser);
+
+ outer_box.add(emoji_button);
outer_box.add(encryption_widget);
text_input.key_press_event.connect(on_text_input_key_press);
diff --git a/main/src/ui/conversation_summary/conversation_item_skeleton.vala b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
index ad12dd85..06af7529 100644
--- a/main/src/ui/conversation_summary/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
@@ -89,6 +89,7 @@ public class ConversationItemSkeleton : EventBox {
default_header.visible = this.show_skeleton;
}
image_content_box.margin_start = this.show_skeleton ? 15 : 58;
+ image_content_box.margin_end = 15;
if (this.show_skeleton && this.last_group_item) {
image_content_box.margin_top = 8;
diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala
index e48d4667..fb973a58 100644
--- a/main/src/ui/unified_window.vala
+++ b/main/src/ui/unified_window.vala
@@ -71,21 +71,9 @@ public class UnifiedWindow : Gtk.Window {
paned = (Paned) builder.get_object("paned");
box.add(paned);
chat_input = ((ChatInput.View) builder.get_object("chat_input")).init(stream_interactor);
+ chat_input.key_press_event.connect(forward_key_press_to_chat_input);
conversation_frame = ((ConversationSummary.ConversationView) builder.get_object("conversation_frame")).init(stream_interactor);
- conversation_frame.key_press_event.connect((event) => {
- // Don't forward / change focus on Control / Alt
- if (event.keyval == Gdk.Key.Control_L || event.keyval == Gdk.Key.Control_R ||
- event.keyval == Gdk.Key.Alt_L || event.keyval == Gdk.Key.Alt_R) {
- return false;
- }
- // Don't forward / change focus on Control + ...
- if ((event.state & ModifierType.CONTROL_MASK) > 0) {
- return false;
- }
- chat_input.text_input.key_press_event(event);
- chat_input.text_input.grab_focus();
- return true;
- });
+ conversation_frame.key_press_event.connect(forward_key_press_to_chat_input);
conversation_selector = ((ConversationSelector) builder.get_object("conversation_list")).init(stream_interactor);
goto_end_revealer = (Revealer) builder.get_object("goto_end_revealer");
goto_end_button = (Button) builder.get_object("goto_end_button");
@@ -124,6 +112,7 @@ public class UnifiedWindow : Gtk.Window {
box.add(headerbar_paned);
}
+ headerbar_paned.key_press_event.connect(forward_key_press_to_chat_input);
}
private void setup_stack() {
@@ -158,6 +147,21 @@ public class UnifiedWindow : Gtk.Window {
}
}
+ private bool forward_key_press_to_chat_input(EventKey event) {
+ // Don't forward / change focus on Control / Alt
+ if (event.keyval == Gdk.Key.Control_L || event.keyval == Gdk.Key.Control_R ||
+ event.keyval == Gdk.Key.Alt_L || event.keyval == Gdk.Key.Alt_R) {
+ return false;
+ }
+ // Don't forward / change focus on Control + ...
+ if ((event.state & ModifierType.CONTROL_MASK) > 0) {
+ return false;
+ }
+ chat_input.text_input.key_press_event(event);
+ chat_input.text_input.grab_focus();
+ return true;
+ }
+
public void loop_conversations(bool backwards) {
conversation_selector.loop_conversations(backwards);
}