示例#1
0
    def setup(self):
        self.tempdir = tempfile.mkdtemp()
        from gui import application
        os.system('cp -a brushes ' + self.tempdir)

        app_statedirs = application.StateDirs(
            app_data=u'..',
            app_icons=u'../desktop',
            user_data=unicode(self.tempdir),
            user_config=unicode(self.tempdir),
        )
        self.app = application.Application(
            filenames=[],
            state_dirs=app_statedirs,
            version='guicontrol_testing',
        )

        # ignore mouse movements during testing (creating extra strokes)
        def motion_ignore_cb(*junk1, **junk2):
            pass

        self.app.doc.tdw.motion_notify_cb = motion_ignore_cb

        # fatal exceptions, please
        def excepthook(exctyp, value, tb):
            traceback.print_exception(exctyp, value, tb, None, sys.stderr)
            sys.exit(1)

        sys.excepthook = excepthook
示例#2
0
    def run():
        logger.debug('user_datapath: %r', userdatapath)
        logger.debug('user_confpath: %r', userconfpath)

        app_state_dirs = application.StateDirs(
            app_data=datapath,
            app_icons=iconspath,
            user_data=userdatapath,
            user_config=userconfpath,
        )
        app = application.Application(
            filenames=args,
            state_dirs=app_state_dirs,
            version=version,
            fullscreen=options.fullscreen,
        )

        settings = Gtk.Settings.get_default()
        dark = app.preferences.get("ui.dark_theme_variant", True)
        settings.set_property("gtk-application-prefer-dark-theme", dark)

        import gtkexcepthook
        func = app.filehandler.confirm_destructive_action
        gtkexcepthook.quit_confirmation_func = func

        # temporary workaround for gtk3 Ctrl-C bug:
        # https://bugzilla.gnome.org/show_bug.cgi?id=622084
        import signal
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        Gtk.main()
示例#3
0
    def run():
        logger.debug('user_datapath: %r', userdatapath)
        logger.debug('user_confpath: %r', userconfpath)

        # User-configured locale (if enabled by user)
        set_user_configured_locale(userconfpath)

        # Locale setting
        from lib.gettext_setup import init_gettext
        init_gettext(localepath)

        # mypaintlib import is performed first in gui.application now.
        from gui import application

        app_state_dirs = application.StateDirs(
            app_data=datapath,
            app_icons=iconspath,
            user_data=userdatapath,
            user_config=userconfpath,
        )
        app = application.Application(
            filenames=args,
            state_dirs=app_state_dirs,
            version=version,
            fullscreen=options.fullscreen,
        )

        # Gtk must not be imported before init_gettext
        # has been run - else locales will not be set
        # up properly (e.g: left-to-right interfaces for right-to-left scripts)
        # Note that this is not the first import of Gtk in the __program__;
        # it is imported indirectly via the import of gui.application
        from lib.gibindings import Gtk
        settings = Gtk.Settings.get_default()
        dark = app.preferences.get("ui.dark_theme_variant", True)
        settings.set_property("gtk-application-prefer-dark-theme", dark)

        if debug and options.run_and_quit:
            from lib.gibindings import GLib
            GLib.timeout_add(1000, lambda *a: Gtk.main_quit())
        else:
            from gui import gtkexcepthook
            func = app.filehandler.confirm_destructive_action
            gtkexcepthook.quit_confirmation_func = func

        # temporary workaround for gtk3 Ctrl-C bug:
        # https://bugzilla.gnome.org/show_bug.cgi?id=622084
        import signal
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        Gtk.main()