init_pref returns value
When I initialize a preference, the actual value of the preference should be returned to the caller.
This commit is contained in:
parent
844106a306
commit
717c36b78e
|
@ -198,8 +198,13 @@ class PrefTree(Tree):
|
||||||
|
|
||||||
def init_pref(self, pref, value):
|
def init_pref(self, pref, value):
|
||||||
path = pref.split('.')
|
path = pref.split('.')
|
||||||
if self.lookup(path) == None:
|
val = self.lookup(path)
|
||||||
|
if val == None:
|
||||||
self.insert(path + [value])
|
self.insert(path + [value])
|
||||||
|
val = value
|
||||||
|
else:
|
||||||
|
val = val[0]
|
||||||
|
return val
|
||||||
|
|
||||||
def set_pref(self, pref, value):
|
def set_pref(self, pref, value):
|
||||||
path = pref.split('.')
|
path = pref.split('.')
|
||||||
|
@ -225,9 +230,10 @@ class PersPrefTree(PrefTree):
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|
||||||
def init_pref(self, pref, value):
|
def init_pref(self, pref, value):
|
||||||
PrefTree.init_pref(self, pref, value)
|
val = PrefTree.init_pref(self, pref, value)
|
||||||
if self.file != None:
|
if self.file != None:
|
||||||
files.save(self, self.file, ".tree")
|
files.save(self, self.file, ".tree")
|
||||||
|
return val
|
||||||
|
|
||||||
def set_pref(self, pref, value):
|
def set_pref(self, pref, value):
|
||||||
PrefTree.set_pref(self, pref, value)
|
PrefTree.set_pref(self, pref, value)
|
||||||
|
|
10
ocarina.py
10
ocarina.py
|
@ -10,14 +10,10 @@ import ocarina
|
||||||
|
|
||||||
from ocarina import collection
|
from ocarina import collection
|
||||||
|
|
||||||
libsaria.init_pref("ocarina.window.width", 800)
|
width = libsaria.init_pref("ocarina.window.width", 800)
|
||||||
libsaria.init_pref("ocarina.window.height", 600)
|
height = libsaria.init_pref("ocarina.window.height", 600)
|
||||||
|
|
||||||
prefs = libsaria.prefs
|
win = ocarina.get_window((width, height))
|
||||||
win_prefs = prefs.lookup_child(["ocarina", "window"])
|
|
||||||
size = (win_prefs.get_pref("width"), win_prefs.get_pref("height"))
|
|
||||||
|
|
||||||
win = ocarina.get_window(size)
|
|
||||||
ocarina.set_window_title("%s Your Music Everywhere" % ocarina.__vers__)
|
ocarina.set_window_title("%s Your Music Everywhere" % ocarina.__vers__)
|
||||||
ocarina.set_window_icon("images/ocarina.png")
|
ocarina.set_window_icon("images/ocarina.png")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue