예제 #1
0
 def __set_surface(self, surface):
     """
         Set artwork from surface
         @param surface as cairo.Surface
     """
     if self.__cancellable.is_cancelled():
         return
     self._artwork.set_from_surface(
         get_round_surface(surface, self._scale_factor, 50))
     self.emit("populated")
예제 #2
0
 def __on_load_from_cache(self, pixbuf):
     """
         Set artwork surface
         @param pixbuf as GdkPixbuf.Pixbuf
     """
     if not self.__cancellable.is_cancelled() and pixbuf is not None:
         surface = Gdk.cairo_surface_create_from_pixbuf(
             pixbuf, self._artwork.get_scale_factor(), None)
         self._artwork.set_from_surface(
             get_round_surface(surface, self._scale_factor,
                               self._art_size / 4))
     emit_signal(self, "populated")
예제 #3
0
 def on_load_from_cache(pixbuf, artwork):
     if pixbuf is not None:
         scale_factor = artwork.get_scale_factor()
         surface = Gdk.cairo_surface_create_from_pixbuf(
             pixbuf.scale_simple(ArtSize.MEDIUM, ArtSize.MEDIUM,
                                 GdkPixbuf.InterpType.BILINEAR),
             scale_factor, None)
         del pixbuf
         rounded = get_round_surface(surface, scale_factor,
                                     ArtSize.MEDIUM / 4)
         artwork.set_from_surface(rounded)
         del rounded
         artwork.show()
예제 #4
0
 def __set_surface(self, surface):
     """
         Set artwork from surface
         @param surface as cairo.Surface
     """
     if self.__cancellable.is_cancelled():
         return
     rounded = get_round_surface(surface, self._scale_factor,
                                 self._art_size / 4)
     del surface
     self._artwork.set_from_surface(rounded)
     App().art.add_artwork_to_cache(self.artwork_name, rounded, "ROUNDED")
     del rounded
     emit_signal(self, "populated")
예제 #5
0
 def _on_get_artwork_pixbuf(self, pixbuf, width, height, scale_factor,
                            effect, callback, *args):
     """
         Transform pixbuf to surface and load surface effects
         @param pixbuf as Gdk.Pixbuf
         @param size as int
         @param scale_factor as int
         @param effect as ArtBehaviour
         @param callback as function
     """
     surface = None
     if pixbuf is not None:
         if effect & ArtBehaviour.ROUNDED:
             radius = pixbuf.get_width() / 2
             surface = get_round_surface(pixbuf, scale_factor, radius)
         elif effect & ArtBehaviour.ROUNDED_BORDER:
             surface = get_round_surface(pixbuf, scale_factor, 5)
         else:
             surface = Gdk.cairo_surface_create_from_pixbuf(
                 pixbuf, scale_factor, None)
         del pixbuf
     App().task_helper.run(self.__surface_effects, surface, width, height,
                           scale_factor, effect, callback, *args)
예제 #6
0
 def _on_get_artwork_pixbuf(self, pixbuf, width, height, scale_factor,
                            callback, effect):
     """
         Set pixbuf as surface
         @param pixbuf as Gdk.Pixbuf
         @param size as int
         @param scale_factor as int
         @param callback as function
         @param effect as ArtHelperEffect
     """
     surface = None
     if pixbuf is not None:
         if effect & ArtHelperEffect.ROUNDED:
             surface = get_round_surface(pixbuf, scale_factor)
         else:
             surface = Gdk.cairo_surface_create_from_pixbuf(
                 pixbuf, scale_factor, None)
     callback(surface)