Thread: [Ap-python-commits] python/aptk control.py,1.4,1.5 info.py,1.5,1.6 misc.py,1.1,1.2 pan.py,1.3,1.4 pl
Status: Beta
Brought to you by:
sjah
From: <sj...@us...> - 2002-07-19 18:04:19
|
Update of /cvsroot/ap-python/python/aptk In directory usw-pr-cvs1:/tmp/cvs-serv24953 Modified Files: control.py info.py misc.py pan.py playlist.py speed.py Log Message: Rewrite all widget for new properties theme. (playlist widget is broken now). Index: control.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/control.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** control.py 6 Jul 2002 16:08:10 -0000 1.4 --- control.py 19 Jul 2002 18:04:13 -0000 1.5 *************** *** 32,107 **** # - - - - - - - - - - - - - - - Buttons - - - - - - - - - ! class _Button (aptk.misc.Button): ! """Internal.""" ! ! def __init__ (self, pl, **keys): ! aptk.misc.Button.__init__ (self, **keys) ! self.connect ("clicked", self._cb_clicked) ! self._pl = pl ! ! class PlayButton (_Button): """Start playback. - - This class takes playlist object as first argument. - Optional arguments are same as for - "misc.Button":misc_Button.py.html#__init__. - - Example:: - - button = PlayButton (alsaplayer.get_playlist(), label="Play") """ ! def _cb_clicked (self, w): gtk.threads_leave () ! self._pl.play (self._pl.get_current ()) gtk.threads_enter () ! class NextButton (_Button): """Move to next song. - - This class takes playlist object as first argument. - Optional arguments are same as for - "misc.Button":misc_Button.py.html#__init__. - - Example:: - - button = NextButton (alsaplayer.get_playlist(), label="Next") """ ! def _cb_clicked (self, w): gtk.threads_leave () ! self._pl.next () gtk.threads_enter () ! class PrevButton (_Button): """Move to previous song. - - This class takes playlist object as first argument. - Optional arguments are same as for - "misc.Button":misc_Button.py.html#__init__. - - Example:: - - button = PrevButton (alsaplayer.get_playlist(), label="Prev") """ ! ! def _cb_clicked (self, w): gtk.threads_leave () ! self._pl.prev () gtk.threads_enter () ! class StopButton (_Button): """Stop playback. ! This class takes playlist object as first argument. ! Optional arguments are same as for ! "misc.Button":misc_Button.py.html#__init__. ! ! Example:: ! button = StopButton (alsaplayer.get_playlist(), label="Stop") ! """ ! def _cb_clicked (self, w): gtk.threads_leave () self._pl.stop () --- 32,115 ---- # - - - - - - - - - - - - - - - Buttons - - - - - - - - - ! class PlayButton (aptk.misc.Button): """Start playback. """ + + def __init__ (self, pl, prop = None, strip = ""): + """Initializer.""" + + # Create strip string for this class + this_strip = (strip and strip + ".") + 'play' + + # Call base contructor + aptk.misc.Button.__init__ (self, prop, this_strip) + + self.connect ("clicked", self.__cb_clicked) + self.__pl = pl ! def __cb_clicked (self, w): gtk.threads_leave () ! self.__pl.play (self._pl.get_current ()) gtk.threads_enter () ! class NextButton (aptk.misc.Button): """Move to next song. """ ! def __init__ (self, pl, prop = None, strip = ""): ! """Initializer.""" ! ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'next' ! ! # Call base contructor ! aptk.misc.Button.__init__ (self, prop, this_strip) ! ! self.connect ("clicked", self.__cb_clicked) ! self.__pl = pl ! ! def __cb_clicked (self, w): gtk.threads_leave () ! self.__pl.next () gtk.threads_enter () ! class PrevButton (aptk.misc.Button): """Move to previous song. """ ! ! def __init__ (self, pl, prop = None, strip = ""): ! """Initializer.""" ! ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'prev' ! ! # Call base contructor ! aptk.misc.Button.__init__ (self, prop, this_strip) ! ! self.connect ("clicked", self.__cb_clicked) ! self.__pl = pl ! ! def __cb_clicked (self, w): gtk.threads_leave () ! self.__pl.prev () gtk.threads_enter () ! class StopButton (aptk.misc.Button): """Stop playback. + """ ! def __init__ (self, pl, prop = None, strip = ""): ! """Initializer.""" ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'stop' ! ! # Call base contructor ! aptk.misc.Button.__init__ (self, prop, this_strip) ! ! self.connect ("clicked", self.__cb_clicked) ! self.__pl = pl ! def __cb_clicked (self, w): gtk.threads_leave () self._pl.stop () *************** *** 112,130 **** """Internal.""" ! def __init__ (self, pl, prev_label=None, prev_xpmfile=None, ! play_label=None, play_xpmfile=None, ! stop_label=None, stop_xpmfile=None, ! next_label=None, next_xpmfile=None, **keys): ! self.prev_button = PrevButton (pl, label=prev_label, xpmfile=prev_xpmfile, **keys) self.add (self.prev_button) ! self.play_button = PlayButton (pl, label=play_label, xpmfile=play_xpmfile, **keys) self.add (self.play_button) ! self.stop_button = StopButton (pl, label=stop_label, xpmfile=stop_xpmfile, **keys) self.add (self.stop_button) ! self.next_button = NextButton (pl, label=next_label, xpmfile=next_xpmfile, **keys) self.add (self.next_button) --- 120,140 ---- """Internal.""" ! def __init__ (self, pl, prop = None, strip = ""): ! """Initializeer.""" ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'control' ! ! # Create buttons ! self.prev_button = PrevButton (pl, prop, this_strip) self.add (self.prev_button) ! self.play_button = PlayButton (pl, prop, this_strip) self.add (self.play_button) ! self.stop_button = StopButton (pl, prop, this_strip) self.add (self.stop_button) ! self.next_button = NextButton (pl, prop, this_strip) self.add (self.next_button) *************** *** 139,231 **** This widget provided to create typical control panel. - **Example**:: - - box = HBox (alsaplayer.get_playlist(), prev_label="Prev", - play_label="Play", - stop_label="Stop", - next_label="Next") """ ! def __init__ (self, pl, prev_label=None, prev_xpmfile=None, ! play_label=None, play_xpmfile=None, ! stop_label=None, stop_xpmfile=None, ! next_label=None, next_xpmfile=None, **keys): """Initialize the HBox. - - Parameters: - - 'prev_label' -- text label for button which sets previous song as current. - - 'prev_xpmfile' -- xpm file name for button which sets previous song as current. - - 'play_label' -- text label for button which starts playback. - - 'play_xpmfile' -- xpm file name for button which starts playback. - - 'stop_label' -- text label for button which stops playback. - - 'stop_xpmfile' -- xpm file name for button which stops playback. - - 'next_label' -- text label for button which sets next song as current. - - 'next_xpmfile' -- xpm file name for button which sets next song as current. - - '**keys' -- additional, optional values for - "misc.Button":misc_Button.py.html#__init__. """ gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, pl, prev_label=prev_label, prev_xpmfile=prev_xpmfile, ! play_label=play_label, play_xpmfile=play_xpmfile, ! stop_label=stop_label, stop_xpmfile=stop_xpmfile, ! next_label=next_label, next_xpmfile=next_xpmfile, ! **keys) class VBox (gtk.GtkVBox, _Box): """Vertical box of all control buttons. This widget provided to create typical control panel. - - **Example**:: - - box = VBox (alsaplayer.get_playlist(), prev_label="Prev", - play_label="Play", - stop_label="Stop", - next_label="Next") """ ! def __init__ (self, pl, prev_label=None, prev_xpmfile=None, ! play_label=None, play_xpmfile=None, ! stop_label=None, stop_xpmfile=None, ! next_label=None, next_xpmfile=None, **keys): """Initialize the VBox. - - Parameters:: - - 'prev_label' -- text label for button which sets previous song as current. - - 'prev_xpmfile' -- xpm file name for button which sets previous song as current. - - 'play_label' -- text label for button which starts playback. - - 'play_xpmfile' -- xpm file name for button which starts playback. - - 'stop_label' -- text label for button which stops playback. - - 'stop_xpmfile' -- xpm file name for button which stops playback. - - 'next_label' -- text label for button which sets next song as current. - - 'next_xpmfile' -- xpm file name for button which sets next song as current. - - '**keys' -- additional, optional values for - "misc.Button":misc_Button.py.html#__init__. """ gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, pl, prev_label=prev_label, prev_xpmfile=prev_xpmfile, ! play_label=play_label, play_xpmfile=play_xpmfile, ! stop_label=stop_label, stop_xpmfile=stop_xpmfile, ! next_label=next_label, next_xpmfile=next_xpmfile, ! **keys) --- 149,172 ---- This widget provided to create typical control panel. """ ! def __init__ (self, pl, prop = None, strip = ""): """Initialize the HBox. """ gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, pl, prop, strip) class VBox (gtk.GtkVBox, _Box): """Vertical box of all control buttons. This widget provided to create typical control panel. """ ! def __init__ (self, pl, prop = None, strip = ""): """Initialize the VBox. """ gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, pl, prop, relief = relief) Index: info.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/info.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** info.py 6 Jul 2002 16:08:10 -0000 1.5 --- info.py 19 Jul 2002 18:04:13 -0000 1.6 *************** *** 141,146 **** --- 141,151 ---- self.time_label.show () + ############################################################################# class TagsLabel (gtk.GtkLabel): + properties = { + "format" : "%a - %t (%y - %l)" + } + ch = { 't' : 'si.title', *************** *** 155,162 **** } ! def __init__ (self, cp, format): """Create instance label which will show tags info accordance with format string. - Format of the 'format' variable is similar to mp3info -p format. """ gtk.GtkLabel.__init__ (self, "") --- 160,172 ---- } ! def __init__ (self, cp, prop = None, strip = ""): """Create instance label which will show tags info accordance with format string. """ + + # Create strip string for this class + this_strip = (strip and strip + ".") + 'tagslabel' + + # Get properties + format = aptk.misc.get_property (self.properties, prop, 'format', this_strip) gtk.GtkLabel.__init__ (self, "") Index: misc.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/misc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** misc.py 11 May 2002 00:01:09 -0000 1.1 --- misc.py 19 Jul 2002 18:04:13 -0000 1.2 *************** *** 24,41 **** __license__ = "GNU" - import gtk class Button (gtk.GtkButton): ! def __init__ (self, label=None, xpmfile=None, window=None, relief=None): ! gtk.GtkButton.__init__ (self, label) ! if xpmfile: ! data = gtk.create_pixmap_from_xpm (window, None, xpmfile) ! pixmap = gtk.GtkPixmap (*data) ! pixmap.show () ! self.add (pixmap) ! if relief: self.set_relief (relief) --- 24,80 ---- __license__ = "GNU" import gtk + ###################################################################### + # Work with properties + + def get_property (default_prop, prop, key, strip = ""): + fullkey = (strip and strip + ".") + key + + if prop and prop.has_key (fullkey): return prop [fullkey] + else: return default_prop [key] + + ###################################################################### + # Button + class Button (gtk.GtkButton): ! properties = { ! "relief" : None, ! "label" : None, ! "xpmfile" : None ! } ! ! def __init__ (self, prop = None, strip = ""): ! """Create button.""" ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'button' ! # Get properties ! label = get_property (self.properties, prop, 'label', this_strip) ! xpmfile = get_property (self.properties, prop, 'xpmfile', this_strip) ! relief = get_property (self.properties, prop, 'relief', this_strip) ! # Remember this. We will load xpm file after a parent will be set ! self.__xpmfile = xpmfile ! self.__pixmap = None ! ! # Create button ! gtk.GtkButton.__init__ (self, label) ! ! if relief is not None: self.set_relief (relief) + + # Connect signals + self.connect ("parent_set", self.__gtkcb_parent_set) + + def __gtkcb_parent_set (self, w, old_parent): + """Calling by gtk if a parent is setted up.""" + + # We have no picture to add or a picture already added + if self.__pixmap or self.__xpmfile is None: return + + # Create Pixmap + self.__pixmap = gtk.GtkPixmap (self, self.__xpmfile) + self.add (self.__pixmap) + self.__pixmap.show () Index: pan.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/pan.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pan.py 6 Jul 2002 16:08:10 -0000 1.3 --- pan.py 19 Jul 2002 18:04:13 -0000 1.4 *************** *** 83,92 **** # - - - - - - - - - Button --------------------------------------------------- class Button (aptk.misc.Button): ! def __init__ (self, cp, value, **keys): ! aptk.misc.Button.__init__ (self, **keys) self.connect ("clicked", self.__cb_clicked) self.__value = value self.__cp = cp def __cb_clicked (self, w): gtk.threads_leave () --- 83,100 ---- # - - - - - - - - - Button --------------------------------------------------- class Button (aptk.misc.Button): ! def __init__ (self, cp, value, prop = None, strip = ""): ! """Intitializer.""" ! ! # Call base class initializer ! aptk.misc.Button.__init__ (self, prop, strip) ! ! # Connect signals self.connect ("clicked", self.__cb_clicked) + + # Remember self.__value = value self.__cp = cp + def __cb_clicked (self, w): gtk.threads_leave () *************** *** 96,109 **** # - - - - - - - - - - - - - - - Boxes - - - - - - - - - - class _Box: ! def __init__ (self, cp, left_label=None, left_xpmfile=None, ! center_label=None, center_xpmfile=None, ! right_label=None, right_xpmfile=None, **keys): ! self.left_button = Button (cp, -100, label=left_label, xpmfile=left_xpmfile, **keys) self.add (self.left_button) ! self.center_button = Button (cp, 0, label=center_label, xpmfile=center_xpmfile, **keys) self.add (self.center_button) ! self.right_button = Button (cp, 100, label=right_label, xpmfile=right_xpmfile, **keys) self.add (self.right_button) --- 104,121 ---- # - - - - - - - - - - - - - - - Boxes - - - - - - - - - - class _Box: ! def __init__ (self, cp, prop = None, strip = ""): ! """Inititalizer.""" ! ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'pan' ! ! # Create buttons ! self.left_button = Button (cp, -100, prop, this_strip + ".left") self.add (self.left_button) ! self.center_button = Button (cp, 0, prop, this_strip + ".center") self.add (self.center_button) ! self.right_button = Button (cp, 100, prop, this_strip + ".right") self.add (self.right_button) *************** *** 114,133 **** class HBox (gtk.GtkHBox, _Box): ! def __init__ (self, cp, **keys): gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, cp, **keys) class VBox (gtk.GtkVBox, _Box): ! def __init__ (self, cp, **keys): gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, cp, **keys) # - - - - - - - - - - - - - Final Widgets class HPan (gtk.GtkHBox): ! def __init__ (self, cp, **keys): gtk.GtkHBox.__init__ (self) ! box = HBox (cp, **keys) scale = HScale (cp) --- 126,145 ---- class HBox (gtk.GtkHBox, _Box): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, cp, prop, strip) class VBox (gtk.GtkVBox, _Box): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, cp, prop, strip) # - - - - - - - - - - - - - Final Widgets class HPan (gtk.GtkHBox): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkHBox.__init__ (self) ! box = HBox (cp, prop, strip) scale = HScale (cp) *************** *** 139,146 **** class VPan (gtk.GtkVBox): ! def __init__ (self, cp, **keys): gtk.GtkVBox.__init__ (self) ! box = VBox (cp, **keys) scale = VScale (cp) --- 151,158 ---- class VPan (gtk.GtkVBox): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkVBox.__init__ (self) ! box = VBox (cp, prop, strip) scale = VScale (cp) Index: playlist.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/playlist.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** playlist.py 19 Jul 2002 07:34:03 -0000 1.3 --- playlist.py 19 Jul 2002 18:04:13 -0000 1.4 *************** *** 119,144 **** ############################################################################### - default_properties = { - 'columns' : ['current', 'playtime', 'track', 'title', 'album', 'artist', 'year', 'genre'], - 'title for playtime' : 'Playtime', - 'title for track' : 'Track', - 'title for title' : 'Title', - 'title for current' : ' ', - 'title for album' : 'Album', - 'title for artist' : 'Artist', - 'title for year' : 'Year', - 'title for genre' : 'Genre', - 'mark for current' : '*' - } - class PlaylistWindow (gtk.GtkWindow): def __init__ (self, pl, prop): """Initializer.""" ! # Helper function def prop_value (key, prop=prop): if prop.has_key (key): return prop [key] else: return default_properties [key] ! # Remember self.pl = pl --- 119,145 ---- ############################################################################### class PlaylistWindow (gtk.GtkWindow): + properties = { + 'playlist.columns' : ['current', 'playtime', 'track', 'title', + 'album', 'artist', 'year', 'genre'], + 'playlist.title.playtime' : ("playtime.xpm",), + 'playlist.title.track' : ("track.xpm",), + 'playlist.title.title' : 'Title', + 'playlist.title.current' : ' ', + 'playlist.title.album' : 'Album', + 'playlist.title.artist' : 'Artist', + 'playlist.title.year' : 'Year', + 'playlist.title.genre' : 'Genre', + 'playlist.current.mark' : ("current_play.xpm",) + } + def __init__ (self, pl, prop): """Initializer.""" ! # Helper function. Get value from given properties or even from default def prop_value (key, prop=prop): if prop.has_key (key): return prop [key] else: return default_properties [key] ! # Remember self.pl = pl *************** *** 153,156 **** --- 154,158 ---- self.vbox.show () + # LIST - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - # Scrolled window for list self.scrolled = gtk.GtkScrolledWindow () *************** *** 175,181 **** self.list.column_titles_passive () ! # Create pixmap to mark the current song self.current_mark = prop_value ('mark for current') # Register new playlist interface pl.register (self) --- 177,186 ---- self.list.column_titles_passive () ! # Create mark for the current song self.current_mark = prop_value ('mark for current') + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- + + # - -- - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - # Register new playlist interface pl.register (self) Index: speed.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/speed.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** speed.py 6 Jul 2002 16:08:10 -0000 1.3 --- speed.py 19 Jul 2002 18:04:13 -0000 1.4 *************** *** 83,93 **** # - - - - - - - - - Button --------------------------------------------------- class Button (aptk.misc.Button): ! def __init__ (self, cp, value, **keys): ! aptk.misc.Button.__init__ (self, **keys) self.connect ("clicked", self.__cb_clicked) self.__value = value self.__cp = cp - def __cb_clicked (self, w): gtk.threads_leave () --- 83,99 ---- # - - - - - - - - - Button --------------------------------------------------- class Button (aptk.misc.Button): ! def __init__ (self, cp, value, prop = None, strip = ""): ! """Intitializer.""" ! ! # Call base class initializer ! aptk.misc.Button.__init__ (self, prop, strip) ! ! # Connect signals self.connect ("clicked", self.__cb_clicked) + + # Remember self.__value = value self.__cp = cp def __cb_clicked (self, w): gtk.threads_leave () *************** *** 97,111 **** # - - - - - - - - - - - - - - - Boxes - - - - - - - - - - class _Box: ! def __init__ (self, cp, pause_label=None, pause_xpmfile=None, ! backward_label=None, backward_xpmfile=None, ! forward_label=None, forward_xpmfile=None, **keys): ! ! self.backward_button = Button (cp, -1, label=backward_label, xpmfile=backward_xpmfile, **keys) self.add (self.backward_button) ! self.pause_button = Button (cp, 0, label=pause_label, xpmfile=pause_xpmfile, **keys) self.add (self.pause_button) ! self.forward_button = Button (cp, 1, label=forward_label, xpmfile=forward_xpmfile, **keys) self.add (self.forward_button) --- 103,120 ---- # - - - - - - - - - - - - - - - Boxes - - - - - - - - - - class _Box: ! def __init__ (self, cp, prop = None, strip = ""): ! """Inititalizer.""" ! ! # Create strip string for this class ! this_strip = (strip and strip + ".") + 'speed' ! ! # Create buttons ! self.backward_button = Button (cp, -1, prop, this_strip + ".backward") self.add (self.backward_button) ! self.pause_button = Button (cp, 0, prop, this_strip + ".pause") self.add (self.pause_button) ! self.forward_button = Button (cp, 1, prop, this_strip + ".forward") self.add (self.forward_button) *************** *** 116,135 **** class HBox (gtk.GtkHBox, _Box): ! def __init__ (self, cp, **keys): gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, cp, **keys) class VBox (gtk.GtkVBox, _Box): ! def __init__ (self, cp, **keys): gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, cp, **keys) # - - - - - - - - - - - - - Final Widgets - - - - - - - - - - - - - - - class HSpeed (gtk.GtkHBox): ! def __init__ (self, cp, **keys): gtk.GtkHBox.__init__ (self) ! box = HBox (cp, **keys) scale = HScale (cp) --- 125,144 ---- class HBox (gtk.GtkHBox, _Box): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkHBox.__init__ (self) ! _Box.__init__ (self, cp, prop, strip) class VBox (gtk.GtkVBox, _Box): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkVBox.__init__ (self) ! _Box.__init__ (self, cp, prop, strip) # - - - - - - - - - - - - - Final Widgets - - - - - - - - - - - - - - - class HSpeed (gtk.GtkHBox): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkHBox.__init__ (self) ! box = HBox (cp, prop, strip) scale = HScale (cp) *************** *** 141,148 **** class VSpeed (gtk.GtkVBox): ! def __init__ (self, cp, **keys): gtk.GtkVBox.__init__ (self) ! box = VBox (cp, **keys) scale = VScale (cp) --- 150,157 ---- class VSpeed (gtk.GtkVBox): ! def __init__ (self, cp, prop = None, strip = ""): gtk.GtkVBox.__init__ (self) ! box = VBox (cp, prop, strip) scale = VScale (cp) |