00001 #!/usr/bin/env python 00002 # -*- coding: utf-8 -*- 00003 00004 # 00005 # This file contains several doxygen pages 00006 # 00007 00008 ## \mainpage Pyjama - Python Jamendo Audiocenter Documentation 00009 # 00010 # \section intro_sec Introduction 00011 # 00012 # On these pages you will find developer related information 00013 # about Pyjama. 00014 # I hope that these informations will help you develop new 00015 # plugins or join me developing Pyjama. 00016 # 00017 # To get started please have a look at the 'Namespace' or the 'Classes' 00018 # sections you can see on the top of the page. 00019 # 00020 # The most central classes will probably be clMain.main(), clWindow.winGTK() and 00021 # clLayouts.Layouts() since these classes handle most of pyjama's actions. 00022 # 00023 # In order to develop Plugins you probably want to have a look at Pyjama's 00024 # <a href = "Plugins.html"><b>plugin</b></a> and <a href = "Events.html"><b>event interface</b></a>. 00025 # 00026 # \section Basic Structure 00027 # Please have a look at the following page to get an idea what the Pyjama object hierarchy looks like \n 00028 # \ref structure 00029 00030 00031 ## \page structure Basic Structure 00032 # Here a brief structure of the program 00033 # 00034 # 00035 # \dot 00036 # digraph example { 00037 # node [shape=record, fontname=Helvetica, fontsize=10]; 00038 # pyjama [ label="pyjama.py" URL="namespacepyjama.html"]; 00039 # clWindow [ label="clWindow.gtkWIN" URL="namespaceclWindow.html"]; 00040 # clMain [ label="clMain.main()" URL=""]; 00041 # dumptools [ label="download_db.dump_tools()" URL=""]; 00042 # tray [ label="notification.TrayIcon()" URL=""]; 00043 # player [ label="clGstreamer010.Player()" URL=""]; 00044 # jamendo [ label="clJamendo.Jamendo()" URL=""]; 00045 # db [ label="clDB.DB()" URL=""]; 00046 # browser [ label="clBrowserInterface.Browser()" URL=""]; 00047 # layouts [ label="clLayouts.Layouts()" URL=""]; 00048 # plugin [ label="clPlugin.Plugins(()" URL=""]; 00049 # 00050 # pyjama -> clWindow [ arrowhead="open", style="line" ]; 00051 # clWindow -> clMain [ arrowhead="open", style="line" ]; 00052 # clMain -> dumptools [ arrowhead="open", style="line" ]; 00053 # clMain -> tray [ arrowhead="open", style="line" ]; 00054 # clMain -> player [ arrowhead="open", style="line" ]; 00055 # clMain -> jamendo [ arrowhead="open", style="line" ]; 00056 # clMain -> db [ arrowhead="open", style="line" ]; 00057 # clMain -> browser [ arrowhead="open", style="line" ]; 00058 # clMain -> layouts [ arrowhead="open", style="line" ]; 00059 # clMain -> plugin [ arrowhead="open", style="line" ]; 00060 00061 # } 00062 # \enddot 00063 # Note that the classes in the above graph are clickable 00064 # (in the HTML output). 00065 00066 00067 00068 00069 00070 ## \page Tracks Pyjama's Tracks 00071 # In any Pyjama version > 0.2.1 Pyjama uses a new track object. This was necessary 00072 # since the old track-dicts where very confusing and caused a lot of errors. 00073 # You can import the new track-object from clGstreamer010: 00074 # from clGstreamer010 import Track 00075 # 00076 # From now on only track objects can be added to the playlist. 00077 # 00078 # Here a list of fields every track object has to have: 00079 # - Track.name 00080 # - Name of this track 00081 # - Track.duration 00082 # - Duration of this track in seconds 00083 # - Track.numalbum 00084 # - Number of the track in the corresponding album 00085 # - Track.id 00086 # - ID of the track 00087 # - Track.id3genre 00088 # - space seperated list of id3genres for this track 00089 # - Track.album_id 00090 # - ID of the track's album 00091 # - Track.album_name 00092 # - name of the track's album 00093 # - Track.arist_id 00094 # - ID of the track's artist 00095 # - Track.artist_name 00096 # - name of the track's artist 00097 # - Track.stream 00098 # - jamendo stream url of this track 00099 # 00100 # There is a new attribute: Track.position_in_playlist is None by default and will be set to an int when the track is actually being played. In pyjama > 0.3 this attribute will be set when the track is being added to a playlist. 00101 # 00102 # The functions clDB.DB.get_multiple_trackinfos() and clDB.DB.get_trackinfos2() now also return Track objects. The new Track object behaves like a dict to calls like Track['name'] but prints out a deprecation warning. You should replace such calls. 00103 00104 ## \page Events Pyjama's Event interface 00105 # 00106 # Pyjama comes with an own simple event interface.\n 00107 # It basically holds four methods which make it quite easy to react on events or create own events:\n 00108 # - pyjama.Events.add_event(EVENT_NAME) 00109 # - Creates an event called EVENT_NAME 00110 # - pyjama.Events.connect_event(EVENT_NAME, CALLBACK_FUNCTION) 00111 # - Connects to the event EVENT_NAME and calles CALLBACK_FUNCTION whenever this event is raised 00112 # - pyjama.Events.raise_event(EVENT_NAME, *ARGS) 00113 # - Raises the event EVENT_NAME with the params *ARGS 00114 # - pyjama.Events.disconnect_event(EVENT_NAME, CALLBACK_FUNCTION) 00115 # - Disconnects CALLBACK_FUNCTION from the event EVENT_NAME 00116 # 00117 # Please notice that some events (e.g. 'pluginloaded') send some additional params to the callback 00118 # function. In order to prevent errors please check, if your callback function takes these params. 00119 # 00120 # Eventlist: 00121 # The following events might interest you: 00122 # - pluginloaded 00123 # - nowplaying 00124 # - alldone 00125 # - showing_album_page 00126 # - showing_artist_page 00127 # - firstrun 00128 # - error 00129 # - layout_changed 00130 # - populate_listmenu 00131 # - popular_playlistmenu 00132 # - scrolled_window_resized 00133 # - playlist_tooltip 00134 # 00135 # For more information have a look at the clEvent module. 00136 00137 00138 ## \page Plugins Pyjama's Plugin interface 00139 # 00140 # Pyjama has a quite simple plugin interface which - so I think - will enable you 00141 # to develop what ever you want as a plugin. For now I am the developer of most 00142 # of pyjama's plugins but I hope this will change soon. If you need another interface, 00143 # a new event or another way to interact with pyjama, please just write a mail and ask 00144 # for it! 00145 # 00146 # The following section was taken from the plugin's readme file: 00147 # <hr> 00148 # 00149 # <pre> 00150 # A short guide to plugins for pyjama 00151 #+-----------------------------------+ 00152 # 00153 # Pyjama uses a new plugin system since version 0.1.29. 00154 # This is a short guide how to do plugins for pyjama now. 00155 # 00156 # Requirements 00157 #+------------+ 00158 # 1) plugins have to be stored in pyjama's plugin folder 00159 # 2) every plugin has its own folder there 00160 # 3) each plugin needs a .info file in its folder 00161 # 4) each plugin needs a file called "__init__.py" in its folder 00162 # 00163 # .info file 00164 #+----------+ 00165 # 1) this file has to have the same name as its folder 00166 # 2) it holds: 00167 # - "name" to store the plugin's full name 00168 # - "version" to store the plugin's current version 00169 # - "order" to influence in which order the plugins are loaded 00170 # the higher this value is the later pyjama will load the plugin 00171 # - "author" to store the author's name 00172 # - "description" for a short description of the plugin 00173 # - "copyright" for a short copyright line 00174 # - "license" the license of the plugin. 00175 # - "homepage" 00176 # 00177 # A proper .info file might look like this: 00178 # 00179 # Name = Example Plugin 123 00180 # Order = 500 00181 # Version = 0.17 00182 # Author = Me 00183 # Description = Just testing 00184 # Copyright = By me 2009-FFFFFF 00185 # license = GPLv3 00186 # homepage = http://www.xn--ngel-5qa.de 00187 # 00188 # __init__.py 00189 #+-----------+ 00190 # * this file is needed to treat the while directory as a module 00191 # * it needs to have a class called "main" 00192 # * pyjama will pass a object holding all pyjama objects to this class 00193 # 00194 # Example 00195 #+-------+ 00196 # the directory scheme should be something like this: 00197 # 00198 # pyjama/ 00199 # plugins/ 00200 # my_plugin/ 00201 # __init__.py 00202 # my_plugin.info 00203 # anotherplugin/ 00204 # __init__.py 00205 # anotherplugin.info 00206 # 00207 #!! Please have a look at pyjama's example plugin - it is quite simple !! 00208 #</pre> 00209 # 00210 # <b> Preferences </b> 00211 # If you want to show preferences for your plugin, you should use pyjama's preferences dialog. 00212 # This can be done in three simple steps: 00213 # - you need ne function that creates a container (i.e. gtk.VBox), puts some widgets on it and returns the container 00214 # - you need a second function that will be called by pyjama after the user has closed the preferences dialog pressing "Ok" 00215 # - tell pyjama about your preferences and call: self.pyjama.preferences.register_plugin("NAME", first_function, second_function) 00216 # 00217 # As said before: Have a look at the example plugin! 00218 00219 00220 ## \page layouts Layouts 00221 # 00222 # Layouts are main user interface in pyjama: They are used to show the albums in pyjama's album-browser, the artist informations on artist-pages and your favorite albums in the starred-albums-plugin. 00223 # If this page confuses you more than it helps you, please have a look at the quite simple stared_albums-plugin. The folder 'clLayouts' contains even more example for the layout interface. 00224 # 00225 # 00226 # <b>Here some information how to create your own layout:</b> 00227 # 00228 # - create a new class called "MyLayout", derived from gtk.Layout 00229 # - create a subclass called "Toolbar" - derived from gtk.HBox 00230 # - MyLayout at least needs the following methode: 00231 # - draw(self, arg1, arg2, arg3, arg4) 00232 # 00233 # 00234 # <b>The draw methode:</b> 00235 # 00236 # The draw methode of your layout is called whenever your layout ist meant to be shown. Pyjama passes 4 params to this methode - use this params to generate the data you need for your layout (e.g. hits per page, page number, order etc). In this methode the information is placed on the layout and shown: For example an album-browser would query jamendo for some albums, download the covers and show them on the layout. 00237 # 00238 # 00239 # <b>Register a layout</b> 00240 # 00241 # Now we need to tell pyjama, that we've created a new layout. As you'll be most probably developing a plugin, just connect to the "alldone" event and call the following function: 00242 # pyjama.layouts.register_layout("my-layout", MyLayout(self.pyjama)) 00243 # - "my-layout" is just a identifier string for your layout. You'll need it, to show your layout 00244 # - MyLayout(self.pyjama) is the actual Layout class - in this example a reference to the pyjama-object is passed to it. At this point you do not need to generate any data or something - just init your layout, don't show or calculate anything. 00245 # 00246 # 00247 # <b>Showing the layout</b> 00248 # 00249 # Now, how do we show the layout? The best way is to create a menu or toolbar entry in the plugin's alldone-methode. Whenever this menu or toolbar entry is being clicked, call: 00250 # - pyjama.layouts.show_layout("my-layout", 10, 1, "listens", "rock") 00251 # 00252 # Pyjama will now call the draw methode of your MyLayout class with the params 10, 1, "listens" and "rock". This is how the params come to your draw() methode ;). 00253 # Please remember: You cannot pass more than 4 params to your draw() methode. Actually you cannot even pass less than 4 values: If you call show_layout("my-layout", 10, 1), pyjama will pass None als arg3 and arg4 to your draw() methode. 00254 # 00255 # 00256 # <b>Arranging the layout</b> 00257 # 00258 # If you want to be notified, when the size of your parent container changes, please connect to pyjama's "scrolled_window_resized" event.
1.5.8