deskbar-applet r2012 - in trunk: . deskbar/core deskbar/core/updater deskbar/interfaces deskbar/ui/preferences



Author: sebp
Date: Tue Mar 18 17:28:57 2008
New Revision: 2012
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2012&view=rev

Log:
Added preliminary Capuchin support. It works, but it's still pretty ugly.

Added:
   trunk/deskbar/core/updater/Capuchin.py
Removed:
   trunk/deskbar/core/updater/NewStuffUpdater.py
Modified:
   trunk/ChangeLog
   trunk/deskbar/core/ModuleList.py
   trunk/deskbar/core/updater/Makefile.am
   trunk/deskbar/interfaces/Module.py
   trunk/deskbar/ui/preferences/DeskbarPreferences.py
   trunk/deskbar/ui/preferences/ModuleListView.py

Modified: trunk/deskbar/core/ModuleList.py
==============================================================================
--- trunk/deskbar/core/ModuleList.py	(original)
+++ trunk/deskbar/core/ModuleList.py	Tue Mar 18 17:28:57 2008
@@ -161,7 +161,7 @@
     def move_module_to_bottom(self, iter):
         self.move_after(iter, self.get_iter(self._bottom_enabled_path))
         
-    def _get_iter_from_module_id(self, modid):
+    def get_iter_from_module_id(self, modid):
         iter = self.get_iter_first ()
         while (iter is not None):
             if self[iter][self.MODULE_CTX_COL].get_id() == modid:
@@ -169,10 +169,9 @@
             iter = self.iter_next(iter)
         return None
             
-    def set_module_update_available(self, modid):
-        iter = self._get_iter_from_module_id(modid)
+    def set_module_update_available(self, iter, val):
         if iter != None:
-            self.set_value(iter, self.UPDATEABLE_COL, True)
+            self.set_value(iter, self.UPDATEABLE_COL, val)
 
 gobject.type_register(ModuleList)
 
@@ -233,31 +232,38 @@
 gobject.type_register(DisabledModuleList)
 
 class WebModuleList (gtk.ListStore):
-    MODULE_CTX_COL = 0
+    
+    (MODULE_ID,
+     MODULE_NAME,
+     MODULE_DESCRIPTION) = range (3)
     
     def __init__ (self):
         # First element is a tuple containing module id, name and description
-        gtk.ListStore.__init__ (self, gobject.TYPE_PYOBJECT, bool)
+        gtk.ListStore.__init__ (self, str, str, str)
         
-    def __iter__ (self):
-        return ModuleListIter (self)
+    def __contains__ (self, mod_id):
+        for mod in self:
+            if mod_id == mod[0]:
+                return True
+        return False
     
-    def get_position_from_context (self, module, value=None):
-        """Returns a tuple (iter, index)
+    def get_position_from_context (self, module_id, value=None):
+        """
+        @param module_id: A module id
+        @type module_id: str
+        @return: a tuple (iter, index) or (None, 0) if the module is not found
         
-        iter is a gtk.TreeIter pointing to the row containing the given module module.
+        iter is a C{gtk.TreeIter} pointing to the row containing the given module module.
         index is the index of the module in the list.
-        
-        If the module module is not found return (None, None).
         """
         i = 0
         iter = self.get_iter_first ()
         while (iter is not None):
             if value == None:
-                if self[iter][self.MODULE_CTX_COL] == module:
+                if self[iter][self.MODULE_ID] == module_id:
                     return (iter, i)
             else:
-                if getattr(self[iter][self.MODULE_CTX_COL], module) == value:
+                if getattr(self[iter][self.MODULE_ID], module_id) == value:
                     return (iter, i)
             
             iter = self.iter_next (iter)
@@ -265,39 +271,31 @@
         
         return (None, 0)
                 
-    def add (self, module, iter=None):
-        """If iter is set this method updates the row pointed to by iter with the 
+    def add (self, mod_id, mod_name, mod_desc, iter=None):
+        """
+        If iter is set this method updates the row pointed to by iter with the 
         values of module. 
         
         If iter is not set it will try to obtain an iter pointing
         to the row containg the module. If there's no such row, it will append it.
         """
