diff --git a/changelog.md b/changelog.md index bfa1609..0727e43 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,8 @@ * A new buffer, called online, has been added in the friends section. It contains friends currently connected to VK. Items in this buffer will be added as soon as new friends are online in the social network, and will be removed when friends are offline. This buffer needs a lot of testing. Please report any possible inconsistency on this method. * Added new options to open the config and logs folder, these options are located in the help menu and may be useful during error reporting. * Added experimental support to "subscribers" buffer, inside frienship requests. This shows friend requests that have been declined by the current user. +* the message when an user is typing in conversation buffers will be announced only if the socializer window is focused. +* In "my audios" buffer, there is a button that allows a direct audio upload from your computer. The audio will be placed in your library. * Fixed an error in Socializer that was making it unable to detect unread messages properly. * Socializer should save all tracebacks directly to error.log instead of displaying an error message during exit. ([#27,](https://code.manuelcortez.net/manuelcortez/socializer/issues/27)) * When displaying user profiles, fixed an error where a married person without specifing relation partner would cause an error in the program. ([#29,](https://code.manuelcortez.net/manuelcortez/socializer/issues/29)) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 555c146..a3f5622 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -12,6 +12,7 @@ import interactors import views import config import paths +import win32gui from vk_api.exceptions import LoginRequired, VkApiError from requests.exceptions import ConnectionError from pubsub import pub @@ -74,6 +75,14 @@ class Controller(object): self.create_controls() call_threaded(updater.do_update, update_type=self.session.settings["general"]["update_channel"]) + def is_focused(self): + """ Return True if the Socializer Window is Focused. """ + app_title = "socializer" + window_title = win32gui.GetWindowText(win32gui.GetForegroundWindow()).lower() + if app_title == window_title: + return True + return False + ### action function # These functions are called by other parts of the program, and are not connected to any event at all. def create_controls(self): @@ -495,9 +504,8 @@ class Controller(object): """ Indicates when someone is typing. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. """ - # ToDo: Need to identify a way to do this only if the main Socializer window is focused. buffer = self.search_chat_buffer(obj.user_id) - if buffer != None and buffer == self.get_current_buffer(): + if buffer != None and buffer == self.get_current_buffer() and self.is_focused(): user = self.session.get_user(obj.user_id) output.speak(_("{user1_nom} is typing...").format(**user))