diff --git a/src/config.py b/src/config.py
index a45e27b3..892ce9a0 100644
--- a/src/config.py
+++ b/src/config.py
@@ -32,7 +32,7 @@ from ct.call import *
################################################################################
################################################################################
-# Set this variable to force verbocity to always be at the same value.
+# Set this variable to force verbosity to always be at the same value.
# Calling ocarina with the -v option will have no effect. A higher value will
# print more output
#vars["$verbose"] = 0
@@ -86,4 +86,32 @@ if exists( history ):
# Set the max number of lines to store in the history file.
# A negative number means unlimited length
-readline.set_history_length(50)
\ No newline at end of file
+readline.set_history_length(50)
+
+
+
+
+################################################################################
+################################################################################
+## ##
+## Section 2.1 ocarina-extra variable configuration ##
+## The goal of ocarina-extra is to provide additional features that most ##
+## may want to have around. These features include a graphical front end ##
+## and a sql based music library. ##
+## ##
+################################################################################
+################################################################################
+
+# Ocarina uses an xml-based system to build up the GUI. This allows you to
+# create your own custom gui.
+#vars["$theme"] = "themes/simple.xml"
+vars["$theme"] = "themes/classic.xml"
+
+# These next variables are the initial text shown in the artist, album, title
+# labels. They will be overwritten when a song begins playback.
+#vars["$artist"] = ""
+#vars["$album"] = ""
+#vars["$title"] = ""
+
+# Initial text for library / playlist / queue filtering
+#vars["$filterText"] = ""
\ No newline at end of file
diff --git a/src/core/gstreamer.py b/src/core/gstreamer.py
index de6e8d45..5dfc00e7 100644
--- a/src/core/gstreamer.py
+++ b/src/core/gstreamer.py
@@ -121,16 +121,15 @@ def getProgress():
# Seek to the desired percent of the song.
# Fraction is True if prcnt is already a fraction
-def seek(prcnt,fraction=False):
+def seek(prcnt):
global player
global time
- if fraction == False:
- prcnt = float(prcnt)
- if prcnt < 0:
- return -1
- elif prcnt > 100:
- return -1
- prcnt = prcnt / 100.0
+ if prcnt < 0:
+ prcnt = 0
+ elif prcnt > 100:
+ prcnt = 1
+ elif prcnt > 1:
+ prcnt = float(prcnt) / 100.0
newTime = duration() * prcnt
player.seek_simple(time,gst.SEEK_FLAG_FLUSH,newTime)
return 0
diff --git a/src/count.sh b/src/count.sh
new file mode 100644
index 00000000..0eb4b009
--- /dev/null
+++ b/src/count.sh
@@ -0,0 +1,4 @@
+
+CORE="core/*.py core/ct/*.py"
+EXTRA="extra/*.py extra/et/*.py extra/oGtk/*.py"
+cat $CORE $EXTRA | grep -v [[:space:]]*# | cat -b
diff --git a/src/extra/et/times.py b/src/extra/et/times.py
deleted file mode 100644
index c47c4a36..00000000
--- a/src/extra/et/times.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /usr/bin/python
-
-# To change this template, choose Tools | Templates
-# and open the template in the editor.
-
-__author__="bjschuma"
-__date__ ="$Mar 16, 2010 7:36:48 PM$"
-
-
-def ftime(time,ms=True):
- time = int(time)
- # Convert to seconds if we were given milliseconds
- if ms==True:
- time = time/1000000000
-
- #print time
- # Find hour
- length = ""
- if time >= 3600:
- hour = time/3600
- time = time - (hour * 3600)
- if hour > 0:
- length=str(hour)+":"
- # Find minute
- if time >= 60:
- min = time/60
- time = time - (min * 60)
- if min < 10:
- length+="0"
- length+=str(min)+":"
- else:
- length+="00:"
- # Remainder is seconds
- sec = time
- if sec < 10:
- length+="0"
- length+=str(sec)
- return length
\ No newline at end of file
diff --git a/src/extra/guibuilder.py b/src/extra/guibuilder.py
index 12aeda6d..60a16813 100644
--- a/src/extra/guibuilder.py
+++ b/src/extra/guibuilder.py
@@ -92,14 +92,22 @@ def fill(node,container):
pack = True
packing = {"expand":False,"fill":False,"padding":0}
- for child in xm.children(node):
- if child.nodeName == "add":
- write("We are adding to "+node.nodeName,2)
+ for child in xm.children(node):
+ viewport = False
+ if child.nodeName == "add" or child.nodeName == "add-viewport":
+ if child.nodeName == "add-viewport":
+ write("We are adding to "+node.nodeName+" with a viewport",2)
+ viewport = True
+ else:
+ write("We are adding to "+node.nodeName,2)
pack = False
for grandchild in xm.children(child):
item = buildFunc(grandchild)
if item != None:
- container.add(item)
+ if viewport == False:
+ container.add(item)
+ else:
+ container.add_with_viewport(item)
elif child.nodeName == "pack":
packing = setPacking( packing,xm.attributes(child) )
diff --git a/src/extra/oGtk/__init__.py b/src/extra/oGtk/__init__.py
index 588d7f3a..3de756d6 100644
--- a/src/extra/oGtk/__init__.py
+++ b/src/extra/oGtk/__init__.py
@@ -3,4 +3,4 @@ __date__ ="$Mar 14, 2010 10:21:40 PM$"
__all__ = ["box", "button", "dialog","entry", "label", "label", "list", "menu",
- "progbar", "songInfo", "tabs", "window"]
\ No newline at end of file
+ "progbar", "tabs", "window"]
\ No newline at end of file
diff --git a/src/extra/oGtk/entry.py b/src/extra/oGtk/entry.py
index 03ab211c..f1b21eac 100644
--- a/src/extra/oGtk/entry.py
+++ b/src/extra/oGtk/entry.py
@@ -25,7 +25,7 @@ class EntryFilter(gtk.Entry):
def textTyped(self,entry):
ocarina.vars["$filterText"] = entry.get_text().lower()
self.filterCount += 1
- gobject.timeout_add(250,self.filter)
+ gobject.timeout_add(100,self.filter)
def filter(self):
diff --git a/src/extra/oGtk/label.py b/src/extra/oGtk/label.py
index f27091ac..444d8e87 100644
--- a/src/extra/oGtk/label.py
+++ b/src/extra/oGtk/label.py
@@ -37,6 +37,7 @@ class LabelLibCount(gtk.Label):
self.set_text("Library (" + str(count) + ")")
+
class Label2(gtk.Alignment):
def __init__(self,size=None,weight=None,text=None):
gtk.Alignment.__init__(self,0,1,0,0)
@@ -63,7 +64,45 @@ class Label2(gtk.Alignment):
self.label.set_text(text)
+
+class SongTitleLabel(Label2):
+ def __init__(self):
+ Label2.__init__(self,13000, 700)
+ ocarina.events.invite("tags-changed", self.setTitle)
+ self.setTitle()
+
+ def setTitle(self):
+ self.set_text(ocarina.vars["$title"])
+
+
+class SongAlbumLabel(Label2):
+ def __init__(self):
+ Label2.__init__(self,10000, 400)
+ ocarina.events.invite("tags-changed", self.setAlbum)
+ self.setAlbum()
+
+ def setAlbum(self):
+ self.set_text("from " + ocarina.vars["$album"])
+
+
+class SongArtistLabel(Label2):
+ def __init__(self):
+ Label2.__init__(self,10000, 400)
+ ocarina.events.invite("tags-changed", self.setArtist)
+ self.setArtist()
+
+ def setArtist(self):
+ self.set_text("by " + ocarina.vars["$artist"])
+
+
+
def make_label(attrs):return Label(attrs)
def make_libcountlabel(attrs):return LabelLibCount()
+def make_titlelabel(attrs):return SongTitleLabel()
+def make_albumlabel(attrs):return SongAlbumLabel()
+def make_artistlabel(attrs):return SongArtistLabel()
guibuilder.parts["label"] = make_label
-guibuilder.parts["libcountlabel"] = make_libcountlabel
\ No newline at end of file
+guibuilder.parts["libcountlabel"] = make_libcountlabel
+guibuilder.parts["titlelabel"] = make_titlelabel
+guibuilder.parts["albumlabel"] = make_albumlabel
+guibuilder.parts["artistlabel"] = make_artistlabel
\ No newline at end of file
diff --git a/src/extra/oGtk/list.py b/src/extra/oGtk/list.py
index f7af180b..f604012d 100644
--- a/src/extra/oGtk/list.py
+++ b/src/extra/oGtk/list.py
@@ -13,7 +13,7 @@ import ocarina
from et import needle
import re
import index
-from et import times
+from ct import times
from ct.call import *
@@ -50,12 +50,8 @@ class SongList(gtk.TreeView):
#self.loadCols()
#self.tree.show()
#self.add(self.tree)
- self.filter = self.list.filter_new()
- self.filter.set_visible_func(self.setvisible)
- self.sort = gtk.TreeModelSort(self.filter)
- self.set_model(self.sort)
- #self.set_model(self.filter)
- #self.set_model(self.list)
+ self.filterModel = self.list.filter_new()
+ self.filterModel.set_visible_func(self.setvisible)
#self.show_all()
@@ -75,11 +71,8 @@ class SongList(gtk.TreeView):
self.results = index.search(ocarina.vars["$filterText"])
if self.countvar != None:
c = len(self.results)
- if c == 0:
- ocarina.vars[self.countvar] = len(self.list)
- else:
- ocarina.vars[self.countvar] = c
- self.filter.refilter()
+ ocarina.vars[self.countvar] = c
+ self.filterModel.refilter()
def setvisible(self,list,iter):
@@ -116,6 +109,10 @@ class LibraryList(SongList):
def insertLibrary(self):
+ # Freeze the model before inserting a lot of rows
+ # this speeds up performance
+ self.freeze_child_notify()
+ self.set_model(None)
try:
libid = db.libid("Music")
ocarina.events.start("ocarina-filter-start")
@@ -123,6 +120,10 @@ class LibraryList(SongList):
self.insert(track[1])
except Exception,e:
print e
+ self.sort = gtk.TreeModelSort(self.filterModel)
+ self.set_model(self.sort)
+ # Unfreeze the model
+ self.thaw_child_notify()
self.show_all()
diff --git a/src/extra/oGtk/progbar.py b/src/extra/oGtk/progbar.py
index fb9b0a30..68248844 100644
--- a/src/extra/oGtk/progbar.py
+++ b/src/extra/oGtk/progbar.py
@@ -14,7 +14,8 @@ import guibuilder
import gstreamer
import ocarina
-from et import times
+from ct import times
+from ct import call
from et import scanlib
@@ -36,14 +37,16 @@ class ProgressBar(gtk.EventBox):
if data.button == 1:
prcnt = float(data.x) / float(self.bar.get_allocation()[2])
self.bar.set_fraction(prcnt)
- gstreamer.seek(prcnt,fraction=True)
+ print prcnt
+ call.seek(prcnt)
+ #gstreamer.seek(prcnt,fraction=True)
def updatebar(self):
try:
self.bar.set_fraction(gstreamer.getProgress())
- current = times.ftime(gstreamer.currentpos())
- duration = times.ftime(gstreamer.duration())
+ current = times.ms2str(gstreamer.currentpos())
+ duration = times.ms2str(gstreamer.duration())
self.bar.set_text(current + " / " + duration)
except:
pass
diff --git a/src/extra/oGtk/songInfo.py b/src/extra/oGtk/songInfo.py
deleted file mode 100644
index 46198d6a..00000000
--- a/src/extra/oGtk/songInfo.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#! /usr/bin/python
-
-# To change this template, choose Tools | Templates
-# and open the template in the editor.
-
-__author__="bjschuma"
-__date__ ="$Mar 15, 2010 10:01:39 PM$"
-
-
-import gtk
-import ocarina
-from oGtk import label
-import guibuilder
-
-
-class SongInfo(gtk.ScrolledWindow):
- def __init__(self):
- gtk.ScrolledWindow.__init__(self)
- self.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)
- box = gtk.VBox(False,0)
-
- self.title = label.Label2(13000,700)
- self.artist = label.Label2(10000,400)
- self.album = label.Label2(10000,400)
-
- box.pack_start(self.title,False,False,0)
- box.pack_start(self.album,False,False,0)
- box.pack_start(self.artist,False,False,0)
- self.add_with_viewport(box)
-
- self.setLabels()
- ocarina.events.invite("tags-changed", self.setLabels)
- self.show_all()
-
-
- def setLabels(self):
- self.title.set_text(ocarina.vars["$title"])
- self.album.set_text("from " + ocarina.vars["$album"])
- self.artist.set_text("by " + ocarina.vars["$artist"])
-
-
-def make_songinfo(attrs=None):return SongInfo()
-guibuilder.parts["songinfo"] = make_songinfo
diff --git a/src/extra/ocarina-extra.py b/src/extra/ocarina-extra.py
index 049e7ac8..bd6f85f1 100644
--- a/src/extra/ocarina-extra.py
+++ b/src/extra/ocarina-extra.py
@@ -24,8 +24,8 @@ def main():
# Potentially the first thing printed
write("Welcome to Ocarina (extra)", 1)
- ocarina.events.start("ocarina-start")
code = ocarina.config()
+ ocarina.events.start("ocarina-start")
if code == 0:
gtk.main()
diff --git a/src/themes/classic.xml b/src/themes/classic.xml
index bb73dceb..d7d39dff 100644
--- a/src/themes/classic.xml
+++ b/src/themes/classic.xml
@@ -16,7 +16,15 @@
-
+
+
+
+
+
+
+
+
+