Exemplo n.º 1
0
 def change_cover_pixbuf(self, new_path):
     cover_name = None
     if self.tag == "album":
         cover_name = "%s-%s" % (self.value_name, self.key_name)
     elif self.tag == "artist":    
         cover_name = self.key_name
     if cover_name:    
         CoverManager.change_cover(cover_name, new_path)            
Exemplo n.º 2
0
    def update_song(self, song):
        self.song = song

        # Update simpler.
        self.cover_image.set_from_pixbuf(
            CoverManager.get_pixbuf_from_song(song, 92, 92, False, False))
        self.title_label.set_text(utils.xmlescape(song.get_str("title")))
        self.artist_label.set_text(utils.xmlescape(song.get_str("artist")))
        self.album_label.set_text(utils.xmlescape(song.get_str("album")))

        # Update detail.
        if self.song.get_type() not in ["cue", "local", "cdda"]:
            utils.ThreadRun(self.get_song_attr, self.file_type_label.set_text,
                            (song, True)).start()
            utils.ThreadRun(self.get_song_attr,
                            self.file_format_label.set_text,
                            (song, False)).start()
        else:
            self.file_type_label.set_text(self.get_song_attr(song, True))
            self.file_format_label.set_text(self.get_song_attr(song, False))

        self.file_size_label.set_text(song.get_str("#size"))
        self.song_duration_label.set_text(song.get_str("#duration"))
        self.song_bitrate_label.set_text(song.get_str("#bitrate"))
        self.song_rate_label.set_text(song.get_str("#rate"))
        self.song_added_label.set_text(song.get_str("#added"))
        self.song_lasted_label.set_text(song.get_str("#lastplayed"))
        self.song_playcount_label.set_text(song.get_str("#playcount"))
        self.song_date_label.set_text(song.get_str("#date"))

        # Update location.
        self.location_entry.set_text(song.get_path())
Exemplo n.º 3
0
    def __get_metadata(self, song):
        meta = {}

        if song is not None:
            ## MPRIS v2 meta map, defined at http://xmms2.org/wiki/MPRIS_Metadata

            meta['mpris:trackid'] = dbus.ObjectPath(self._get_trackid(song))
            meta['xesam:url'] = song.get_str("uri")
            meta['xesam:title'] = song.get_str("title")
            artist = song.get_str("artist")
            if artist:
                meta['xesam:artist'] = dbus.types.Array([artist],
                                                        signature='s')

            album = song.get_str("album")
            if album:
                meta['xesam:album'] = album

            genre = song.get_str("genre")
            if genre:
                meta['xesam:genre'] = dbus.types.Array([genre], signature='s')

            tracklen = song.get("#duration")
            if tracklen:
                meta['mpris:length'] = dbus.types.Int64(tracklen / 1000 *
                                                        MICROSECOND)

            # this is a workaround, write data to a tmp file and return name
            meta['mpris:artUrl'] = "file://" + (CoverManager.get_cover(
                song, False) or CoverManager.default_cover)

        return dbus.types.Dictionary(meta, signature='sv', variant_level=1)
Exemplo n.º 4
0
    def set_current_cover(self, try_web=True, force_song=None):
        if not force_song:
            force_song = self.current_song
        filename = CoverManager.get_cover(force_song, try_web)
        if Player.song != force_song:
            return False

        if not filename:
            if not try_web:
                if force_song.get_type() == "webcast":
                    pixbuf = utils.get_optimum_pixbuf(
                        self.webcast_dpixbuf.get_pixbuf(), COVER_SIZE["x"],
                        COVER_SIZE["y"])
                    self.start_animation(pixbuf, is_default=True)
                    return True
                else:
                    pixbuf = utils.get_optimum_pixbuf(
                        self.local_dpixbuf.get_pixbuf(), COVER_SIZE["x"],
                        COVER_SIZE["y"])
                    self.start_animation(pixbuf, is_default=True)
                    return False
            return False
        else:
            try:
                pixbuf = get_optimum_pixbuf_from_file(filename,
                                                      COVER_SIZE["x"],
                                                      COVER_SIZE["y"])
            except gobject.GError:
                return False
            else:
                self.start_animation(pixbuf, is_default=False)
                return True
    def __get_metadata(self, song):
        meta = {}

        if song is not None:
            ## MPRIS v2 meta map, defined at http://xmms2.org/wiki/MPRIS_Metadata

            meta['mpris:trackid'] = dbus.ObjectPath(self._get_trackid(song))
            meta['xesam:url'] = song.get_str("uri")
            meta['xesam:title'] = song.get_str("title")
            artist = song.get_str("artist")
            if artist:
                meta['xesam:artist'] = dbus.types.Array([artist], signature='s')

            album = song.get_str("album")
            if album:
                meta['xesam:album'] = album

            genre = song.get_str("genre")
            if genre:
                meta['xesam:genre'] = dbus.types.Array([genre], signature='s')

            tracklen = song.get("#duration")
            if tracklen:
                meta['mpris:length'] = dbus.types.Int64(tracklen / 1000 * MICROSECOND)

            # this is a workaround, write data to a tmp file and return name
            meta['mpris:artUrl'] = "file://" + (CoverManager.get_cover(song, False) or CoverManager.default_cover)

        return dbus.types.Dictionary(meta, signature='sv', variant_level=1)
