aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-06-03 21:41:24 +0200
committerfiaxh <git@lightrise.org>2020-06-03 21:50:40 +0200
commit8a64c8501d028ead3fe85a3378cc127db67392a7 (patch)
tree7674f2a428f03f7f0ff8548ccd2e9d0bacf5ff37
parent2f40726f556b5edf5d0302a293a528943b9a214b (diff)
downloaddino-8a64c8501d028ead3fe85a3378cc127db67392a7.tar.gz
dino-8a64c8501d028ead3fe85a3378cc127db67392a7.zip
Add shortcuts for search (CTRL+F) and file upload (CTRL+U)
fixes #806
-rw-r--r--main/data/chat_input.ui1
-rw-r--r--main/data/shortcuts.ui20
-rw-r--r--main/src/ui/conversation_view_controller.vala13
-rw-r--r--main/src/ui/main_window_controller.vala7
4 files changed, 39 insertions, 2 deletions
diff --git a/main/data/chat_input.ui b/main/data/chat_input.ui
index fb004fec..3ddb29b9 100644
--- a/main/data/chat_input.ui
+++ b/main/data/chat_input.ui
@@ -19,6 +19,7 @@
<property name="visible">True</property>
<child>
<object class="GtkButton" id="file_button">
+ <property name="tooltip-text" translatable="yes">Send a file</property>
<property name="can-focus">False</property>
<property name="margin-top">3</property>
<property name="relief">none</property>
diff --git a/main/data/shortcuts.ui b/main/data/shortcuts.ui
index 68c71237..0b0732a9 100644
--- a/main/data/shortcuts.ui
+++ b/main/data/shortcuts.ui
@@ -29,6 +29,26 @@
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
+ <property name="title" translatable="yes">Conversation</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="accelerator">&lt;ctrl&gt;F</property>
+ <property name="title" translatable="yes">Search messages</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">True</property>
+ <property name="accelerator">&lt;ctrl&gt;U</property>
+ <property name="title" translatable="yes">Send a file</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">True</property>
<property name="title" translatable="yes">Navigation</property>
<child>
<object class="GtkShortcutsShortcut">
diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala
index 8e17cc91..1745593f 100644
--- a/main/src/ui/conversation_view_controller.vala
+++ b/main/src/ui/conversation_view_controller.vala
@@ -38,7 +38,7 @@ public class ConversationViewController : Object {
this.chat_input_controller = new ChatInputController(view.chat_input, stream_interactor);
chat_input_controller.activate_last_message_correction.connect(() => view.conversation_frame.activate_last_message_correction());
- chat_input_controller.file_picker_selected.connect(() => on_file_picker_selected());
+ chat_input_controller.file_picker_selected.connect(() => open_file_picker());
view.conversation_frame.init(stream_interactor);
@@ -89,6 +89,15 @@ public class ConversationViewController : Object {
foreach(var entry in app.plugin_registry.conversation_titlebar_entries) {
titlebar.insert_entry(entry);
}
+
+ AccelGroup accel_group = new AccelGroup();
+ accel_group.connect(Gdk.Key.U, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE, () => {
+ if (conversation != null && stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation)) {
+ open_file_picker();
+ }
+ return false;
+ });
+ ((Gtk.Window)view.get_toplevel()).add_accel_group(accel_group);
}
public void select_conversation(Conversation? conversation, bool default_initialize_conversation) {
@@ -174,7 +183,7 @@ public class ConversationViewController : Object {
}
}
- private void on_file_picker_selected() {
+ private void open_file_picker() {
PreviewFileChooserNative chooser = new PreviewFileChooserNative(_("Select file"), view.get_toplevel() as Gtk.Window, FileChooserAction.OPEN, _("Select"), _("Cancel"));
if (chooser.run() == Gtk.ResponseType.ACCEPT) {
open_send_file_overlay(File.new_for_path(chooser.get_filename()));
diff --git a/main/src/ui/main_window_controller.vala b/main/src/ui/main_window_controller.vala
index 65f5aa1d..dceb4094 100644
--- a/main/src/ui/main_window_controller.vala
+++ b/main/src/ui/main_window_controller.vala
@@ -88,6 +88,13 @@ public class MainWindowController : Object {
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(() => update_stack_state());
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => update_stack_state());
update_stack_state();
+
+ AccelGroup accel_group = new AccelGroup();
+ accel_group.connect(Gdk.Key.F, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE, () => {
+ window.search_revealer.reveal_child = true;
+ return false;
+ });
+ window.add_accel_group(accel_group);
}
public void select_conversation(Conversation? conversation, bool do_reset_search = true, bool default_initialize_conversation = true) {