diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 61443d55..81a6b243 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -58,10 +58,14 @@ class Controller(object): def bind_other_events(self): pub.subscribe(self.editing_keystroke, "editing_keystroke") + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.learn_sounds, menuitem=self.view.sounds_tutorial) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.exit, menuitem=self.view.close) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_tweet, self.view.compose) def __init__(self): super(Controller, self).__init__() - self.view = view.mainFrame(self) + self.view = view.mainFrame() self.buffers = [] self.view.prepare() self.bind_stream_events() @@ -138,7 +142,7 @@ class Controller(object): tl.timer = RepeatingTimer(180, tl.start_stream) tl.timer.start() - def search(self, event=None): + def search(self, *args, **kwargs): dlg = dialogs.search.searchDialog() if dlg.get_response() == widgetUtils.OK: term = dlg.get("term") @@ -200,7 +204,7 @@ class Controller(object): def delete(self): pass - def exit(self, event=None): + def exit(self, *args, **kwargs): for item in session.sessions: session.sessions[item].settings.write() session.sessions[item].main_stream.disconnect() diff --git a/src/wxUI/view.py b/src/wxUI/view.py index b3275d4e..79cb1397 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -11,96 +11,57 @@ class mainFrame(wx.Frame): # Application menu app = wx.Menu() - updateProfile = app.Append(wx.NewId(), _(u"&Update profile")) -# self.Bind(wx.EVT_MENU, self.controller.update_profile, updateProfile) - show_hide = app.Append(wx.NewId(), _(u"&Hide window")) -# self.Bind(wx.EVT_MENU, self.controller.show_hide, show_hide) - search = app.Append(wx.NewId(), _(u"&Search")) - self.Bind(wx.EVT_MENU, self.controller.search, search) - lists = app.Append(wx.NewId(), _(u"&Lists manager")) -# self.view.Bind(wx.EVT_MENU, self.list_manager, lists) - sounds_tutorial = app.Append(wx.NewId(), _(u"Sounds &tutorial")) - self.Bind(wx.EVT_MENU, self.controller.learn_sounds, sounds_tutorial) - keystroke_editor = app.Append(wx.NewId(), _(u"&Edit keystrokes")) - self.Bind(wx.EVT_MENU, self.controller.edit_keystrokes, keystroke_editor) - prefs = app.Append(wx.ID_PREFERENCES, _(u"&Preferences")) -# self.view.Bind(wx.EVT_MENU, self.preferences, prefs) - close = app.Append(wx.ID_EXIT, _(u"E&xit")) -# self.view.Bind(wx.EVT_MENU, self.close, close) + self.updateProfile = app.Append(wx.NewId(), _(u"&Update profile")) + self.show_hide = app.Append(wx.NewId(), _(u"&Hide window")) + self.menuitem_search = app.Append(wx.NewId(), _(u"&Search")) + self.lists = app.Append(wx.NewId(), _(u"&Lists manager")) + self.sounds_tutorial = app.Append(wx.NewId(), _(u"Sounds &tutorial")) + self.keystroke_editor = app.Append(wx.NewId(), _(u"&Edit keystrokes")) + self.prefs = app.Append(wx.ID_PREFERENCES, _(u"&Preferences")) + self.close = app.Append(wx.ID_EXIT, _(u"E&xit")) # Tweet menu tweet = wx.Menu() - compose = tweet.Append(wx.NewId(), _(u"&Tweet")) - self.Bind(wx.EVT_MENU, self.controller.post_tweet, compose) - response = tweet.Append(wx.NewId(), _(u"Re&ply")) -# self.view.Bind(wx.EVT_MENU, self.reply, response) - retweet = tweet.Append(wx.NewId(), _(u"&Retweet")) -# self.view.Bind(wx.EVT_MENU, self.retweet, retweet) - fav = tweet.Append(wx.NewId(), _(u"Add to &favourites")) -# self.view.Bind(wx.EVT_MENU, self.fav, fav) - unfav = tweet.Append(wx.NewId(), _(u"Remove from favo&urites")) -# self.view.Bind(wx.EVT_MENU, self.unfav, unfav) - view = tweet.Append(wx.NewId(), _(u"&Show tweet")) -# self.view.Bind(wx.EVT_MENU, self.view, view) - delete = tweet.Append(wx.NewId(), _(u"&Delete")) -# self.view.Bind(wx.EVT_MENU, self.delete, delete) + self.compose = tweet.Append(wx.NewId(), _(u"&Tweet")) + self.reply = tweet.Append(wx.NewId(), _(u"Re&ply")) + self.retweet = tweet.Append(wx.NewId(), _(u"&Retweet")) + self.fav = tweet.Append(wx.NewId(), _(u"Add to &favourites")) + self.unfav = tweet.Append(wx.NewId(), _(u"Remove from favo&urites")) + self.view = tweet.Append(wx.NewId(), _(u"&Show tweet")) + self.delete = tweet.Append(wx.NewId(), _(u"&Delete")) # User menu user = wx.Menu() - follow = user.Append(wx.NewId(), _(u"&Follow")) -# self.view.Bind(wx.EVT_MENU, self.onFollow, follow) - unfollow = user.Append(wx.NewId(), _(u"&Unfollow")) -# self.view.Bind(wx.EVT_MENU, self.onUnfollow, unfollow) - mute = user.Append(wx.NewId(), _(u"&Mute")) -# self.view.Bind(wx.EVT_MENU, self.onMute, mute) - unmute = user.Append(wx.NewId(), _(u"U&nmute")) -# self.view.Bind(wx.EVT_MENU, self.onUnmute, unmute) - report = user.Append(wx.NewId(), _(u"&Report as spam")) -# self.view.Bind(wx.EVT_MENU, self.onReport, report) - block = user.Append(wx.NewId(), _(u"&Block")) -# self.view.Bind(wx.EVT_MENU, self.onBlock, block) - unblock = user.Append(wx.NewId(), _(u"Unb&lock")) -# self.view.Bind(wx.EVT_MENU, self.onUnblock, unblock) - dm = user.Append(wx.NewId(), _(u"Direct me&ssage")) -# self.view.Bind(wx.EVT_MENU, self.dm, dm) - addToList = user.Append(wx.NewId(), _(u"&Add to list")) -# self.view.Bind(wx.EVT_MENU, self.add_to_list, addToList) - removeFromList = user.Append(wx.NewId(), _(u"R&emove from list")) -# self.view.Bind(wx.EVT_MENU, self.remove_from_list, removeFromList) - viewLists = user.Append(wx.NewId(), _(u"&View lists")) -# self.view.Bind(wx.EVT_MENU, self.view_user_lists, viewLists) - details = user.Append(wx.NewId(), _(u"Show user &profile")) -# self.view.Bind(wx.EVT_MENU, self.details, details) - timeline = user.Append(wx.NewId(), _(u"&Timeline")) -# self.view.Bind(wx.EVT_MENU, self.open_timeline, timeline) - favs = user.Append(wx.NewId(), _(u"V&iew favourites")) -# self.view.Bind(wx.EVT_MENU, self.favs_timeline, favs) + self.follow = user.Append(wx.NewId(), _(u"&Follow")) + self.unfollow = user.Append(wx.NewId(), _(u"&Unfollow")) + self.mute = user.Append(wx.NewId(), _(u"&Mute")) + self.unmute = user.Append(wx.NewId(), _(u"U&nmute")) + self.report = user.Append(wx.NewId(), _(u"&Report as spam")) + self.block = user.Append(wx.NewId(), _(u"&Block")) + self.unblock = user.Append(wx.NewId(), _(u"Unb&lock")) + self.dm = user.Append(wx.NewId(), _(u"Direct me&ssage")) + self.addToList = user.Append(wx.NewId(), _(u"&Add to list")) + self.removeFromList = user.Append(wx.NewId(), _(u"R&emove from list")) + self.viewLists = user.Append(wx.NewId(), _(u"&View lists")) + self.details = user.Append(wx.NewId(), _(u"Show user &profile")) + self.timeline = user.Append(wx.NewId(), _(u"&Timeline")) + self.favs = user.Append(wx.NewId(), _(u"V&iew favourites")) # buffer menu buffer = wx.Menu() - mute = buffer.Append(wx.NewId(), _(u"&Mute")) -# self.view.Bind(wx.EVT_MENU, self.toggle_mute, mute) - autoread = buffer.Append(wx.NewId(), _(u"&Autoread tweets for this buffer")) -# self.view.Bind(wx.EVT_MENU, self.toggle_autoread, autoread) - clear = buffer.Append(wx.NewId(), _(u"&Clear buffer")) -# self.view.Bind(wx.EVT_MENU, self.clear_list, clear) - deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer")) -# self.view.Bind(wx.EVT_MENU, self.delete_buffer, deleteTl) + self.mute = buffer.Append(wx.NewId(), _(u"&Mute")) + self.autoread = buffer.Append(wx.NewId(), _(u"&Autoread tweets for this buffer")) + self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer")) + self.deleteTl = buffer.Append(wx.NewId(), _(u"&Remove buffer")) # Help Menu help = wx.Menu() - doc = help.Append(-1, _(u"&Documentation")) -# self.view.Bind(wx.EVT_MENU, self.onManual, doc) - changelog = help.Append(wx.NewId(), _(u"&What's new in this version?")) -# self.view.Bind(wx.EVT_MENU, self.onChangelog, changelog) - check_for_updates = help.Append(wx.NewId(), _(u"&Check for updates")) -# self.view.Bind(wx.EVT_MENU, self.onCheckForUpdates, check_for_updates) - reportError = help.Append(wx.NewId(), _(u"&Report an error")) -# self.view.Bind(wx.EVT_MENU, self.onReportBug, reportError) - visit_website = help.Append(-1, _(u"TW Blue &website")) -# self.view.Bind(wx.EVT_MENU, self.onVisit_website, visit_website) - about = help.Append(-1, _(u"About &TW Blue")) -# self.view.Bind(wx.EVT_MENU, self.onAbout, about) + self.doc = help.Append(-1, _(u"&Documentation")) + self.changelog = help.Append(wx.NewId(), _(u"&What's new in this version?")) + self.check_for_updates = help.Append(wx.NewId(), _(u"&Check for updates")) + self.reportError = help.Append(wx.NewId(), _(u"&Report an error")) + self.visit_website = help.Append(-1, _(u"TW Blue &website")) + self.about = help.Append(-1, _(u"About &TW Blue")) # Add all to the menu Bar menuBar.Append(app, _(u"&Application")) @@ -110,40 +71,38 @@ class mainFrame(wx.Frame): menuBar.Append(help, _(u"&Help")) self.accel_tbl = wx.AcceleratorTable([ -(wx.ACCEL_CTRL, ord('N'), compose.GetId()), -(wx.ACCEL_CTRL, ord('R'), response.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('R'), retweet.GetId()), -(wx.ACCEL_CTRL, ord('F'), fav.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('F'), unfav.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('V'), view.GetId()), -(wx.ACCEL_CTRL, ord('D'), dm.GetId()), +(wx.ACCEL_CTRL, ord('N'), self.compose.GetId()), +(wx.ACCEL_CTRL, ord('R'), self.reply.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('R'), self.retweet.GetId()), +(wx.ACCEL_CTRL, ord('F'), self.fav.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('F'), self.unfav.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('V'), self.view.GetId()), +(wx.ACCEL_CTRL, ord('D'), self.dm.GetId()), -(wx.ACCEL_CTRL, ord('Q'), close.GetId()), -(wx.ACCEL_CTRL, ord('S'), follow.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('S'), unfollow.GetId()), -(wx.ACCEL_CTRL, ord('K'), block.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('K'), report.GetId()), -(wx.ACCEL_CTRL, ord('I'), timeline.GetId()), -(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('I'), deleteTl.GetId()), -(wx.ACCEL_CTRL, ord('M'), show_hide.GetId()), -(wx.ACCEL_CTRL, ord('P'), updateProfile.GetId()), +(wx.ACCEL_CTRL, ord('Q'), self.close.GetId()), +(wx.ACCEL_CTRL, ord('S'), self.follow.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('S'), self.unfollow.GetId()), +(wx.ACCEL_CTRL, ord('K'), self.block.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('K'), self.report.GetId()), +(wx.ACCEL_CTRL, ord('I'), self.timeline.GetId()), +(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('I'), self.deleteTl.GetId()), +(wx.ACCEL_CTRL, ord('M'), self.show_hide.GetId()), +(wx.ACCEL_CTRL, ord('P'), self.updateProfile.GetId()), ]) self.SetAcceleratorTable(self.accel_tbl) return menuBar ### MAIN - def __init__(self, controller): + def __init__(self): """ Main function of this class.""" super(mainFrame, self).__init__(None, -1, "TW Blue", size=(1600, 1600)) - self.controller = controller self.panel = wx.Panel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetTitle("TW Blue") self.SetMenuBar(self.makeMenus()) self.nb = wx.Treebook(self.panel, wx.NewId()) self.buffers = {} - self.SetMenuBar(self.makeMenus()) def add_buffer(self, buffer, name): self.nb.AddPage(buffer, name)