35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2026 Storm Dragon
|
|
# Authors: Storm Dragon, Angus Kola
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""A GTK 4 popover menu, whose items expose their label only through a relation."""
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
from gi.repository import Gio, GLib, Gtk
|
|
|
|
|
|
def activate(app):
|
|
window = Gtk.ApplicationWindow(application=app, title="GTK 4 menu label probe")
|
|
for name in ("compose", "add-account", "grouping"):
|
|
action = (Gio.SimpleAction.new_stateful(name, None, GLib.Variant.new_boolean(True))
|
|
if name == "grouping" else Gio.SimpleAction.new(name, None))
|
|
window.add_action(action)
|
|
app.set_accels_for_action("win.compose", ["<Control>n"])
|
|
window.add_action(Gio.SimpleAction.new_stateful("filter", GLib.VariantType.new("s"),
|
|
GLib.Variant.new_string("all")))
|
|
menu = Gio.Menu()
|
|
menu.append("_New Message", "win.compose")
|
|
menu.append("_Add Account…", "win.add-account")
|
|
menu.append("Group into _Conversations", "win.grouping")
|
|
menu.append("_All Messages", "win.filter::all")
|
|
button = Gtk.MenuButton(label="File", menu_model=menu)
|
|
window.set_child(button)
|
|
window.present()
|
|
GLib.timeout_add(300, lambda: (button.popup(), False)[1])
|
|
|
|
|
|
app = Gtk.Application(application_id="org.stormux.CthulhuGtk4MenuProbe")
|
|
app.connect("activate", activate)
|
|
app.run(None)
|