A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/themix-project/themix-gui/commit/8666920318aab85a98c90c8be25e40c3e285fbed below:

make plugin_loader and theme_model lazy load instead of loa… · themix-project/themix-gui@8666920 · GitHub

14 14

from .gtk_helpers import (

15 15

ImageButton, ImageMenuButton,

16 16

EntryDialog, YesNoDialog,

17 -

ActionsEnum,

17 +

ActionsEnum, warn_once,

18 18

)

19 19

from .theme_file import (

20 20

get_user_theme_path, is_user_colorscheme, is_colorscheme_exists,

25 25

from .colors_list import ThemeColorsList

26 26

from .preview import ThemePreview

27 27

from .terminal import generate_terminal_colors_for_oomox

28 -

from .plugin_loader import (

29 -

THEME_PLUGINS, ICONS_PLUGINS, IMPORT_PLUGINS, EXPORT_PLUGINS,

30 -

)

28 +

from .plugin_loader import PluginLoader

31 29

from .plugin_api import PLUGIN_PATH_PREFIX

32 30

from .settings import UI_SETTINGS

33 31

from .about import show_about

34 32 35 33 34 +

from typing import TYPE_CHECKING # pylint: disable=wrong-import-order

35 +

if TYPE_CHECKING:

36 +

# pylint: disable=ungrouped-imports

37 +

from typing import Optional # noqa

38 + 39 + 36 40

class NewDialog(EntryDialog):

37 41 38 42

def __init__(

@@ -324,14 +328,14 @@ def ask_colorscheme_exists(self, colorscheme_name):

324 328

def _select_theme_plugin(self):

325 329

theme_plugin_name = self.colorscheme['THEME_STYLE']

326 330

self.plugin_theme = None

327 -

for theme_plugin in THEME_PLUGINS.values():

331 +

for theme_plugin in PluginLoader.THEME_PLUGINS.values():

328 332

if theme_plugin.name == theme_plugin_name:

329 333

self.plugin_theme = theme_plugin

330 334 331 335

def _select_icons_plugin(self):

332 336

icons_plugin_name = self.colorscheme['ICONS_STYLE']

333 337

self.plugin_icons = None

334 -

for icons_plugin in ICONS_PLUGINS.values():

338 +

for icons_plugin in PluginLoader.ICONS_PLUGINS.values():

335 339

if icons_plugin.name == icons_plugin_name:

336 340

self.plugin_icons = icons_plugin

337 341

@@ -359,13 +363,10 @@ def _load_colorscheme_callback(self):

359 363

for theme_value in self.colorscheme.values():

360 364

if not isinstance(theme_value, Exception):

361 365

continue

362 -

error_dialog = Gtk.MessageDialog(

366 +

warn_once(

363 367

text=theme_value,

364 -

# secondary_text='',

365 368

buttons=Gtk.ButtonsType.CLOSE

366 369

)

367 -

error_dialog.run()

368 -

error_dialog.destroy()

369 370 370 371

@staticmethod

371 372

def schedule_task(task, *args):

@@ -438,7 +439,7 @@ def _on_import_themix_colors(self, _action, _param=None):

438 439

return self.import_themix_colors()

439 440 440 441

def _on_import_plugin(self, action, _param=None):

441 -

plugin = IMPORT_PLUGINS[

442 +

plugin = PluginLoader.IMPORT_PLUGINS[ # pylint: disable=unsubscriptable-object

442 443

action.props.name.replace('import_plugin_', '')

443 444

]

444 445

self.import_from_plugin(plugin)

@@ -475,7 +476,7 @@ def _on_export_icontheme(self, _action, _param=None):

475 476

)

476 477 477 478

def _on_export_plugin(self, action, _param=None):

478 -

plugin = EXPORT_PLUGINS[

479 +

plugin = PluginLoader.EXPORT_PLUGINS[ # pylint: disable=unsubscriptable-object

479 480

action.props.name.replace('export_plugin_', '')

480 481

]

481 482

plugin.export_dialog(

@@ -535,7 +536,7 @@ def _init_headerbar(self): # pylint: disable=too-many-locals,too-many-statement

535 536

WindowActions.import_themix_colors.get_id() # pylint:disable=no-member

536 537

))

537 538 538 -

for plugin_name, plugin in IMPORT_PLUGINS.items():

539 +

for plugin_name, plugin in PluginLoader.IMPORT_PLUGINS.items():

539 540

if plugin.import_text:

540 541

import_menu.append_item(Gio.MenuItem.new(

541 542

plugin.import_text or plugin.display_name,

@@ -631,8 +632,8 @@ def _init_headerbar(self): # pylint: disable=too-many-locals,too-many-statement

631 632

self.attach_action(export_icons_button, WindowActions.export_icons)

632 633 633 634

export_menu = Gio.Menu()

634 -

if EXPORT_PLUGINS:

635 -

for plugin_name, plugin in EXPORT_PLUGINS.items():

635 +

if PluginLoader.EXPORT_PLUGINS: # pylint: disable=using-constant-test

636 +

for plugin_name, plugin in PluginLoader.EXPORT_PLUGINS.items():

636 637

export_menu.append_item(Gio.MenuItem.new(

637 638

plugin.export_text or plugin.display_name,

638 639

f"win.export_plugin_{plugin_name}"

@@ -704,7 +705,7 @@ def _init_actions(self):

704 705

self.add_simple_action(

705 706

WindowActions.import_themix_colors, self._on_import_themix_colors

706 707

)

707 -

for plugin_name in IMPORT_PLUGINS:

708 +

for plugin_name in PluginLoader.IMPORT_PLUGINS: # pylint: disable=not-an-iterable

708 709

self.add_simple_action(

709 710

f"import_plugin_{plugin_name}", self._on_import_plugin

710 711

)

@@ -716,14 +717,27 @@ def _init_actions(self):

716 717

self.add_simple_action(WindowActions.export_icons, self._on_export_icontheme)

717 718

self.add_simple_action(WindowActions.show_help, self._on_show_help)

718 719

self.add_simple_action(WindowActions.show_about, self._on_show_about)

719 -

for plugin_name in EXPORT_PLUGINS:

720 +

for plugin_name in PluginLoader.EXPORT_PLUGINS: # pylint: disable=not-an-iterable

720 721

self.add_simple_action(

721 722

f"export_plugin_{plugin_name}", self._on_export_plugin

722 723

)

723 724 724 725

def _init_plugins(self):

725 -

for plugin in IMPORT_PLUGINS.values():

726 -

plugin.set_app(self)

726 +

pass

727 + 728 +

_window_instance: 'Optional[OomoxApplicationWindow]' = None

729 + 730 +

@classmethod

731 +

def set_instance(cls, window_instance):

732 +

if cls._window_instance:

733 +

raise RuntimeError('App window already set')

734 +

cls._window_instance = window_instance

735 + 736 +

@classmethod

737 +

def get_instance(cls):

738 +

if not cls._window_instance:

739 +

raise RuntimeError('App window not yet set')

740 +

return cls._window_instance

727 741 728 742

def __init__(self, application):

729 743

super().__init__(

@@ -732,6 +746,7 @@ def __init__(self, application):

732 746

startup_id=application.get_application_id(),

733 747

)

734 748

self.application = application

749 +

self.set_instance(self)

735 750

self.colorscheme = {}

736 751

mkdir_p(USER_COLORS_DIR)

737 752

@@ -815,8 +830,8 @@ def set_accels_for_action(action, accels, action_id=None):

815 830

set_accels_for_action(WindowActions.show_help, ["<Primary>question"])

816 831

_plugin_shortcuts = {}

817 832

for plugin_list, plugin_action_template in (

818 -

(IMPORT_PLUGINS, "import_plugin_{}"),

819 -

(EXPORT_PLUGINS, "export_plugin_{}"),

833 +

(PluginLoader.IMPORT_PLUGINS, "import_plugin_{}"),

834 +

(PluginLoader.EXPORT_PLUGINS, "export_plugin_{}"),

820 835

):

821 836

for plugin_name, plugin in plugin_list.items():

822 837

if not plugin.shortcut:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4