diff frontends/primitivus/primitivus @ 222:3198bfd66daa

primitivus: refactoring to use urwid-satext which is now a separate project
author Goffi <goffi@goffi.org>
date Tue, 28 Dec 2010 23:10:13 +0100
parents 782319a64ac6
children
line wrap: on
line diff
--- a/frontends/primitivus/primitivus	Mon Dec 27 21:56:12 2010 +0100
+++ b/frontends/primitivus/primitivus	Tue Dec 28 23:10:13 2010 +0100
@@ -29,7 +29,7 @@
 from contact_list import ContactList
 from chat import Chat
 from gateways import GatewaysManager
-import custom_widgets
+from urwid_satext import sat_widgets
 import logging
 from logging import debug, info, error
 import sys, os
@@ -99,7 +99,7 @@
 
         ##misc setup##
         self.chat_wins=ChatList(self)
-        self.notBar = custom_widgets.NotificationBar()
+        self.notBar = sat_widgets.NotificationBar()
         urwid.connect_signal(self.notBar,'change',self.onNotification)
         self.progress_wid = Progress(self)
         urwid.connect_signal(self.notBar.progress,'click',lambda x:self.addWindow(self.progress_wid))
@@ -196,7 +196,7 @@
             return input
 
     def __buildMenuRoller(self):
-        menu = custom_widgets.Menu(self.loop)
+        menu = sat_widgets.Menu(self.loop)
         general = _("General")
         menu.addMenu(general, _("Connect"), self.onConnectRequest)
         menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest)
@@ -221,18 +221,18 @@
             assert(type=="NORMAL") #TODO: manage other types
             menu.addMenu(unicode(category), unicode(item), add_menu_cb)
             
-        menu_roller = custom_widgets.MenuRoller([(_('Main menu'),menu)])
+        menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)])
         return menu_roller 
 
     def __buildMainWidget(self):
         self.contactList = ContactList(self, self.CM, on_click = self.contactSelected, on_change=lambda w: self.redraw())
         #self.center_part = urwid.Columns([('weight',2,self.contactList),('weight',8,Chat('',self))])
         self.center_part = urwid.Columns([('weight',2,self.contactList), ('weight',8,urwid.Filler(urwid.Text('')))])
-        self.editBar = custom_widgets.AdvancedEdit('> ')
+        self.editBar = sat_widgets.AdvancedEdit('> ')
         self.editBar.setCompletionMethod(self._nick_completion)
         urwid.connect_signal(self.editBar,'click',self.onTextEntered)
         self.menu_roller = self.__buildMenuRoller()
-        self.main_widget = custom_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer')
+        self.main_widget = sat_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer')
         return self.main_widget
 
     def _nick_completion(self, text, completion_data):
@@ -357,25 +357,25 @@
 
     def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
         if type == 'info':
-            popup = custom_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
+            popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
             flags = wx.OK | wx.ICON_INFORMATION
         elif type == 'error':
-            popup = custom_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
+            popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
         elif type == 'yes/no':
-            popup = custom_widgets.ConfirmDialog(unicode(message),
+            popup = sat_widgets.ConfirmDialog(unicode(message),
                     yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data),
                     no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data))
         else:
-            popup = custom_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
+            popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
             error(_('unmanaged dialog type: %s'), type)
         self.showPopUp(popup)
     
     def onNotification(self, notBar):
         """Called when a new notification has been received"""
-        if not isinstance(self.main_widget, custom_widgets.FocusFrame):
+        if not isinstance(self.main_widget, sat_widgets.FocusFrame):
             #if we are not in the main configuration, we ignore the notifications bar
             return
-        if isinstance(self.main_widget.footer,custom_widgets.AdvancedEdit):
+        if isinstance(self.main_widget.footer,sat_widgets.AdvancedEdit):
             if not self.notBar.canHide():
                 #the notification bar is not visible and has usefull informations, we show it
                 pile = urwid.Pile([self.notBar, self.editBar])
@@ -411,7 +411,7 @@
                 ui.show('window')
         elif type == "ERROR":
             self.current_action_ids.remove(id)
-            self.showPopUp(custom_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
+            self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 
         elif type == "RESULT":
             self.current_action_ids.remove(id)
             if self.current_action_ids_cb.has_key(id):
@@ -437,7 +437,7 @@
         else:
             message = _("'%s' is an invalid JID !") % room_jid
             error (message)
-            self.showPopUp(custom_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) 
+            self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) 
 
     def onAddContact(self, button, edit):
         self.removePopUp()
@@ -447,7 +447,7 @@
         else:
             message = _("'%s' is an invalid JID !") % jid
             error (message)
-            self.showPopUp(custom_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
+            self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
 
     def onRemoveContact(self, button):
         self.removePopUp()
@@ -471,7 +471,7 @@
 
     def onJoinRoomRequest(self, menu):
         """User wants to join a MUC room"""
-        pop_up_widget = custom_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
+        pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
         self.showPopUp(pop_up_widget)
 
     def onFindGatewaysRequest(self, e):
@@ -481,19 +481,19 @@
         self.current_action_ids_cb[id] = self.onGatewaysFound
 
     def onAddContactRequest(self, menu):
-        pop_up_widget = custom_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact)
+        pop_up_widget = sat_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact)
         self.showPopUp(pop_up_widget)
 
     def onRemoveContactRequest(self, menu):
         contact = self.contactList.get_contact()
         if not contact:
-            self.showPopUp(custom_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp))
+            self.showPopUp(sat_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp))
         else:
-            pop_up_widget = custom_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
+            pop_up_widget = sat_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
             self.showPopUp(pop_up_widget)
 
     def onAboutRequest(self, menu):
-        self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) 
+        self.showPopUp(sat_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) 
        
     #MISC CALLBACKS#