From a714e4100c409feb02c454874d030d192bfb0ae5 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 19 Jun 2024 20:45:23 +0000 Subject: [PATCH] playerctl: add settings to control which elements are displayed the defaults are to keep existing behavior, and display all fields. new boolean options are added for: - show-previous shows "<<" icon to rewind the player - show-play-pause shows "||" or "|>" icon to play/pause the player - show-next shows ">>" icon to advance the player - show-name shows the media name (e.g. the artist + title) and the number of players these are especially useful for narrow screens, like mobile phones, where a user may wish to disable all but "show-play-pause" in order to fit size limitations of the panel. --- nwg_panel/modules/playerctl.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/nwg_panel/modules/playerctl.py b/nwg_panel/modules/playerctl.py index ff48d4c..a9a454c 100644 --- a/nwg_panel/modules/playerctl.py +++ b/nwg_panel/modules/playerctl.py @@ -30,6 +30,10 @@ def __init__(self, settings, voc, icons_path=""): check_key(settings, "chars", 30) check_key(settings, "scroll", True) check_key(settings, "show-cover", True) + check_key(settings, "show-previous", True) + check_key(settings, "show-play-pause", True) + check_key(settings, "show-next", True) + check_key(settings, "show-name", True) check_key(settings, "cover-size", 24) check_key(settings, "angle", 0.0) check_key(settings, "button-css-name", "") @@ -218,7 +222,8 @@ def build_box(self): if self.settings["button-css-name"]: btn.set_property("name", self.settings["button-css-name"]) btn.connect("clicked", self.launch, self.PlayerOps.PREVIOUS) - button_box.pack_start(btn, False, False, 1) + if self.settings["show-previous"]: + button_box.pack_start(btn, False, False, 1) self.play_pause_btn = Gtk.Button() if self.settings["button-css-name"]: @@ -227,7 +232,8 @@ def build_box(self): update_image(img, "media-playback-start-symbolic", self.settings["icon-size"], icons_path=self.icons_path) self.play_pause_btn.set_image(img) self.play_pause_btn.connect("clicked", self.launch, self.PlayerOps.PLAY_PAUSE) - button_box.pack_start(self.play_pause_btn, False, False, 1) + if self.settings["show-play-pause"]: + button_box.pack_start(self.play_pause_btn, False, False, 1) img = Gtk.Image() update_image(img, "media-skip-forward-symbolic", self.settings["icon-size"], icons_path=self.icons_path) @@ -236,7 +242,8 @@ def build_box(self): if self.settings["button-css-name"]: btn.set_property("name", self.settings["button-css-name"]) btn.connect("clicked", self.launch, self.PlayerOps.NEXT) - button_box.pack_start(btn, False, False, 1) + if self.settings["show-next"]: + button_box.pack_start(btn, False, False, 1) self.num_players_lbl = Gtk.Label.new("") if self.settings["label-css-name"]: @@ -257,13 +264,15 @@ def build_box(self): self.box.pack_start(button_box, False, False, 2) if self.settings["show-cover"]: self.box.pack_start(self.cover_img, False, False, 0) - self.box.pack_start(self.num_players_lbl, False, False, 0) - self.box.pack_start(self.label, False, False, 5) + if self.settings["show-name"]: + self.box.pack_start(self.num_players_lbl, False, False, 0) + self.box.pack_start(self.label, False, False, 5) else: if self.settings["show-cover"]: self.box.pack_start(self.cover_img, False, False, 2) - self.box.pack_start(self.num_players_lbl, False, False, 0) - self.box.pack_start(self.label, False, False, 2) + if self.settings["show-name"]: + self.box.pack_start(self.num_players_lbl, False, False, 0) + self.box.pack_start(self.label, False, False, 2) self.box.pack_start(button_box, False, False, 10) def launch(self, button, op):