Beispiel #1
0
 def test_split_icon_ext(self):
     from softwarecenter.utils import split_icon_ext
     for unchanged in ["foo.bar.baz", "foo.bar", "foo", 
                       "foo.pngx", "foo.png.xxx"]:
         self.assertEqual(split_icon_ext(unchanged), unchanged)
     for changed in ["foo.png", "foo.tiff", "foo.jpg", "foo.jpeg"]:
         self.assertEqual(split_icon_ext(changed), 
                         os.path.splitext(changed)[0])
 def test_split_icon_ext(self):
     from softwarecenter.utils import split_icon_ext
     for unchanged in ["foo.bar.baz", "foo.bar", "foo", 
                       "foo.pngx", "foo.png.xxx"]:
         self.assertEqual(split_icon_ext(unchanged), unchanged)
     for changed in ["foo.png", "foo.tiff", "foo.jpg", "foo.jpeg"]:
         self.assertEqual(split_icon_ext(changed), 
                         os.path.splitext(changed)[0])
Beispiel #3
0
 def test_split_icon_ext(self):
     for unchanged in [
             "foo.bar.baz", "foo.bar", "foo", "foo.pngx", "foo.png.xxx"
     ]:
         self.assertEqual(split_icon_ext(unchanged), unchanged)
     for changed in ["foo.png", "foo.tiff", "foo.jpg", "foo.jpeg"]:
         self.assertEqual(split_icon_ext(changed),
                          os.path.splitext(changed)[0])
Beispiel #4
0
 def icon(self):
     if self.pkg_state == PkgStates.NOT_FOUND:
         return Icons.MISSING_PKG
     if self._doc:
         return split_icon_ext(self._db.get_iconname(self._doc))
     if not self.summary:
         return Icons.MISSING_PKG
Beispiel #5
0
    def get_icon(self, doc):
        try:
            full_icon_file_name = self.db.get_iconname(doc)
            icon_file_name = split_icon_ext(full_icon_file_name)
            if icon_file_name:
                icon_name = icon_file_name
                if icon_name in self.icon_cache:
                    return self.icon_cache[icon_name]
                # icons.load_icon takes between 0.001 to 0.01s on my
                # machine, this is a significant burden because get_value
                # is called *a lot*. caching is the only option

                # look for the icon on the iconpath
                if self.icons.has_icon(icon_name):
                    icon = self.icons.load_icon(icon_name, self.icon_size, 0)
                    if icon:
                        self.icon_cache[icon_name] = icon
                        return icon
                elif self.db.get_icon_download_url(doc):
                    url = self.db.get_icon_download_url(doc)
                    self._download_icon_and_show_when_ready(
                        url,
                        self.get_pkgname(doc),
                        full_icon_file_name)
                    # display the missing icon while the real one downloads
                    self.icon_cache[icon_name] = self.missing_icon
        except GObject.GError as e:
            LOG.debug("get_icon returned '%s'" % e)
        return self.missing_icon
Beispiel #6
0
    def get_icon(self, doc):
        try:
            full_icon_file_name = self.db.get_iconname(doc)
            icon_file_name = split_icon_ext(full_icon_file_name)
            if icon_file_name:
                icon_name = icon_file_name
                if icon_name in self.icon_cache:
                    return self.icon_cache[icon_name]
                # icons.load_icon takes between 0.001 to 0.01s on my
                # machine, this is a significant burden because get_value
                # is called *a lot*. caching is the only option

                # look for the icon on the iconpath
                if self.icons.has_icon(icon_name):
                    icon = self.icons.load_icon(icon_name, self.icon_size, 0)
                    if icon:
                        self.icon_cache[icon_name] = icon
                        return icon
                elif self.db.get_icon_download_url(doc):
                    url = self.db.get_icon_download_url(doc)
                    self._download_icon_and_show_when_ready(
                        url,
                        self.get_pkgname(doc),
                        full_icon_file_name)
                    # display the missing icon while the real one downloads
                    self.icon_cache[icon_name] = self._missing_icon
        except GObject.GError as e:
            LOG.debug("get_icon returned '%s'" % e)
        return self._missing_icon
Beispiel #7
0
 def on_image_download_complete(downloader, image_file_path):
     pb = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file_path,
                                               self.icon_size,
                                               self.icon_size)
     # replace the icon in the icon_cache now that we've got the real one
     icon_file = split_icon_ext(os.path.basename(image_file_path))
     self.icon_cache[icon_file] = pb
Beispiel #8
0
 def on_image_download_complete(downloader, image_file_path, pkgname):
     LOG.debug("download for '%s' complete" % image_file_path)
     pb = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file_path, self.icon_size, self.icon_size)
     # replace the icon in the icon_cache now that we've got the real
     # one
     icon_file = split_icon_ext(os.path.basename(image_file_path))
     self.icon_cache[icon_file] = pb
     self.emit("needs-refresh", pkgname)
Beispiel #9
0
 def on_image_download_complete(downloader, image_file_path, pkgname):
     LOG.debug("download for '%s' complete" % image_file_path)
     pb = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file_path,
                                                 self.icon_size,
                                                 self.icon_size)
     # replace the icon in the icon_cache now that we've got the real
     # one
     icon_file = split_icon_ext(os.path.basename(image_file_path))
     self.icon_cache[icon_file] = pb
     self.emit("needs-refresh", pkgname)
 def _on_image_download_complete(self, downloader, image_file_path,
                                 pkgname):
     LOG.debug("download for '%s' complete" % image_file_path)
     try:
         pb = GdkPixbuf.Pixbuf.new_from_file_at_size(
             image_file_path, self.icon_size, self.icon_size)
     except GObject.GError as e:
         LOG.warn("Failed to get image file for '%s' (%s)", image_file_path,
                  e)
         return
     # replace the icon in the icon_cache now that we've got the real
     # one
     icon_file = split_icon_ext(os.path.basename(image_file_path))
     self.icon_cache[icon_file] = pb
     self.emit("needs-refresh", pkgname)
Beispiel #11
0
 def _on_image_download_complete(
         self, downloader, image_file_path, pkgname):
     LOG.debug("download for '%s' complete" % image_file_path)
     try:
         pb = GdkPixbuf.Pixbuf.new_from_file_at_size(image_file_path,
                                                     self.icon_size,
                                                     self.icon_size)
     except GObject.GError as e:
         LOG.warn("Failed to get image file for '%s' (%s)",
                  image_file_path, e)
         return
     # replace the icon in the icon_cache now that we've got the real
     # one
     icon_file = split_icon_ext(os.path.basename(image_file_path))
     self.icon_cache[icon_file] = pb
     self.emit("needs-refresh", pkgname)
Beispiel #12
0
 def test_split_icon_ext(self):
     for unchanged in ["foo.bar.baz", "foo.bar", "foo", "foo.pngx", "foo.png.xxx"]:
         self.assertEqual(split_icon_ext(unchanged), unchanged)
     for changed in ["foo.png", "foo.tiff", "foo.jpg", "foo.jpeg"]:
         self.assertEqual(split_icon_ext(changed), os.path.splitext(changed)[0])