From 301bd5fd395fa3274ca14f1ed774b5d48113454a Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 20 Oct 2021 15:52:58 -0500 Subject: [PATCH 1/2] Pushed a new snapshot --- scripts/twblue_snapshot.nsi | 10 +++++----- src/application.py | 2 +- updates/snapshots.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/twblue_snapshot.nsi b/scripts/twblue_snapshot.nsi index 62f88198..f7d20764 100644 --- a/scripts/twblue_snapshot.nsi +++ b/scripts/twblue_snapshot.nsi @@ -15,10 +15,10 @@ SetCompressor /solid lzma SetDatablockOptimize on VIAddVersionKey ProductName "TWBlue Snapshot version" VIAddVersionKey LegalCopyright "Copyright 2014-2021 Manuel Cortéz." -VIAddVersionKey ProductVersion "9" -VIAddVersionKey FileVersion "9" -VIProductVersion "9.0.0.0" -VIFileVersion "9.0.0.0" +VIAddVersionKey ProductVersion "11" +VIAddVersionKey FileVersion "11" +VIProductVersion "11.0.0.0" +VIFileVersion "11.0.0.0" !insertmacro MUI_PAGE_WELCOME !define MUI_LICENSEPAGE_RADIOBUTTONS !insertmacro MUI_PAGE_LICENSE "license.txt" @@ -72,7 +72,7 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "D WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortéz" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "9" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "11" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "URLInfoAbout" "https://twblue.es" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMajor" 0 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMinor" 0 diff --git a/src/application.py b/src/application.py index e4253581..64d123da 100644 --- a/src/application.py +++ b/src/application.py @@ -9,7 +9,7 @@ if snapshot == False: update_url = 'https://twblue.es/updates/stable.php' mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/stable.json' else: - version = "10" + version = "11" update_url = 'https://twblue.es/updates/snapshot.php' mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/snapshots.json' authors = ["Manuel Cortéz", "José Manuel Delicado"] diff --git a/updates/snapshots.json b/updates/snapshots.json index 1b0348d7..ad94bf92 100644 --- a/updates/snapshots.json +++ b/updates/snapshots.json @@ -1,4 +1,4 @@ -{"current_version": "10", +{"current_version": "11", "description": "Snapshot version.", "date": "unknown", "downloads": From e3e0ac94579de99dadef7d6ee538116e1152f57c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 10:45:11 -0500 Subject: [PATCH 2/2] Added an alias manager dialog in the application menu --- doc/changelog.md | 1 + src/controller/mainController.py | 8 ++++ src/controller/userAliasController.py | 53 ++++++++++++++++++++++++ src/wxUI/dialogs/userAliasDialogs.py | 59 +++++++++++++++++++++++++++ src/wxUI/view.py | 1 + 5 files changed, 122 insertions(+) create mode 100644 src/controller/userAliasController.py diff --git a/doc/changelog.md b/doc/changelog.md index 3b8931e7..e0c489bc 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -2,6 +2,7 @@ ## changes in this version +* Added an user alias manager, located in the application menu in the menu bar. From this dialog, it is possible to review, add, edit or remove user aliases for the current account. ([#401](https://github.com/manuelcortez/TWBlue/issues/401)) * TWBlue now closes the VLC player window automatically when a video reaches its end. ([#399](https://github.com/manuelcortez/TWBlue/issues/399)) * After a lot of time, TWBlue now uses a new default Soundpack, called FreakyBlue. This soundpack will be set by default in all new sessions created in the application. Thanks to [Andre Louis](https://twitter.com/FreakyFwoof) for the pack. ([#247](https://github.com/manuelcortez/TWBlue/issues/247)) * When reading a tweet, if the tweet contains more than 2 consecutive mentions, TWBlue will announce how many more users the tweet includes, as opposed to read every user in the conversation. You still can display the tweet to read all users. diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 7241707f..c3d97ff9 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -2,6 +2,7 @@ import platform system = platform.system() import application +import wx import requests from audio_services import youtube_utils import arrow @@ -24,6 +25,7 @@ from sessions.twitter import utils, compose from sessionmanager import manager, sessionManager from controller import buffers from . import messages +from . import userAliasController import sessions from sessions.twitter import session as session_ from pubsub import pub @@ -189,6 +191,7 @@ class Controller(object): 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) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_buffer, self.view.update_buffer) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.manage_aliases, self.view.manageAliases) def set_systray_icon(self): self.systrayIcon = sysTrayIcon.SysTrayIcon() @@ -756,6 +759,11 @@ class Controller(object): buff.session.settings["user-aliases"][str(user_id)] = alias buff.session.settings.write() output.speak(_("Alias has been set correctly for {}.").format(user)) + pub.sendMessage("alias-added") + + def manage_aliases(self, *args, **kwargs): + buff = self.get_best_buffer() + alias_controller = userAliasController.userAliasController(buff.session.settings) def post_tweet(self, event=None): buffer = self.get_best_buffer() diff --git a/src/controller/userAliasController.py b/src/controller/userAliasController.py new file mode 100644 index 00000000..69a4fa8f --- /dev/null +++ b/src/controller/userAliasController.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +import widgetUtils +from pubsub import pub +from wxUI.dialogs import userAliasDialogs +from extra import autocompletionUsers + +class userAliasController(object): + def __init__(self, settings): + super(userAliasController, self).__init__() + self.settings = settings + self.dialog = userAliasDialogs.userAliasEditorDialog() + self.update_aliases_manager() + widgetUtils.connect_event(self.dialog.add, widgetUtils.BUTTON_PRESSED, self.on_add) + widgetUtils.connect_event(self.dialog.edit, widgetUtils.BUTTON_PRESSED, self.on_edit) + widgetUtils.connect_event(self.dialog.remove, widgetUtils.BUTTON_PRESSED, self.on_remove) + pub.subscribe(self.update_aliases_manager, "alias-added") + self.dialog.ShowModal() + + def update_aliases_manager(self): + self.dialog.users.Clear() + aliases = [self.settings["user-aliases"].get(k) for k in self.settings["user-aliases"].keys()] + if len(aliases) > 0: + self.dialog.users.InsertItems(aliases, 0) + self.dialog.on_selection_changes() + + def on_add(self, *args, **kwargs): + pub.sendMessage("execute-action", action="add_alias") + + def on_edit(self, *args, **kwargs): + selection = self.dialog.get_selected_user() + if selection != "": + edited = self.dialog.edit_alias_dialog(_("Edit alias for {}").format(selection)) + if edited == None or edited == "": + return + for user_key in self.settings["user-aliases"].keys(): + if self.settings["user-aliases"][user_key] == selection: + self.settings["user-aliases"][user_key] = edited + self.settings.write() + self.update_aliases_manager() + break + + def on_remove(self, *args, **kwargs): + selection = self.dialog.get_selected_user() + if selection == None or selection == "": + return + should_remove = self.dialog.remove_alias_dialog() + if should_remove: + for user_key in self.settings["user-aliases"].keys(): + if self.settings["user-aliases"][user_key] == selection: + self.settings["user-aliases"].pop(user_key) + self.settings.write() + self.update_aliases_manager() + break diff --git a/src/wxUI/dialogs/userAliasDialogs.py b/src/wxUI/dialogs/userAliasDialogs.py index 6fca9237..9156c0b5 100644 --- a/src/wxUI/dialogs/userAliasDialogs.py +++ b/src/wxUI/dialogs/userAliasDialogs.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import wx +import gettext from . import baseDialog class addAliasDialog(baseDialog.BaseWXDialog): @@ -34,3 +35,61 @@ class addAliasDialog(baseDialog.BaseWXDialog): def get_user(self): return (self.cb.GetValue(), self.alias.GetValue()) +class userAliasEditorDialog(wx.Dialog): + def __init__(self, *args, **kwds): + super(userAliasEditorDialog, self).__init__(parent=None) + self.SetTitle(_("Edit user aliases")) + main_sizer = wx.BoxSizer(wx.VERTICAL) + userListSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Users")), wx.VERTICAL) + main_sizer.Add(userListSizer, 1, wx.EXPAND, 0) + self.users = wx.ListBox(self, wx.ID_ANY, choices=[]) + self.users.Bind(wx.EVT_LISTBOX, self.on_selection_changes) + userListSizer.Add(self.users, 0, 0, 0) + actionsSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Actions")), wx.HORIZONTAL) + main_sizer.Add(actionsSizer, 1, wx.EXPAND, 0) + self.add = wx.Button(self, wx.ID_ANY, _("Add alias")) + self.add.SetToolTip(_("Adds a new user alias")) + actionsSizer.Add(self.add, 0, 0, 0) + self.edit = wx.Button(self, wx.ID_ANY, _("Edit")) + self.edit.SetToolTip(_("Edit the currently focused user Alias.")) + self.edit.Enable(False) + actionsSizer.Add(self.edit, 0, 0, 0) + self.remove = wx.Button(self, wx.ID_ANY, _("Remove")) + self.remove.SetToolTip(_("Remove the currently focused user alias.")) + self.remove.Enable(False) + actionsSizer.Add(self.remove, 0, 0, 0) + btnSizer = wx.StdDialogButtonSizer() + main_sizer.Add(btnSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4) + self.button_CLOSE = wx.Button(self, wx.ID_CLOSE, "") + btnSizer.AddButton(self.button_CLOSE) + btnSizer.Realize() + self.SetSizer(main_sizer) + main_sizer.Fit(self) + self.SetEscapeId(self.button_CLOSE.GetId()) + self.Layout() + + def on_selection_changes(self, *args, **kwargs): + selection = self.users.GetSelection() + if selection == -1: + self.enable_action_buttons(False) + else: + self.enable_action_buttons(True) + + def get_selected_user(self): + return self.users.GetStringSelection() + + def remove_alias_dialog(self, *args, **kwargs): + dlg = wx.MessageDialog(self, _("Are you sure you want to delete this user alias?"), _("Remove user alias"), wx.YES_NO) + if dlg.ShowModal() == wx.ID_YES: + return True + else: + return False + + def enable_action_buttons(self, enabled=True): + self.edit.Enable(enabled) + self.remove.Enable(enabled) + + def edit_alias_dialog(self, title): + dlg = wx.TextEntryDialog(self, title, _("User alias")) + if dlg.ShowModal() == wx.ID_OK: + return dlg.GetValue() \ No newline at end of file diff --git a/src/wxUI/view.py b/src/wxUI/view.py index 5e5f034b..2d260023 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -20,6 +20,7 @@ class mainFrame(wx.Frame): self.show_hide = app.Append(wx.ID_ANY, _(u"&Hide window")) self.menuitem_search = app.Append(wx.ID_ANY, _(u"&Search")) self.lists = app.Append(wx.ID_ANY, _(u"&Lists manager")) + self.manageAliases = app.Append(wx.ID_ANY, _("Manage user aliases")) self.keystroke_editor = app.Append(wx.ID_ANY, _(u"&Edit keystrokes")) self.account_settings = app.Append(wx.ID_ANY, _(u"Account se&ttings")) self.prefs = app.Append(wx.ID_PREFERENCES, _(u"&Global settings"))