Exemplo n.º 6
0
    def update_song(self, song):
        self.song = song
        
        # Update simpler.
        self.cover_image.set_from_pixbuf(CoverManager.get_pixbuf_from_song(song, 92, 92, False, False))
        self.title_label.set_text(utils.xmlescape(song.get_str("title")))
        self.artist_label.set_text(utils.xmlescape(song.get_str("artist")))
        self.album_label.set_text(utils.xmlescape(song.get_str("album")))
        
        # Update detail.
        if self.song.get_type() not in ["cue", "local", "cdda"]:
            utils.ThreadRun(self.get_song_attr, self.file_type_label.set_text, (song, True)).start()
            utils.ThreadRun(self.get_song_attr, self.file_format_label.set_text, (song, False)).start()
        else:    
            self.file_type_label.set_text(self.get_song_attr(song, True))
            self.file_format_label.set_text(self.get_song_attr(song, False))        

        self.file_size_label.set_text(song.get_str("#size"))
        self.song_duration_label.set_text(song.get_str("#duration"))        
        self.song_bitrate_label.set_text(song.get_str("#bitrate"))
        self.song_rate_label.set_text(song.get_str("#rate"))        
        self.song_added_label.set_text(song.get_str("#added"))
        self.song_lasted_label.set_text(song.get_str("#lastplayed"))
        self.song_playcount_label.set_text(song.get_str("#playcount"))
        self.song_date_label.set_text(song.get_str("#date"))        
        
        # Update location.
        self.location_entry.set_text(song.get_path())