-        (mod_id, mod_name, mod_desc) = module
         for mod in self:
             if mod_id == mod[0]:
                 # We don't want a duplicate module
                 return
-                
+    
         if iter is None:
-            res = self.get_position_from_context(module)
-        if res is None or res[0] is None:
             iter = self.append ()
         
-        self.set_value(iter, self.MODULE_CTX_COL, module)
+        self.set_value(iter, self.MODULE_ID, mod_id)
+        self.set_value(iter, self.MODULE_NAME, mod_name)
+        self.set_value(iter, self.MODULE_DESCRIPTION, mod_desc)
     
     def module_changed(self, module):
         iter, index = self.get_position_from_context(module)
         if iter != None:
             self.emit('row-changed', self.get_path(iter), iter)
-        
-    def update_row_cb (self, sender, module, iter=None):
-        """
-        Callback for updating the row containing module.
-        If iter is set the row to which it points to will be
-        updated with the module.
-        """
-        self.add(module, iter)
-
+   
 gobject.type_register(WebModuleList)
 
 class ModuleListIter : 

Added: trunk/deskbar/core/updater/Capuchin.py
==============================================================================
--- (empty file)
+++ trunk/deskbar/core/updater/Capuchin.py	Tue Mar 18 17:28:57 2008
@@ -0,0 +1,180 @@
+import gobject
+import dbus
+import dbus.glib
+import logging
+
+LOGGER = logging.getLogger(__name__)
+
+CAPUCHIN_DBUS_SERVICE = "org.gnome.Capuchin"
+APP_OBJECT_MANAGER_DBUS_INTERFACE = "org.gnome.Capuchin"
+APP_OBJECT_MANAGER_DBUS_PATH = "/org/gnome/Capuchin/AppObjectManager"
+APP_OBJECT_DBUS_INTERFACE = "org.gnome.Capuchin.AppObject"
+
+(ACTION_UPDATING_REPO,
+ACTION_DOWNLOADING_PLUGIN,
+ACTION_EXTRACTING_PLUGIN) = range (3)
+
+def is_capuchin_available():
+    try:
+        bus = dbus.SessionBus()
+        proxy = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+        _dbus = dbus.Interface(proxy, 'org.freedesktop.DBus')
+        _dbus.ReloadConfig()
+        bus_names = _dbus.ListActivatableNames()
+        return (CAPUCHIN_DBUS_SERVICE in bus_names)
+    except dbus.exceptions.DBusException, e:
+        LOGGER.exception("D-Bus Error: %s" % e)
+        return False
+
+class AppObjectManager:
+    
+    def __init__(self):
+        bus = dbus.SessionBus()
+        # Get proxy object
+        proxy_obj_manager = bus.get_object(CAPUCHIN_DBUS_SERVICE, APP_OBJECT_MANAGER_DBUS_PATH)
+        # Apply the correct interace to the proxy object
+        self.manager = dbus.Interface(proxy_obj_manager, APP_OBJECT_MANAGER_DBUS_INTERFACE)
+        
+    def get_app_object(self, url):
+        """
+        @return: New L{AppObject} instance for the given URL
+        """
+        object_path = self.manager.GetAppObject (url)
+        return AppObject(object_path)
+        
+class AppObject (gobject.GObject):
+    
+    __gsignals__ = {
+        "update-finished": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+        "install-finished": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [str]),
+        "status": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [int, str, float, int]),
+                    }
+    
+    def __init__(self, object_path):
+        gobject.GObject.__init__(self)
+        
+        bus = dbus.SessionBus()
+        proxy_obj = bus.get_object(CAPUCHIN_DBUS_SERVICE, object_path)
+        self.appobject = dbus.Interface(proxy_obj, APP_OBJECT_DBUS_INTERFACE)
+        
+        self.appobject.connect_to_signal('InstallFinished', self.__on_install_finished)
+        self.appobject.connect_to_signal('Status', self.__on_status)
+        self.appobject.connect_to_signal('UpdateFinished', self.__on_update_finished)
+        
+    def __on_install_finished(self, plugin_id):
+        self.emit ("install-finished", plugin_id)
+    
+    def __on_status(self, action, plugin_id, progress, speed):
+        """
+        @param action: One of C{ACTION_UPDATING_REPO},
+        C{ACTION_DOWNLOADING_PLUGIN}, C{ACTION_EXTRACTING_PLUGIN}
+        """
+        self.emit ("status", action, plugin_id, progress, speed)
+    
+    def __on_update_finished(self):
+        self.emit ("update-finished")
+    
+    def __check_plugin_id(self, plugin_id):
+        if plugin_id == None:
+            raise ValueError ("plugin_id must not be None")
+        
+    def update (self, force_update):
+        """
+        @type force_update: bool
+        """
+        self.appobject.Update (force_update)
+    
+    def install (self, plugin_id):
+        self.__check_plugin_id (plugin_id)
+        self.appobject.Install (plugin_id)
+    
+    def get_application_name (self):
+        return self.appobject.GetApplicationName ()
+    
+    def get_available_plugins (self):
+        return self.appobject.GetAvailablePlugins ()
+    
+    def get_available_updates (self, plugins):
+        """
+        @type plugins: List of PuginInfo objects
+        """
+        plugins_list = []
+        
+        for p in plugins:
+            plugins_list.append( (p.get_id(), p.get_version()) )
+        
+        return self.appobject.GetAvailableUpdates (plugins_list)
+    
+    def get_plugins_with_tag (self, tag):
+        return self.appobject.GetPluginsWithTag (tag)
+    
+    def get_plugin_name (self, plugin_id):
+        self.__check_plugin_id (plugin_id)
+        return self.appobject.GetPluginName (plugin_id)
+    
+    def get_plugin_description (self, plugin_id):
+        self.__check_plugin_id (plugin_id)
+        return self.appobject.GetPluginDescription (plugin_id)
+    
+    def get_plugin_changes (self, plugin_id, version):
+        self.__check_plugin_id (plugin_id)
+        return self.appobject.GetPluginChanges (plugin_id, version)
+    
+    def get_plugin_tags (self, plugin_id):
+        self.__check_plugin_id (plugin_id)
+        return self.appobject.GetPluginTags (plugin_id)
+    
+    def get_plugin_author (self, plugin_id):
+        """
+        @return: PluginAuthor object
+        """
+        self.__check_plugin_id (plugin_id)
+        author_list = self.appobject.GetPluginAuthor (plugin_id)
+        return PluginAuthor (author_list[0], author_list[1])
+    
+    def get_plugin_version (self, plugin_id):
+        self.__check_plugin_id (plugin_id)
+        return self.appobject.GetPluginVersion (plugin_id)
+    
+    def get_tags (self):
+        return self.appobject.GetTags ()
+    
+    def close (self):
+        self.appobject.Close ()
+    
+class PluginInfo:
+    
+    def __init__(self, plugin_id, version):
+        self.__id = plugin_id
+        self.__version = version
+        
+    def get_version(self):
+        return self.__version
+    
+    def get_id(self):
+        return self.__id
+    
+    def set_version(self, val):
+        self.__version = val
+        
+    def set_id(self, val):
+        self.__id = val
+        
+class PluginAuthor:
+    
+    def __init__(self, name, email):
+        self.__name = name
+        self.__email = email
+        
+    def get_name(self):
+        return name
+    
+    def get_email(self):
+        return email
+    
+    def set_name(self, val):
+        self.__name = val
+        
+    def set_email(self, val):
+        self.__email = val
+        
\ No newline at end of file

