Autoread and mute buffer now are checkable items in the WX interface

This commit is contained in:
Manuel Cortez 2015-03-12 08:31:39 -06:00
parent e63db7b150
commit 05f75bf5d0
2 changed files with 19 additions and 4 deletions

View File

@ -153,6 +153,7 @@ class Controller(object):
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_profile, menuitem=self.view.updateProfile) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_profile, menuitem=self.view.updateProfile)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.user_details, menuitem=self.view.details) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.user_details, menuitem=self.view.details)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.toggle_autoread, menuitem=self.view.autoread) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.toggle_autoread, menuitem=self.view.autoread)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.toggle_buffer_mute, self.view.mute_buffer)
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed) widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
def set_systray_icon(self): def set_systray_icon(self):
@ -720,8 +721,17 @@ class Controller(object):
self.view.advance_selection(forward) self.view.advance_selection(forward)
def buffer_changed(self, *args, **kwargs): def buffer_changed(self, *args, **kwargs):
if self.get_current_buffer().account != self.current_account: buffer = self.get_current_buffer()
self.current_account = self.get_current_buffer().account if buffer.account != self.current_account:
self.current_account = buffer.account
if not hasattr(buffer, "session") or buffer.session == None: return
muted = autoread = False
if buffer.name in buffer.session.settings["other_buffers"]["muted_buffers"]:
muted = True
elif buffer.name in buffer.session.settings["other_buffers"]["autoread_buffers"]:
autoread = True
self.view.check_menuitem("mute_buffer", muted)
self.view.check_menuitem("autoread", autoread)
def fix_wrong_buffer(self): def fix_wrong_buffer(self):
buffer = self.get_current_buffer() buffer = self.get_current_buffer()

View File

@ -61,8 +61,9 @@ class mainFrame(wx.Frame):
# buffer menu # buffer menu
buffer = wx.Menu() buffer = wx.Menu()
self.load_previous_items = buffer.Append(wx.NewId(), _(u"&Load previous items")) self.load_previous_items = buffer.Append(wx.NewId(), _(u"&Load previous items"))
self.mute = buffer.Append(wx.NewId(), _(u"&Mute")) buffer.AppendSeparator()
self.autoread = buffer.Append(wx.NewId(), _(u"&Autoread tweets for this buffer")) self.mute_buffer = buffer.AppendCheckItem(wx.NewId(), _(u"&Mute"))
self.autoread = buffer.AppendCheckItem(wx.NewId(), _(u"&Autoread tweets for this buffer"))
self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer")) self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer"))
self.deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer")) self.deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
@ -181,5 +182,9 @@ class mainFrame(wx.Frame):
def set_focus(self): def set_focus(self):
self.SetFocus() self.SetFocus()
def check_menuitem(self, menuitem, check=True):
if hasattr(self, menuitem):
getattr(self, menuitem).Check(check)
def no_update_available(): def no_update_available():
wx.MessageDialog(None, _(u"Your TW Blue version is up to date"), _(u"Update"), style=wx.OK).ShowModal() wx.MessageDialog(None, _(u"Your TW Blue version is up to date"), _(u"Update"), style=wx.OK).ShowModal()