Added action to notification which I think works maybe?

This commit is contained in:
Sumner Evans
2019-09-29 14:50:38 -06:00
parent e03f6585d7
commit 5d9df23b7d

View File

@@ -109,13 +109,10 @@ class LibremsonicApp(Gtk.Application):
) )
def do_activate(self): def do_activate(self):
def show_window():
self.window.show_all()
self.window.present()
# We only allow a single window and raise any existing ones # We only allow a single window and raise any existing ones
if self.window: if self.window:
show_window() self.show_window()
return return
# Windows are associated with the application when the last one is # Windows are associated with the application when the last one is
@@ -145,7 +142,7 @@ class LibremsonicApp(Gtk.Application):
'value-changed', self.on_volume_change) 'value-changed', self.on_volume_change)
self.window.connect('key-press-event', self.on_window_key_press) self.window.connect('key-press-event', self.on_window_key_press)
show_window() self.show_window()
# Load the configuration and update the UI with the curent server, if # Load the configuration and update the UI with the curent server, if
# it exists. # it exists.
@@ -470,6 +467,10 @@ class LibremsonicApp(Gtk.Application):
return self.state.config.servers[self.state.config.current_server] return self.state.config.servers[self.state.config.current_server]
# ########## HELPER METHODS ########## # # ########## HELPER METHODS ########## #
def show_window(self):
self.window.show_all()
self.window.present()
def show_configure_servers_dialog(self): def show_configure_servers_dialog(self):
"""Show the Connect to Server dialog.""" """Show the Connect to Server dialog."""
dialog = ConfigureServersDialog(self.window, self.state.config) dialog = ConfigureServersDialog(self.window, self.state.config)
@@ -557,11 +558,22 @@ class LibremsonicApp(Gtk.Application):
# Show a song play notification. # Show a song play notification.
if self.state.config.song_play_notification: if self.state.config.song_play_notification:
# TODO someone needs to test this, Dunst doesn't seem to
# support it.
def on_notification_click(*args):
self.show_window()
try: try:
song_notification = Notify.Notification.new( song_notification = Notify.Notification.new(
song.title, song.title,
f'<i>{song.album}</i>\n{song.artist}', f'<i>{song.album}</i>\n{song.artist}',
) )
song_notification.add_action(
'clicked',
'Open LibremSonic',
on_notification_click,
)
song_notification.show() song_notification.show()
def on_cover_art_download_complete(cover_art_filename): def on_cover_art_download_complete(cover_art_filename):