Added buttons for toggling favorites and bookmarks in base buffer's GUI

This commit is contained in:
Manuel Cortez 2022-11-17 16:57:49 -06:00
parent 10d4d47a17
commit cbc4fd0632
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 17 additions and 1 deletions

View File

@ -228,6 +228,8 @@ class BaseBuffer(base.Buffer):
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.share_item, self.buffer.boost) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.share_item, self.buffer.boost)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.dm) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.dm)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.toggle_favorite, self.buffer.fav)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.toggle_bookmark, self.buffer.bookmark)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key)
@ -460,7 +462,7 @@ class BaseBuffer(base.Buffer):
item = item.reblog item = item.reblog
call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id) call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id)
def toggle_favorite(self): def toggle_favorite(self, *args, **kwargs):
item = self.get_item() item = self.get_item()
if item.reblog != None: if item.reblog != None:
item = item.reblog item = item.reblog
@ -470,6 +472,16 @@ class BaseBuffer(base.Buffer):
else: else:
call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id) call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id)
def toggle_bookmark(self, *args, **kwargs):
item = self.get_item()
if item.reblog != None:
item = item.reblog
item = self.session.api.status(item.id)
if item.bookmarked == False:
call_threaded(self.session.api_call, call_name="status_bookmark", preexec_message=_("Adding to bookmarks..."), _sound="favourite.ogg", id=item.id)
else:
call_threaded(self.session.api_call, call_name="status_unbookmark", preexec_message=_("Removing from bookmarks..."), _sound="favourite.ogg", id=item.id)
def view_item(self): def view_item(self):
post = self.get_item() post = self.get_item()
# Update object so we can retrieve newer stats # Update object so we can retrieve newer stats

View File

@ -24,11 +24,15 @@ class basePanel(wx.Panel):
self.post = wx.Button(self, -1, _("Post")) self.post = wx.Button(self, -1, _("Post"))
self.boost = wx.Button(self, -1, _("Boost")) self.boost = wx.Button(self, -1, _("Boost"))
self.reply = wx.Button(self, -1, _(u"Reply")) self.reply = wx.Button(self, -1, _(u"Reply"))
self.fav = wx.Button(self, wx.ID_ANY, _("Favorite"))
self.bookmark = wx.Button(self, wx.ID_ANY, _("Bookmark"))
self.dm = wx.Button(self, -1, _(u"Direct message")) self.dm = wx.Button(self, -1, _(u"Direct message"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(self.post, 0, wx.ALL, 5) btnSizer.Add(self.post, 0, wx.ALL, 5)
btnSizer.Add(self.boost, 0, wx.ALL, 5) btnSizer.Add(self.boost, 0, wx.ALL, 5)
btnSizer.Add(self.reply, 0, wx.ALL, 5) btnSizer.Add(self.reply, 0, wx.ALL, 5)
btnSizer.Add(self.fav, 0, wx.ALL, 5)
btnSizer.Add(self.bookmark, 0, wx.ALL, 5)
btnSizer.Add(self.dm, 0, wx.ALL, 5) btnSizer.Add(self.dm, 0, wx.ALL, 5)
self.sizer.Add(btnSizer, 0, wx.ALL, 5) self.sizer.Add(btnSizer, 0, wx.ALL, 5)
self.sizer.Add(self.list.list, 0, wx.ALL|wx.EXPAND, 5) self.sizer.Add(self.list.list, 0, wx.ALL|wx.EXPAND, 5)