Random new preferences

The random feature uses the new preferences tree, rather than the
preferences map.
This commit is contained in:
Bryan Schumaker 2010-11-15 08:24:45 -05:00
parent 5a02227e99
commit 3cd7f4b20f
3 changed files with 8 additions and 4 deletions

View File

@ -8,6 +8,7 @@ call = libsaria.event.call
exists = libsaria.path.exists
expand = libsaria.path.expand
FileRef = tagpy.FileRef
prefs = None
import library
import playlist
@ -20,11 +21,13 @@ inc_score = library.inc_score
inc_count = library.inc_count
def init():
libsaria.init_pref("random", False)
global prefs
prefs = libsaria.prefs2
prefs.init_pref("libsaria.random", False)
libsaria.event.invite("POSTINIT", init)
def toggle_rand():
libsaria.prefs["random"] = not libsaria.prefs["random"]
prefs.set_pref("libsaria.random", not prefs.get_pref("libsaria.random"))
cur_lib_id = -1

View File

@ -111,7 +111,7 @@ def rand_next():
return id
def next():
if libsaria.prefs["random"] == True:
if libsaria.prefs2.get_pref("libsaria.random") == True:
id = rand_next()
else:
id = seq_next()

View File

@ -5,6 +5,7 @@ import image
LS = ocarina.libsaria
gtk = ocarina.gtk
prefs = LS.prefs
prefs2 = LS.prefs2
class Button(gtk.Button):
@ -115,7 +116,7 @@ class RandomButton(gtk.ToggleButton):
img = gtk.image_new_from_file("images/random.png")
img.show()
self.add(img)
self.set_active(prefs["random"])
self.set_active(prefs2.get_pref("libsaria.random"))
self.set_relief(gtk.RELIEF_NONE)
self.connect("toggled", self.toggle)
self.show()