~gilir/sessioninstaller/defer-migration

« back to all changes in this revision

Viewing changes to sessioninstaller/core.py

  • Committer: sebi at glatzor
  • Date: 2010-05-24 06:42:23 UTC
  • Revision ID: sebi@glatzor.de-20100524064223-ewvu1t8zy4t3fswv
Make use of app-install-data and apt-xapian-index to render applications in the confirm dialog

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
import pango
45
45
from xdg.DesktopEntry import DesktopEntry
46
46
 
 
47
import utils
47
48
import errors
48
49
 
49
50
_backend_env = os.getenv("SESSIONINSTALLER_BACKEND", "aptdaemon")
104
105
DAEMON_IDLE_TIMEOUT = 3 * 60
105
106
DAEMON_IDLE_CHECK_INTERVAL = 30
106
107
 
107
 
APP_INSTALL_DATA = "/usr/share/app-install/desktop"
108
108
 
109
109
def track_usage(func):
110
110
    """Decorator to keep track of running methods and to update the time
290
290
        self.install_button.props.sensitive = False
291
291
        for pkg in pkgs:
292
292
            self.add_package(pkg)
293
 
 
294
293
    def add_package(self, pkg, active=True, details="", score=0):
295
294
        """Show the package in the confirmation dialog.
296
295
 
363
362
    def _render_description(self, cell, renderer, model, iter):
364
363
        """Helper to render the package description."""
365
364
        pkg = model.get_value(iter, COLUMN_PACKAGE)
366
 
        markup = "<b>%s</b>\n%s" % (pkg.summary, pkg.name)
 
365
        markup = utils.get_package_desc(pkg)
367
366
        renderer.set_property("markup", markup)
368
367
 
369
368
    def _render_details(self, cell, renderer, model, iter):
782
781
 
783
782
    @track_usage
784
783
    def _install_mime_types(self, xid, mime_types_list, interaction):
785
 
        if not os.path.exists(APP_INSTALL_DATA):
 
784
        if not os.path.exists(utils.APP_INSTALL_DATA):
786
785
            #FIXME: should provide some information about how to find apps
787
786
            header = _("Installing mime type handlers isn't supported")
788
787
            message = _("To search and install software which can open "
828
827
        package_map = {}
829
828
        unsatisfied = mime_types.copy()
830
829
        mixed = False
831
 
        for count, path in enumerate(os.listdir(APP_INSTALL_DATA)):
 
830
        for count, path in enumerate(os.listdir(utils.APP_INSTALL_DATA)):
832
831
            if path[0] == "." or not path.endswith(".desktop"):
833
832
                continue
834
833
            if not count % 20:
839
838
                    progress.hide()
840
839
                    progress.destroy()
841
840
                    raise errors.ModifyCancelled
842
 
            desktop_entry = DesktopEntry(os.path.join(APP_INSTALL_DATA, path))
 
841
            desktop_entry = DesktopEntry(os.path.join(utils.APP_INSTALL_DATA,
 
842
                                                      path))
843
843
            pkg_name = desktop_entry.get("X-AppInstall-Package")
844
844
            try:
845
845
                if self._cache[pkg_name].is_installed: