1+ # Import StreamController modules
2+ from src .backend .PluginManager .ActionBase import ActionBase
3+ from src .backend .DeckManagement .DeckController import DeckController
4+ from src .backend .PageManagement .Page import Page
5+ from src .backend .PluginManager .PluginBase import PluginBase
6+
7+ # Import python modules
8+ import os
9+ from loguru import logger as log
10+ from GtkHelper .GenerativeUI .EntryRow import EntryRow # For regular text input
11+ from GtkHelper .GenerativeUI .PasswordEntryRow import PasswordEntryRow # For secrets
12+
13+ # Import gtk modules - used for the config rows
14+ import gi
15+
16+ from ...utils .SpotifyController import SpotifyController
17+
18+ gi .require_version ("Gtk" , "4.0" )
19+ gi .require_version ("Adw" , "1" )
20+ from gi .repository import Gtk , Adw
21+
22+ class Repeat (ActionBase ):
23+ def __init__ (self , * args , ** kwargs ):
24+ super ().__init__ (* args , ** kwargs )
25+ self .repeat_context_icon = os .path .join (self .plugin_base .PATH , "assets" , "repeat.png" )
26+ self .repeat_one_icon = os .path .join (self .plugin_base .PATH , "assets" , "repeat_one.png" )
27+ self .no_repeat_icon = os .path .join (self .plugin_base .PATH , "assets" , "no_repeat.png" )
28+ self .repeat_states = ["off" , "track" , "context" ]
29+ self .icon_paths = [self .no_repeat_icon , self .repeat_one_icon , self .repeat_context_icon ]
30+
31+ @property
32+ def get_controller (self ) -> SpotifyController :
33+ return self .plugin_base .get_controller
34+
35+ def on_ready (self ) -> None :
36+ self .on_update ()
37+ self .get_controller .register_update_callback (self .on_update )
38+
39+ def on_key_down (self ) -> None :
40+ repeat = self .get_controller .get_repeat_state ()
41+ idx = max ((self .repeat_states .index (repeat )+ 1 )% 3 ,0 )
42+ next_state = self .repeat_states [idx ]
43+ next_state_icon = self .repeat_context_icon [idx ]
44+ self .get_controller .set_repeat (next_state )
45+ self .set_media (media_path = next_state_icon , size = 0.75 )
46+
47+ def on_update (self , state = None ):
48+ repeat_state = self .get_controller .get_repeat_state (state )
49+ icon = self .icon_paths [self .repeat_states .index (repeat_state )]
50+ self .set_media (media_path = icon , size = 0.75 )
51+
52+ def on_key_up (self ) -> None :
53+ pass
0 commit comments