simplified startup

This commit is contained in:
Martin Wagner 2022-03-15 00:06:37 +01:00
parent 08a6b223e3
commit e8d086e760

View File

@ -3779,17 +3779,23 @@ class mpdevil(Gtk.Application):
def __init__(self):
super().__init__(application_id="org.mpdevil.mpdevil", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.add_main_option("debug", ord("d"), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, _("Debug mode"), None)
def do_startup(self):
Gtk.Application.do_startup(self)
self._settings=Settings()
self._client=Client(self._settings)
Notify.init("mpdevil")
self._notify=Notify.Notification()
self._window=None
def do_activate(self):
if not self._window: # allow just one instance
self._window=MainWindow(self._client, self._settings, self._notify, application=self)
self._window.connect("delete-event", self._on_quit)
self._window.insert_action_group("mpd", MPDActionGroup(self._client))
# actions
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)
# accelerators
action_accels=(
("app.quit", ["<Control>q"]),("win.mini-player", ["<Control>m"]),("win.help", ["F1"]),("win.menu", ["F10"]),
@ -3807,16 +3813,9 @@ class mpdevil(Gtk.Application):
self.set_accels_for_action(action, accels)
# disable item activation on space key pressed in treeviews
Gtk.binding_entry_remove(Gtk.binding_set_find('GtkTreeView'), Gdk.keyval_from_name("space"), Gdk.ModifierType.MOD2_MASK)
self._window.present()
def do_startup(self):
Gtk.Application.do_startup(self)
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)
def do_activate(self):
self._window.present()
def do_shutdown(self):
Gtk.Application.do_shutdown(self)