Exemplo n.º 7
0
 def set_current_cover(self, try_web=True, force_song=None):            
     if not force_song:
         force_song = self.current_song
     filename = CoverManager.get_cover(force_song, try_web)    
     if Player.song != force_song:
         return False
     
     if not filename:
         if not try_web:
             if force_song.get_type() == "webcast":
                 pixbuf = utils.get_optimum_pixbuf(self.webcast_dpixbuf.get_pixbuf(), 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
                 self.start_animation(pixbuf, is_default=True)
                 return True
             else:    
                 pixbuf = utils.get_optimum_pixbuf(self.local_dpixbuf.get_pixbuf(), 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
                 self.start_animation(pixbuf, is_default=True)
                 return False
         return False    
     else:
         try:
             pixbuf = get_optimum_pixbuf_from_file(filename, 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
         except gobject.GError:    
             return False
         else:
             self.start_animation(pixbuf, is_default=False)
             return True
Exemplo n.º 8
0
 def update_song(self, song):
     self.song = song
     song_cover_pixbuf = CoverManager.get_pixbuf_from_song(song,
                                                           300,
                                                           180,
                                                           False,
                                                           optimum=False)
     self.cover_image.set_from_pixbuf(song_cover_pixbuf)
Exemplo n.º 9
0
 def on_new_song(self, player, song):    
     icon = CoverManager.get_path_from_song(song)
     self.dbus_notify.set_icon_from_path(icon)
     self.dbus_notify.set_summary(song.get_str("title"))
     body = ""
     if song.get_str("artist"):
         body = "%s: %s\n" % (_("Artist"), song.get_str("artist"))
     if song.get_str("album"):    
         body += "%s: %s\n" % (_("Album"), song.get_str("album"))
     self.dbus_notify.set_body(body)    
     self.dbus_notify.notify()
Exemplo n.º 10
0
 def on_new_song(self, player, song):
     icon = CoverManager.get_path_from_song(song)
     self.dbus_notify.set_icon_from_path(icon)
     self.dbus_notify.set_summary(song.get_str("title"))
     body = ""
     if song.get_str("artist"):
         body = "%s: %s\n" % (_("Artist"), song.get_str("artist"))
     if song.get_str("album"):
         body += "%s: %s\n" % (_("Album"), song.get_str("album"))
     self.dbus_notify.set_body(body)
     self.dbus_notify.notify()
Exemplo n.º 11
0
 def create_pixbuf(self):
     try:
         if self.pixbuf:
             del self.pixbuf
     except: pass        
         
     if not self.key_name:
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.name_label, self.cell_width, self.cell_width,
                                                             return_default=False)            
         
     elif self.key_name == "deepin-all-songs":    
         # self.pixbuf = CoverManager.get_all_song_cover(self.cell_width, self.cell_width)
         pixbuf = CoverManager.get_combo_all_cover(self.tag)
         if pixbuf:
             self.pixbuf = pixbuf
         else:    
             self.pixbuf = app_theme.get_pixbuf("cover/all_song.png").get_pixbuf()
         # self.draw_side_flag = False
     else:    
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         elif self.tag == "album":    
             self.pixbuf = CoverManager.get_pixbuf_from_name("%s-%s" % (self.value_name, self.key_name), 
                                                             self.cell_width, self.cell_width,
                                                             return_default=False)            
         elif self.tag == "folder":
                self.pixbuf = app_theme.get_pixbuf("local/music.png").get_pixbuf()
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.key_name, self.cell_width, self.cell_width,
                                                             return_default=False)
Exemplo n.º 12
0
 def set_current_cover(self, try_web=True, force_song=None):            
     if not force_song:
         force_song = self.current_song
     filename = CoverManager.get_cover(force_song, try_web)    
     try:
         pixbuf = get_optimum_pixbuf_from_file(filename, COVER_SIZE["x"], COVER_SIZE["y"])
     except gobject.GError:    
         pass
     else:
         self.current_cover_pixbuf = pixbuf
         self.queue_draw()            
         del pixbuf
         if not try_web:
             return CoverManager.default_cover != filename
Exemplo n.º 13
0
    def render_info(self, cr, rect):
        if self.is_hover:
            draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height, "globalItemHover")
        
        if self.icon_pixbuf is None:
            self.icon_pixbuf = CoverManager.get_pixbuf_from_song(self.song, 37, 38, try_web=False)
            
            
        icon_width = self.icon_pixbuf.get_width()
        icon_height = self.icon_pixbuf.get_height()
        icon_x = rect.x + self.info_padding_x
        icon_y = rect.y + (rect.height - icon_height) / 2
        
        # Draw shadow.
        drop_shadow_padding = 3
        drop_shadow_radious = 3
        draw_shadow(
            cr,
            icon_x,
            icon_y,
            icon_width + drop_shadow_padding,
            icon_height + drop_shadow_padding,
            drop_shadow_radious,
            app_theme.get_shadow_color("window_shadow")
            )

        outside_shadow_padding = 2
        outside_shadow_radious = 3
        draw_shadow(
            cr,
            icon_x - outside_shadow_padding,
            icon_y - outside_shadow_padding,
            icon_width + outside_shadow_padding * 2,
            icon_height + outside_shadow_padding * 2,
            outside_shadow_radious,
            app_theme.get_shadow_color("window_shadow")
            )
        
        # Draw wallpaper.
        
        draw_pixbuf(cr, self.icon_pixbuf, icon_x, icon_y)
        rect.x = icon_x + self.icon_pixbuf.get_width() + self.info_padding_x
        rect.width -= self.info_padding_x * 2 - self.icon_pixbuf.get_width()
        _width, _height = get_content_size("%s" % self.song.get_str("title"))
        draw_text(cr, "<b>%s</b>" % self.song.get_str("title"), rect.x, icon_y, rect.width, _height,
                  text_size=10)                   
        
        rect.y = icon_y + icon_width - _height
        _width, _height = get_content_size(self.status_text)
        draw_text(cr, self.status_text, rect.x, rect.y, rect.width, _height)
