diff --git a/DemonEditor.spec b/DemonEditor.spec index 79d20d8a..2dd62e51 100644 --- a/DemonEditor.spec +++ b/DemonEditor.spec @@ -11,7 +11,8 @@ block_cipher = None ui_files = [('app/ui/*.glade', 'ui'), ('app/ui/*.css', 'ui'), - ('app/ui/*.ui', 'ui') + ('app/ui/*.ui', 'ui'), + ('app/ui/lang*', 'share/locale') ] a = Analysis([EXE_NAME], diff --git a/app/ui/dialogs.py b/app/ui/dialogs.py index 97b54a0c..20a996e3 100644 --- a/app/ui/dialogs.py +++ b/app/ui/dialogs.py @@ -94,17 +94,21 @@ def get_chooser_dialog(transient, settings, pattern, name): def get_file_chooser_dialog(transient, text, settings, action_type, file_filter): - dialog = Gtk.FileChooserDialog(get_message(text) if text else "", transient, - action_type if action_type is not None else Gtk.FileChooserAction.SELECT_FOLDER, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK), - use_header_bar=IS_GNOME_SESSION) + dialog = Gtk.FileChooserNative() + dialog.set_title(get_message(text) if text else "") + dialog.set_transient_for(transient) + dialog.set_action(action_type if action_type is not None else Gtk.FileChooserAction.SELECT_FOLDER) + dialog.set_create_folders(False) + dialog.set_modal(True) + if file_filter is not None: dialog.add_filter(file_filter) path = settings.data_dir_path dialog.set_current_folder(path) response = dialog.run() - if response == Gtk.ResponseType.OK: + + if response == Gtk.ResponseType.ACCEPT: if dialog.get_filename(): path = dialog.get_filename() if action_type is not Gtk.FileChooserAction.OPEN: diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py index c735e819..97c57a33 100644 --- a/app/ui/uicommons.py +++ b/app/ui/uicommons.py @@ -1,4 +1,7 @@ +import gettext +import locale import os +import sys import gi from enum import Enum, IntEnum @@ -6,19 +9,22 @@ from enum import Enum, IntEnum gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk +GTK_PATH = os.environ.get("GTK_PATH", None) # For launching from the bundle. -if os.getcwd() == "/": - try: - os.chdir(os.environ["GTK_PATH"]) - except KeyError: - pass +if os.getcwd() == "/" and GTK_PATH: + os.chdir(GTK_PATH) - # path to *.glade files +# path to *.glade files UI_RESOURCES_PATH = "app/ui/" if os.path.exists("app/ui/") else "ui/" IS_GNOME_SESSION = int(bool(os.environ.get("GNOME_DESKTOP_SESSION_ID"))) # translation +os.environ["LANG"] = "{}.{}".format(*locale.getlocale()) TEXT_DOMAIN = "demon-editor" +LANG_PATH = GTK_PATH + "/share/locale" if GTK_PATH else UI_RESOURCES_PATH + "lang" +gettext.bindtextdomain(TEXT_DOMAIN, LANG_PATH) +if sys.platform != "darwin": + locale.bindtextdomain(TEXT_DOMAIN, LANG_PATH) theme = Gtk.IconTheme.get_default() _IMAGE_MISSING = theme.load_icon("image-missing", 16, 0) if theme.lookup_icon("image-missing", 16, 0) else None diff --git a/dist/DemonEditor.app.zip b/dist/DemonEditor.app.zip index 673d6726..d058d7df 100644 Binary files a/dist/DemonEditor.app.zip and b/dist/DemonEditor.app.zip differ