mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Integrate template edition into account settings dialog
This commit is contained in:
parent
b2f9aef7f7
commit
b4526c12c9
@ -5,9 +5,9 @@ from typing import List
|
|||||||
from sessions.twitter.templates import tweet_variables, dm_variables, person_variables
|
from sessions.twitter.templates import tweet_variables, dm_variables, person_variables
|
||||||
from wxUI.dialogs.twitterDialogs import templateDialogs
|
from wxUI.dialogs.twitterDialogs import templateDialogs
|
||||||
|
|
||||||
class editTemplateController(object):
|
class EditTemplate(object):
|
||||||
def __init__(self, template: str, type: str) -> None:
|
def __init__(self, template: str, type: str) -> None:
|
||||||
super(editTemplateController, self).__init__()
|
super(EditTemplate, self).__init__()
|
||||||
self.default_template = template
|
self.default_template = template
|
||||||
if type == "tweet":
|
if type == "tweet":
|
||||||
self.variables = tweet_variables
|
self.variables = tweet_variables
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import logging
|
||||||
import sound_lib
|
import sound_lib
|
||||||
import paths
|
import paths
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
@ -8,17 +9,18 @@ import config
|
|||||||
import languageHandler
|
import languageHandler
|
||||||
import output
|
import output
|
||||||
import application
|
import application
|
||||||
|
import config_utils
|
||||||
|
import keys
|
||||||
|
from collections import OrderedDict
|
||||||
|
from pubsub import pub
|
||||||
|
from mysc import autostart as autostart_windows
|
||||||
from wxUI.dialogs import configuration
|
from wxUI.dialogs import configuration
|
||||||
from wxUI import commonMessageDialogs
|
from wxUI import commonMessageDialogs
|
||||||
from extra.autocompletionUsers import settings
|
from extra.autocompletionUsers import settings
|
||||||
from extra.ocr import OCRSpace
|
from extra.ocr import OCRSpace
|
||||||
from pubsub import pub
|
from .editTemplateController import EditTemplate
|
||||||
import logging
|
|
||||||
import config_utils
|
|
||||||
log = logging.getLogger("Settings")
|
log = logging.getLogger("Settings")
|
||||||
import keys
|
|
||||||
from collections import OrderedDict
|
|
||||||
from mysc import autostart as autostart_windows
|
|
||||||
|
|
||||||
class globalSettingsController(object):
|
class globalSettingsController(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -152,6 +154,15 @@ class accountSettingsController(globalSettingsController):
|
|||||||
self.dialog.create_reporting()
|
self.dialog.create_reporting()
|
||||||
self.dialog.set_value("reporting", "speech_reporting", self.config["reporting"]["speech_reporting"])
|
self.dialog.set_value("reporting", "speech_reporting", self.config["reporting"]["speech_reporting"])
|
||||||
self.dialog.set_value("reporting", "braille_reporting", self.config["reporting"]["braille_reporting"])
|
self.dialog.set_value("reporting", "braille_reporting", self.config["reporting"]["braille_reporting"])
|
||||||
|
tweet_template = self.config["templates"]["tweet"]
|
||||||
|
dm_template = self.config["templates"]["dm"]
|
||||||
|
sent_dm_template = self.config["templates"]["dm_sent"]
|
||||||
|
person_template = self.config["templates"]["person"]
|
||||||
|
self.dialog.create_templates(tweet_template=tweet_template, dm_template=dm_template, sent_dm_template=sent_dm_template, person_template=person_template)
|
||||||
|
widgetUtils.connect_event(self.dialog.templates.tweet, widgetUtils.BUTTON_PRESSED, self.edit_tweet_template)
|
||||||
|
widgetUtils.connect_event(self.dialog.templates.dm, widgetUtils.BUTTON_PRESSED, self.edit_dm_template)
|
||||||
|
widgetUtils.connect_event(self.dialog.templates.sent_dm, widgetUtils.BUTTON_PRESSED, self.edit_sent_dm_template)
|
||||||
|
widgetUtils.connect_event(self.dialog.templates.person, widgetUtils.BUTTON_PRESSED, self.edit_person_template)
|
||||||
self.dialog.create_other_buffers()
|
self.dialog.create_other_buffers()
|
||||||
buffer_values = self.get_buffers_list()
|
buffer_values = self.get_buffers_list()
|
||||||
self.dialog.buffers.insert_buffers(buffer_values)
|
self.dialog.buffers.insert_buffers(buffer_values)
|
||||||
@ -160,7 +171,6 @@ class accountSettingsController(globalSettingsController):
|
|||||||
widgetUtils.connect_event(self.dialog.buffers.up, widgetUtils.BUTTON_PRESSED, self.dialog.buffers.move_up)
|
widgetUtils.connect_event(self.dialog.buffers.up, widgetUtils.BUTTON_PRESSED, self.dialog.buffers.move_up)
|
||||||
widgetUtils.connect_event(self.dialog.buffers.down, widgetUtils.BUTTON_PRESSED, self.dialog.buffers.move_down)
|
widgetUtils.connect_event(self.dialog.buffers.down, widgetUtils.BUTTON_PRESSED, self.dialog.buffers.move_down)
|
||||||
|
|
||||||
|
|
||||||
self.dialog.create_ignored_clients(self.config["twitter"]["ignored_clients"])
|
self.dialog.create_ignored_clients(self.config["twitter"]["ignored_clients"])
|
||||||
widgetUtils.connect_event(self.dialog.ignored_clients.add, widgetUtils.BUTTON_PRESSED, self.add_ignored_client)
|
widgetUtils.connect_event(self.dialog.ignored_clients.add, widgetUtils.BUTTON_PRESSED, self.add_ignored_client)
|
||||||
widgetUtils.connect_event(self.dialog.ignored_clients.remove, widgetUtils.BUTTON_PRESSED, self.remove_ignored_client)
|
widgetUtils.connect_event(self.dialog.ignored_clients.remove, widgetUtils.BUTTON_PRESSED, self.remove_ignored_client)
|
||||||
@ -185,6 +195,42 @@ class accountSettingsController(globalSettingsController):
|
|||||||
self.dialog.set_title(_(u"Account settings for %s") % (self.user,))
|
self.dialog.set_title(_(u"Account settings for %s") % (self.user,))
|
||||||
self.response = self.dialog.get_response()
|
self.response = self.dialog.get_response()
|
||||||
|
|
||||||
|
def edit_tweet_template(self, *args, **kwargs):
|
||||||
|
template = self.config["templates"]["tweet"]
|
||||||
|
control = EditTemplate(template=template, type="tweet")
|
||||||
|
result = control.run_dialog()
|
||||||
|
if result != "": # Template has been saved.
|
||||||
|
self.config["templates"]["tweet"] = result
|
||||||
|
self.config.write()
|
||||||
|
self.dialog.templates.tweet.SetLabel(_("Edit template for tweets. Current template: {}").format(result))
|
||||||
|
|
||||||
|
def edit_dm_template(self, *args, **kwargs):
|
||||||
|
template = self.config["templates"]["dm"]
|
||||||
|
control = EditTemplate(template=template, type="dm")
|
||||||
|
result = control.run_dialog()
|
||||||
|
if result != "": # Template has been saved.
|
||||||
|
self.config["templates"]["dm"] = result
|
||||||
|
self.config.write()
|
||||||
|
self.dialog.templates.dm.SetLabel(_("Edit template for direct messages. Current template: {}").format(result))
|
||||||
|
|
||||||
|
def edit_sent_dm_template(self, *args, **kwargs):
|
||||||
|
template = self.config["templates"]["dm_sent"]
|
||||||
|
control = EditTemplate(template=template, type="dm")
|
||||||
|
result = control.run_dialog()
|
||||||
|
if result != "": # Template has been saved.
|
||||||
|
self.config["templates"]["dm_sent"] = result
|
||||||
|
self.config.write()
|
||||||
|
self.dialog.templates.sent_dm.SetLabel(_("Edit template for sent direct messages. Current template: {}").format(result))
|
||||||
|
|
||||||
|
def edit_person_template(self, *args, **kwargs):
|
||||||
|
template = self.settings["templates"]["person"]
|
||||||
|
control = EditTemplate(template=template, type="person")
|
||||||
|
result = control.run_dialog()
|
||||||
|
if result != "": # Template has been saved.
|
||||||
|
self.config["templates"]["person"] = result
|
||||||
|
self.config.write()
|
||||||
|
self.dialog.templates.person.SetLabel(_("Edit template for persons. Current template: {}").format(result))
|
||||||
|
|
||||||
def save_configuration(self):
|
def save_configuration(self):
|
||||||
if self.config["general"]["relative_times"] != self.dialog.get_value("general", "relative_time"):
|
if self.config["general"]["relative_times"] != self.dialog.get_value("general", "relative_time"):
|
||||||
self.needs_restart = True
|
self.needs_restart = True
|
||||||
|
@ -233,6 +233,20 @@ class other_buffers(wx.Panel):
|
|||||||
buffers_list.append(self.buffers.get_text_column(i, 0))
|
buffers_list.append(self.buffers.get_text_column(i, 0))
|
||||||
return buffers_list
|
return buffers_list
|
||||||
|
|
||||||
|
class templates(wx.Panel, baseDialog.BaseWXDialog):
|
||||||
|
def __init__(self, parent, tweet_template, dm_template, sent_dm_template, person_template):
|
||||||
|
super(templates, self).__init__(parent)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
self.tweet = wx.Button(self, wx.ID_ANY, _("Edit template for tweets. Current template: {}").format(tweet_template))
|
||||||
|
sizer.Add(self.tweet, 0, wx.ALL, 5)
|
||||||
|
self.dm = wx.Button(self, wx.ID_ANY, _("Edit template for direct messages. Current template: {}").format(dm_template))
|
||||||
|
sizer.Add(self.dm, 0, wx.ALL, 5)
|
||||||
|
self.sent_dm = wx.Button(self, wx.ID_ANY, _("Edit template for sent direct messages. Current template: {}").format(sent_dm_template))
|
||||||
|
sizer.Add(self.sent_dm, 0, wx.ALL, 5)
|
||||||
|
self.person = wx.Button(self, wx.ID_ANY, _("Edit template for persons. Current template: {}").format(person_template))
|
||||||
|
sizer.Add(self.person, 0, wx.ALL, 5)
|
||||||
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
class ignoredClients(wx.Panel):
|
class ignoredClients(wx.Panel):
|
||||||
def __init__(self, parent, choices):
|
def __init__(self, parent, choices):
|
||||||
super(ignoredClients, self).__init__(parent=parent)
|
super(ignoredClients, self).__init__(parent=parent)
|
||||||
@ -380,6 +394,10 @@ class configurationDialog(baseDialog.BaseWXDialog):
|
|||||||
self.ignored_clients = ignoredClients(self.notebook, ignored_clients_list)
|
self.ignored_clients = ignoredClients(self.notebook, ignored_clients_list)
|
||||||
self.notebook.AddPage(self.ignored_clients, _(u"Ignored clients"))
|
self.notebook.AddPage(self.ignored_clients, _(u"Ignored clients"))
|
||||||
|
|
||||||
|
def create_templates(self, tweet_template, dm_template, sent_dm_template, person_template):
|
||||||
|
self.templates = templates(self.notebook, tweet_template=tweet_template, dm_template=dm_template, sent_dm_template=sent_dm_template, person_template=person_template)
|
||||||
|
self.notebook.AddPage(self.templates, _("Templates"))
|
||||||
|
|
||||||
def create_sound(self, output_devices, input_devices, soundpacks):
|
def create_sound(self, output_devices, input_devices, soundpacks):
|
||||||
self.sound = sound(self.notebook, output_devices, input_devices, soundpacks)
|
self.sound = sound(self.notebook, output_devices, input_devices, soundpacks)
|
||||||
self.notebook.AddPage(self.sound, _(u"Sound"))
|
self.notebook.AddPage(self.sound, _(u"Sound"))
|
||||||
|
Loading…
Reference in New Issue
Block a user