Added the update current buffer function

This commit is contained in:
Manuel Cortez 2016-02-25 04:52:02 -06:00
parent 7946f3cced
commit 34b6a50e47
3 changed files with 18 additions and 17 deletions

View File

@ -118,6 +118,8 @@ class feedBuffer(baseBuffer):
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [self.insert(i) for i in self.session.db[self.name]["items"][:num]]
def update(self):
output.speak(_(u"Wall buffers can't get up to 100 items."))
class audioBuffer(feedBuffer): class audioBuffer(feedBuffer):
def create_tab(self, parent): def create_tab(self, parent):

View File

@ -38,15 +38,15 @@ class Controller(object):
self.connect_events() self.connect_events()
def create_controls(self): def create_controls(self):
home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed", identifier="id") home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed")
self.buffers.append(home) self.buffers.append(home)
self.window.add_buffer(home.tab, _(u"Home")) self.window.add_buffer(home.tab, _(u"Home"))
self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers) self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers)
self.repeatedUpdate.start() self.repeatedUpdate.start()
feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", identifier="id") feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall")
self.buffers.append(feed) self.buffers.append(feed)
self.window.add_buffer(feed.tab, _(u"My wall")) self.window.add_buffer(feed.tab, _(u"My wall"))
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, identifier="aid") audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True)
self.buffers.append(audio) self.buffers.append(audio)
self.window.add_buffer(audio.tab, _(u"My audios")) self.window.add_buffer(audio.tab, _(u"My audios"))
@ -93,7 +93,6 @@ class Controller(object):
call_threaded(player.player.play, audio_object) call_threaded(player.player.play, audio_object)
def view_post(self, post_object, controller_): def view_post(self, post_object, controller_):
print controller_
p = getattr(posts, controller_)(self.session, post_object) p = getattr(posts, controller_)(self.session, post_object)
p.dialog.get_response() p.dialog.get_response()
p.dialog.Destroy() p.dialog.Destroy()
@ -105,5 +104,4 @@ class Controller(object):
def update_buffer(self, *args, **kwargs): def update_buffer(self, *args, **kwargs):
b = self.get_current_buffer() b = self.get_current_buffer()
b.update() b.get_items()
print "updated"

View File

@ -14,16 +14,17 @@ sessions = {}
# Saves possible set of identifier keys for VK'S data types # Saves possible set of identifier keys for VK'S data types
# see https://vk.com/dev/datatypes for more information. # see https://vk.com/dev/datatypes for more information.
# I've added the Date identifier (this is a field in unix time format), for special objects (like friendships indicators) because these objects doesn't have an own identifier. # I've added the Date identifier (this is a field in unix time format), for special objects (like friendships indicators) because these objects doesn't have an own identifier.
identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"] identifiers = ["date", "aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"]
def find_item(list, item): def find_item(list, item):
""" Finds an item in a list by taking an identifier""" """ Finds an item in a list by taking an identifier"""
# determines the kind of identifier that we are using # determines the kind of identifier that we are using
global identifiers global identifiers
identifier = None identifier = "date"
for i in identifiers: # for i in identifiers:
if item.has_key(i): # if item.has_key(i):
identifier = i # identifier = i
# break
if identifier == None: if identifier == None:
# if there are objects that can't be processed by lack of identifier, let's print keys for finding one. # if there are objects that can't be processed by lack of identifier, let's print keys for finding one.
print item.keys() print item.keys()
@ -125,14 +126,14 @@ class vkSession(object):
if i.has_key("type") and i["type"] == "wall_photo": continue if i.has_key("type") and i["type"] == "wall_photo": continue
if find_item(self.db[name]["items"], i) == False: if find_item(self.db[name]["items"], i) == False:
# if i not in self.db[name]["items"]: # if i not in self.db[name]["items"]:
if first_addition or show_nextpage == True: if first_addition == True or show_nextpage == True:
if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].append(i) if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].append(i)
else: self.db[name]["items"].insert(0, i) else: self.db[name]["items"].insert(0, i)
else: else:
if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].insert(0, i) if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].insert(0, i)
else: self.db[name]["items"].append(i) else: self.db[name]["items"].append(i)
num = num+1 num = num+1
print len(self.db[name]["items"])
return num return num
def __init__(self, session_id): def __init__(self, session_id):
@ -186,14 +187,14 @@ class vkSession(object):
def get_newsfeed(self, name="newsfeed", show_nextpage=False, endpoint="", *args, **kwargs): def get_newsfeed(self, name="newsfeed", show_nextpage=False, endpoint="", *args, **kwargs):
if show_nextpage == True: if show_nextpage == True:
kwargs["start_from"] = self.db[name]["cursor"] kwargs["start_from"] = self.db[name]["cursor"]
kwargs["v"] = "5.21" print kwargs
data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs) data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs)
if data != None: if data != None:
if show_nextpage == False: if show_nextpage == False:
self.process_usernames(data) self.process_usernames(data)
else: # else:
print data.keys() # print data.keys(), len(data["items"]), data["next_from"]
num = self.order_buffer(name, data["items"][:-1], show_nextpage) num = self.order_buffer(name, data["items"], show_nextpage)
print data.keys() print data.keys()
self.db[name]["cursor"] = data["next_from"] self.db[name]["cursor"] = data["next_from"]
return num return num