Added 'helldon' to transparently port the thing to the desktop :P
authorKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Tue, 5 Jan 2010 16:04:21 +0000 (17:04 +0100)
committerKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Wed, 6 Jan 2010 13:56:42 +0000 (14:56 +0100)
16 files changed:
helldon/__init__.py [new file with mode: 0644]
jamaendo/api.py
jamaui/__init__.py
jamaui/albumlist.py
jamaui/colors.py
jamaui/favorites.py
jamaui/featured.py
jamaui/listbox.py
jamaui/player.py
jamaui/playerwindow.py
jamaui/playlists.py
jamaui/radios.py
jamaui/search.py
jamaui/showalbum.py
jamaui/showartist.py
jamaui/ui.py

diff --git a/helldon/__init__.py b/helldon/__init__.py
new file mode 100644 (file)
index 0000000..d3aa134
--- /dev/null
@@ -0,0 +1,76 @@
+import gtk
+
+gtk.HILDON_SIZE_AUTO = -1
+gtk.HILDON_SIZE_AUTO_WIDTH = -1
+gtk.HILDON_SIZE_FINGER_HEIGHT = 32
+gtk.HILDON_SIZE_THUMB_HEIGHT = 48
+
+BUTTON_ARRANGEMENT_VERTICAL = 1
+
+def hildon_gtk_window_set_progress_indicator(wnd, onoff):
+    pass
+
+class Program(gtk.Window):
+    instance = None
+
+    def __init__(self):
+        gtk.Window.__init__(self, type=gtk.WINDOW_TOPLEVEL)
+        self._vbox = gtk.VBox()
+        self._title = gtk.Label("Jamaendo")
+        self._backbtn = gtk.Button("<<<")
+        self._hbox = gtk.HBox()
+        self._hbox.pack_start(self._title, True)
+        self._hbox.pack_start(self._backbtn, False)
+        self._notebook = gtk.Notebook()
+        self._notebook.set_size_request(800, 445)
+        self._notebook.set_show_tabs(False)
+        self._vbox.pack_start(self._hbox, False)
+        self._vbox.pack_start(self._notebook, True)
+        self.add(self._vbox)
+        self.show_all()
+        Program.instance = self
+
+    def add_window(self, wnd):
+        pass
+
+    def add_stackable(self, wnd):
+        idx = self._notebook.append_page(wnd)
+        self._notebook.set_current_page(idx)
+        wnd.show_all()
+        wnd._nb_index = idx
+
+class StackableWindow(gtk.Frame):
+    def __init__(self):
+        gtk.Frame.__init__(self)
+        self._nb_index = 0
+        Program.instance.add_stackable(self)
+    def set_app_menu(self, menu):
+        pass
+
+    def set_title(self, title):
+        Program.instance._title.set_text(title)#_notebook.set_tab_label_text(self, title)
+
+class AppMenu(object):
+    def __init__(self):
+        pass
+
+    def append(self, widget):
+        pass
+
+    def show_all(self):
+        pass
+
+class GtkButton(gtk.Button):
+    def __init__(self, size):
+        gtk.Button.__init__(self)
+
+
+class Button(gtk.Button):
+    def __init__(self, size, layout):
+        gtk.Button.__init__(self)
+
+    def set_text(self, title, subtitle):
+        self.set_label(title)
+
+class PannableArea(gtk.ScrolledWindow):
+    pass
index feeb17d..7792c33 100644 (file)
@@ -277,6 +277,9 @@ class CoverFetcher(threading.Thread):
         self.work = []
 
     def _retrieve(self, url, fname):
         self.work = []
 
     def _retrieve(self, url, fname):
+        BROKEN = 'http://imgjam.com/radios/default/default.100.png'
+        if url == BROKEN:
+            return None
         f = open(fname, 'wb')
         c = pycurl.Curl()
         c.setopt(pycurl.FOLLOWLOCATION, 1)
         f = open(fname, 'wb')
         c = pycurl.Curl()
         c.setopt(pycurl.FOLLOWLOCATION, 1)
index 9705ea1..819b0d7 100644 (file)
@@ -27,7 +27,16 @@ import sys
 
 LOG_FILENAME = '/tmp/jamaendo.log'
 LOG_LEVEL = logging.DEBUG
 
 LOG_FILENAME = '/tmp/jamaendo.log'
 LOG_LEVEL = logging.DEBUG
