本文整理汇总了Python中gi.repository.Gio.Menu方法的典型用法代码示例。如果您正苦于以下问题:Python Gio.Menu方法的具体用法?Python Gio.Menu怎么用?Python Gio.Menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gio
的用法示例。
在下文中一共展示了Gio.Menu方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def __init__(self):
Gtk.Application.__init__(self,
application_id="com.github.bilelmoussaoui.Authenticator",
flags=Gio.ApplicationFlags.FLAGS_NONE)
GLib.set_application_name(_("Authenticator"))
GLib.set_prgname("Authenticator")
self.alive = True
self._menu = Gio.Menu()
示例2: __generate_menu
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def __generate_menu(self):
"""Generate application menu."""
# Backup
backup_content = Gio.Menu.new()
import_menu = Gio.Menu.new()
export_menu = Gio.Menu.new()
import_menu.append_item(Gio.MenuItem.new(_("from a plain-text JSON file"), "app.import_json"))
import_menu.append_item(Gio.MenuItem.new(_("from an OpenPGP-encrypted JSON file"), "app.import_pgp_json"))
export_menu.append_item(Gio.MenuItem.new(_("in a plain-text JSON file"), "app.export_json"))
export_menu.append_item(Gio.MenuItem.new(_("in an OpenPGP-encrypted JSON file"), "app.export_pgp_json"))
backup_content.insert_submenu(0, _("Restore"), import_menu)
backup_content.insert_submenu(1, _("Backup"), export_menu)
backup_section = Gio.MenuItem.new_section(None, backup_content)
self._menu.append_item(backup_section)
# Main section
main_content = Gio.Menu.new()
# Night mode action
main_content.append_item(Gio.MenuItem.new(_("Settings"), "app.settings"))
main_content.append_item(Gio.MenuItem.new(_("About"), "app.about"))
main_content.append_item(Gio.MenuItem.new(_("Quit"), "app.quit"))
help_section = Gio.MenuItem.new_section(None, main_content)
self._menu.append_item(help_section)
示例3: __init__
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def __init__(self):
Gtk.Application.__init__(self,
application_id="com.github.bilelmoussaoui.AudioCutter",
flags=Gio.ApplicationFlags.FLAGS_NONE)
GLib.set_application_name(_("Audio Cutter"))
GLib.set_prgname("Audio Cutter")
self.app_menu = Gio.Menu()
self._setup_css()
Application.instance = self
示例4: _setup_app_menu
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def _setup_app_menu(self):
"""Create the appmenu."""
# Help section
help_content = Gio.Menu.new()
help_content.append_item(Gio.MenuItem.new(_("Night Mode"),
"app.night_mode"))
if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
help_content.append_item(Gio.MenuItem.new(_("Keyboard Shortcuts"),
"app.shortcuts"))
help_content.append_item(Gio.MenuItem.new(_("About Audio Cutter"), "app.about"))
help_section = Gio.MenuItem.new_section(None, help_content)
self.app_menu.append_item(help_section)
# Night Mode action
is_night_mode = Settings.get_default().is_night_mode
is_night_mode = GLib.Variant.new_boolean(is_night_mode)
action = Gio.SimpleAction.new_stateful("night_mode", None,
is_night_mode)
action.connect("change-state", self._on_night_mode)
self.add_action(action)
# Shortcuts action
if Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20:
action = Gio.SimpleAction.new("shortcuts", None)
action.connect("activate", self._on_shortcuts)
self.add_action(action)
# About action
action = Gio.SimpleAction.new("about", None)
action.connect("activate", self._on_about)
self.add_action(action)
# Quit action
action = Gio.SimpleAction.new("quit", None)
action.connect("activate", self._on_quit)
self.add_action(action)
示例5: do_activate
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def do_activate(self):
self.add_window(self.window)
self.window.set_wmclass('HydraPaper', 'HydraPaper')
# self.window.set_title('HydraPaper')
appMenu = Gio.Menu()
appMenu.append("About", "app.about")
appMenu.append("Settings", "app.settings")
appMenu.append("Quit", "app.quit")
about_action = Gio.SimpleAction.new("about", None)
about_action.connect("activate", self.on_about_activate)
self.builder.get_object("aboutdialog").connect(
"delete-event", lambda *_:
self.builder.get_object("aboutdialog").hide() or True
)
self.add_action(about_action)
settings_action = Gio.SimpleAction.new("settings", None)
settings_action.connect("activate", self.on_settings_activate)
self.builder.get_object("settingsWindow").connect(
"delete-event", lambda *_:
self.builder.get_object("settingsWindow").hide() or True
)
self.add_action(settings_action)
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.on_quit_activate)
self.add_action(quit_action)
self.set_app_menu(appMenu)
self.fill_monitors_flowbox()
self.fill_wallpapers_folders_popover_listbox()
self.window.show_all()
self.refresh_wallpapers_flowbox()
示例6: __init__
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def __init__(self, win):
super(HeaderBar, self).__init__()
self.win = win
self.set_show_close_button(True)
self.set_title('RunSQLRun')
self.set_subtitle('Database query tool')
self.pack_start(self._btn_from_command('app', 'neweditor'))
self.pack_start(self._btn_from_command('editor', 'run'))
# gears button
menu = Gio.Menu()
action = Gio.SimpleAction.new('manage_connections', None)
action.connect('activate', self.on_manage_connections)
self.win.app.add_action(action)
menu.append('Manage connections', 'app.manage_connections')
action = Gio.SimpleAction.new('about', None)
action.connect('activate', self.on_show_about)
self.win.app.add_action(action)
menu.append('About RunSQLRun', 'app.about')
btn = Gtk.MenuButton()
icon = Gio.ThemedIcon(name="preferences-system-symbolic")
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
btn.add(image)
btn.set_popover(Gtk.Popover.new_from_model(btn, menu))
self.pack_end(btn)
示例7: do_activate
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def do_activate(self):
window = self.builder.get_object('window')
self.add_window(window)
window.set_wmclass('razerCommander', 'razerCommander')
window.set_title('razerCommander')
appMenu = Gio.Menu()
appMenu.append("About", "app.about")
appMenu.append("Quit", "app.quit")
about_action = Gio.SimpleAction.new("about", None)
about_action.connect("activate", self.on_about_activate)
self.builder.get_object("aboutdialog").connect(
"delete-event", lambda *_:
self.builder.get_object("aboutdialog").hide() or True
)
self.add_action(about_action)
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.on_quit_activate)
self.add_action(quit_action)
self.set_app_menu(appMenu)
# initialization protocols
self.refreshDevices()
self.refreshProfiles()
self.keyboardBox.hide()
self.updateDevicesConnected()
# Quit if we only need initialization
if self.args.quit_after_init:
self.quit()
window.show_all()
self.updateDevicesConnected()
self.refreshFxList()
self.keyboardBox.hide()
示例8: on_stats_button_clicked
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def on_stats_button_clicked(self, _button):
self.stats_button.set_state_flags(Gtk.StateFlags.CHECKED, False)
menu = Gio.Menu()
stats = self.settings.props.settings_schema.get_key("stat-default").get_range()[1]
for i, stat in enumerate(stats):
menu_item = Gio.MenuItem.new(self.get_text_for_stat(i), None)
menu_item.set_action_and_target_value("app.stat_default", GLib.Variant.new_string(stat))
menu.append_item(menu_item)
self.popover = Gtk.Popover.new_from_model(self.stats_button, menu)
self.popover.connect('closed', self.on_popover_closed)
self.popover.popup()
示例9: activateCb
# 需要导入模块: from gi.repository import Gio [as 别名]
# 或者: from gi.repository.Gio import Menu [as 别名]
def activateCb(self, app):
window = builder.get_object("window1")
window.set_wmclass("mLauncher", "mLauncher")
app.add_window(window)
appMenu=Gio.Menu()
appMenu.append("About", "app.about")
appMenu.append("Quit", "app.quit")
about_action = Gio.SimpleAction.new("about", None)
about_action.connect("activate", self.on_about_activate)
app.add_action(about_action)
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.on_quit_activate)
app.add_action(quit_action)
app.set_app_menu(appMenu)
window.show_all()