From 158b48e4d53d3fb42813e1f055214ec83f38be4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Mon, 31 Aug 2015 10:08:34 -0500 Subject: [PATCH] Add and remove user to list are implemented in GUI --- src/controller/mainController.py | 30 ++++++++++++++++++++++++++++-- src/wxUI/dialogs/lists.py | 1 + src/wxUI/view.py | 1 - 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 6d21e375..4aa1a5be 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -174,6 +174,8 @@ class Controller(object): widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.report_error, self.view.reportError) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.view_documentation, self.view.doc) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_list, self.view.addToList) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_list, self.view.removeFromList) def set_systray_icon(self): self.systrayIcon = sysTrayIcon.SysTrayIcon() @@ -496,8 +498,32 @@ class Controller(object): except TwythonError as e: output.speak("error %s: %s" % (e.error_code, e.msg)) - def remove_from_list(self, user): - pass + def remove_from_list(self, *args, **kwargs): + buff = self.get_best_buffer() + if not hasattr(buff, "get_right_tweet"): return + tweet = buff.get_right_tweet() + if buff.type != "people": + users = utils.get_all_users(tweet, buff.session.db) + else: + users = [tweet["screen_name"]] + dlg = dialogs.utils.selectUserDialog(_(u"Select the user"), users) + if dlg.get_response() == widgetUtils.OK: + user = dlg.get_user() + else: + return + dlg = dialogs.lists.removeUserListDialog() + dlg.populate_list([compose.compose_list(item) for item in buff.session.db["lists"]]) + if dlg.get_response() == widgetUtils.OK: + try: + list = buff.session.twitter.twitter.delete_list_member(list_id=buff.session.db["lists"][dlg.get_item()]["id"], screen_name=user) + older_list = utils.find_item(buff.session.db["lists"][dlg.get_item()]["id"], buff.session.db["lists"]) + listBuffer = self.search_buffer("%s-list" % (buff.session.db["lists"][dlg.get_item()]["name"].lower()), buff.session.db["user_name"]) + if listBuffer != None: listBuffer.get_user_ids() + buff.session.db["lists"].pop(older_list) + buff.session.db["lists"].append(list) + if listBuffer != None: pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session) + except TwythonError as e: + output.speak("error %s: %s" % (e.error_code, e.msg)) def list_manager(self, *args, **kwargs): s = self.get_best_buffer().session diff --git a/src/wxUI/dialogs/lists.py b/src/wxUI/dialogs/lists.py index c3bf0ed7..3e5e0d74 100644 --- a/src/wxUI/dialogs/lists.py +++ b/src/wxUI/dialogs/lists.py @@ -123,6 +123,7 @@ class removeUserListDialog(listViewer): self.SetTitle(_(u"Select a list to remove the user")) self.createBtn.SetLabel(_(u"Remove")) self.createBtn.SetDefault() + self.createBtn.SetId(wx.ID_OK) self.editBtn.Disable() self.view.Disable() # self.subscriptors.Disable() diff --git a/src/wxUI/view.py b/src/wxUI/view.py index ec50dd70..214604cf 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -41,7 +41,6 @@ class mainFrame(wx.Frame): 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.removeFromList.Enable(False) self.viewLists = user.Append(wx.NewId(), _(u"&View lists")) self.viewLists.Enable(False) self.details = user.Append(wx.NewId(), _(u"Show user &profile"))