Compare commits

..

No commits in common. "56b7476a425348b43bad4337162dbe3964b3926a" and "f55c4fc4a587576c54b2e380fff3e66177a5e895" have entirely different histories.

2 changed files with 74 additions and 98 deletions

View file

@ -6,14 +6,10 @@ ignore =
E114
# Indent for continuation lines is smaller than expected
E121
# Hanging indent on a continuation line is unaligned
E131
# Import not at the top of the file
E402
# Line too long
E501
# `except` without an exception type
E722
# Newline before a binary operator
W503
# Newline after a binary operator

View file

@ -8,7 +8,6 @@
import math
import gi
import sys
gi.require_version("Playerctl", "2.0")
@ -168,17 +167,6 @@ def iter_actions_for_player(player):
)
is_already_activated = False
def on_activate(application):
global is_already_activated
if is_already_activated:
# Ignore activations triggered by remote instances. See this:
# <https://stackoverflow.com/a/42044391/12005228>
return
is_already_activated = True
root_menu = Gtk.Menu()
player_names = Playerctl.list_players()
@ -217,6 +205,7 @@ def on_activate(application):
actions_menu = Gtk.Menu()
track_metadata = player.props.metadata
any_metadata_was_added = False
for meta_entry_text in iter_metadata_entries_for_player(player):
meta_menu_item = Gtk.MenuItem.new_with_label(meta_entry_text)
@ -248,7 +237,7 @@ def on_activate(application):
if action_fn is not None:
action_menu_item.connect(
"activate",
lambda _target, action_fn, action_fn_args: action_fn(*action_fn_args),
lambda _menu_item, action_fn, action_fn_args: action_fn(*action_fn_args),
action_fn,
action_fn_args,
)
@ -262,20 +251,11 @@ def on_activate(application):
menu_item.set_sensitive(False)
root_menu.append(menu_item)
root_menu.connect("selection-done", lambda _target: application.quit())
root_menu.connect("deactivate", lambda _target: application.quit())
root_menu.connect("destroy", lambda _target: application.quit())
root_menu.connect("selection-done", Gtk.main_quit)
root_menu.connect("deactivate", Gtk.main_quit)
root_menu.connect("destroy", Gtk.main_quit)
root_menu.show_all()
root_menu.popup(None, None, None, None, 0, Gdk.CURRENT_TIME)
Gdk.notify_startup_complete()
# `hold` needs to be done last, so that if an exception occurs during the
# initialization the application doesn't hang.
application.hold()
application = Gtk.Application(application_id="com.github.dmitmel.dotfiles.playerctl-simple-menu")
application.connect("activate", on_activate)
sys.exit(application.run(sys.argv))
Gtk.main()