Exemplo n.º 14
0
    def render_info(self, cr, rect):
        if self.is_hover:
            draw_single_mask(cr, rect.x, rect.y, rect.width, rect.height,
                             "globalItemHover")

        if self.icon_pixbuf is None:
            self.icon_pixbuf = CoverManager.get_pixbuf_from_song(self.song,
                                                                 37,
                                                                 38,
                                                                 try_web=False)

        icon_width = self.icon_pixbuf.get_width()
        icon_height = self.icon_pixbuf.get_height()
        icon_x = rect.x + self.info_padding_x
        icon_y = rect.y + (rect.height - icon_height) / 2

        # Draw shadow.
        drop_shadow_padding = 3
        drop_shadow_radious = 3
        draw_shadow(cr, icon_x, icon_y, icon_width + drop_shadow_padding,
                    icon_height + drop_shadow_padding, drop_shadow_radious,
                    app_theme.get_shadow_color("window_shadow"))

        outside_shadow_padding = 2
        outside_shadow_radious = 3
        draw_shadow(cr, icon_x - outside_shadow_padding,
                    icon_y - outside_shadow_padding,
                    icon_width + outside_shadow_padding * 2,
                    icon_height + outside_shadow_padding * 2,
                    outside_shadow_radious,
                    app_theme.get_shadow_color("window_shadow"))

        # Draw wallpaper.

        draw_pixbuf(cr, self.icon_pixbuf, icon_x, icon_y)
        rect.x = icon_x + self.icon_pixbuf.get_width() + self.info_padding_x
        rect.width -= self.info_padding_x * 2 - self.icon_pixbuf.get_width()
        _width, _height = get_content_size("%s" % self.song.get_str("title"))
        draw_text(cr,
                  "<b>%s</b>" % self.song.get_str("title"),
                  rect.x,
                  icon_y,
                  rect.width,
                  _height,
                  text_size=10)

        rect.y = icon_y + icon_width - _height
        _width, _height = get_content_size(self.status_text)
        draw_text(cr, self.status_text, rect.x, rect.y, rect.width, _height)
Exemplo n.º 15
0
    def __init__(self):
        super(CoverButton, self).__init__()
        
        self.current_cover_pixbuf = CoverManager.get_default_cover(COVER_SIZE["x"], COVER_SIZE["y"])
        self.cover_side_pixbuf = app_theme.get_pixbuf("cover/side.png").get_pixbuf()
        self.set_size_request(self.cover_side_pixbuf.get_width(), self.cover_side_pixbuf.get_height())

        self.connect("expose-event", self.expose_button_cb)
        MediaDB.connect("simple-changed", self.update_cover)
        self.current_song = None
        self.next_cover_to_download = None
        
        self.condition = threading.Condition()
        self.thread = threading.Thread(target=self.func_thread)
        self.thread.setDaemon(True)
        self.thread.start()
Exemplo n.º 16
0
 def update_song(self, song):
     self.song = song
     
     # Update simpler.
     self.cover_image.set_from_pixbuf(CoverManager.get_pixbuf_from_song(song, 92, 92, False, False))
     self.title_label.set_text(song.get_str("title"))
     self.artist_label.set_text(song.get_str("artist"))
     self.album_label.set_text(song.get_str("album"))
     
     # Update detail.
     self.file_type_label.set_text(self.get_song_attr(song, True))
     self.file_format_label.set_text(self.get_song_attr(song, False))        
     self.file_size_label.set_text(song.get_str("#size"))
     self.song_duration_label.set_text(song.get_str("#duration"))        
     self.song_bitrate_label.set_text(song.get_str("#bitrate"))
     self.song_rate_label.set_text(song.get_str("#rate"))        
     self.song_added_label.set_text(song.get_str("#added"))
     self.song_lasted_label.set_text(song.get_str("#lastplayed"))
     self.song_playcount_label.set_text(song.get_str("#playcount"))
     self.song_date_label.set_text(song.get_str("#date"))        
     
     # Update location.
     self.location_entry.set_text(song.get_path())
