Remove old XML Console

This commit is contained in:
Philipp Hörist 2017-08-10 01:08:42 +02:00
parent fc4bc7eabb
commit e6f1d29471
1 changed files with 0 additions and 174 deletions

View File

@ -3347,180 +3347,6 @@ class SingleMessageWindow:
self.save_pos()
self.window.destroy()
class XMLConsoleWindow:
def __init__(self, account):
self.account = account
self.xml = gtkgui_helpers.get_gtk_builder('xml_console_window.ui')
self.window = self.xml.get_object('xml_console_window')
self.input_textview = self.xml.get_object('input_textview')
self.stanzas_log_textview = self.xml.get_object('stanzas_log_textview')
self.input_tv_buffer = self.input_textview.get_buffer()
self.parent = self.stanzas_log_textview.get_parent()
buffer_ = self.stanzas_log_textview.get_buffer()
self.tagIn = buffer_.create_tag('incoming')
color = gajim.config.get('inmsgcolor')
self.tagIn.set_property('foreground', color)
self.tagInPresence = buffer_.create_tag('incoming_presence')
self.tagInPresence.set_property('foreground', color)
self.tagInMessage = buffer_.create_tag('incoming_message')
self.tagInMessage.set_property('foreground', color)
self.tagInIq = buffer_.create_tag('incoming_iq')
self.tagInIq.set_property('foreground', color)
self.tagOut = buffer_.create_tag('outgoing')
color = gajim.config.get('outmsgcolor')
self.tagOut.set_property('foreground', color)
self.tagOutPresence = buffer_.create_tag('outgoing_presence')
self.tagOutPresence.set_property('foreground', color)
self.tagOutMessage = buffer_.create_tag('outgoing_message')
self.tagOutMessage.set_property('foreground', color)
self.tagOutIq = buffer_.create_tag('outgoing_iq')
self.tagOutIq.set_property('foreground', color)
buffer_.create_tag('') # Default tag
self.enabled = True
self.xml.get_object('enable_checkbutton').set_active(True)
if len(gajim.connections) > 1:
title = _('XML Console for %s') % self.account
else:
title = _('XML Console')
self.window.set_title(title)
self.window.show_all()
gajim.ged.register_event_handler('stanza-received', ged.GUI1,
self._nec_stanza_received)
gajim.ged.register_event_handler('stanza-sent', ged.GUI1,
self._nec_stanza_sent)
self.xml.connect_signals(self)
def on_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_Escape:
self.window.destroy()
def on_xml_console_window_destroy(self, widget):
del gajim.interface.instances[self.account]['xml_console']
gajim.ged.remove_event_handler('stanza-received', ged.GUI1,
self._nec_stanza_received)
gajim.ged.remove_event_handler('stanza-sent', ged.GUI1,
self._nec_stanza_sent)
def on_clear_button_clicked(self, widget):
buffer_ = self.stanzas_log_textview.get_buffer()
buffer_.set_text('')
def on_enable_checkbutton_toggled(self, widget):
self.enabled = widget.get_active()
def on_in_stanza_checkbutton_toggled(self, widget):
active = widget.get_active()
self.tagIn.set_property('invisible', active)
self.tagInPresence.set_property('invisible', active)
self.tagInMessage.set_property('invisible', active)
self.tagInIq.set_property('invisible', active)
def on_presence_stanza_checkbutton_toggled(self, widget):
active = widget.get_active()
self.tagInPresence.set_property('invisible', active)
self.tagOutPresence.set_property('invisible', active)
def on_out_stanza_checkbutton_toggled(self, widget):
active = widget.get_active()
self.tagOut.set_property('invisible', active)
self.tagOutPresence.set_property('invisible', active)
self.tagOutMessage.set_property('invisible', active)
self.tagOutIq.set_property('invisible', active)
def on_message_stanza_checkbutton_toggled(self, widget):
active = widget.get_active()
self.tagInMessage.set_property('invisible', active)
self.tagOutMessage.set_property('invisible', active)
def on_iq_stanza_checkbutton_toggled(self, widget):
active = widget.get_active()
self.tagInIq.set_property('invisible', active)
self.tagOutIq.set_property('invisible', active)
def print_stanza(self, stanza, kind):
# kind must be 'incoming' or 'outgoing'
if not self.enabled:
return
if not stanza:
return
at_the_end = gtkgui_helpers.at_the_end(self.parent)
buffer = self.stanzas_log_textview.get_buffer()
end_iter = buffer.get_end_iter()
type_ = ''
if stanza[1:9] == 'presence':
type_ = 'presence'
elif stanza[1:8] == 'message':
type_ = 'message'
elif stanza[1:3] == 'iq':
type_ = 'iq'
if type_:
type_ = kind + '_' + type_
else:
type_ = kind # 'incoming' or 'outgoing'
if kind == 'incoming':
buffer.insert_with_tags_by_name(end_iter, '<!-- In %s -->\n' % \
time.strftime('%c'), type_)
elif kind == 'outgoing':
buffer.insert_with_tags_by_name(end_iter, '<!-- Out %s -->\n' % \
time.strftime('%c'), type_)
end_iter = buffer.get_end_iter()
buffer.insert_with_tags_by_name(end_iter, stanza.replace('><', '>\n<') \
+ '\n\n', type_)
if at_the_end:
GLib.idle_add(gtkgui_helpers.scroll_to_end, self.parent)
def _nec_stanza_received(self, obj):
if obj.conn.name != self.account:
return
self.print_stanza(obj.stanza_str, 'incoming')
def _nec_stanza_sent(self, obj):
if obj.conn.name != self.account:
return
self.print_stanza(obj.stanza_str, 'outgoing')
def on_send_button_clicked(self, widget):
if gajim.connections[self.account].connected <= 1:
# if offline or connecting
ErrorDialog(_('Connection not available'),
_('Please make sure you are connected with "%s".') % \
self.account)
return
begin_iter, end_iter = self.input_tv_buffer.get_bounds()
stanza = self.input_tv_buffer.get_text(begin_iter, end_iter, True)
if stanza:
gajim.connections[self.account].send_stanza(stanza)
self.input_tv_buffer.set_text('') # we sent ok, clear the textview
def on_presence_button_clicked(self, widget):
self.input_tv_buffer.set_text(
'<presence><show></show><status></status><priority></priority>'
'</presence>')
def on_iq_button_clicked(self, widget):
self.input_tv_buffer.set_text(
'<iq to="" type=""><query xmlns=""></query></iq>')
def on_message_button_clicked(self, widget):
self.input_tv_buffer.set_text(
'<message to="" type=""><body></body></message>')
def on_expander_activate(self, widget):
if not widget.get_expanded(): # it's the opposite!
# it's expanded!!
self.input_textview.grab_focus()
#Action that can be done with an incoming list of contacts
TRANSLATED_ACTION = {'add': _('add'), 'modify': _('modify'),