PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/decibel-audio-player-1.08/src/tools/consts.py

#
Python | 223 lines | 126 code | 49 blank | 48 comment | 4 complexity | c3909f22abba844a382c8f58278ca5e3 MD5 | raw file
Possible License(s): GPL-2.0
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Author: Ingelrest Fran??ois (Francois.Ingelrest@gmail.com)
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Library General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. import gtk, os.path, random, time
  19. from gettext import gettext as _
  20. # --- Not a constant, but it fits well here
  21. random.seed(int(time.time()))
  22. # --- Miscellaneous
  23. socketTimeout = 10
  24. # --- Strings
  25. appName = 'Decibel Audio Player'
  26. appVersion = '1.08'
  27. appNameShort = 'decibel-audio-player'
  28. # --- URLs
  29. urlMain = 'http://decibel.silent-blade.org'
  30. urlHelp = 'http://decibel.silent-blade.org/index.php?n=Main.Help'
  31. # --- Directories
  32. dirBaseUsr = os.path.expanduser('~')
  33. dirBaseCfg = os.path.join(dirBaseUsr, '.config')
  34. dirBaseSrc = os.path.join(os.path.dirname(__file__), '..')
  35. dirRes = os.path.join(dirBaseSrc, '..', 'res')
  36. dirDoc = os.path.join(dirBaseSrc, '..', 'doc')
  37. dirPix = os.path.join(dirBaseSrc, '..', 'pix')
  38. dirCfg = os.path.join(dirBaseCfg, appNameShort)
  39. dirLog = os.path.join(dirCfg, 'Logs')
  40. dirLocale = os.path.join(dirBaseSrc, '..', 'locale')
  41. if not os.path.isdir(dirLocale) :
  42. dirLocale = os.path.join(dirBaseSrc, '..', '..', 'locale')
  43. # Make sure the config directory exists
  44. if not os.path.exists(dirBaseCfg):
  45. os.mkdir(dirBaseCfg)
  46. if not os.path.exists(dirCfg):
  47. os.mkdir(dirCfg)
  48. # Make sure the log directory exists
  49. if not os.path.exists(dirLog): os.mkdir(dirLog)
  50. # --- Icons
  51. fileImgIcon16 = os.path.join(dirPix, 'decibel-audio-player-16.png')
  52. fileImgIcon24 = os.path.join(dirPix, 'decibel-audio-player-24.png')
  53. fileImgIcon32 = os.path.join(dirPix, 'decibel-audio-player-32.png')
  54. fileImgIcon48 = os.path.join(dirPix, 'decibel-audio-player-48.png')
  55. fileImgIcon64 = os.path.join(dirPix, 'decibel-audio-player-64.png')
  56. fileImgIcon128 = os.path.join(dirPix, 'decibel-audio-player-128.png')
  57. fileImgStar16 = os.path.join(dirPix, 'star-16.png')
  58. fileImgCatAll = os.path.join(dirPix, 'category-all.png')
  59. fileImgCatDesktop = os.path.join(dirPix, 'category-desktop.png')
  60. fileImgCatDecibel = os.path.join(dirPix, 'category-decibel.png')
  61. fileImgCatExplorer = os.path.join(dirPix, 'category-explorer.png')
  62. fileImgCatInternet = os.path.join(dirPix, 'category-internet.png')
  63. # --- Files
  64. fileLog = os.path.join(dirLog, 'log')
  65. filePrefs = os.path.join(dirCfg, 'prefs.txt')
  66. fileLicense = os.path.join(dirDoc, 'LICENCE')
  67. # --- DBus constants
  68. dbusService = 'org.mpris.dap'
  69. dbusInterface = 'org.freedesktop.MediaPlayer'
  70. # --- Tracks
  71. UNKNOWN_DATE = 0
  72. UNKNOWN_GENRE = _('Unknown Genre')
  73. UNKNOWN_TITLE = _('Unknown Title')
  74. UNKNOWN_ALBUM = _('Unknown Album')
  75. UNKNOWN_ARTIST = _('Unknown Artist')
  76. UNKNOWN_LENGTH = 0
  77. UNKNOWN_BITRATE = 0
  78. UNKNOWN_ENC_MODE = 0
  79. UNKNOWN_MB_TRACKID = 0
  80. UNKNOWN_DISC_NUMBER = 0
  81. UNKNOWN_SAMPLE_RATE = 0
  82. UNKNOWN_TRACK_NUMBER = 0
  83. UNKNOWN_ALBUM_ARTIST = _('Unknown Album Artist')
  84. # --- Drag'n'Drop
  85. (
  86. DND_URI, # From another application (e.g., from Nautilus)
  87. DND_DAP_URI, # Inside DAP when tags are not known (e.g., from the FileExplorer)
  88. DND_DAP_TRACKS # Inside DAP when tags are already known (e.g., from the Library)
  89. ) = range(3)
  90. DND_TARGETS = {
  91. DND_URI: ('text/uri-list', 0, DND_URI),
  92. DND_DAP_URI: ('dap/uri-list', gtk.TARGET_SAME_APP, DND_DAP_URI),
  93. DND_DAP_TRACKS: ('dap/tracks-list', gtk.TARGET_SAME_APP, DND_DAP_TRACKS)
  94. }
  95. # --- View modes
  96. # --- Don't change the order!
  97. (
  98. VIEW_MODE_FULL,
  99. VIEW_MODE_LEAN,
  100. VIEW_MODE_MINI,
  101. VIEW_MODE_PLAYLIST,
  102. VIEW_MODE_NETBOOK,
  103. ) = range(5)
  104. # -- Categories a module can belong to
  105. (
  106. MODCAT_NONE,
  107. MODCAT_DECIBEL,
  108. MODCAT_DESKTOP,
  109. MODCAT_INTERNET,
  110. MODCAT_EXPLORER,
  111. ) = range(5)
  112. # --- Message that can be sent/received by modules
  113. # --- A message is always associated with a (potentially empty) dictionnary containing its parameters
  114. (
  115. # --== COMMANDS ==--
  116. # GStreamer player
  117. MSG_CMD_PLAY, # Play a resource Parameters: 'uri', 'forced'
  118. MSG_CMD_STOP, # Stop playing Parameters:
  119. MSG_CMD_SEEK, # Jump to a position Parameters: 'seconds'
  120. MSG_CMD_STEP, # Step back or forth Parameters: 'seconds'
  121. MSG_CMD_SET_VOLUME, # Change the volume Parameters: 'value'
  122. MSG_CMD_BUFFER, # Buffer a file Parameters: 'filename'
  123. MSG_CMD_TOGGLE_PAUSE, # Toggle play/pause Parameters:
  124. MSG_CMD_ENABLE_EQZ, # Enable the equalizer Parameters:
  125. MSG_CMD_SET_EQZ_LVLS, # Set the levels of the 10-bands equalizer Parameters: 'lvls'
  126. MSG_CMD_ENABLE_RG, # Enable ReplayGain Parameters:
  127. MSG_CMD_SET_CD_SPEED, # Change drive speed when reading a CD Parameters: 'speed'
  128. # Tracklist
  129. MSG_CMD_NEXT, # Play the next track Parameters:
  130. MSG_CMD_PREVIOUS, # Play the previous track Parameters:
  131. MSG_CMD_TRACKLIST_SET, # Replace tracklist Parameters: 'tracks', 'playNow'
  132. MSG_CMD_TRACKLIST_ADD, # Extend tracklist Parameters: 'tracks', 'playNow'
  133. MSG_CMD_TRACKLIST_DEL, # Remove a track Parameters: 'idx'
  134. MSG_CMD_TRACKLIST_CLR, # Clear tracklist Parameters:
  135. MSG_CMD_TRACKLIST_PLAY, # Play the given track Parameters: 'idx', 'seconds'
  136. MSG_CMD_TRACKLIST_REPEAT, # Set/Unset the repeat function Parameters: 'repeat'
  137. MSG_CMD_TRACKLIST_SHUFFLE, # Shuffle the tracklist Parameters:
  138. MSG_CMD_TRACKLIST_PLAY_PAUSE, # Play the given track and pause immediately Parameters: 'idx', 'seconds'
  139. # Explorers
  140. MSG_CMD_EXPLORER_ADD, # Add a new explorer Parameters: 'modName', 'expName', 'icon', 'widget'
  141. MSG_CMD_EXPLORER_REMOVE, # Remove an explorer Parameters: 'modName', 'expName'
  142. MSG_CMD_EXPLORER_RENAME, # Rename an explorer Parameters: 'modName', 'expName', 'newExpName'
  143. # Covers
  144. MSG_CMD_SET_COVER, # Cover file for the given track Parameters: 'track', 'pathThumbnail', 'pathFullSize'
  145. # Misc
  146. MSG_CMD_THREAD_EXECUTE, # An *internal* command for threaded modules Parameters: N/A
  147. # --== EVENTS ==--
  148. # Current track
  149. MSG_EVT_PAUSED, # Paused Parameters:
  150. MSG_EVT_STOPPED, # Stopped Parameters:
  151. MSG_EVT_UNPAUSED, # Unpaused Parameters:
  152. MSG_EVT_NEW_TRACK, # The current track has changed Parameters: 'track'
  153. MSG_EVT_NEED_BUFFER, # The next track should be buffered Parameters:
  154. MSG_EVT_TRACK_POSITION, # New position in the current track Parameters: 'seconds'
  155. MSG_EVT_TRACK_ENDED_OK, # The current track has ended Parameters:
  156. MSG_EVT_TRACK_ENDED_ERROR, # The current track has ended because of an error Parameters:
  157. # GStreamer player
  158. MSG_EVT_VOLUME_CHANGED, # The volume has changed Parameters: 'value'
  159. # Tracklist
  160. MSG_EVT_TRACK_MOVED, # The position of the current track has changed Parameters: 'hasPrevious', 'hasNext'
  161. MSG_EVT_NEW_TRACKLIST, # A new tracklist has been set Parameters: 'tracks', 'playtime'
  162. MSG_EVT_REPEAT_CHANGED, # The repeat function has been enabled/disabled Parameters: 'repeat'
  163. MSG_EVT_TRACKLIST_NEW_SEL, # The tracklist has a new set of selected tracks Parameters: 'tracks'
  164. # Application
  165. MSG_EVT_APP_QUIT, # The application is quitting Parameters:
  166. MSG_EVT_APP_STARTED, # The application has just started Parameters:
  167. # Modules
  168. MSG_EVT_MOD_LOADED, # The module has been loaded by request of the user Parameters:
  169. MSG_EVT_MOD_UNLOADED, # The module has been unloaded by request of the user Parameters:
  170. # Explorer manager
  171. MSG_EVT_EXPLORER_CHANGED, # A new explorer has been selected Parameters: 'modName', 'expName'
  172. # End value
  173. MSG_END_VALUE
  174. ) = range(45)