Allow to copy messages
This commit is contained in:
parent
964de8706d
commit
7fbdd24b50
|
@ -11,6 +11,7 @@ namespace Dino.Ui.ConversationSummary {
|
|||
public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins.NotificationCollection {
|
||||
|
||||
public signal void on_quote_text(string text);
|
||||
public signal void on_copy_text(string text);
|
||||
public Conversation? conversation { get; private set; }
|
||||
|
||||
[GtkChild] public unowned ScrolledWindow scrolled;
|
||||
|
@ -330,6 +331,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
|||
|
||||
MessageMetaItem current_item = item as MessageMetaItem;
|
||||
current_item.on_quote_text.connect((t, text) => on_quote_text(text));
|
||||
current_item.on_copy_text.connect((t, text) => on_copy_text(text));
|
||||
}
|
||||
meta_items.add(item);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Dino.Ui.ConversationSummary {
|
|||
public class MessageMetaItem : ContentMetaItem {
|
||||
|
||||
public signal void on_quote_text(string text);
|
||||
public signal void on_copy_text(string text);
|
||||
private StreamInteractor stream_interactor;
|
||||
private MessageItemWidget message_item_widget;
|
||||
private MessageItem message_item;
|
||||
|
@ -56,6 +57,14 @@ public class MessageMetaItem : ContentMetaItem {
|
|||
};
|
||||
actions.add(action2);
|
||||
|
||||
Plugins.MessageAction copy_action = new Plugins.MessageAction();
|
||||
copy_action.icon_name = "edit-copy";
|
||||
copy_action.callback = (button, content_meta_item_activated, widget) => {
|
||||
string text = ((MessageItem) message_item_widget.content_item).message.body;
|
||||
on_copy_text(text);
|
||||
};
|
||||
actions.add(copy_action);
|
||||
|
||||
if (allowed && !in_edit_mode) {
|
||||
Plugins.MessageAction action1 = new Plugins.MessageAction();
|
||||
action1.icon_name = "document-edit-symbolic";
|
||||
|
|
|
@ -14,10 +14,12 @@ public class ConversationView : Gtk.Overlay {
|
|||
[GtkChild] public unowned ChatInput.View chat_input;
|
||||
[GtkChild] public unowned ConversationSummary.ConversationView conversation_frame;
|
||||
[GtkChild] public unowned Revealer white_revealer;
|
||||
public signal void copy_text(string text);
|
||||
|
||||
construct {
|
||||
white_revealer.notify["child-revealed"].connect_after(on_child_revealed_changed);
|
||||
conversation_frame.on_quote_text.connect((t, text) => on_quote_text(text));
|
||||
conversation_frame.on_copy_text.connect((t, text) => copy_text(text));
|
||||
}
|
||||
|
||||
public void on_quote_text(string text) {
|
||||
|
|
|
@ -78,6 +78,12 @@ public class MainWindow : Gtk.Window {
|
|||
search_entry = (SearchEntry) builder.get_object("search_entry");
|
||||
Image conversation_list_placeholder_image = (Image) builder.get_object("conversation_list_placeholder_image");
|
||||
conversation_list_placeholder_image.set_from_pixbuf(new Pixbuf.from_resource("/im/dino/Dino/icons/dino-conversation-list-placeholder-arrow.svg"));
|
||||
|
||||
conversation_view.copy_text.connect((text) => {
|
||||
var display = get_display();
|
||||
var clipboard = Gtk.Clipboard.get_default(display);
|
||||
clipboard.set_text(text, text.length);
|
||||
});
|
||||
}
|
||||
|
||||
private void update_headerbar() {
|
||||
|
|
Loading…
Reference in New Issue