add escape to close the singlemessagewindow also add sendandclose button (as default)

This commit is contained in:
Nikos Kouremenos 2005-07-05 23:55:33 +00:00
parent 5df9361bc4
commit 7877b5c2ac
2 changed files with 96 additions and 64 deletions

View File

@ -822,12 +822,14 @@ class SingleMessageWindow:
self.message_tv_buffer = self.message_textview.get_buffer() self.message_tv_buffer = self.message_textview.get_buffer()
self.send_button = self.xml.get_widget('send_button') self.send_button = self.xml.get_widget('send_button')
self.reply_button = self.xml.get_widget('reply_button') self.reply_button = self.xml.get_widget('reply_button')
self.send_and_close_button = self.xml.get_widget('send_and_close_button')
self.message_tv_buffer.connect('changed', self.update_char_counter) self.message_tv_buffer.connect('changed', self.update_char_counter)
self.to_entry.set_text(self.contact.jid) self.to_entry.set_text(self.contact.jid)
self.send_button.set_no_show_all(True) self.send_button.set_no_show_all(True)
self.reply_button.set_no_show_all(True) self.reply_button.set_no_show_all(True)
self.send_and_close_button.set_no_show_all(True)
self.to_label.set_no_show_all(True) self.to_label.set_no_show_all(True)
self.to_entry.set_no_show_all(True) self.to_entry.set_no_show_all(True)
self.from_label.set_no_show_all(True) self.from_label.set_no_show_all(True)
@ -867,17 +869,19 @@ class SingleMessageWindow:
if action == 'send': if action == 'send':
title = _('Send %s') % title title = _('Send %s') % title
self.send_button.show() self.send_button.show()
self.send_and_close_button.show()
self.to_label.show() self.to_label.show()
self.to_entry.show() self.to_entry.show()
self.reply_button.hide() self.reply_button.hide()
self.from_label.hide() self.from_label.hide()
self.from_entry.hide() self.from_entry.hide()
elif action == 'receive': elif action == 'receive':
title = _('%s Received') % title title = _('Received %s') % title
self.reply_button.show() self.reply_button.show()
self.from_label.show() self.from_label.show()
self.from_entry.show() self.from_entry.show()
self.send_button.hide() self.send_button.hide()
self.send_and_close_button.hide()
self.to_label.hide() self.to_label.hide()
self.to_entry.hide() self.to_entry.hide()
@ -890,7 +894,7 @@ class SingleMessageWindow:
characters_no = self.message_tv_buffer.get_char_count() characters_no = self.message_tv_buffer.get_char_count()
self.count_chars_label.set_text(str(characters_no)) self.count_chars_label.set_text(str(characters_no))
def on_send_button_clicked(self, widget): def send_single_message(self):
to_whom_jid = self.to_entry.get_text() to_whom_jid = self.to_entry.get_text()
if to_whom_jid.find('@') == -1: # if no @ was given if to_whom_jid.find('@') == -1: # if no @ was given
ErrorDialog(_('Invalid contact ID'), ErrorDialog(_('Invalid contact ID'),
@ -907,15 +911,26 @@ class SingleMessageWindow:
self.subject_entry.set_text('') # we sent ok, clear the subject self.subject_entry.set_text('') # we sent ok, clear the subject
self.message_tv_buffer.set_text('') # we sent ok, clear the textview self.message_tv_buffer.set_text('') # we sent ok, clear the textview
def on_send_button_clicked(self, widget):
self.send_single_message()
def on_reply_button_clicked(self, widget): def on_reply_button_clicked(self, widget):
# we create a new blank window to send and we preset RE: and to jid # we create a new blank window to send and we preset RE: and to jid
self.subject = _('RE: %s') % self.subject self.subject = _('RE: %s') % self.subject
self.message = _('\n-< Original Message >-\n%s') % self.message self.message = _('\n\n\n== Original Message ==\n%s') % self.message
self.window.destroy() self.window.destroy()
SingleMessageWindow(self.plugin, self.account, self.contact, SingleMessageWindow(self.plugin, self.account, self.contact,
action = 'send', from_whom = self.from_whom, subject = self.subject, action = 'send', from_whom = self.from_whom, subject = self.subject,
message = self.message) message = self.message)
def on_send_and_close_button_clicked(self, widget):
self.send_single_message()
self.window.destroy()
def on_single_message_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: # ESCAPE
self.window.destroy()
class XMLConsoleWindow: class XMLConsoleWindow:
def __init__(self, plugin, account): def __init__(self, plugin, account):
self.plugin = plugin self.plugin = plugin

View File

@ -15400,7 +15400,7 @@ the Jabber network.</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
<property name="default_width">400</property> <property name="default_width">400</property>
<property name="default_height">250</property> <property name="default_height">280</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="decorated">True</property> <property name="decorated">True</property>
@ -15408,6 +15408,7 @@ the Jabber network.</property>
<property name="skip_pager_hint">False</property> <property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<signal name="key_press_event" handler="on_single_message_window_key_press_event" last_modification_time="Tue, 05 Jul 2005 22:02:15 GMT"/>
<child> <child>
<widget class="GtkVBox" id="vbox97"> <widget class="GtkVBox" id="vbox97">
@ -15648,77 +15649,21 @@ the Jabber network.</property>
<child> <child>
<widget class="GtkButton" id="send_button"> <widget class="GtkButton" id="send_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Send message</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Sen_d</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_send_button_clicked" last_modification_time="Tue, 05 Jul 2005 18:37:42 GMT"/> <signal name="clicked" handler="on_send_button_clicked" last_modification_time="Tue, 05 Jul 2005 18:37:42 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment81">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2981">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image861">
<property name="visible">True</property>
<property name="stock">gtk-ok</property>
<property name="icon_size">4</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">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label345">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send</property>
<property name="use_underline">True</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">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkButton" id="reply_button"> <widget class="GtkButton" id="reply_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Reply to this message</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
@ -15786,6 +15731,78 @@ the Jabber network.</property>
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkButton" id="send_and_close_button">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Send message and close window</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_send_and_close_button_clicked" last_modification_time="Tue, 05 Jul 2005 22:03:11 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment83">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2983">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image878">
<property name="visible">True</property>
<property name="stock">gtk-ok</property>
<property name="icon_size">4</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">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label347">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send &amp; Close</property>
<property name="use_underline">True</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">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">6</property> <property name="padding">6</property>