Exemple #1
0
    def _on_use_speller(value, *args):
        if not value:
            return

        lang = app.settings.get('speller_language')
        gspell_lang = Gspell.language_lookup(lang)
        if gspell_lang is None:
            gspell_lang = Gspell.language_get_default()
        app.settings.set('speller_language', gspell_lang.get_code())
        for ctrl in get_app_window('Preferences').get_all_controls():
            if isinstance(ctrl, ChatControlBase):
                ctrl.set_speller()
Exemple #2
0
 def _apply_speller(self):
     if app.settings.get('use_speller') and app.is_installed('GSPELL'):
         lang = app.settings.get('speller_language')
         gspell_lang = Gspell.language_lookup(lang)
         if gspell_lang is None:
             gspell_lang = Gspell.language_get_default()
         spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
             self._message_buffer)
         spell_buffer.set_spell_checker(Gspell.Checker.new(gspell_lang))
         spell_view = Gspell.TextView.get_from_gtk_text_view(
             self._ui.message_textview)
         spell_view.set_inline_spell_checking(True)
         spell_view.set_enable_language_menu(True)
Exemple #3
0
 def on_speller_checkbutton_toggled(self, widget):
     active = widget.get_active()
     app.config.set('use_speller', active)
     if not active:
         return
     lang = app.config.get('speller_language')
     gspell_lang = Gspell.language_lookup(lang)
     if gspell_lang is None:
         gspell_lang = Gspell.language_get_default()
     if gspell_lang is None:
         AspellDictError(lang)
         app.config.set('use_speller', False)
         widget.set_active(False)
     else:
         app.config.set('speller_language', gspell_lang.get_code())
         self.apply_speller()
Exemple #4
0
    def __init__(self, account, to='', action='', from_whom='', subject='',
                 message='', resource='', session=None):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_title(_('Send Single Message'))
        self.set_name('SendSingleMessageWindow')
        self.account = account
        self._action = action

        self._subject = subject
        self._message = message
        self._to = to
        self._from_whom = from_whom
        self._resource = resource
        self._session = session

        self._ui = get_builder('single_message_window.ui')
        self._message_tv_buffer = self._ui.message_textview.get_buffer()
        self._conversation_textview = ConversationTextview(
            account, used_in_history_window=True)
        self._conversation_textview.tv.show()
        self._conversation_textview.tv.set_left_margin(6)
        self._conversation_textview.tv.set_right_margin(6)
        self._conversation_textview.tv.set_top_margin(6)
        self._conversation_textview.tv.set_bottom_margin(6)
        self._ui.conversation_scrolledwindow.add(
            self._conversation_textview.tv)

        self._message_tv_buffer.connect('changed', self._update_char_counter)
        if isinstance(to, list):
            jid = ', '.join([i[0].jid for i in to])
            self._ui.to_entry.set_text(jid)
        else:
            self._ui.to_entry.set_text(to)

        if (app.settings.get('use_speller') and
                app.is_installed('GSPELL') and
                action == 'send'):
            lang = app.settings.get('speller_language')
            gspell_lang = Gspell.language_lookup(lang)
            if gspell_lang is None:
                gspell_lang = Gspell.language_get_default()
            spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
                self._ui.message_textview.get_buffer())
            spell_buffer.set_spell_checker(Gspell.Checker.new(gspell_lang))
            spell_view = Gspell.TextView.get_from_gtk_text_view(
                self._ui.message_textview)
            spell_view.set_inline_spell_checking(True)
            spell_view.set_enable_language_menu(True)

        self._prepare_widgets_for(self._action)

        # set_text(None) raises TypeError exception
        if self._subject is None:
            self._subject = _('(No subject)')
        self._ui.subject_entry.set_text(self._subject)
        self._ui.subject_from_entry_label.set_text(self._subject)

        if to == '':
            liststore = get_completion_liststore(self._ui.to_entry)
            self._completion_dict = helpers.get_contact_dict_for_account(
                account)
            keys = sorted(self._completion_dict.keys())
            for jid in keys:
                contact = self._completion_dict[jid]
                status_icon = get_icon_name(contact.show)
                liststore.append((status_icon, jid))
        else:
            self._completion_dict = {}

        self.add(self._ui.box)

        self.connect('delete-event', self._on_delete)
        self.connect('destroy', self._on_destroy)
        self.connect('key-press-event', self._on_key_press_event)

        self._ui.to_entry.connect('changed', self._on_to_entry_changed)
        self._ui.connect_signals(self)

        # get window position and size from config
        resize_window(self,
                      app.settings.get('single-msg-width'),
                      app.settings.get('single-msg-height'))
        move_window(self,
                    app.settings.get('single-msg-x-position'),
                    app.settings.get('single-msg-y-position'))

        self.show_all()