-#LOG_FORMAT = "%(asctime)s %(name)-19s %(levelname)-5s - %(message)s"
 LOG_FORMAT = "%(asctime)s %(name)-10s: [%(lineno)4d] %(levelname)-5s %(message)s"
 LOG_FORMAT = "%(asctime)s %(name)-10s: [%(lineno)4d] %(levelname)-5s %(message)s"
-logging.basicConfig(filename=LOG_FILENAME, level=LOG_LEVEL, format=LOG_FORMAT)
+
+_rootlogger = logging.getLogger()
+_fhandler = logging.FileHandler(LOG_FILENAME)
+_shandler = logging.StreamHandler()
+_formatter = logging.Formatter(LOG_FORMAT)
+_fhandler.setFormatter(_formatter)
+_shandler.setFormatter(_formatter)
+
+_rootlogger.addHandler(_fhandler)
+_rootlogger.addHandler(_shandler)
+_rootlogger.setLevel(LOG_LEVEL)
 
 
index 5653310..dbaa8ff 100644 (file)
@@ -1,7 +1,10 @@
 import os
 import gtk
 import gobject
 import os
 import gtk
 import gobject
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 import util
 from settings import settings
 import jamaendo
 import util
 from settings import settings
index c17dbc9..391d18a 100644 (file)
@@ -1,7 +1,12 @@
 # hildon colors
 
 import gtk
 # hildon colors
 
 import gtk
-import hildon
+try:
+    import hildon
+    _using_helldon = False
+except:
+    import helldon as hildon
+    _using_helldon = True
 
 # See the Fremantle Master Layout Guide for more information:
 # http://tinyurl.com/fremantle-master-layout-guide
 
 # See the Fremantle Master Layout Guide for more information:
 # http://tinyurl.com/fremantle-master-layout-guide
@@ -30,6 +35,10 @@ def get_font_desc(logicalfontname):
     settings = gtk.settings_get_default()
     font_style = gtk.rc_get_style_by_paths(settings, logicalfontname, \
                                                None, None)
     settings = gtk.settings_get_default()
     font_style = gtk.rc_get_style_by_paths(settings, logicalfontname, \
                                                None, None)
+    if not font_style:
+        font_style = gtk.rc_get_style_by_paths(settings,
+                                               'GtkButton', 'GtkButton', gtk.Button)
+
     font_desc = font_style.font_desc
     return font_desc
 
     font_desc = font_style.font_desc
     return font_desc
 
@@ -37,20 +46,31 @@ def get_color(logicalcolorname):
     settings = gtk.settings_get_default()
     color_style = gtk.rc_get_style_by_paths(settings, 'GtkButton', \
                                                 'osso-logical-colors', gtk.Button)
     settings = gtk.settings_get_default()
     color_style = gtk.rc_get_style_by_paths(settings, 'GtkButton', \
                                                 'osso-logical-colors', gtk.Button)
-    return color_style.lookup_color(logicalcolorname)
 
 
-def font(name):
-    return get_font_desc(name).to_string()
+    if not color_style:
+        font_style = gtk.rc_get_style_by_paths(settings,
+                                               'GtkButton', 'GtkButton', gtk.Button)
+    return color_style.lookup_color(logicalcolorname)
 
 
+if _using_helldon:
+    def font(name):
+        return "normal"
+else:
+    def font(name):
+        return get_font_desc(name).to_string()
 
 
-def color(name):
-    return get_color('SecondaryTextColor').to_string()
+if _using_helldon:
+    def color(name):
+        return "#333333"
+else:
+    def color(name):
+        return get_color('SecondaryTextColor').to_string()
 
 import sys
 current_module = sys.modules[__name__]
 
 for fnt in logical_font_names:
 
 import sys
 current_module = sys.modules[__name__]
 
 for fnt in logical_font_names:
-    setattr(current_module, fnt, font(fnt))
+    setattr(current_module, fnt, lambda: font(fnt))
 
 for clr in logical_color_names:
 
 for clr in logical_color_names:
-    setattr(current_module, clr, color(clr))
+    setattr(current_module, clr, lambda: color(clr))
index 5a0474c..6e829ac 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
index 3f9aa20..2eef82d 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
index edef878..bc34d09 100644 (file)
@@ -1,6 +1,9 @@
 # what the fuck, GTK
 import gtk
 # what the fuck, GTK
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 
 class ListBox(gtk.TreeView):
     def __init__(self):
 
 class ListBox(gtk.TreeView):
     def __init__(self):
