def activateMenu(self): """ Connect main menu options to callbacks """ action = SimpleAction.new('import_xml', None) action.connect('activate', self.callbacks.onImportXMLMenuOptionSelected) self.add_action(action) action = SimpleAction.new('export_xml', None) action.connect('activate', self.callbacks.onExportXMLMenuOptionSelected) self.add_action(action)
def do_startup(self): GtkApplication.do_startup(self) action = SimpleAction.new("new-window", None) action.connect("activate", self.on_new_window) self.add_action(action) action = SimpleAction.new("shortcuts", None) action.connect("activate", self.on_shortcuts) self.add_action(action) action = SimpleAction.new("about", None) action.connect("activate", self.on_about) self.add_action(action) action = SimpleAction.new("traceback", VariantType.new('s')) action.connect("activate", self.on_traceback) self.add_action(action) action = SimpleAction.new("quit", None) action.connect("activate", self.on_quit) self.add_action(action) self.set_app_menu(AppMenu())
def do_startup(self): """ Perform startup operations. Called once, on application startup. """ Application.do_startup(self) # Connect the close button to a callback action = SimpleAction.new('quit', None) action.connect('activate', self.on_quit) self.add_action(action) # Install main menu builder = Builder() builder.add_from_string(MENU) self.set_app_menu(builder.get_object('app-menu')) # Get a (single) view and model. # Because this function is executed only once, # multiple models or views cannot exist. self.view = View(application=self, title=APP_TITLE) self.model = Model() # Pass view all the callbacks, to assign each one to the appropriate GUI object. self.view.setCallbacks( self.Callbacks(self.model, self.view, self.XML(self.model, self.view))) # Initialize the GUI self.view.initGUI() # Connect each view component with its corresponding model. # This is clearly a controller's responsibility. self.view.zones.set_model(self.model.zones) self.view.playlists.set_model(self.model.playlists) for dayIndex in range(7): self.view.schedule[dayIndex].set_model( self.model.schedule[dayIndex]) # Set app title and logo in gnome's top bar self.view.set_wmclass('Flow Dashboard', 'Flow Dashboard') self.view.set_icon_from_file('src/resources/logo.png') # Make the GUI visible self.view.show_all() # Zone Inspector is set initially invisible, until a zone is selected self.view.zoneInspector.hide()
def __init__(self, editor, renderer, preferences): super(EditorActionGroup, self).__init__() self.editor = editor self.renderer = renderer self.preferences = preferences self.editor_pref = preferences.editor self.create_stateful_action("period-save-toggle", 'b', self.editor_pref.period_save, self.on_period_save) self.create_stateful_action("check-spelling-toggle", 'b', self.editor_pref.check_spelling, self.on_check_spelling) action = SimpleAction.new("spell-lang", VariantType('s')) action.connect("activate", self.on_spell_lang) self.add_action(action) self.create_stateful_action("use-spaces-toggle", 'b', self.editor_pref.spaces_instead_of_tabs, self.on_use_spaces) self.create_stateful_action("tab-width", 'i', self.editor_pref.tab_width, self.on_tab_width) self.create_stateful_action("auto-indent-toggle", 'b', self.editor_pref.auto_indent, self.on_auto_indent) self.create_stateful_action("line-numbers-toggle", 'b', self.editor_pref.line_numbers, self.on_line_numbers) self.create_stateful_action("right-margin-toggle", 'b', self.editor_pref.right_margin, self.on_right_margin) self.create_stateful_action("current-line-toggle", 'b', self.editor_pref.current_line, self.on_current_line) self.create_stateful_action("text-wrapping-toggle", 'b', self.editor_pref.text_wrapping, self.on_text_wrapping) self.create_stateful_action("white-chars-toggle", 'b', self.editor_pref.white_chars, self.on_white_chars)
def do_startup(self): Application.do_startup(self) #TODO: Parse args #if "open-entity" in args: # Set app menu action = SimpleAction.new("preferences", None) action.connect("activate", self.on_preferences) #self.set_accels_for_action("app.preferences", ["<Control>,"]) self.add_action(action) action = SimpleAction.new("shortcuts", None) action.connect("activate", self.on_shortcuts) self.set_accels_for_action("app.shortcuts", ["<Control>F1"]) self.add_action(action) # Set app menu action = SimpleAction.new("help", None) action.connect("activate", self.on_help) self.set_accels_for_action("app.help", ["F1"]) self.add_action(action) action = SimpleAction.new("about", None) action.connect("activate", self.on_about) self.add_action(action) action = SimpleAction.new("quit", None) action.connect("activate", self.on_quit) self.set_accels_for_action("app.quit", ["<Control>q"]) self.add_action(action) # Set entity menu action = SimpleAction.new("entity_close", None) action.connect("activate", self.on_entity_close) self.set_accels_for_action("app.entity_close", ["<Control>w"]) self.add_action(action)
def create_stateful_action(self, name, _type, default_value, method): action = SimpleAction.new_stateful(name, VariantType.new(_type), Variant(_type, default_value)) action.connect("change-state", method) self.add_action(action)
def item_clicked(self, b: Gio.SimpleAction, e): self.listener(b.get_name())