diff options
author | fiaxh <git@mx.ax.lt> | 2018-04-24 14:59:28 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-04-30 11:03:59 +0200 |
commit | c1533f25775d3d9db5395107d6f3fd695b041926 (patch) | |
tree | 340a3da2c48cb9809a00b734c35c8172e9b89b6c /main/src/ui/conversation_titlebar | |
parent | f0dd0e0c3af10f2772efd94aadbded38f3c155bb (diff) | |
download | dino-c1533f25775d3d9db5395107d6f3fd695b041926.tar.gz dino-c1533f25775d3d9db5395107d6f3fd695b041926.zip |
Redesign chat input + move file upload there
Diffstat (limited to 'main/src/ui/conversation_titlebar')
-rw-r--r-- | main/src/ui/conversation_titlebar/file_entry.vala | 71 | ||||
-rw-r--r-- | main/src/ui/conversation_titlebar/view.vala | 1 |
2 files changed, 0 insertions, 72 deletions
diff --git a/main/src/ui/conversation_titlebar/file_entry.vala b/main/src/ui/conversation_titlebar/file_entry.vala deleted file mode 100644 index fb6ac3a0..00000000 --- a/main/src/ui/conversation_titlebar/file_entry.vala +++ /dev/null @@ -1,71 +0,0 @@ -using Gtk; - -using Dino.Entities; - -namespace Dino.Ui { - -public class FileEntry : Plugins.ConversationTitlebarEntry, Object { - public string id { get { return "send_files"; } } - - StreamInteractor stream_interactor; - - public FileEntry(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - } - - public double order { get { return 4; } } - public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) { - if (type == Plugins.WidgetType.GTK) { - return new FileWidget(stream_interactor) { visible=true }; - } - return null; - } -} - -public class FileWidget : Button, Plugins.ConversationTitlebarWidget { - - private const int PREVIEW_SIZE = 180; - private const int PREVIEW_PADDING = 3; - - private Conversation? conversation; - private StreamInteractor stream_interactor; - - public FileWidget(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - image = new Image.from_icon_name("mail-attachment-symbolic", IconSize.MENU); - clicked.connect(on_clicked); - stream_interactor.get_module(FileManager.IDENTITY).upload_available.connect(on_upload_available); - } - - public void on_clicked() { - PreviewFileChooserNative chooser = new PreviewFileChooserNative("Select file", get_toplevel() as Window, FileChooserAction.OPEN, "Select", "Cancel"); - -// long max_file_size = stream_interactor.get_module(Manager.IDENTITY).get_max_file_size(conversation.account); -// if (max_file_size != -1) { -// FileFilter filter = new FileFilter(); -// filter.add_custom(FileFilterFlags.URI, (filter_info) => { -// File file = File.new_for_uri(filter_info.uri); -// FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE); -// return file_info.get_size() <= max_file_size; -// }); -// chooser.set_filter(filter); -// } - if (chooser.run() == Gtk.ResponseType.ACCEPT) { - string uri = chooser.get_filename(); - stream_interactor.get_module(FileManager.IDENTITY).send_file(uri, conversation); - } - } - - public void on_upload_available(Account account) { - if (conversation != null && conversation.account.equals(account)) { - visible = true; - } - } - - public new void set_conversation(Conversation conversation) { - this.conversation = conversation; - visible = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation); - } -} - -} diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index baa036a8..d01cd9bb 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -23,7 +23,6 @@ public class ConversationTitlebar : Gtk.HeaderBar { Application app = GLib.Application.get_default() as Application; app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor)); app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor, window)); - app.plugin_registry.register_contact_titlebar_entry(new FileEntry(stream_interactor)); foreach(var e in app.plugin_registry.conversation_titlebar_entries) { Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK); |