index 70d261a..7908dea 100644 (file)
@@ -158,7 +158,7 @@ class GStreamer(_Player):
         self.filesrc = self.player
         self.filesrc_property = 'uri'
         self.volume_control = self.player
         self.filesrc = self.player
         self.filesrc_property = 'uri'
         self.volume_control = self.player
-        self.volume_multiplier = 1.
+        self.volume_multiplier = 10.
         self.volume_property = 'volume'
 
     def _on_decoder_pad_added(self, decoder, src_pad, sink_pad):
         self.volume_property = 'volume'
 
     def _on_decoder_pad_added(self, decoder, src_pad, sink_pad):
index c9b965b..2fd350a 100644 (file)
 #
 import gtk
 import gobject
 #
 import gtk
 import gobject
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import util
 import pango
 import jamaendo
 import util
 import pango
 import jamaendo
@@ -205,11 +208,11 @@ class PlayerWindow(hildon.StackableWindow):
         if self.playlist.radio_mode:
             ppstr = '<span size="small">Radio: %s</span>'%(cgi.escape(self.playlist.radio_name))
         else:
         if self.playlist.radio_mode:
             ppstr = '<span size="small">Radio: %s</span>'%(cgi.escape(self.playlist.radio_name))
         else:
-            ppstr = '<span font_desc="%s" foreground="%s">Track %s of %s</span>'%(colors.SmallSystemFont, colors.SecondaryTextColor, int(playlist_pos)+1, playlist_size)
+            ppstr = '<span font_desc="%s" foreground="%s">Track %s of %s</span>'%(colors.SmallSystemFont(), colors.SecondaryTextColor(), int(playlist_pos)+1, playlist_size)
         self.playlist_pos.set_markup(ppstr)
         self.playlist_pos.set_markup(ppstr)
-        self.track.set_markup('<span font_desc="%s">%s</span>'%(colors.LargeSystemFont, cgi.escape(track)))
+        self.track.set_markup('<span font_desc="%s">%s</span>'%(colors.LargeSystemFont(), cgi.escape(track)))
         self.artist.set_markup('%s'%(cgi.escape(artist)))
         self.artist.set_markup('%s'%(cgi.escape(artist)))
-        self.album.set_markup('<span foreground="%s">%s</span>'%(colors.SecondaryTextColor, cgi.escape(album)))
+        self.album.set_markup('<span foreground="%s">%s</span>'%(colors.SecondaryTextColor(), cgi.escape(album)))
 
     def show_banner(self, message, timeout = 2000):
         banner = hildon.hildon_banner_show_information(self, '', message)
 
     def show_banner(self, message, timeout = 2000):
         banner = hildon.hildon_banner_show_information(self, '', message)
index ece1527..3012e29 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from settings import settings
 import logging
 import jamaendo
 from settings import settings
 import logging
index da10c77..44d92f3 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from playerwindow import open_playerwindow
 from albumlist import RadioList
 import jamaendo
 from playerwindow import open_playerwindow
 from albumlist import RadioList
index 4092048..4ea8dd3 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
 import jamaendo
 from playerwindow import open_playerwindow
 from showartist import ShowArtist
index a13ffe8..218d998 100644 (file)
 #
 import gtk
 import cgi
 #
 import gtk
 import cgi
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from player import Playlist
 from playerwindow import open_playerwindow
 import jamaendo
 from player import Playlist
 from playerwindow import open_playerwindow
index 9cae975..6751b97 100644 (file)
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
 #  (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
 #
 import gtk
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import jamaendo
 from playerwindow import open_playerwindow
 from albumlist import AlbumList
 import jamaendo
 from playerwindow import open_playerwindow
 from albumlist import AlbumList
index 2eb3261..dda0ecc 100644 (file)
@@ -47,8 +47,8 @@ except:
         log.critical('Using GTK widgets, install "python2.5-hildon" '
             'for this to work properly.')
     else:
         log.critical('Using GTK widgets, install "python2.5-hildon" '
             'for this to work properly.')
     else:
-        log.critical('This ui only works in maemo')
-        sys.exit(1)
+        log.critical('This ui (probably) only works in maemo')
+        import helldon as hildon
 
 from dbus.mainloop.glib import DBusGMainLoop
 
 
 from dbus.mainloop.glib import DBusGMainLoop