add close button [no new string here, thanks to GTK+] and show it for when we read received single messages instead of showing cancel [which is when we send]; add icon to send button; move ui preparation code to the right method and add some code to handle show/hide for close/cancel button. add a fixme for after 0.9 for string thing

This commit is contained in:
Nikos Kouremenos 2005-12-08 14:51:35 +00:00
parent b5aa849dc5
commit b284ea89a0
2 changed files with 115 additions and 23 deletions

View File

@ -969,6 +969,9 @@ class SingleMessageWindow:
self.subject = subject
self.message = message
self.to = to
self.from_whom = from_whom
self.resource = resource
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'single_message_window', APP)
self.window = self.xml.get_widget('single_message_window')
@ -983,6 +986,8 @@ class SingleMessageWindow:
self.send_button = self.xml.get_widget('send_button')
self.reply_button = self.xml.get_widget('reply_button')
self.send_and_close_button = self.xml.get_widget('send_and_close_button')
self.cancel_button = self.xml.get_widget('cancel_button')
self.close_button = self.xml.get_widget('close_button')
self.message_tv_buffer.connect('changed', self.update_char_counter)
self.to_entry.set_text(to)
@ -1002,26 +1007,11 @@ class SingleMessageWindow:
self.to_entry.set_no_show_all(True)
self.from_label.set_no_show_all(True)
self.from_entry.set_no_show_all(True)
self.close_button.set_no_show_all(True)
self.cancel_button.set_no_show_all(True)
self.prepare_widgets_for(self.action)
if self.action == 'send':
if self.message: # we come from a reply?
self.message_textview.grab_focus()
else: # we write a new message
if to: # do we already have jid?
self.subject_entry.grab_focus()
elif self.action == 'receive':
self.from_whom = from_whom
fjid = from_whom # Full jid of sender (with resource)
if resource:
fjid += '/' + resource
self.from_entry.set_text(fjid)
self.from_entry.set_property('editable', False)
self.subject_entry.set_property('editable', False)
self.message_textview.set_editable(False)
self.reply_button.grab_focus()
# set_text(None) raises TypeError exception
if self.subject is None:
self.subject = ''
@ -1063,11 +1053,12 @@ class SingleMessageWindow:
def prepare_widgets_for(self, action):
if len(gajim.connections) > 1:
#FIXME: for Received with should become 'in'
title = _('Single Message with account %s') % self.account
else:
title = _('Single Message')
if action == 'send':
if action == 'send': # prepare UI for Sending
title = _('Send %s') % title
self.send_button.show()
self.send_and_close_button.show()
@ -1076,7 +1067,17 @@ class SingleMessageWindow:
self.reply_button.hide()
self.from_label.hide()
self.from_entry.hide()
elif action == 'receive':
if self.message: # we come from a reply?
self.message_textview.grab_focus()
self.cancel_button.hide()
self.close_button.show()
else: # we write a new message (not from reply)
self.close_button.hide()
if self.to: # do we already have jid?
self.subject_entry.grab_focus()
elif action == 'receive': # prepare UI for Receiving
title = _('Received %s') % title
self.reply_button.show()
self.from_label.show()
@ -1085,6 +1086,17 @@ class SingleMessageWindow:
self.send_and_close_button.hide()
self.to_label.hide()
self.to_entry.hide()
fjid = self.from_whom
if self.resource:
fjid += '/' + self.resource # Full jid of sender (with resource)
self.from_entry.set_text(fjid)
self.from_entry.set_property('editable', False)
self.subject_entry.set_property('editable', False)
self.message_textview.set_editable(False)
self.reply_button.grab_focus()
self.cancel_button.hide()
self.close_button.show()
self.window.set_title(title)
@ -1092,13 +1104,17 @@ class SingleMessageWindow:
self.save_pos()
self.window.destroy()
def on_close_button_clicked(self, widget):
self.save_pos()
self.window.destroy()
def update_char_counter(self, widget):
characters_no = self.message_tv_buffer.get_char_count()
self.count_chars_label.set_text(unicode(characters_no))
def send_single_message(self):
if gajim.connections[self.account].connected <= 1:
#if offline or connecting
# if offline or connecting
ErrorDialog(_('Connection not available'),
_('Please make sure you are connected with "%s".' % self.account)
).get_response()
@ -1305,7 +1321,8 @@ class ProgressDialog:
message = self.messages_queue.get()
end_iter = self.textview_buffer.get_end_iter()
self.textview_buffer.insert(end_iter, message + '\n')
self.textview.scroll_to_mark(self.textview_buffer.get_mark('end'), 0, True, 0, 1)
self.textview.scroll_to_mark(self.textview_buffer.get_mark('end'), 0,
True, 0, 1)
return True # loop for ever

View File

@ -16693,6 +16693,19 @@ Banner</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">12</property>
<child>
<widget class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</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_close_button_clicked" last_modification_time="Thu, 08 Dec 2005 14:01:10 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="cancel_button">
<property name="visible">True</property>
@ -16712,11 +16725,73 @@ Banner</property>
<property name="tooltip" translatable="yes">Send message</property>
<property name="can_default">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="focus_on_click">True</property>
<signal name="clicked" handler="on_send_button_clicked" last_modification_time="Tue, 05 Jul 2005 18:37:42 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment98">
<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="hbox3003">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image1326">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</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="label370">
<property name="visible">True</property>
<property name="label" translatable="yes">Sen_d</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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">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>