From c7a83055b15c9c2e963be6d57d07f0098abd90fc Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 1 Aug 2018 00:47:57 +0300 Subject: [PATCH] various fixes --- toxygen/contacts/contacts_manager.py | 5 +++-- toxygen/middleware/callbacks.py | 2 +- toxygen/ui/main_screen.py | 5 +++-- toxygen/wrapper/tox.py | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/toxygen/contacts/contacts_manager.py b/toxygen/contacts/contacts_manager.py index 9b4ad93..c1d0b10 100644 --- a/toxygen/contacts/contacts_manager.py +++ b/toxygen/contacts/contacts_manager.py @@ -203,8 +203,9 @@ class ContactsManager(ToxSave): self._settings['sorting'] = self._sorting self._settings.save() # update active contact - index = self._contacts.index(contact) - self.set_active(index) + if contact is not None: + index = self._contacts.index(contact) + self.set_active(index) def update_filtration(self): """ diff --git a/toxygen/middleware/callbacks.py b/toxygen/middleware/callbacks.py index f8300ff..36bb960 100644 --- a/toxygen/middleware/callbacks.py +++ b/toxygen/middleware/callbacks.py @@ -409,7 +409,7 @@ def group_invite(window, settings, tray, profile, groups_service, contacts_provi if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY'] and not settings.locked: friend = contacts_provider.get_friend_by_number(friend_number) title = util_ui.tr('New invite to group chat') - text = util_ui.tr('{} invites you to group {}').format(friend.name, group_name) + text = util_ui.tr('{} invites you to group "{}"').format(friend.name, group_name) invoke_in_main_thread(tray_notification, title, text, tray, window) icon = os.path.join(util.get_images_directory(), 'icon_new_messages.png') invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon)) diff --git a/toxygen/ui/main_screen.py b/toxygen/ui/main_screen.py index edf7ac6..4cccdd5 100644 --- a/toxygen/ui/main_screen.py +++ b/toxygen/ui/main_screen.py @@ -678,8 +678,9 @@ class MainWindow(QtWidgets.QMainWindow): def _selected_contact_changed(self): num = self.friends_list.currentRow() - self._contacts_manager.active_contact = num - self.groupMenuButton.setVisible(not self._contacts_manager.is_active_a_friend()) + if self._contacts_manager.active_contact != num: + self._contacts_manager.active_contact = num + self.groupMenuButton.setVisible(self._contacts_manager.is_active_a_group()) def mouseReleaseEvent(self, event): pos = self.connection_status.pos() diff --git a/toxygen/wrapper/tox.py b/toxygen/wrapper/tox.py index d705293..782020c 100644 --- a/toxygen/wrapper/tox.py +++ b/toxygen/wrapper/tox.py @@ -1553,10 +1553,11 @@ class Tox: error = c_int() peer_info = self.group_self_peer_info_new() nick = bytes(nick, 'utf-8') + group_name = group_name.encode('utf-8') peer_info.contents.nick = c_char_p(nick) peer_info.contents.nick_length = len(nick) peer_info.contents.user_status = status - result = Tox.libtoxcore.tox_group_new(self._tox_pointer, privacy_state, group_name.encode('utf-8'), + result = Tox.libtoxcore.tox_group_new(self._tox_pointer, privacy_state, group_name, len(group_name), peer_info, byref(error)) return result @@ -2180,11 +2181,12 @@ class Tox: result = Tox.libtoxcore.tox_group_invite_friend(self._tox_pointer, group_number, friend_number, byref(error)) return result - def group_self_peer_info_new(self): + @staticmethod + def group_self_peer_info_new(): error = c_int() f = Tox.libtoxcore.tox_group_self_peer_info_new f.restype = POINTER(GroupChatSelfPeerInfo) - result = f(self._tox_pointer, byref(error)) + result = f(byref(error)) return result