def do_startup(self, **kw): Gtk.Application.do_startup(self, **kw) # Make tranlsating strings possible: # (We use the same message catalouge as rmlint) gettext.install('rmlint') rel_dir = os.path.dirname(__file__) resource_file = os.path.join(rel_dir, 'resources/shredder.gresource') LOGGER.info('Loading resources from: ' + resource_file) resource_bundle = Gio.Resource.load(resource_file) Gio.resources_register(resource_bundle) # Load the application CSS files. css_data = Gio.resources_lookup_data( '/org/gnome/shredder/shredder.css', 0) try: load_css_from_data(css_data.get_data()) except Exception as err: LOGGER.warning("Failed to load css data: " + str(err)) # Init the config system self.settings = Gio.Settings.new('org.gnome.Shredder') self.win = MainWindow(self) self.add_action( _create_action('settings', lambda *_: self.win.views.switch('settings'))) self.add_action( _create_action('about', lambda *_: AboutDialog(self.win).show_all())) self.add_action( _create_action('search', lambda *_: self.win.views.set_search_mode(True))) self.add_action( _create_action('activate', lambda *_: self.win.views.do_default_action())) self.add_action(_create_action('quit', lambda *_: self.quit())) self.set_accels_for_action('app.quit', ['<Ctrl>Q']) self.set_accels_for_action('app.search', ['<Ctrl>F']) self.set_accels_for_action('app.activate', ['<Ctrl>Return']) # Set the fallback window title. # This is only used if no .desktop file is provided. self.win.set_wmclass(APP_TITLE, APP_TITLE) # Load the application icon self.win.set_default_icon(_load_app_icon()) LOGGER.debug('Instancing views.') self.win.views.add_view(SettingsView(self), 'settings') self.win.views.add_view(LocationView(self), 'locations') self.win.views.add_view(RunnerView(self), 'runner') self.win.views.add_view(EditorView(self), 'editor') LOGGER.debug('Done instancing views.') initial_view = 'locations' if self.cmd_opts.tagged or self.cmd_opts.untagged: self.win.views['runner'].trigger_run(self.cmd_opts.untagged or [], self.cmd_opts.tagged or []) initial_view = 'runner' if self.cmd_opts.show_settings: initial_view = 'settings' for path in self.cmd_opts.locations or []: self.win.views['locations'].add_recent_item(path) if self.cmd_opts.script: self.win.views['editor'].override_script( Script(self.cmd_opts.script)) initial_view = 'editor' # Set the default view visible at startup self.win.views.switch(initial_view) self.win.show_all()
def on_replay_finish(self, _, runner): """Called once ``rmlint --replay`` finished running.""" LOGGER.info('Loading script from temporary directory') self.override_script(Script(runner.get_sh_path()))