keep the stream flowing
This commit is contained in:
parent
112df2abe2
commit
0f8d45219a
1 changed files with 25 additions and 7 deletions
|
@ -194,6 +194,8 @@ class Timeline(Gtk.Box):
|
||||||
super().__init__(orientation='vertical')
|
super().__init__(orientation='vertical')
|
||||||
|
|
||||||
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||||
|
self.max_id = 0
|
||||||
|
self.min_id = 0
|
||||||
|
|
||||||
scroller = Gtk.ScrolledWindow(
|
scroller = Gtk.ScrolledWindow(
|
||||||
halign='fill',
|
halign='fill',
|
||||||
|
@ -209,6 +211,7 @@ class Timeline(Gtk.Box):
|
||||||
self.load_timeline()
|
self.load_timeline()
|
||||||
|
|
||||||
self.view.connect('button-press-event', self.on_button_pressed)
|
self.view.connect('button-press-event', self.on_button_pressed)
|
||||||
|
scroller.connect('edge-reached', self.on_edge_reached)
|
||||||
|
|
||||||
action_group = Gio.SimpleActionGroup()
|
action_group = Gio.SimpleActionGroup()
|
||||||
|
|
||||||
|
@ -241,15 +244,25 @@ class Timeline(Gtk.Box):
|
||||||
builder = Gtk.Builder.new_from_resource("/dev/thrrgilag/squeak/menu.ui")
|
builder = Gtk.Builder.new_from_resource("/dev/thrrgilag/squeak/menu.ui")
|
||||||
self.menu = builder.get_object("post-menu")
|
self.menu = builder.get_object("post-menu")
|
||||||
|
|
||||||
def load_timeline(self):
|
def load_timeline(self, older=False):
|
||||||
|
params = {
|
||||||
|
'include_raw': 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if older:
|
||||||
|
params['before_id'] = self.min_id
|
||||||
|
|
||||||
if self.stream == 'unified':
|
if self.stream == 'unified':
|
||||||
posts, meta = pnutpy.api.users_post_streams_unified(include_raw=1)
|
posts, meta = pnutpy.api.users_post_streams_unified(**params)
|
||||||
elif self.stream == 'mentions':
|
elif self.stream == 'mentions':
|
||||||
posts, meta = pnutpy.api.users_mentioned_posts('me', include_raw=1)
|
posts, meta = pnutpy.api.users_mentioned_posts('me', **params)
|
||||||
elif self.stream == 'bookmarks':
|
elif self.stream == 'bookmarks':
|
||||||
posts, meta = pnutpy.api.users_bookmarked_posts('me', include_raw=1)
|
posts, meta = pnutpy.api.users_bookmarked_posts('me', **params)
|
||||||
else:
|
else:
|
||||||
posts, meta = pnutpy.api.posts_streams_global(include_raw=1)
|
posts, meta = pnutpy.api.posts_streams_global(**params)
|
||||||
|
|
||||||
|
self.max_id = meta.max_id
|
||||||
|
self.min_id = meta.min_id
|
||||||
|
|
||||||
for item in posts:
|
for item in posts:
|
||||||
if 'is_deleted' in item:
|
if 'is_deleted' in item:
|
||||||
|
@ -258,6 +271,8 @@ class Timeline(Gtk.Box):
|
||||||
postitem.connect('menu-pressed', self.show_menu)
|
postitem.connect('menu-pressed', self.show_menu)
|
||||||
self.view.add(postitem)
|
self.view.add(postitem)
|
||||||
|
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
def do_refresh(self):
|
def do_refresh(self):
|
||||||
rows = self.view.get_children()
|
rows = self.view.get_children()
|
||||||
for item in rows:
|
for item in rows:
|
||||||
|
@ -265,10 +280,13 @@ class Timeline(Gtk.Box):
|
||||||
self.load_timeline()
|
self.load_timeline()
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
def on_edge_reached(self, widget, pos):
|
||||||
|
if pos == Gtk.PositionType.BOTTOM:
|
||||||
|
self.load_timeline(True)
|
||||||
|
|
||||||
def on_button_pressed(self, widget, event):
|
def on_button_pressed(self, widget, event):
|
||||||
logging.debug("-blarp-")
|
|
||||||
if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
|
if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
|
||||||
logging.debug("-blarp- right button")
|
pass
|
||||||
|
|
||||||
def show_menu(self, widget, index):
|
def show_menu(self, widget, index):
|
||||||
self.post_index = index
|
self.post_index = index
|
||||||
|
|
Loading…
Reference in a new issue