Modified: trunk/deskbar/core/updater/Makefile.am
==============================================================================
--- trunk/deskbar/core/updater/Makefile.am	(original)
+++ trunk/deskbar/core/updater/Makefile.am	Tue Mar 18 17:28:57 2008
@@ -1,4 +1,4 @@
 updaterdir = $(pythondir)/deskbar/core/updater
 updater_PYTHON = \
 	__init__.py \
-	NewStuffUpdater.py
+	Capuchin.py

Modified: trunk/deskbar/interfaces/Module.py
==============================================================================
--- trunk/deskbar/interfaces/Module.py	(original)
+++ trunk/deskbar/interfaces/Module.py	Tue Mar 18 17:28:57 2008
@@ -15,6 +15,7 @@
         super(Module, self).__init__()
         self._priority = 0
         self._enabled = False
+        self._updateable = False
         self._filename = None
         self._id = ""
     
@@ -34,6 +35,15 @@
         Set handler's enabled state
         """
         self._enabled = val
+        
+    def is_updateable(self):
+        """
+        Whether a update for the plugin is available
+        """
+        return self._updateable
+    
+    def set_updateable(self, val):
+        self._updateable = val
     
     def get_priority(self):
         """

Modified: trunk/deskbar/ui/preferences/DeskbarPreferences.py
==============================================================================
--- trunk/deskbar/ui/preferences/DeskbarPreferences.py	(original)
+++ trunk/deskbar/ui/preferences/DeskbarPreferences.py	Tue Mar 18 17:28:57 2008
@@ -5,14 +5,17 @@
 from gettext import gettext as _
 from os.path import join
 import deskbar
