Now About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/chat.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/chat.py')
-rw-r--r--src/chat.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/chat.py b/src/chat.py
index 5e52347..bb498c3 100644
--- a/src/chat.py
+++ b/src/chat.py
@@ -24,6 +24,7 @@ from gi.repository import GObject
from .message import WeegtkMessage
from .color import Color
from weegtk import config
+from weegtk import netfile
import json
@@ -153,3 +154,20 @@ class WeegtkChat(Adw.Bin):
entry_buffer.set_text("", 0)
self.emit("buffer_input", self.data['full_name'], text)
+ def open_file_dialog(self, dialog, result, caller):
+ try:
+ file = dialog.open_finish(result)
+ except GLib.GError:
+ # gtk-dialog-error-quark: Dismissed by user
+ pass
+ else:
+ conf = config.read()
+ file_url = netfile.upload(file.get_path(), conf["upload"]["url"])
+ entry_buffer = self.text_entry.get_buffer()
+ entry_buffer.insert_text(self.text_entry.get_position(), file_url, -1)
+
+ @Gtk.Template.Callback()
+ def attach_file(self, *args):
+ dialog = Gtk.FileDialog()
+ dialog.set_title("Select file to upload")
+ dialog.open(self.get_root(), None, self.open_file_dialog, self)