nearly no blocking dialogs

This commit is contained in:
Yann Leboulanger 2008-08-07 21:57:19 +00:00
parent 00523de494
commit df895d4817
3 changed files with 32 additions and 46 deletions

View File

@ -2442,15 +2442,12 @@ class GroupchatConfigWindow:
'4. domain (the domain itself matches, as does any user@domain,\n' '4. domain (the domain itself matches, as does any user@domain,\n'
'domain/resource, or address containing a subdomain.') 'domain/resource, or address containing a subdomain.')
instance = dialogs.InputDialog(title, prompt) def on_ok(jid):
response = instance.get_response() if not jid:
if response != gtk.RESPONSE_OK: return
return model = self.affiliation_treeview[affiliation].get_model()
jid = instance.input_entry.get_text().decode('utf-8') model.append((jid,'', '', ''))
if not jid: instance = dialogs.InputDialog(title, prompt, ok_handler=on_ok)
return
model = self.affiliation_treeview[affiliation].get_model()
model.append((jid,'', '', ''))
def on_remove_button_clicked(self, widget, affiliation): def on_remove_button_clicked(self, widget, affiliation):
selection = self.affiliation_treeview[affiliation].get_selection() selection = self.affiliation_treeview[affiliation].get_selection()

View File

@ -1495,6 +1495,8 @@ class CommonInputDialog:
def on_okbutton_clicked(self, widget): def on_okbutton_clicked(self, widget):
user_input = self.get_text() user_input = self.get_text()
if user_input:
user_input = user_input.decode('utf-8')
self.cancel_handler = None self.cancel_handler = None
self.dialog.destroy() self.dialog.destroy()
if isinstance(self.ok_handler, tuple): if isinstance(self.ok_handler, tuple):

View File

@ -1721,17 +1721,15 @@ class GroupchatControl(ChatControlBase):
return nb return nb
def _on_change_subject_menuitem_activate(self, widget): def _on_change_subject_menuitem_activate(self, widget):
instance = dialogs.InputTextDialog(_('Changing Subject'), def on_ok(subject):
_('Please specify the new subject:'), self.subject)
response = instance.get_response()
if response == gtk.RESPONSE_OK:
# Note, we don't update self.subject since we don't know whether it # Note, we don't update self.subject since we don't know whether it
# will work yet # will work yet
start_iter, end_iter = instance.input_buffer.get_bounds()
subject = instance.input_buffer.get_text(start_iter, end_iter).decode(
'utf-8')
gajim.connections[self.account].send_gc_subject(self.room_jid, subject) gajim.connections[self.account].send_gc_subject(self.room_jid, subject)
instance = dialogs.InputTextDialog(_('Changing Subject'),
_('Please specify the new subject:'), input_str=self.subject,
ok_handler=on_ok)
def _on_change_nick_menuitem_activate(self, widget): def _on_change_nick_menuitem_activate(self, widget):
title = _('Changing Nickname') title = _('Changing Nickname')
prompt = _('Please specify the new nickname you want to use:') prompt = _('Please specify the new nickname you want to use:')
@ -1748,15 +1746,7 @@ class GroupchatControl(ChatControlBase):
= config.GroupchatConfigWindow(self.account, self.room_jid) = config.GroupchatConfigWindow(self.account, self.room_jid)
def _on_destroy_room_menuitem_activate(self, widget): def _on_destroy_room_menuitem_activate(self, widget):
# Ask for a reason def on_ok(reason, jid):
instance = dialogs.DubbleInputDialog(_('Destroying %s') % self.room_jid,
_('You are going to definitively destroy this room.\n'
'You may specify a reason below:'),
_('You may also enter an alternate venue:'))
response = instance.get_response()
if response == gtk.RESPONSE_OK:
reason = instance.input_entry1.get_text().decode('utf-8')
jid = instance.input_entry2.get_text().decode('utf-8')
if jid: if jid:
# Test jid # Test jid
try: try:
@ -1765,11 +1755,14 @@ class GroupchatControl(ChatControlBase):
dialogs.ErrorDialog(_('Invalid group chat Jabber ID'), dialogs.ErrorDialog(_('Invalid group chat Jabber ID'),
_('The group chat Jabber ID has not allowed characters.')) _('The group chat Jabber ID has not allowed characters.'))
return return
else: gajim.connections[self.account].destroy_gc_room(self.room_jid, reason,
# Abord destroy operation jid)
return
gajim.connections[self.account].destroy_gc_room(self.room_jid, reason, # Ask for a reason
jid) instance = dialogs.DubbleInputDialog(_('Destroying %s') % self.room_jid,
_('You are going to definitively destroy this room.\n'
'You may specify a reason below:'),
_('You may also enter an alternate venue:'), ok_handler=on_ok)
def _on_bookmark_room_menuitem_activate(self, widget): def _on_bookmark_room_menuitem_activate(self, widget):
'''bookmark the room, without autojoin and not minimized''' '''bookmark the room, without autojoin and not minimized'''
@ -1937,16 +1930,13 @@ class GroupchatControl(ChatControlBase):
def kick(self, widget, nick): def kick(self, widget, nick):
'''kick a user''' '''kick a user'''
def on_ok(reason):
gajim.connections[self.account].gc_set_role(self.room_jid, nick,
'none', reason)
# ask for reason # ask for reason
instance = dialogs.InputDialog(_('Kicking %s') % nick, instance = dialogs.InputDialog(_('Kicking %s') % nick,
_('You may specify a reason below:')) _('You may specify a reason below:'), ok_handler=on_ok)
response = instance.get_response()
if response == gtk.RESPONSE_OK:
reason = instance.input_entry.get_text().decode('utf-8')
else:
return # stop kicking procedure
gajim.connections[self.account].gc_set_role(self.room_jid, nick, 'none',
reason)
def mk_menu(self, event, iter): def mk_menu(self, event, iter):
'''Make contact's popup menu''' '''Make contact's popup menu'''
@ -2235,18 +2225,15 @@ class GroupchatControl(ChatControlBase):
def ban(self, widget, jid): def ban(self, widget, jid):
'''ban a user''' '''ban a user'''
def on_ok(reason):
gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid,
'outcast', reason)
# to ban we know the real jid. so jid is not fakejid # to ban we know the real jid. so jid is not fakejid
nick = gajim.get_nick_from_jid(jid) nick = gajim.get_nick_from_jid(jid)
# ask for reason # ask for reason
instance = dialogs.InputDialog(_('Banning %s') % nick, instance = dialogs.InputDialog(_('Banning %s') % nick,
_('You may specify a reason below:')) _('You may specify a reason below:'), ok_handler=on_ok)
response = instance.get_response()
if response == gtk.RESPONSE_OK:
reason = instance.input_entry.get_text().decode('utf-8')
else:
return # stop banning procedure
gajim.connections[self.account].gc_set_affiliation(self.room_jid, jid,
'outcast', reason)
def grant_membership(self, widget, jid): def grant_membership(self, widget, jid):
'''grant membership privilege to a user''' '''grant membership privilege to a user'''