Ejemplo n.º 1
0
    def _position_window(self, win, acct, type_):
        """
        Moves window according to config settings
        """
        if (self.mode in [
                self.ONE_MSG_WINDOW_NEVER,
                self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER
        ]):
            return

        if self.mode == self.ONE_MSG_WINDOW_ALWAYS:
            pos = (app.config.get('msgwin-x-position'),
                   app.config.get('msgwin-y-position'))
        elif self.mode == self.ONE_MSG_WINDOW_PERACCT:
            pos = (app.config.get_per('accounts', acct, 'msgwin-x-position'),
                   app.config.get_per('accounts', acct, 'msgwin-y-position'))
        elif self.mode == self.ONE_MSG_WINDOW_PERTYPE:
            pos = (app.config.get(type_ + '-msgwin-x-position'),
                   app.config.get(type_ + '-msgwin-y-position'))
        else:
            return

        move_window(win.window, pos[0], pos[1])
Ejemplo n.º 2
0
    def __init__(self,
                 account,
                 to='',
                 action='',
                 from_whom='',
                 subject='',
                 message='',
                 resource='',
                 session=None,
                 form_node=None):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        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.conversation_tv_buffer = self.conversation_textview.tv.get_buffer(
        )
        self._ui.conversation_scrolledwindow.add(self.conversation_textview.tv)

        self.form_widget = None
        parent_box = self._ui.conversation_scrolledwindow.get_parent()
        if form_node:
            self.form_widget = DataFormWidget(form_node)
            self.form_widget.show_all()
            self._ui.conversation_scrolledwindow.hide()
            self._ui.message_label_received.hide()
            parent_box.add(self.form_widget)
            parent_box.child_set_property(self.form_widget, 'top-attach', 2)
            parent_box.child_set_property(self.form_widget, 'left-attach', 0)
            parent_box.child_set_property(self.form_widget, 'width', 2)
            self.action = 'form'

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

        if app.config.get('use_speller') and app.is_installed(
                'GSPELL') and action == 'send':
            lang = app.config.get('speller_language')
            gspell_lang = Gspell.language_lookup(lang)
            if gspell_lang is None:
                AspellDictError(lang)
            else:
                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._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._ui.single_message_window,
                      app.config.get('single-msg-width'),
                      app.config.get('single-msg-height'))
        move_window(self._ui.single_message_window,
                    app.config.get('single-msg-x-position'),
                    app.config.get('single-msg-y-position'))

        self._ui.single_message_window.show_all()
Ejemplo n.º 3
0
    def __init__(self, jid=None, account=None):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_title(_('Conversation History'))

        self._ui = get_builder('history_window.ui')

        self.add(self._ui.history_box)

        self.history_textview = conversation_textview.ConversationTextview(
            account, used_in_history_window=True)
        self._ui.scrolledwindow.add(self.history_textview.tv)
        self.history_buffer = self.history_textview.tv.get_buffer()
        highlight_color = app.css_config.get_value(
            '.gajim-highlight-message', StyleAttr.COLOR)
        self.history_buffer.create_tag('highlight', background=highlight_color)
        self.history_buffer.create_tag('invisible', invisible=True)

        self.clearing_search = False

        # jid, contact_name, date, message, time, log_line_id
        model = Gtk.ListStore(str, str, str, str, str, int)
        self._ui.results_treeview.set_model(model)
        col = Gtk.TreeViewColumn(_('Name'))
        self._ui.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
        # user can click this header and sort
        col.set_sort_column_id(Column.CONTACT_NAME)
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Date'))
        self._ui.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.UNIXTIME)
        # user can click this header and sort
        col.set_sort_column_id(Column.UNIXTIME)
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Message'))
        self._ui.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.MESSAGE)
        col.set_resizable(True)

        self.jid = None  # The history we are currently viewing
        self.account = account
        self.completion_dict = {}
        self.accounts_seen_online = []  # Update dict when new accounts connect
        self.jids_to_search = []

        # This will load history too
        task = self._fill_completion_dict()
        GLib.idle_add(next, task)

        if jid:
            self._ui.query_entry.get_child().set_text(jid)
        else:
            self._load_history(None)

        resize_window(self,
                      app.config.get('history_window_width'),
                      app.config.get('history_window_height'))
        move_window(self,
                    app.config.get('history_window_x-position'),
                    app.config.get('history_window_y-position'))

        self._ui.connect_signals(self)
        self.connect('delete-event', self._on_delete)
        self.connect('destroy', self._on_destroy)
        self.connect('key-press-event', self._on_key_press)
        self.show_all()

        # PluginSystem: adding GUI extension point for
        # HistoryWindow instance object
        app.plugin_manager.gui_extension_point(
            'history_window', self)
