2023-08-17 00:06:21 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import gi, sys, os
|
|
|
|
# import dbus
|
|
|
|
# import dbus.service, dbus.mainloop.glib
|
|
|
|
from pprint import pprint as print
|
|
|
|
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
|
|
|
|
from gi.repository import Gtk, Gdk, GLib, GdkPixbuf
|
|
|
|
|
|
|
|
from window import SonistWindow
|
2023-08-17 20:51:59 +08:00
|
|
|
|
2023-08-17 00:06:21 +08:00
|
|
|
# from mpd.asyncio import MPDClient
|
|
|
|
from mpd.base import MPDClient
|
|
|
|
|
|
|
|
app_id = 'fun.wkit.sonist'
|
|
|
|
|
|
|
|
|
|
|
|
class Application(Gtk.Application):
|
|
|
|
def __init__(self):
|
|
|
|
Gtk.Application.__init__(self, application_id = app_id)
|
|
|
|
|
2023-08-17 20:51:59 +08:00
|
|
|
self.add_window(SonistWindow())
|
2023-08-17 00:06:21 +08:00
|
|
|
|
|
|
|
self.mpc = MPDClient()
|
|
|
|
self.mpc.timeout = 10
|
|
|
|
self.mpc.connect("localhost", 6600)
|
|
|
|
|
|
|
|
|
|
|
|
def do_activate(self):
|
|
|
|
print('hello mpc')
|
2023-08-17 20:51:59 +08:00
|
|
|
self.set_app_menu(None)
|
|
|
|
self.set_menubar(None)
|
2023-08-17 00:06:21 +08:00
|
|
|
# self.window.show_all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" class ApplicationService(dbus.service.Object):
|
|
|
|
def __init__(self, app):
|
|
|
|
self.app = app
|
|
|
|
bus_name = dbus.service.BusName(app_id, bus = dbus.SessionBus())
|
|
|
|
dbus.service.Object.__init__(self, bus_name, '/')
|
|
|
|
|
|
|
|
|
|
|
|
@dbus.service.method(app_id)
|
|
|
|
def call_app(self):
|
|
|
|
self.app.present()
|
|
|
|
"""
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
|
|
|
|
# bus = dbus.SessionBus()
|
|
|
|
|
|
|
|
# try:
|
|
|
|
# obj = bus.get_object(app_id, '/')
|
|
|
|
# obj.call_app()
|
|
|
|
# sys.exit(0)
|
|
|
|
# except dbus.DBusException:
|
|
|
|
# pass
|
|
|
|
|
|
|
|
|
|
|
|
app = Application()
|
|
|
|
app.run(sys.argv)
|
|
|
|
|
|
|
|
# ApplicationService(app)
|
|
|
|
|
|
|
|
Gtk.main()
|