xml console is now hidden instead of destroyed, has an enable checkbutton and a clear button, and scroll to the end if we was at the end

This commit is contained in:
Yann Leboulanger 2005-08-06 00:38:24 +00:00
parent 2187606bc8
commit 5cca92fb4e
4 changed files with 116 additions and 8 deletions

View File

@ -1321,8 +1321,12 @@ class XMLConsoleWindow:
self.window = self.xml.get_widget('xml_console_window')
self.input_textview = self.xml.get_widget('input_textview')
self.stanzas_log_textview = self.xml.get_widget('stanzas_log_textview')
self.input_tv_buffer = self.input_textview.get_buffer()
buffer = self.stanzas_log_textview.get_buffer()
end_iter = buffer.get_end_iter()
buffer.create_mark('end', end_iter, False)
self.tagIn = buffer.create_tag('incoming')
color = gajim.config.get('inmsgcolor')
self.tagIn.set_property('foreground', color)
@ -1330,8 +1334,9 @@ class XMLConsoleWindow:
color = gajim.config.get('outmsgcolor')
self.tagOut.set_property('foreground', color)
self.enable = False
self.stanzas_log_textview.modify_text(
self.input_textview.modify_text(
gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
if len(gajim.connections) > 1:
@ -1342,13 +1347,43 @@ class XMLConsoleWindow:
self.window.set_title(title)
self.xml.signal_autoconnect(self)
self.window.show_all()
def print_stanza(self, stanza, tag):
# tag must be 'incoming' or 'outgoing'
def on_xml_console_window_delete_event(self, widget, event):
self.window.hide()
return True # do NOT destroy the window
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.enable = widget.get_active()
def scroll_to_end(self, ):
parent = self.stanzas_log_textview.get_parent()
buffer = self.stanzas_log_textview.get_buffer()
self.stanzas_log_textview.scroll_to_mark(buffer.get_mark('end'), 0, True,
0, 1)
adjustment = parent.get_hadjustment()
adjustment.set_value(0)
return False
def print_stanza(self, stanza, kind):
# kind must be 'incoming' or 'outgoing'
if not self.enable:
return
buffer = self.stanzas_log_textview.get_buffer()
at_the_end = False
end_iter = buffer.get_end_iter()
buffer.insert_with_tags_by_name(end_iter, stanza + '\n\n', tag)
end_rect = self.stanzas_log_textview.get_iter_location(end_iter)
visible_rect = self.stanzas_log_textview.get_visible_rect()
if end_rect.y <= (visible_rect.y + visible_rect.height):
at_the_end = True
end_iter = buffer.get_end_iter()
buffer.insert_with_tags_by_name(end_iter, stanza + '\n\n', kind)
if at_the_end:
gobject.idle_add(self.scroll_to_end)
def on_send_button_clicked(self, widget):
begin_iter, end_iter = self.input_tv_buffer.get_bounds()

View File

@ -1106,6 +1106,8 @@ class Interface:
self.windows['roster'] = self.roster
for account in gajim.connections:
self.windows[account]['xml_console'] = \
dialogs.XMLConsoleWindow(self, account)
self.register_handlers(gajim.connections[account])
gobject.timeout_add(100, self.autoconnect)

View File

@ -16710,6 +16710,7 @@ Maybe I'll refactor later</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="destroy" handler="on_xml_console_window_destroy" last_modification_time="Mon, 04 Jul 2005 20:12:04 GMT"/>
<signal name="delete_event" handler="on_xml_console_window_delete_event" last_modification_time="Sat, 06 Aug 2005 00:03:05 GMT"/>
<child>
<widget class="GtkVBox" id="vbox">
@ -16774,6 +16775,77 @@ Maybe I'll refactor later</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2988">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="enable_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Enable</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_enable_checkbutton_toggled" last_modification_time="Sat, 06 Aug 2005 00:13:30 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label351">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="clear_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-clear</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_clear_button_clicked" last_modification_time="Sat, 06 Aug 2005 00:20:16 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander">
<property name="visible">True</property>

View File

@ -936,8 +936,7 @@ class RosterWindow:
if self.plugin.windows[account].has_key('xml_console'):
self.plugin.windows[account]['xml_console'].window.present()
else:
self.plugin.windows[account]['xml_console'] = \
dialogs.XMLConsoleWindow(self.plugin, account)
self.plugin.windows[account]['xml_console'].window.show_all()
def on_edit_account(self, widget, account):
if self.plugin.windows[account].has_key('account_modification'):