Began moving functions from the gui collection to the gui list where
they belong.
This commit is contained in:
parent
45e2b0325f
commit
519f4c0fd8
|
@ -11,16 +11,22 @@ event = ocarina.libsaria.event
|
||||||
gtk = ocarina.gtk
|
gtk = ocarina.gtk
|
||||||
|
|
||||||
|
|
||||||
|
class Actions:
|
||||||
|
def __init__(self):
|
||||||
|
self.mouse_motion = None
|
||||||
|
self.selected_row = None
|
||||||
|
self.refilter = None
|
||||||
|
|
||||||
|
|
||||||
class Collection(gtk.ScrolledWindow):
|
class Collection(gtk.ScrolledWindow):
|
||||||
def __init__(self, mouse_motion, select, refilter):
|
def __init__(self, actions):
|
||||||
gtk.ScrolledWindow.__init__(self)
|
gtk.ScrolledWindow.__init__(self)
|
||||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
self.list = list.List(refilter)
|
self.list = list.List(actions)
|
||||||
|
|
||||||
self.list.connect("motion-notify-event", self.on_mouse_motion)
|
self.list.connect("motion-notify-event", self.on_mouse_motion)
|
||||||
self.list.connect("row-activated", self.row_activated)
|
self.mouse_motion = actions.mouse_motion
|
||||||
self.mouse_motion = mouse_motion
|
self.selected_row = actions.selected_row
|
||||||
self.selected_row = select
|
|
||||||
|
|
||||||
self.add(self.list)
|
self.add(self.list)
|
||||||
self.show()
|
self.show()
|
||||||
|
@ -50,17 +56,14 @@ class Collection(gtk.ScrolledWindow):
|
||||||
string = self.mouse_motion(list_row)
|
string = self.mouse_motion(list_row)
|
||||||
list.set_value(list_iter, len(list_row)-1, "Played: %s"%string)
|
list.set_value(list_iter, len(list_row)-1, "Played: %s"%string)
|
||||||
|
|
||||||
def row_activated(self, widget, path, column):
|
|
||||||
list = self.list.filter_model
|
|
||||||
iter = list.get_iter(path)
|
|
||||||
row = list[iter]
|
|
||||||
self.selected_row(row)
|
|
||||||
|
|
||||||
|
|
||||||
class Library(Collection):
|
class Library(Collection):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Collection.__init__(self, self.mouse_motion, self.select_row,
|
actions = Actions()
|
||||||
self.refilter)
|
actions.mouse_motion = self.mouse_motion
|
||||||
|
actions.selected_row = self.select_row
|
||||||
|
actions.refilter = self.refilter
|
||||||
|
Collection.__init__(self, actions)
|
||||||
libsaria.event.invite("POSTSTART", self.populate, bg=True)
|
libsaria.event.invite("POSTSTART", self.populate, bg=True)
|
||||||
libsaria.event.invite("POSTNEWSOURCE", self.refresh, bg=True)
|
libsaria.event.invite("POSTNEWSOURCE", self.refresh, bg=True)
|
||||||
|
|
||||||
|
@ -79,7 +82,6 @@ class Library(Collection):
|
||||||
return collection.lib_get_attr(row[0], "playcount")
|
return collection.lib_get_attr(row[0], "playcount")
|
||||||
|
|
||||||
def select_row(self, row):
|
def select_row(self, row):
|
||||||
print row[0], row[1]
|
|
||||||
collection.lib_play_id(row[0])
|
collection.lib_play_id(row[0])
|
||||||
|
|
||||||
def filter(self, text):
|
def filter(self, text):
|
||||||
|
|
|
@ -7,12 +7,12 @@ gobject = ocarina.gobject
|
||||||
#UNI = gobject.TYPE_UNICHAR
|
#UNI = gobject.TYPE_UNICHAR
|
||||||
|
|
||||||
class List(gtk.TreeView):
|
class List(gtk.TreeView):
|
||||||
def __init__(self, refilter):
|
def __init__(self, actions):
|
||||||
gtk.TreeView.__init__(self)
|
gtk.TreeView.__init__(self)
|
||||||
|
self.actions = actions
|
||||||
self.list = gtk.ListStore(int, str, str, str, str, int, str)
|
self.list = gtk.ListStore(int, str, str, str, str, int, str)
|
||||||
|
|
||||||
self.append = self.list.append
|
self.append = self.list.append
|
||||||
self.set_visible = refilter
|
|
||||||
|
|
||||||
cell = gtk.CellRendererText()
|
cell = gtk.CellRendererText()
|
||||||
cell.set_fixed_height_from_font(1)
|
cell.set_fixed_height_from_font(1)
|
||||||
|
@ -34,12 +34,20 @@ class List(gtk.TreeView):
|
||||||
self.set_tooltip_column(len(cols)-1)
|
self.set_tooltip_column(len(cols)-1)
|
||||||
|
|
||||||
self.filter_model = self.list.filter_new()
|
self.filter_model = self.list.filter_new()
|
||||||
self.filter_model.set_visible_func(self.set_visible)
|
self.filter_model.set_visible_func(actions.refilter)
|
||||||
self.refilter = self.filter_model.refilter
|
self.refilter = self.filter_model.refilter
|
||||||
|
|
||||||
|
self.connect("row-activated", self.row_activated)
|
||||||
|
|
||||||
self.set_model(self.filter_model)
|
self.set_model(self.filter_model)
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
def row_activated(self, widget, path, column):
|
||||||
|
list = self.filter_model
|
||||||
|
iter = list.get_iter(path)
|
||||||
|
row = list[iter]
|
||||||
|
self.actions.selected_row(row)
|
||||||
|
|
||||||
|
|
||||||
def freeze(self):
|
def freeze(self):
|
||||||
self.set_model(None)
|
self.set_model(None)
|
||||||
|
|
Loading…
Reference in New Issue