diff options
author | fiaxh <git@lightrise.org> | 2019-09-09 19:47:11 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-09-09 19:47:11 +0200 |
commit | 9950742bf1903291c271619aea101b0e2f81d19c (patch) | |
tree | 49550030dd678a52adce9a0de81688cf95b4dfcb /main | |
parent | ecb3e783b9fde0fc6164a8058531b0be54eb7ef0 (diff) | |
download | dino-9950742bf1903291c271619aea101b0e2f81d19c.tar.gz dino-9950742bf1903291c271619aea101b0e2f81d19c.zip |
Add emoji button to chat input
Diffstat (limited to 'main')
-rw-r--r-- | main/CMakeLists.txt | 1 | ||||
-rw-r--r-- | main/data/icons/dino-emoticon-symbolic.svg | 4 | ||||
-rw-r--r-- | main/src/ui/chat_input/encryption_button.vala | 1 | ||||
-rw-r--r-- | main/src/ui/chat_input/view.vala | 15 | ||||
-rw-r--r-- | main/src/ui/conversation_summary/conversation_item_skeleton.vala | 1 | ||||
-rw-r--r-- | main/src/ui/unified_window.vala | 32 |
6 files changed, 38 insertions, 16 deletions
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 4cdea694..9abb2d6b 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -15,6 +15,7 @@ find_packages(MAIN_PACKAGES REQUIRED set(RESOURCE_LIST icons/dino-changes-prevent-symbolic.svg icons/dino-double-tick-symbolic.svg + icons/dino-emoticon-symbolic.svg icons/dino-qr-code-symbolic.svg icons/dino-party-popper-symbolic.svg icons/dino-status-away.svg diff --git a/main/data/icons/dino-emoticon-symbolic.svg b/main/data/icons/dino-emoticon-symbolic.svg new file mode 100644 index 00000000..5656303d --- /dev/null +++ b/main/data/icons/dino-emoticon-symbolic.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg version="1.1" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"> + <path d="m7 0c-3.866 0-7 3.134-7 7 0 3.866 3.134 7 7 7 3.866 0 7-3.0493 7-6.9153s-3.134-7.0847-7-7.0847zm-2 4c0.558 0 1.031 0.473 1.031 1.031v0.61307c0 0.558-0.473 1-1.031 1s-1-0.442-1-1v-0.61307c0-0.558 0.442-1.031 1-1.031zm4 0c0.558 0 1 0.473 1 1.031v0.63002c0 0.558-0.442 1-1 1s-1-0.442-1-1v-0.63002c0-0.558 0.442-1.031 1-1.031zm-6.5 4.1157c2 1.304 6.956 1.304 9 0-0.70196 2.8903-2.5245 3.853-4.499 3.8533-1.975 2.17e-4 -3.7981-1.1706-4.501-3.8533z" fill="#474747"/> +</svg> 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); } |