Improve startup time, show count of 0 when everything is filtered out
This commit is contained in:
parent
376b584899
commit
2a586f9755
|
@ -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)
|
||||
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"] = ""
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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) )
|
||||
|
|
|
@ -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"]
|
||||
"progbar", "tabs", "window"]
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
guibuilder.parts["libcountlabel"] = make_libcountlabel
|
||||
guibuilder.parts["titlelabel"] = make_titlelabel
|
||||
guibuilder.parts["albumlabel"] = make_albumlabel
|
||||
guibuilder.parts["artistlabel"] = make_artistlabel
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -16,7 +16,15 @@
|
|||
<menutheme/>
|
||||
</menuitem>
|
||||
</menu-bar>
|
||||
<songinfo/>
|
||||
<scrolled-window hscroll="always">
|
||||
<add-viewport>
|
||||
<vbox>
|
||||
<titlelabel/>
|
||||
<albumlabel/>
|
||||
<artistlabel/>
|
||||
</vbox>
|
||||
</add-viewport>
|
||||
</scrolled-window>
|
||||
<pack expand="True" fill="True"/>
|
||||
<tabs>
|
||||
<tab>
|
||||
|
|
Loading…
Reference in New Issue