Add files via upload
This commit is contained in:
@@ -1383,17 +1383,23 @@ class ChatApp(Gtk.Application):
|
|||||||
|
|
||||||
self._open_files_dialog_modern(title=title, image_only=image_only, multiple=False, callback=_cb)
|
self._open_files_dialog_modern(title=title, image_only=image_only, multiple=False, callback=_cb)
|
||||||
|
|
||||||
|
|
||||||
def _open_files_dialog_native(self, title="Dosya Seç", image_only=False, multiple=True, callback=None):
|
def _open_files_dialog_native(self, title="Dosya Seç", image_only=False, multiple=True, callback=None):
|
||||||
callback = callback or (lambda paths: None)
|
callback = callback or (lambda paths: None)
|
||||||
|
|
||||||
|
dialog = Gtk.FileChooserDialog(
|
||||||
|
title=title,
|
||||||
|
transient_for=self.win,
|
||||||
|
modal=True,
|
||||||
action=Gtk.FileChooserAction.OPEN
|
action=Gtk.FileChooserAction.OPEN
|
||||||
chooser = Gtk.FileChooserNative.new(title, self.win, action, self("o_Open") if hasattr(self, "__call__") else "Open", self("o_Cancel") if hasattr(self, "__call__") else "Cancel")
|
)
|
||||||
chooser.set_modal(True)
|
|
||||||
chooser.set_select_multiple(bool(multiple))
|
dialog.add_button(self("o_Cancel"), Gtk.ResponseType.CANCEL)
|
||||||
|
dialog.add_button(self("o_Open"), Gtk.ResponseType.ACCEPT)
|
||||||
|
|
||||||
|
dialog.set_select_multiple(bool(multiple))
|
||||||
|
|
||||||
for f in self._build_file_filters(image_only=image_only):
|
for f in self._build_file_filters(image_only=image_only):
|
||||||
chooser.add_filter(f)
|
dialog.add_filter(f)
|
||||||
|
|
||||||
def on_response(dlg, response):
|
def on_response(dlg, response):
|
||||||
paths = []
|
paths = []
|
||||||
@@ -1416,15 +1422,14 @@ class ChatApp(Gtk.Application):
|
|||||||
p = gfile.get_path()
|
p = gfile.get_path()
|
||||||
if p:
|
if p:
|
||||||
paths.append(p)
|
paths.append(p)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
print("file chooser error:", e)
|
||||||
|
|
||||||
dlg.destroy()
|
dlg.destroy()
|
||||||
callback(paths)
|
callback(paths)
|
||||||
|
|
||||||
chooser.connect("response", on_response)
|
dialog.connect("response", on_response)
|
||||||
chooser.show()
|
dialog.present()
|
||||||
|
|
||||||
|
|
||||||
def _open_single_file_dialog_native(self, title="Dosya Seç", image_only=False, callback=None):
|
def _open_single_file_dialog_native(self, title="Dosya Seç", image_only=False, callback=None):
|
||||||
callback = callback or (lambda path: None)
|
callback = callback or (lambda path: None)
|
||||||
@@ -1432,8 +1437,12 @@ class ChatApp(Gtk.Application):
|
|||||||
def _cb(paths):
|
def _cb(paths):
|
||||||
callback(paths[0] if paths else None)
|
callback(paths[0] if paths else None)
|
||||||
|
|
||||||
self._open_files_dialog_native(title=title, image_only=image_only, multiple=False, callback=_cb)
|
self._open_files_dialog_native(
|
||||||
|
title=title,
|
||||||
|
image_only=image_only,
|
||||||
|
multiple=False,
|
||||||
|
callback=_cb
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user