Project

Profile

Help

Revision 45185932

ID45185932174ef92a287f5cbeee2f55df47760fa6
Parent 4994e1b7
Child b856b073

Added by Vincent Le Goff over 2 years ago

Fix #91: add a checkbox to disable auto-send-paste

View differences:

src/config.py
144 144

  
145 145
        # Create the ConfigObj
146 146
        try:
147
            config = ConfigObj(fullpath + ".conf", encoding="utf-8",
147
            config = ConfigObj(fullpath + ".conf", encoding="UTF8",
148 148
                    configspec=spec.split("\n"))
149
            config.backup_encoding = "utf-8"
149 150
        except (ParseError, UnicodeError):
150 151
            logger.warning("Unable to parse {}, try in latin-1 encoding".format(
151 152
                    repr(fullpath)))
152 153
            config = ConfigObj(fullpath + ".conf", configspec=spec.split("\n"), encoding="latin-1")
153
            config.encoding = "utf-8"
154
            config.encoding = "UTF8"
155
            config.backup_encoding = "utf-8"
154 156
            config.write()
155 157

  
156 158
        # Validates the configuration
......
243 245
    def load_options(self):
244 246
        """Load the file containing the options."""
245 247
        lang = locale.getdefaultlocale()[0].split("_")[0]
246
        spec = dedent("""
248
        spec = dedent(u"""
247 249
            [general]
248 250
                language = option('en', 'fr', default='{lang}')
249 251
                encoding = string(default="iso8859_15")
......
251 253

  
252 254
            [input]
253 255
                command_stacking = string(default=";")
256
                auto_send_paste = boolean(default=True)
254 257

  
255 258
            [output]
256 259
                richtext = boolean(default=True)
......
285 288
    def load_options(self):
286 289
        """Load the file containing the options."""
287 290
        world = self.world
288
        spec = dedent("""
291
        spec = dedent(u"""
289 292
            [connection]
290 293
                name = string
291 294
                hostname = string
src/translations/en/ui/dialog/preferences.yml
3 3
encodings: Encodings
4 4
input: Input
5 5
command_stacking: Command stacking
6
auto_send_paste: Send the text to the server when pasting from the clipboard
6 7
accessibility: Accessibility
7 8
screenreader: Enable screen reader support
8 9
TTS:
src/translations/fr/ui/dialog/preferences.yml
3 3
encodings: Encodages
4 4
input: Commandes
5 5
command_stacking: Multiple commandes
6
auto_send_paste: Envoyer le texte au serveur quand on colle depuis le presse-papier
6 7
accessibility: Accessibilité
7 8
screenreader: Activer le support pour lecteur d'écran
8 9
TTS:
src/ui/dialogs/preferences.py
250 250
        h_stacking = wx.Button(self,
251 251
                label=t("ui.button.what.command_stacking"))
252 252

  
253
        # Auto-send
254
        self.auto_send_paste = wx.CheckBox(self,
255
                label=t("ui.dialog.preferences.auto_send_paste"))
256
        self.auto_send_paste.SetValue(settings["options.input.auto_send_paste"])
257

  
253 258
        # Append to the sizer
254 259
        sizer.Add(l_stacking, pos=(0, 0))
255 260
        sizer.Add(t_stacking, pos=(1, 0))
256 261
        sizer.Add(h_stacking, pos=(0, 1))
262
        sizer.Add(self.auto_send_paste, pos=(2, 0))
257 263

  
258 264
        # Event binding
259 265
        h_stacking.Bind(wx.EVT_BUTTON, self.OnHelpStacking)
......
379 385
        old_language = settings.get_language()
380 386
        interrupt = accessibility.TTS_interrupt.GetValue()
381 387
        old_richtext = settings["options.output.richtext"]
388
        auto_send_paste = input.auto_send_paste.GetValue()
382 389
        richtext = accessibility.richtext.GetValue()
383 390
        srs = accessibility.srs_on.GetValue()
384 391
        settings["options.general.language"] = new_language
385 392
        settings["options.general.encoding"] = encoding
386 393
        settings["options.general.screenreader"] = srs
387 394
        settings["options.input.command_stacking"] = command_stacking
395
        settings["options.input.auto_send_paste"] = auto_send_paste
388 396
        settings["options.TTS.on"] = accessibility.TTS_on.GetValue()
389 397
        settings["options.TTS.outside"] = accessibility.TTS_outside.GetValue()
390 398
        settings["options.TTS.interrupt"] = interrupt
391 399
        settings["options.output.richtext"] = richtext
400
        print repr(settings["options.input.command_stacking"])
401
        import pdb; pdb.set_trace()
392 402
        settings["options"].write()
393 403
        self.engine.TTS_on = accessibility.TTS_on.GetValue()
394 404
        self.engine.TTS_outside  = accessibility.TTS_outside.GetValue()
src/ui/window.py
668 668
                    self.output.SetInsertionPoint(self.output.GetLastPosition())
669 669

  
670 670
                input = self.input + clipboard
671
                if input.endswith("\n"):
671
                if input.endswith("\n") and self.engine.settings[
672
                        "options.input.auto_send_paste"]:
672 673
                    lines = input.splitlines()
673 674
                    for line in lines:
674 675
                        self.OnInput(line)
src/world.py
163 163

  
164 164
        if self.settings is None:
165 165
            try:
166
                self.settings = ConfigObj(spec.split("\n"), encoding="latin-1")
167
            except ParseError:
166
                self.settings = ConfigObj(spec.split("\n"), encoding="utf-8")
167
            except (ParseError, UnicodeError):
168 168
                logger.warning("Error while parsing the config file, " \
169 169
                        "trying without encoding")
170 170
                self.settings = ConfigObj(spec.split("\n"))
171
                self.settings.encoding = "latin-1"
171
                self.settings.encoding = "utf-8"
172 172
                self.settings.write()
173 173

  
174 174
        connection = self.settings["connection"]
......
347 347
    @classmethod
348 348
    def get_infos(cls, configuration):
349 349
        """Get the information in the configuration and return a dict."""
350
        config = ConfigObj(StringIO(configuration), encoding="latin-1")
350
        config = ConfigObj(StringIO(configuration), encoding="utf-8")
351 351
        data = {}
352 352

  
353 353
        for key, value in config.items():

Also available in: Unified diff