aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_view_controller.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-06-04 14:03:34 +0200
committerfiaxh <git@lightrise.org>2020-06-04 14:07:51 +0200
commitcdc505f550242801ef53894f21e2dfa1a263be48 (patch)
tree6466cfe81d6ed4af85243dedbea85990803d29c3 /main/src/ui/conversation_view_controller.vala
parent8a64c8501d028ead3fe85a3378cc127db67392a7 (diff)
downloaddino-cdc505f550242801ef53894f21e2dfa1a263be48.tar.gz
dino-cdc505f550242801ef53894f21e2dfa1a263be48.zip
Add image sending via clipboard paste
fixes #385
Diffstat (limited to 'main/src/ui/conversation_view_controller.vala')
-rw-r--r--main/src/ui/conversation_view_controller.vala14
1 files changed, 14 insertions, 0 deletions
diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala
index 1745593f..d830fc9e 100644
--- a/main/src/ui/conversation_view_controller.vala
+++ b/main/src/ui/conversation_view_controller.vala
@@ -39,6 +39,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(() => open_file_picker());
+ chat_input_controller.clipboard_pasted.connect(on_clipboard_paste);
view.conversation_frame.init(stream_interactor);
@@ -165,6 +166,19 @@ public class ConversationViewController : Object {
}
}
+ private void on_clipboard_paste() {
+ Clipboard clipboard = Clipboard.get(Gdk.SELECTION_CLIPBOARD);
+ if (clipboard.wait_is_image_available()) {
+ clipboard.request_image((_, pixbuf) => {
+ File file = File.new_for_path(Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png"));
+ DataOutputStream fos = new DataOutputStream(file.create(FileCreateFlags.REPLACE_DESTINATION));
+ pixbuf.save_to_stream_async.begin(fos, "png", null, () => {
+ open_send_file_overlay(file);
+ });
+ });
+ }
+ }
+
private void on_drag_data_received(Widget widget, Gdk.DragContext context, int x, int y, SelectionData selection_data, uint target_type, uint time) {
if ((selection_data != null) && (selection_data.get_length() >= 0)) {
switch (target_type) {