Ejemplo n.º 4
0
    def __init__(self, jid=None, account=None):
        xml = util.get_builder('history_window.ui')
        self.window = xml.get_object('history_window')
        self.window.set_application(app.app)
        self.calendar = xml.get_object('calendar')
        self.button_first_day = xml.get_object('button_first_day')
        self.button_previous_day = xml.get_object('button_previous_day')
        self.button_next_day = xml.get_object('button_next_day')
        self.button_last_day = xml.get_object('button_last_day')
        scrolledwindow = xml.get_object('scrolledwindow')
        self.history_textview = conversation_textview.ConversationTextview(
            account, used_in_history_window=True)
        scrolledwindow.add(self.history_textview.tv)
        self.history_buffer = self.history_textview.tv.get_buffer()
        self.history_buffer.create_tag('highlight', background='yellow')
        self.history_buffer.create_tag('invisible', invisible=True)
        self.checkbutton = xml.get_object('log_history_checkbutton')
        self.show_status_checkbutton = xml.get_object(
            'show_status_checkbutton')
        self.search_entry = xml.get_object('search_entry')
        self.query_liststore = xml.get_object('query_liststore')
        self.jid_entry = xml.get_object('query_entry')
        self.results_treeview = xml.get_object('results_treeview')
        self.results_window = xml.get_object('results_scrolledwindow')
        self.search_in_date = xml.get_object('search_in_date')
        self.date_label = xml.get_object('date_label')
        self.search_menu_button = xml.get_object('search_menu_button')

        self.clearing_search = False

        # jid, contact_name, date, message, time, log_line_id
        model = Gtk.ListStore(str, str, str, str, str, int)
        self.results_treeview.set_model(model)
        col = Gtk.TreeViewColumn(_('Name'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
        # user can click this header and sort
        col.set_sort_column_id(Column.CONTACT_NAME)
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Date'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.UNIXTIME)
        # user can click this header and sort
        col.set_sort_column_id(Column.UNIXTIME)
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Message'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.MESSAGE)
        col.set_resizable(True)

        self.jid = None  # The history we are currently viewing
        self.account = account
        self.completion_dict = {}
        self.accounts_seen_online = []  # Update dict when new accounts connect
        self.jids_to_search = []

        # This will load history too
        task = self._fill_completion_dict()
        GLib.idle_add(next, task)

        if jid:
            self.jid_entry.get_child().set_text(jid)
        else:
            self._load_history(None)

        util.resize_window(self.window, app.config.get('history_window_width'),
                           app.config.get('history_window_height'))
        util.move_window(self.window,
                         app.config.get('history_window_x-position'),
                         app.config.get('history_window_y-position'))

        xml.connect_signals(self)
        self.window.show_all()

        # PluginSystem: adding GUI extension point for
        # HistoryWindow instance object
        app.plugin_manager.gui_extension_point('history_window', self)
Ejemplo n.º 5
0
    def __init__(self, account, to='', action='', from_whom='', subject='',
            message='', resource='', session=None, form_node=None):
        self.instances.append(self)
        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.xml = get_builder('single_message_window.ui')
        self.window = self.xml.get_object('single_message_window')
        self.count_chars_label = self.xml.get_object('count_chars_label')
        self.from_label = self.xml.get_object('from_label')
        self.from_entry = self.xml.get_object('from_entry')
        self.to_label = self.xml.get_object('to_label')
        self.to_entry = self.xml.get_object('to_entry')
        self.subject_entry = self.xml.get_object('subject_entry')
        self.message_scrolledwindow = self.xml.get_object(
                'message_scrolledwindow')
        self.message_textview = self.xml.get_object('message_textview')
        self.message_tv_buffer = self.message_textview.get_buffer()
        self.conversation_scrolledwindow = self.xml.get_object(
                'conversation_scrolledwindow')
        self.conversation_textview = ConversationTextview(
            account, used_in_history_window=True)
        self.conversation_textview.tv.show()
        self.conversation_tv_buffer = self.conversation_textview.tv.get_buffer()
        self.xml.get_object('conversation_scrolledwindow').add(
                self.conversation_textview.tv)

        self.form_widget = None
        parent_box = self.xml.get_object('conversation_scrolledwindow').\
                           get_parent()
        if form_node:
            dataform = dataforms.ExtendForm(node=form_node)
            dataform.type_ = 'submit'
            self.form_widget = DataFormWidget(dataform)
            self.form_widget.show_all()
            parent_box.add(self.form_widget)
            parent_box.child_set_property(self.form_widget, 'position',
                parent_box.child_get_property(self.xml.get_object(
                'conversation_scrolledwindow'), 'position'))
            self.action = 'form'

        self.send_button = self.xml.get_object('send_button')
        self.reply_button = self.xml.get_object('reply_button')
        self.send_and_close_button = self.xml.get_object('send_and_close_button')
        self.cancel_button = self.xml.get_object('cancel_button')
        self.close_button = self.xml.get_object('close_button')
        self.message_tv_buffer.connect('changed', self.update_char_counter)
        if isinstance(to, list):
            jid = ', '.join( [i[0].get_full_jid() for i in to])
            self.to_entry.set_text(jid)
            self.to_entry.set_sensitive(False)
        else:
            self.to_entry.set_text(to)

        if app.config.get('use_speller') and app.is_installed('GSPELL') and action == 'send':
            lang = app.config.get('speller_language')
            gspell_lang = Gspell.language_lookup(lang)
            if gspell_lang is None:
                AspellDictError(lang)
            else:
                spell_buffer = Gspell.TextBuffer.get_from_gtk_text_buffer(
                    self.message_textview.get_buffer())
                spell_buffer.set_spell_checker(Gspell.Checker.new(gspell_lang))
                spell_view = Gspell.TextView.get_from_gtk_text_view(
                    self.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 = ''
        self.subject_entry.set_text(self.subject)


        if to == '':
            liststore = get_completion_liststore(self.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_iconset_name_for(contact.show)
                liststore.append((status_icon, jid))
        else:
            self.completion_dict = {}
        self.xml.connect_signals(self)

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

        self.window.show_all()