Set sensitivity for toolbar. Fixes #7389

This commit is contained in:
Denis Fomin 2013-07-27 19:10:08 +04:00
parent b71ad6b419
commit a1e28bdcf1
2 changed files with 67 additions and 8 deletions

View File

@ -364,6 +364,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
# when/if we do XHTML we will put formatting buttons back
widget = self.xml.get_object('emoticons_button')
widget.set_sensitive(False)
id_ = widget.connect('clicked', self.on_emoticons_button_clicked)
self.handlers[id_] = widget
@ -459,6 +460,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
# Hook up send button
widget = self.xml.get_object('send_button')
id_ = widget.connect('clicked', self._on_send_button_clicked)
widget.set_sensitive(False)
self.handlers[id_] = widget
widget = self.xml.get_object('formattings_button')
@ -622,10 +624,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
"""
When send button is pressed: send the current message
"""
if gajim.connections[self.account].connected < 2: # we are not connected
dialogs.ErrorDialog(_('A connection is not available'),
_('Your message can not be sent until you are connected.'))
return
message_buffer = self.msg_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
@ -1502,7 +1500,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
def got_connected(self):
self.msg_textview.set_sensitive(True)
self.msg_textview.set_editable(True)
# FIXME: Set sensitivity for toolbar
self.update_toolbar()
def got_disconnected(self):
@ -1511,7 +1508,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self.conv_textview.tv.grab_focus()
self.no_autonegotiation = False
# FIXME: Set sensitivity for toolbar
self.update_toolbar()
@ -1785,6 +1781,13 @@ class ChatControl(ChatControlBase):
gajim.events.event_removed_unsubscribe(self.on_event_removed)
def _update_toolbar(self):
if (gajim.connections[self.account].connected > 1 and not \
self.TYPE_ID == 'pm') or (self.contact.show != 'offline' and \
self.TYPE_ID == 'pm'):
emoticons_button = self.xml.get_object('emoticons_button')
emoticons_button.set_sensitive(True)
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(True)
# Formatting
if self.contact.supports(NS_XHTML_IM) and not self.gpg_is_active:
self._formattings_button.set_sensitive(True)
@ -1833,9 +1836,10 @@ class ChatControl(ChatControlBase):
self._video_button.set_tooltip_text(video_tooltip_text[:-1])
# Send file
if (self.contact.supports(NS_FILE) or \
if ((self.contact.supports(NS_FILE) or \
self.contact.supports(NS_JINGLE_FILE_TRANSFER)) or \
self.type_id == 'chat' or self.gc_contact.resource:
self.type_id == 'chat' or self.gc_contact.resource) and \
self.contact.show != 'offline':
self._send_file_button.set_sensitive(True)
self._send_file_button.set_tooltip_text(_('Send files'))
else:
@ -3258,6 +3262,30 @@ class ChatControl(ChatControlBase):
if contact:
self.contact = contact
self.draw_banner()
emoticons_button = self.xml.get_object('emoticons_button')
emoticons_button.set_sensitive(True)
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(True)
def got_disconnected(self):
# Emoticons button
emoticons_button = self.xml.get_object('emoticons_button')
emoticons_button.set_sensitive(False)
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(False)
# Add to roster
self._add_to_roster_button.hide()
# Audio button
self._audio_button.set_sensitive(False)
# Video button
self._video_button.set_sensitive(False)
# Send file button
self._send_file_button.set_tooltip_text('')
self._send_file_button.set_sensitive(False)
# Convert to GC button
self._convert_to_gc_button.set_sensitive(False)
ChatControlBase.got_disconnected(self)
def update_status_display(self, name, uf_show, status):
"""

View File

@ -284,6 +284,9 @@ class PrivateChatControl(ChatControl):
is_anonymous=self.room_ctrl.is_anonymous)
return menu
def got_disconnected(self):
ChatControl.got_disconnected(self)
class GroupchatControl(ChatControlBase):
TYPE_ID = message_control.TYPE_GC
@ -308,6 +311,8 @@ class GroupchatControl(ChatControlBase):
# Keep error dialog instance to be sure to have only once at a time
self.error_dialog = None
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(False)
self.actions_button = self.xml.get_object('muc_window_actions_button')
id_ = self.actions_button.connect('clicked',
@ -315,14 +320,19 @@ class GroupchatControl(ChatControlBase):
self.handlers[id_] = self.actions_button
widget = self.xml.get_object('change_nick_button')
widget.set_sensitive(False)
id_ = widget.connect('clicked', self._on_change_nick_menuitem_activate)
self.handlers[id_] = widget
widget = self.xml.get_object('change_subject_button')
widget.set_sensitive(False)
id_ = widget.connect('clicked',
self._on_change_subject_menuitem_activate)
self.handlers[id_] = widget
formattings_button = self.xml.get_object('formattings_button')
formattings_button.set_sensitive(False)
widget = self.xml.get_object('bookmark_button')
for bm in gajim.connections[self.account].bookmarks:
if bm['jid'] == self.contact.jid:
@ -1350,7 +1360,28 @@ class GroupchatControl(ChatControlBase):
if self.parent_win:
self.parent_win.redraw_tab(self)
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(True)
emoticons_button = self.xml.get_object('emoticons_button')
emoticons_button.set_sensitive(True)
formattings_button = self.xml.get_object('formattings_button')
formattings_button.set_sensitive(True)
change_nick_button = self.xml.get_object('change_nick_button')
change_nick_button.set_sensitive(True)
change_subject_button = self.xml.get_object('change_subject_button')
change_subject_button.set_sensitive(True)
def got_disconnected(self):
send_button = self.xml.get_object('send_button')
send_button.set_sensitive(False)
emoticons_button = self.xml.get_object('emoticons_button')
emoticons_button.set_sensitive(False)
formattings_button = self.xml.get_object('formattings_button')
formattings_button.set_sensitive(False)
change_nick_button = self.xml.get_object('change_nick_button')
change_nick_button.set_sensitive(False)
change_subject_button = self.xml.get_object('change_subject_button')
change_subject_button.set_sensitive(False)
self.list_treeview.set_model(None)
self.model.clear()
nick_list = gajim.contacts.get_nick_list(self.account, self.room_jid)