-from deskbar.core.updater.NewStuffUpdater import NewStuffUpdater
+from deskbar.core.updater.Capuchin import *
 from deskbar.core.ModuleList import WebModuleList
 from deskbar.ui.preferences.AccelEntry import AccelEntry
 from deskbar.ui.preferences.ErrorDialog import ErrorDialog
 from deskbar.ui.preferences.ModuleListView import ModuleListView, DisabledModuleListView, WebModuleListView
+from deskbar.ui.preferences.ProgressbarDialog import ProgressbarDialog
 import dbus
-if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
-    import dbus.glib
+import time
+import dbus.glib
+    
+DESKBAR_CAPUCHIN_REPO = "http://www.gnome.org/~sebp/deskbar/deskbar-applet.xml";
 
 class InfoBox(gtk.HBox):
     
@@ -40,8 +43,12 @@
         
         self.dialog = self.glade.get_widget("preferences")
         
-        # Since newstuff is optional we have to check if self.newstuff is None each time we use it
-        self.newstuff = None
+        # Since capuchin is optional we have to check if self.capuchin is None each time we use it
+        self.__capuchin = None
+        self.has_capuchin = False
+        self.__capuchin_updated = False
+        self.progessdialog = None
+        self.__capuchin_installing = False
         
         self.keybinding = self._model.get_keybinding()
         
@@ -54,8 +61,8 @@
         
         self.__setup_disabled_modules_tab()
         
-        # Setup new-stuff-manager
-        self.__enable_newstuffmanager( self.__is_nsm_available() )
+        # Setup capuchin
+        self.__setup_updater()
           
         self.__select_first_tab()
         
@@ -101,12 +108,10 @@
         self.keyboard_shortcut_entry = AccelEntry()
         self.keyboard_shortcut_entry.connect('accel-edited', self.on_keyboard_shortcut_entry_changed)
         self.glade.get_widget("keybinding_entry_container").pack_start(self.keyboard_shortcut_entry.get_widget(), False)
-        #self.keybinding_notify_id = deskbar.GCONF_CLIENT.notify_add(applet.prefs.GCONF_KEYBINDING, lambda x, y, z, a: self.on_config_keybinding(z.value))
         
         self.use_selection = self._model.get_use_selection()
         self.use_selection_box = self.glade.get_widget("use_selection")
         self.use_selection_box.connect('toggled', self.on_use_selection_toggled)
-        #self.use_selection_id = deskbar.GCONF_CLIENT.notify_add(applet.prefs.GCONF_USE_SELECTION, lambda x, y, z, a: self.on_config_use_selection(z.value))
 
         self.sticktopanel_checkbox = self.glade.get_widget("sticktopanel_checkbox")
         self.sticktopanel_checkbox.connect("toggled", self.on_ui_changed)
@@ -134,26 +139,17 @@
         self.disabledhandlers_box = self.glade.get_widget("disabledhandlers_box")
 
     def __select_first_tab(self):
