misc fixes
This commit is contained in:
parent
9caff8237a
commit
66a6d7599c
4 changed files with 21 additions and 21 deletions
|
|
@ -118,7 +118,7 @@ class List(urwid.WidgetWrap):
|
|||
try:
|
||||
self.content.remove(value)
|
||||
except ValueError:
|
||||
pass
|
||||
raise ValuError("%s ==> %s" % (str(value),str(self.content)))
|
||||
|
||||
def getValue(self):
|
||||
"""Convenience method to get the value selected as a string in single mode, or None"""
|
||||
|
|
@ -140,7 +140,7 @@ class List(urwid.WidgetWrap):
|
|||
self.content[:] = widgets
|
||||
if self.single and new_values:
|
||||
self.content[0].setState(True)
|
||||
display_widget = urwid.BoxAdapter(self.list_box, min(len(new_values),5))
|
||||
display_widget = urwid.BoxAdapter(self.list_box, min(len(new_values),5) or 1)
|
||||
urwid.WidgetWrap.__init__(self, display_widget)
|
||||
|
||||
def selectValue(self, value):
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class PrimitivusApp(QuickApp):
|
|||
QuickApp.__init__(self) #XXX: yes it's an unusual place for the constructor of a parent class, but the init order is important
|
||||
|
||||
## main loop setup ##
|
||||
self.main_widget = self.__buildMainWidget()
|
||||
self.main_widget = ProfileManager(self)
|
||||
self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), unhandled_input=self.key_handler)
|
||||
|
||||
def start(self):
|
||||
|
|
@ -77,14 +77,20 @@ class PrimitivusApp(QuickApp):
|
|||
raise urwid.ExitMainLoop()
|
||||
|
||||
def __buildMainWidget(self):
|
||||
#main_widget = urwid.Filler(ProfileManager(self))
|
||||
main_widget = ProfileManager(self)
|
||||
return main_widget
|
||||
self.contactList = ContactList(self, self.CM)
|
||||
return self.contactList
|
||||
|
||||
def plug_profile(self, profile_key='@DEFAULT@'):
|
||||
self.loop.widget = self.contactList = ContactList(self, self.CM)
|
||||
self.main_widget = self.loop.widget = self.__buildMainWidget()
|
||||
QuickApp.plug_profile(self, profile_key)
|
||||
|
||||
|
||||
def removePopUp(self):
|
||||
self.loop.widget = self.main_widget
|
||||
|
||||
def showPopUp(self, pop_up_widget):
|
||||
display_widget = urwid.Overlay(pop_up_widget, self.main_widget, 'center', ('relative', 40), 'middle', ('relative', 40))
|
||||
self.loop.widget = display_widget
|
||||
|
||||
sat = PrimitivusApp()
|
||||
sat.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -63,35 +63,31 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
profiles.sort()
|
||||
self.list_profile.changeValues(profiles)
|
||||
|
||||
def __showPopUp(self, pop_up_widget):
|
||||
display_widget = urwid.Overlay(pop_up_widget, self.main_widget, 'center', ('relative', 40), 'middle', ('relative', 40))
|
||||
self._set_w(display_widget)
|
||||
|
||||
def cancelDialog(self, button):
|
||||
self._set_w(self.main_widget)
|
||||
self.host.removePopUp()
|
||||
|
||||
def newProfile(self, button, edit):
|
||||
self._set_w(self.main_widget)
|
||||
name = edit.get_edit_text()
|
||||
self.host.bridge.createProfile(name)
|
||||
self.__refillProfiles()
|
||||
self.list_profile.selectValue(name)
|
||||
self.host.removePopUp()
|
||||
|
||||
def deleteProfile(self, button):
|
||||
self._set_w(self.main_widget)
|
||||
profile_name = self.list_profile.getValue()
|
||||
if profile_name:
|
||||
self.host.bridge.deleteProfile(profile_name)
|
||||
self.__refillProfiles()
|
||||
self.host.removePopUp()
|
||||
|
||||
|
||||
def onNewProfile(self, e):
|
||||
pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile)
|
||||
self.__showPopUp(pop_up_widget)
|
||||
self.host.showPopUp(pop_up_widget)
|
||||
|
||||
def onDeleteProfile(self, e):
|
||||
pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile)
|
||||
self.__showPopUp(pop_up_widget)
|
||||
self.host.showPopUp(pop_up_widget)
|
||||
|
||||
def onProfileChange(self, list_wid):
|
||||
profile_name = list_wid.getValue()
|
||||
|
|
@ -105,10 +101,10 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
profile_name = self.list_profile.getValue()
|
||||
if not profile_name:
|
||||
pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog)
|
||||
self.__showPopUp(pop_up_widget)
|
||||
self.host.showPopUp(pop_up_widget)
|
||||
elif profile_name[0] == '@':
|
||||
pop_up_widget = Alert(_('Bad profile name'), _("A profile name can't start with a @"), ok_cb=self.cancelDialog)
|
||||
self.__showPopUp(pop_up_widget)
|
||||
self.host.showPopUp(pop_up_widget)
|
||||
else:
|
||||
profile = self.host.bridge.getProfileName(profile_name)
|
||||
assert(profile)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ class QuickApp():
|
|||
def presenceUpdate(self, jabber_id, show, priority, statuses, profile):
|
||||
if not self.__check_profile(profile):
|
||||
return
|
||||
print "check ok"
|
||||
debug (_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") % {'jid':jabber_id, 'show':show, 'priority':priority, 'statuses':statuses, 'profile':profile});
|
||||
from_jid=JID(jabber_id)
|
||||
debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short})
|
||||
|
|
@ -284,7 +283,6 @@ class QuickApp():
|
|||
if not self.__check_profile(profile):
|
||||
return
|
||||
debug (_("New Tarot Game"))
|
||||
print "room: %s, hand: %s" % (room_jid,hand)
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Tarot").newGame(hand)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue