Add files via upload

This commit is contained in:
FURK4NGG
2026-03-15 14:26:13 +03:00
committed by GitHub
parent d6674c1e92
commit 9d7bff4a48
+22 -13
View File
@@ -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)
action = Gtk.FileChooserAction.OPEN dialog = Gtk.FileChooserDialog(
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") title=title,
chooser.set_modal(True) transient_for=self.win,
chooser.set_select_multiple(bool(multiple)) modal=True,
action=Gtk.FileChooserAction.OPEN
)
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
)