def do_activate(self): self.connection_manager = ConnectionManager(self) self.config = config.load() self.config.connect('notify::ui-dark-theme', self.on_use_dark_theme) self.on_use_dark_theme() self.action_groups = {} accel_group = Gtk.AccelGroup() commands = self.config.get_commands() for group_key in commands: group = Gio.SimpleActionGroup() self.action_groups[group_key] = group data = commands[group_key] for action_key in data['actions']: action_data = data['actions'][action_key] action = Gio.SimpleAction.new( '{}_{}'.format(group_key, action_key), None) callback = partial(self._generic_callback, group_key, action_data['callback'], action_data.get('args', ())) action.connect('activate', callback) group.insert(action) key, mod = Gtk.accelerator_parse(action_data['shortcut']) accel_group.connect(key, mod, Gtk.AccelFlags.VISIBLE, callback) self.add_action(action) if self.win is None: self.win = MainWindow(self) statefile = os.path.join( xdg.BaseDirectory.save_config_path('runsqlrun'), 'state') if os.path.isfile(statefile): with open(statefile) as f: state = json.load(f) self.win.restore_state(state) self.win.add_accel_group(accel_group) self.win.present()