-         # Select first tab
+        """ Select first tab """
         notebook = self.glade.get_widget("notebook1")
         current = notebook.get_current_page()
         if (current != 0):
             for i in range(current):
                 notebook.prev_page()
 
-    def __is_nsm_available(self):
-        try:
-            bus = dbus.SessionBus()
-            proxy = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
-            _dbus = dbus.Interface(proxy, 'org.freedesktop.DBus')
-            _dbus.ReloadConfig()
-            bus_names = _dbus.ListActivatableNames()
-            return (NewStuffUpdater.NEW_STUFF_SERVICE in bus_names)
-        except dbus.exceptions.DBusException:
-            return False
-
-    def __enable_newstuffmanager(self, status):
-        if status:
+    def __setup_updater(self):
+        if is_capuchin_available():
+            self.has_capuchin = True
+            
             self.web_module_list = WebModuleList()
             
             container = self.glade.get_widget("newhandlers")
@@ -181,16 +177,37 @@
             self.glade.get_widget("check").destroy()
             self.glade.get_widget("update").destroy()
     
-    def _call_on_newstuffmanager(self, method, *args):
-        if self.newstuff == None:
-            self.newstuff = NewStuffUpdater()
-            self.newstuff.connect('ready', lambda s: getattr(self.newstuff, method)(*args) )
-            self.newstuff.connect('error', self.on_newstuff_error)
-            self.newstuff.connect('new-modules-available', self.on_new_modules_available)
-            self.newstuff.connect('updates-available', self.on_updates_available)
+    def _get_capuchin_instance(self):
+        if self.__capuchin == None:
+            manager = AppObjectManager ()
+            self.__capuchin = manager.get_app_object (DESKBAR_CAPUCHIN_REPO)
+            self.__capuchin.connect ('update-finished', self._on_update_finished)
+            self.__capuchin.connect ('install-finished', self._on_install_finished)
+            self.__capuchin.connect ('status', self._on_status)
+            self.__capuchin.update (False)
+
+            # FIXME
+            time.sleep(2)
+
+            return self.__capuchin
         else:
-            getattr(self.newstuff, method)(*args)
-   
+            return self.__capuchin
+       
+    def _show_error_dialog(self, error):
+          """
+          An error message will be displayed in a MessageDialog
+          """
+          dialog = ErrorDialog(self.dialog, _("A problem occured"), error)
+          dialog.run()
+    
+    def _show_module_installed_dialog(self):
+        dialog = gtk.MessageDialog(parent=self.dialog,
+                       flags=gtk.DIALOG_DESTROY_WITH_PARENT,
+                       type=gtk.MESSAGE_INFO,
+                       buttons=gtk.BUTTONS_OK,
+                       message_format=_("Extension has been installed successfully"))
+        dialog.connect('response', lambda w, id: dialog.destroy())
+          
     def show_run_hide(self, parent):
         self.dialog.set_screen(parent.get_screen())
         self.dialog.show_all()
@@ -200,8 +217,9 @@
     def on_dialog_response(self, dialog, response):
         self._model.update_gconf()
         self.dialog.destroy()
-        if self.newstuff != None:
-            self.newstuff.close()
+        # Check if capuchin service is available and if actually used it
+        if self.has_capuchin and self.__capuchin != None:
+            self.__capuchin.close()
         
     def sync_ui(self):
         if self.keybinding != None:
@@ -242,17 +260,21 @@
         self._model.reload_all_modules()
     
     def on_module_selected(self, selection):
-        module_context = self.moduleview.get_selected_module()
-        
-        if module_context != None:
-            self.check_requirements(module_context)
+        """
+        Check if update for module is available
+        and set button (in)sensitive
+        """
+        module = self.moduleview.get_selected_module()
             
         # Check if we can update
-        if self.newstuff != None:
-            #TODO: Save information whether update is available
-            self.update.set_sensitive(module_context != None)                
+        if self.has_capuchin:
+            self.update.set_sensitive(module.is_updateable())                
     
     def set_buttons(self, selection):
+        """
+        Set top/up/down/bottom sensitive according
+        to the selected module
+        """
         model, iter = selection.get_selected()
         if iter == None:
             self.__set_top_buttons_sensitive(False)