Exemplo n.º 17
0
 def __init__(self, _tuple):
     super(IconItem, self).__init__()
     self.cell_width = 83        
     self.key_name, value_name, nums, self.tag = _tuple
     self.draw_side_flag = True
     
     if not self.key_name:
         self.name_label= _("Unknown")
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.name_label, self.cell_width, self.cell_width)            
         
     elif self.key_name == "deepin-all-songs":    
         self.pixbuf = CoverManager.get_all_song_cover(self.cell_width, self.cell_width)
         self.name_label = _("All tracks")
         self.draw_side_flag = False
     else:    
         self.name_label = self.key_name
         if self.tag == "genre":
             self.pixbuf = CoverManager.get_pixbuf_from_genre(self.name_label)
         elif self.tag == "album":    
             self.pixbuf = CoverManager.get_pixbuf_from_name("%s-%s" % (value_name, self.key_name), 
                                                             self.cell_width, self.cell_width)            
         else:    
             self.pixbuf = CoverManager.get_pixbuf_from_name(self.key_name, self.cell_width, self.cell_width)
         
     self.labels = _("%d tracks") % nums
     self.padding_x = 4
     self.padding_y = 4
     self.hover_flag = False
     self.highlight_flag = False
     self.__draw_play_hover_flag = False
     self.__draw_play_press_flag = False
     self.__normal_side_pixbuf =  app_theme.get_pixbuf("filter/side_normal.png").get_pixbuf()
     self.__normal_play_pixbuf =  app_theme.get_pixbuf("filter/play_normal.png").get_pixbuf()
     
     self.play_rect = gtk.gdk.Rectangle(
         self.__normal_side_pixbuf.get_width() - self.__normal_play_pixbuf.get_width() - 2 - 6,
         self.__normal_side_pixbuf.get_height() - self.__normal_play_pixbuf.get_height() - 2 - 6,
         self.__normal_play_pixbuf.get_width(),
         self.__normal_play_pixbuf.get_height()
         )
     
     self.retrieve = TransforDB.convert(self.name_label.lower().replace(" ", "")) + self.name_label.lower().replace(" ", "")
Exemplo n.º 18
0
 def fetch_cover_image(self, widget):
     CoverManager.fetch_cover(self.song)
Exemplo n.º 19
0
 def delete_cover_image(self, widget):        
     CoverManager.remove_cover(self.song, True)
Exemplo n.º 20
0
 def change_cover_image(self, widget):
     new_cover_path = WinFile(False, _("Select image")).run()
     if new_cover_path:
         CoverManager.change_cover(self.song, new_cover_path)
Exemplo n.º 21
0
 def update_song(self, song):    
     self.song = song
     song_cover_pixbuf = CoverManager.get_pixbuf_from_song(song, 300, 180, False, optimum=False)
     self.cover_image.set_from_pixbuf(song_cover_pixbuf)
Exemplo n.º 22
0
 def fetch_cover_image(self, widget):        
     CoverManager.fetch_cover(self.song)
Exemplo n.º 23
0
 def update_default_cover(self, widget, song):            
     if not self.current_song or CoverManager.get_cover_search_str(self.current_song) != CoverManager.get_cover_search_str(song):
         pixbuf = CoverManager.get_pixbuf_from_album("", COVER_SIZE["x"], COVER_SIZE["y"])
         self.current_cover_pixbuf = pixbuf
         self.queue_draw()
Exemplo n.º 24
0
 def change_cover_image(self, widget):
     new_cover_path = WinFile(False, _("Select image")).run()
     if new_cover_path:
         CoverManager.change_cover(self.song, new_cover_path)
Exemplo n.º 25
0
 def delete_cover_image(self, widget):
     CoverManager.remove_cover(self.song, True)
Exemplo n.º 26
0
 def instant_update_cover(self, widget, song):    
     if not CoverManager.get_cover(song, False):
         self.update_default_cover(widget, song)
     else:    
         self.update_cover(widget, song)
Exemplo n.º 27
0
 def get_song_cover(self):
     return CoverManager.get_pixbuf_from_song(self.song, 
                                             BROWSER_COVER_SIZE["x"], 
                                             BROWSER_COVER_SIZE["y"],
                                             try_web=False,
                                             optimum=True)