def reconfig(self): for w in self.windows(): self.save_state(w) mode = app.config.get('one_message_window') if self.mode == common.config.opt_one_window_types.index(mode): # No change return self.mode = common.config.opt_one_window_types.index(mode) controls = [] for w in self.windows(): # Note, we are taking care not to hide/delete the roster window when the # MessageWindow is embedded. if not w.parent_paned: w.window.hide() else: # Stash current size so it can be restored if the MessageWindow # is not longer embedded roster_width = w.parent_paned.get_position() app.config.set('roster_width', roster_width) while w.notebook.get_n_pages(): page = w.notebook.get_nth_page(0) ctrl = w._widget_to_control(page) w.notebook.remove_page(0) page.unparent() controls.append(ctrl) # Must clear _controls to prevent MessageControl.shutdown calls w._controls = {} if not w.parent_paned: w.window.destroy() else: # Don't close parent window, just remove the child child = w.parent_paned.get_child2() w.parent_paned.remove(child) self.parent_win.lookup_action('show-roster').set_enabled(False) resize_window(w.window, app.config.get('roster_width'), app.config.get('roster_height')) self._windows = {} for ctrl in controls: mw = self.get_window(ctrl.contact.jid, ctrl.account) if not mw: mw = self.create_window(ctrl.contact, ctrl.account, ctrl.type_id) ctrl.parent_win = mw ctrl.add_actions() ctrl.update_actions() mw.new_tab(ctrl)
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()
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)
def resize(self, width, height): resize_window(self.window, width, height)
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)
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()