47 lines
1.1 KiB
Python
Executable file
47 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# Copyright 2023 Johannes Findeisen <you@hanez.org>.
|
|
#
|
|
import gi
|
|
import sys
|
|
gi.require_version('Gtk', '3.0')
|
|
from gi.repository import Gtk
|
|
gi.require_version('AppIndicator3', '0.1')
|
|
from gi.repository import AppIndicator3
|
|
|
|
__VERSION__ = "0.0.2"
|
|
|
|
|
|
def menuitem_response(w, buf):
|
|
print(buf)
|
|
|
|
|
|
def exit_app():
|
|
sys.exit()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ind = AppIndicator3.Indicator.new("example-simple-client",
|
|
"indicator-messages",
|
|
AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
|
|
ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
|
|
ind.set_attention_icon("indicator-messages-new")
|
|
|
|
# create a menu
|
|
menu = Gtk.Menu()
|
|
|
|
# create some sub menus
|
|
for i in range(3):
|
|
buf = "Test-sub-menu - %d" % i
|
|
menu_items = Gtk.MenuItem(buf)
|
|
menu.append(menu_items)
|
|
|
|
# this is where you would connect your menu item up with a function:
|
|
menu_items.connect("activate", menuitem_response, buf)
|
|
|
|
# show the items
|
|
menu_items.show()
|
|
|
|
ind.set_menu(menu)
|
|
|
|
Gtk.main()
|