@@ -325,62 +347,130 @@
         else:
             self._model.initialize_module (module, False)
         self._model.update_gconf()
-       
-    def on_newstuff_error(self, newstuff, error):
-          """
-          Called if a connection to the repository failed
-          
-          An error message will be displayed in a MessageDialog
-          and C{self.newstuff} is reset
-          
-          @type error: dbus_bindings.DBusException instance
-          """
-          dialog = ErrorDialog(self.dialog, _("A problem occured"), error)
-          dialog.run()
-          self.newstuff.close()
-          self.newstuff = None
-          
+    
     def on_check_handlers(self, button):
-        #Update all handlers
-        current_modules = []
+        """
+        Check if updates for the installed modules are available
+        """
+        installed_modules = set()
         for mod in self.module_list:
-            current_modules.append((mod.get_id(), mod.INFOS["version"]))
-        self._call_on_newstuffmanager("fetch_updates", current_modules)
+            installed_modules.add( mod.get_id() )
+        
+        try:
+            repo_plugins = set (self._get_capuchin_instance().get_available_plugins())
+            
+            # Get modules that are installed locally and are in the repository
+            updateable_modules = repo_plugins & installed_modules 
+                
+            current_modules = []
+            for mod in self.module_list:
+                if mod.get_id() in updateable_modules:
+                    current_modules.append( PluginInfo(mod.get_id(), mod.INFOS["version"]) )
+            
+            updates = self._get_capuchin_instance().get_available_updates (current_modules)
+           
+            for modid in updates:
+                iter = self.module_list.get_iter_from_module_id (modid)
+                self.module_list[iter][self.module_list.MODULE_CTX_COL].set_updateable (True)
+                self.module_list.set_module_update_available(iter, True)
+        except dbus.exceptions.DBusException, e:
+            self._show_error_dialog(e)
+            self.__capuchin.close()
+            self.__capuchin = None
             
     def on_check_new_extensions(self, button):
-        current_modules = []
+        """
+        Display a list of modules that aren't installed, yet
+        """
+        local_modules = set()
         for mod in self.module_list:
-            current_modules.append(mod.get_id())
-        self._call_on_newstuffmanager("fetch_new_modules", current_modules)
+            local_modules.add(mod.get_id())
         
-    def on_new_modules_available(self, newstuff, modules):
-        for mod in modules:
-            self.web_module_list.add(mod)
-        
-    def on_updates_available(self, newstuff, modules):
-        for modid, desc in modules:
-            self.module_list.set_module_update_available(modid)
+        try:
+            repo_modules = set (self._get_capuchin_instance().get_available_plugins())
+            
+            new_modules = repo_modules - local_modules
+            
+            for mod_id in new_modules:
+                mod_name = self._get_capuchin_instance().get_plugin_name (mod_id)
+                mod_desc = self._get_capuchin_instance().get_plugin_description (mod_id)
+                self.web_module_list.add(mod_id, mod_name, mod_desc)
+        except dbus.exceptions.DBusException, e:
+            self._show_error_dialog(e)
+            self.__capuchin.close()
+            self.__capuchin = None
         
     def on_update_handler(self, button):
+        """ Update the selected module """
         module = self.moduleview.get_selected_module()
         if module != None:
-            # Trigger module update
-            if self.newstuff != None:
-                self.newstuff.install_module(module.get_id())
+            self.__capuchin_installing = False
+            self._capuchin_install(module.get_id())
             button.set_sensitive(False)
         
     def on_install_handler(self, button):
-        # Install the selected new handler
+        """ Install the selected new handler """
         mod_id = self.webmoduleview.get_selected_module_id()
+        self.__capuchin_installing = True
+        self._capuchin_install(mod_id)
+        button.set_sensitive(False)
+        
+    def _capuchin_install(self, mod_id):
         if mod_id != None:
-            if self.newstuff != None:
-                self.newstuff.install_module(mod_id)
-            button.set_sensitive(False)
+            if self.has_capuchin:
+                try:
+                    self._get_capuchin_instance().install(mod_id)
+                except dbus.exceptions.DBusException, e:
+                    self._show_error_dialog(e)
+                    self.__capuchin.close()
+                    self.__capuchin = None
      
     def on_webmodule_selected(self, selection):
         mod_id = self.webmoduleview.get_selected_module_id()
         self.install.set_sensitive(mod_id != None)
-              
+          
+    def _on_update_finished(self, appobject):
+        self.__capuchin_updated = True
+        if self.progessdialog != None:
+            self.progessdialog.destroy()
+            self.progessdialog = None
+    
+    def _on_status(self, appobject, action, plugin_id, progress, speed):
+        if action == ACTION_UPDATING_REPO:
+            action_text = _("Retrieving the extension index")
+        elif action == ACTION_DOWNLOADING_PLUGIN:
+            action_text = _("Downloading extension")
+        elif action == ACTION_EXTRACTING_PLUGIN:
+            action_text = _("Extracting archive")
+        else:
+            return
+        
+        if self.progessdialog == None:
+            # Create new dialog
+            self.progessdialog = ProgressbarDialog (self.dialog)
+            self.progessdialog.set_text ( _("Installing extension"),
+                                      _("The extension will be downloaded and installed.") )
+            self.progessdialog.run_nonblocked ()
+        
+        self.progessdialog.set_current_operation (action_text)
+        self.progessdialog.set_fraction (progress)
+    
+    def _on_install_finished(self, appobject, plugin_id):
+        self.progessdialog.destroy ()
+        self.progessdialog = None
+        
+        # Remove from webmodulelist
+        if self.__capuchin_installing:
+            model, iter = self.webmoduleview.get_selection().get_selected()
+            self.web_module_list.remove (iter)
+            self.__capuchin_installing = False
+        else:
+            model, iter = self.moduleview.get_selection().get_selected()
+            self.module_list[iter][self.module_list.MODULE_CTX_COL].set_updateable (False)
+            self.module_list.set_module_update_available(iter, False)
+        
+        self._show_module_installed_dialog()
+           
     def on_drag_motion(self, widget, drag_context, x, y, timestamp):
         return False
     
@@ -396,14 +486,11 @@
             data = selection.data.strip()
         try:
             self._model.install_module(data)
-            dialog = gtk.MessageDialog(parent=self.dialog,
-                       flags=gtk.DIALOG_DESTROY_WITH_PARENT,
-                       type=gtk.MESSAGE_INFO,
-                       buttons=gtk.BUTTONS_OK,
-                       message_format=_("Handler has been installed successfully"))
-            dialog.connect('response', lambda w, id: dialog.destroy())
+            self._show_module_installed_dialog()
         except Exception, e:
-            dialog = ErrorDialog(self.dialog, _("Handler could not be installed due a problem with the provided file"), traceback.format_exc() )
+            dialog = ErrorDialog(self.dialog,
+                                 _("Extension could not be installed due a problem with the provided file"),
+                                 traceback.format_exc() )
         
         dialog.run()
         return

Modified: trunk/deskbar/ui/preferences/ModuleListView.py
==============================================================================
--- trunk/deskbar/ui/preferences/ModuleListView.py	(original)
+++ trunk/deskbar/ui/preferences/ModuleListView.py	Tue Mar 18 17:28:57 2008
@@ -141,8 +141,9 @@
         self.append_column(column_description)
     
     def get_description_data(self, column, cell, model, iter, data=None):
-        mod = model[iter][model.MODULE_CTX_COL]
-        description = "<b>%s</b>\n%s" % (mod[1], mod[2])
+        mod_name = model[iter][model.MODULE_NAME]
+        mod_desc = model[iter][model.MODULE_DESCRIPTION]
+        description = "<b>%s</b>\n%s" % (mod_name, mod_desc)
             
         cell.set_property ("markup", description)
         
@@ -150,7 +151,7 @@
         model, iter = self.get_selection().get_selected()
         if iter is None:
             return None
-        return model[iter][model.MODULE_CTX_COL][0]
+        return model[iter][model.MODULE_ID]
         
 if gtk.pygtk_version < (2,8,0):
     gobject.type_register(WebModuleListView)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]