def generate_menu(self):
# Help section
help_content = Gio.Menu.new()
help_content.append_item(Gio.MenuItem.new(_("Night Mode"), "app.night_mode"))
help_content.append_item(Gio.MenuItem.new(_("About"), "app.about"))
help_content.append_item(Gio.MenuItem.new(_("Quit"), "app.quit"))
help_section = Gio.MenuItem.new_section(None, help_content)
self.menu.append_item(help_section)
action = Gio.SimpleAction.new_stateful("night_mode", None, GLib.Variant.new_boolean(settings.get_is_night_mode()))
action.connect("change-state", self.on_night_mode)
self.add_action(action)
action = Gio.SimpleAction.new("about", None)
action.connect("activate", self.on_about)
self.add_action(action)
action = Gio.SimpleAction.new("quit", None)
action.connect("activate", self.on_quit)
self.add_action(action)
if is_gnome() and not is_app_menu():
self.set_app_menu(self.menu)
logging.debug("Adding gnome shell menu")
评论列表
文章目录