Announcement of users typing will be send only when the socializer window is focused

This commit is contained in:
Manuel Cortez 2019-02-26 16:17:53 -06:00
parent b3f5c532dd
commit 55eaa85979
2 changed files with 12 additions and 2 deletions

View File

@ -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. * 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 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. * 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. * 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)) * 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)) * 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))

View File

@ -12,6 +12,7 @@ import interactors
import views import views
import config import config
import paths import paths
import win32gui
from vk_api.exceptions import LoginRequired, VkApiError from vk_api.exceptions import LoginRequired, VkApiError
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from pubsub import pub from pubsub import pub
@ -74,6 +75,14 @@ class Controller(object):
self.create_controls() self.create_controls()
call_threaded(updater.do_update, update_type=self.session.settings["general"]["update_channel"]) 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 ### action function
# These functions are called by other parts of the program, and are not connected to any event at all. # These functions are called by other parts of the program, and are not connected to any event at all.
def create_controls(self): def create_controls(self):
@ -495,9 +504,8 @@ class Controller(object):
""" Indicates when someone is typing. """ Indicates when someone is typing.
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. @ 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) 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) user = self.session.get_user(obj.user_id)
output.speak(_("{user1_nom} is typing...").format(**user)) output.speak(_("{user1_nom} is typing...").format(**user))