Added 'custom' notifications for chat settings
This commit is contained in:
parent
1affb38cd5
commit
2699feada5
@ -4,6 +4,18 @@ from wxUI.dialogs import configuration as configurationUI
|
||||
|
||||
class configuration(object):
|
||||
|
||||
def get_notification_type(self, value):
|
||||
if value == _(u"Native"):
|
||||
return "native"
|
||||
else:
|
||||
return "custom"
|
||||
|
||||
def get_notification_label(self, value):
|
||||
if value == "native":
|
||||
return _(u"Native")
|
||||
else:
|
||||
return _(u"Custom")
|
||||
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
self.dialog = configurationUI.configurationDialog(_(u"Preferences"))
|
||||
@ -19,6 +31,7 @@ class configuration(object):
|
||||
self.dialog.set_value("chat", "notify_offline", self.session.settings["chat"]["notify_offline"])
|
||||
self.dialog.set_value("chat", "open_unread_conversations", self.session.settings["chat"]["open_unread_conversations"])
|
||||
self.dialog.set_value("chat", "automove_to_conversations", self.session.settings["chat"]["automove_to_conversations"])
|
||||
self.dialog.set_value("chat", "notifications", self.get_notification_label(self.session.settings["chat"]["notifications"]))
|
||||
self.dialog.realize()
|
||||
self.response = self.dialog.get_response()
|
||||
|
||||
@ -29,4 +42,5 @@ class configuration(object):
|
||||
self.session.settings["chat"]["notify_offline"] = self.dialog.get_value("chat", "notify_offline")
|
||||
self.session.settings["chat"]["open_unread_conversations"] = self.dialog.get_value("chat", "open_unread_conversations")
|
||||
self.session.settings["chat"]["automove_to_conversations"] = self.dialog.get_value("chat", "automove_to_conversations")
|
||||
self.session.settings["chat"]["notifications"] = self.get_notification_type(self.dialog.get_value("chat", "notifications"))
|
||||
self.session.settings.write()
|
||||
|
@ -11,6 +11,7 @@ import posts
|
||||
import profiles
|
||||
import webbrowser
|
||||
import logging
|
||||
import output
|
||||
import longpollthread
|
||||
import selector
|
||||
from vk_api.exceptions import LoginRequired, VkApiError
|
||||
@ -376,14 +377,16 @@ class Controller(object):
|
||||
return
|
||||
user_name = self.session.get_user_name(event.user_id, "nom")
|
||||
msg = _(u"{0} is online.").format(user_name,)
|
||||
self.window.notify(_("Socializer"), msg)
|
||||
sound = "friend_online.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
|
||||
def user_offline(self, event):
|
||||
if self.session.settings["chat"]["notify_offline"] == False:
|
||||
return
|
||||
user_name = self.session.get_user_name(event.user_id, "nom")
|
||||
msg = _(u"{0} is offline.").format(user_name,)
|
||||
self.window.notify(_("Socializer"), msg)
|
||||
sound = "friend_offline.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
|
||||
def get_chat(self, obj=None):
|
||||
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
|
||||
@ -617,5 +620,11 @@ class Controller(object):
|
||||
def view_my_profile_in_browser(self, *args, **kwargs):
|
||||
webbrowser.open_new_tab("https://vk.com/id{id}".format(id=self.session.user_id,))
|
||||
|
||||
def notify(self, message=""):
|
||||
self.window.notify(_("Socializer"), message)
|
||||
def notify(self, message="", sound="", type="native"):
|
||||
if type == "native":
|
||||
self.window.notify(_("Socializer"), message)
|
||||
else:
|
||||
if sound != "":
|
||||
self.session.soundplayer.play(sound)
|
||||
if message != "":
|
||||
output.speak(message)
|
@ -22,4 +22,5 @@ current_soundpack = string(default="default")
|
||||
notify_online = boolean(default=True)
|
||||
notify_offline = boolean(default=True)
|
||||
open_unread_conversations = boolean(default=True)
|
||||
automove_to_conversations = boolean(default=True)
|
||||
automove_to_conversations = boolean(default=True)
|
||||
notifications = string(default="custom")
|
BIN
src/sounds/default/friend_offline.ogg
Normal file
BIN
src/sounds/default/friend_offline.ogg
Normal file
Binary file not shown.
BIN
src/sounds/default/friend_online.ogg
Normal file
BIN
src/sounds/default/friend_online.ogg
Normal file
Binary file not shown.
@ -36,6 +36,12 @@ class chat(wx.Panel, widgetUtils.BaseDialog):
|
||||
sizer.Add(self.open_unread_conversations, 0, wx.ALL, 5)
|
||||
self.automove_to_conversations = wx.CheckBox(self, wx.NewId(), _(u"Move focus to new conversations"))
|
||||
sizer.Add(self.automove_to_conversations, 0, wx.ALL, 5)
|
||||
lbl = wx.StaticText(self, wx.NewId(), _(u"Notification type"))
|
||||
self.notifications = wx.ComboBox(self, wx.NewId(), choices=[_(u"Native"), _(u"Custom"),], value=_(u"Native"), style=wx.CB_READONLY)
|
||||
nbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
nbox.Add(lbl, 0, wx.ALL, 5)
|
||||
nbox.Add(self.notifications, 0, wx.ALL, 5)
|
||||
sizer.Add(nbox, 0, wx.ALL, 5)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class configurationDialog(widgetUtils.BaseDialog):
|
||||
|
Loading…
Reference in New Issue
Block a user