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())
Exemple #2
0
    def init_size(self):
        tw = self.default_width - self.padding_x * 2
        intro = self.channel_info.get("intro", "").strip()
        intro = utils.xmlescape(intro)
        intro_text = "<b>%s:</b> %s" % ("简介", intro)
        intro_th = 0
        if intro:
            intro_tw, intro_th = get_content_size(intro_text,
                                                  wrap_width=tw,
                                                  text_size=9)
            if intro_th > self.line_height * 2:
                intro_th = self.line_height * 2

        hotsongs = " / ".join(self.channel_info.get("hot_songs", [])).strip()
        hotsongs = utils.xmlescape(hotsongs)
        hotsongs_text = "<b>%s:</b> %s" % ("热门歌曲", hotsongs)
        hotsongs_tw, hotsongs_th = get_content_size(hotsongs_text,
                                                    wrap_width=tw,
                                                    text_size=9)
        if hotsongs_th > self.line_height * 2:
            hotsongs_th = self.line_height * 2

        if intro_th == 0:
            height = hotsongs_th + self.line_height * 2
        else:
            height = hotsongs_th + intro_th + self.line_height * 4
        self.set_size_request(self.default_width, height)
Exemple #3
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())
Exemple #4
0
 def get_channel_contents(self, channel_info):
     name = utils.xmlescape(channel_info.get("name", ""))
     intro = utils.xmlescape(channel_info.get("intro", ""))
     hot_songs = "%s: %s" % ("热门歌曲",
                             utils.xmlescape(" / ".join(
                                 channel_info.get("hot_songs", []))))
     songs = "%s%s" % (str(channel_info.get("song_num", "0")), "首歌曲")
     return (name, intro, hot_songs, songs)
 def update_size(self):    
     self.channel_name = utils.xmlescape(self.channel_info.get("name", ""))
     __, self.name_h = get_content_size(self.channel_name, text_size=9)
     
     self.detail_info = "%s首歌曲 %s制作" % (self.channel_info.get("song_num"),
                                    utils.xmlescape(self.channel_info.get("creator", {}).get("name", "")))
     __, self.detail_h = get_content_size(self.detail_info, text_size=8)
     
     intro = utils.xmlescape(self.channel_info.get("intro", "").strip())
     hotsongs = utils.xmlescape(" ".join(self.channel_info.get("hot_songs")))
     self.channel_intro = intro or hotsongs               
     __, self.intro_h = get_content_size(self.channel_intro, text_size=8)
Exemple #6
0
    def render(self, cr, rect):
        '''
        Render item.
        
        This is IconView interface, you should implement it.
        '''
        # Draw cover.

        if self.pixbuf is None:
            self.create_cover_pixbuf()

        pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2

        cr.save()
        cr.arc(pixbuf_x + self.pixbuf.get_width() / 2,
               rect.y + self.pixbuf.get_height() / 2,
               self.pixbuf.get_width() / 2, 0, 2 * math.pi)
        cr.clip()
        draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y)
        cr.restore()

        if self.pixbuf_rect is None:
            self.pixbuf_rect = gtk.gdk.Rectangle(
                (rect.width - self.pixbuf.get_width()) / 2, 0,
                self.pixbuf.get_width(), self.pixbuf.get_height())

        if self.mask_flag:
            if self.mask_pixbuf is None:
                self.create_mask_pixbuf()
            cr.save()
            cr.arc(pixbuf_x + self.pixbuf.get_width() / 2,
                   rect.y + self.pixbuf.get_height() / 2,
                   self.pixbuf.get_width() / 2, 0, 2 * math.pi)
            cr.clip()
            draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y)
            cr.restore()

        title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x,
                                       rect.y + self.pixbuf.get_height() + 5,
                                       rect.width - self.padding_x * 2, 11)
        total_rect = gtk.gdk.Rectangle(title_rect.x, title_rect.y + 16,
                                       title_rect.width, 9)

        render_text(
            cr,
            utils.xmlescape(self.title),
            title_rect,
            # app_theme.get_color("labelText").get_color(),
            "#444444",
            10)
        render_text(cr, utils.xmlescape(self.description), total_rect,
                    app_theme.get_color("labelText").get_color(), 8)
Exemple #7
0
    def on_panel_expose_event(self, widget, event):    
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        draw_line(cr, (rect.x, rect.y + 1), (rect.x + rect.width, rect.y + 1), "#c7c7c7")
        draw_line(cr, (rect.x + rect.width, rect.y), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x, rect.y + rect.height), (rect.x + rect.width, rect.y + rect.height), "#c7c7c7")
        draw_line(cr, (rect.x + 1, rect.y), (rect.x + 1, rect.y + rect.height), "#c7c7c7")
        
        tx = rect.x + self.padding_x        
        ty = rect.y + self.padding_y
        tw = rect.width - self.padding_x * 2
        intro = self.channel_info.get("intro", "").strip()
        intro = utils.xmlescape(intro)
        if intro:
            intro_text = "<b>%s:</b> %s" % ("简介", intro)
            intro_tw, intro_th = get_content_size(intro_text, wrap_width=tw,text_size=9)
            if intro_th > self.line_height * 2:
                intro_th = self.line_height * 2
            cr.save()
            cr.rectangle(tx, ty, intro_tw, intro_th)
            cr.clip()
            draw_text(cr, intro_text, tx, ty, intro_tw, intro_th, text_size=9,
                      text_color="#878787", wrap_width=tw)
            cr.restore()

            with cairo_disable_antialias(cr):
                cr.save()
                cr.move_to(tx, ty + intro_th + self.line_height)
                cr.rel_line_to(tw, 0)
                cr.set_dash([2.0, 2.0])
                cr.stroke()
                cr.restore()
            
        hotsongs =  " / ".join(self.channel_info.get("hot_songs", [])).strip()
        hotsongs = utils.xmlescape(hotsongs)
        hotsongs_text = "<b>%s:</b> %s" % ("热门歌曲", hotsongs)
        if intro:
            new_ty = ty + intro_th + self.line_height * 2
        else:    
            new_ty = ty
            
        hotsongs_tw, hotsongs_th = get_content_size(hotsongs_text, wrap_width=tw,text_size=9)
        if hotsongs_th > self.line_height * 2:
            hotsongs_th = self.line_height * 2
        cr.save()
        cr.rectangle(tx, new_ty, hotsongs_tw, hotsongs_th)
        cr.clip()
        draw_text(cr, hotsongs_text, tx, new_ty, hotsongs_tw, hotsongs_th, text_size=9,
                  text_color="#878787", wrap_width=tw)
        return True
 def render(self, cr, rect):
     '''
     Render item.
     
     This is IconView interface, you should implement it.
     '''
     # Draw cover.
         
     if self.pixbuf is None:
         self.create_cover_pixbuf()
          
     pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2
         
     cr.save()    
     cr.arc(pixbuf_x + self.pixbuf.get_width() / 2,
            rect.y + self.pixbuf.get_height() / 2,
            self.pixbuf.get_width() / 2,
            0, 2 * math.pi)
     cr.clip()
     draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y)        
     cr.restore()
     
     if self.pixbuf_rect is None:
         self.pixbuf_rect = gtk.gdk.Rectangle((rect.width - self.pixbuf.get_width()) / 2, 
                                              0, self.pixbuf.get_width(), self.pixbuf.get_height())
         
     if self.mask_flag:    
         if self.mask_pixbuf is None:
             self.create_mask_pixbuf()
         cr.save()    
         cr.arc(pixbuf_x + self.pixbuf.get_width() / 2,
                rect.y + self.pixbuf.get_height() / 2,
                self.pixbuf.get_width() / 2,
                0, 2 * math.pi)
         cr.clip()
         draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y)                                
         cr.restore()
         
     title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x, 
                                    rect.y + self.pixbuf.get_height() + 5,
                                    rect.width - self.padding_x * 2, 11)
     total_rect = gtk.gdk.Rectangle(title_rect.x, title_rect.y + 16, title_rect.width, 9)
     
     render_text(cr, utils.xmlescape(self.title), title_rect, 
                 # app_theme.get_color("labelText").get_color(),
                 "#444444",
                 10)
     render_text(cr, utils.xmlescape(self.description), total_rect,
                 app_theme.get_color("labelText").get_color(),
                 8)
Exemple #9
0
    def on_expose_event(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation

        rect.x += self.padding_x
        rect.width -= self.padding_x * 2

        # Draw title.
        # _width, _height = get_content_size(self.title)
        # draw_text(cr, self.title, rect.x, rect.y, rect.width, _height)
        # rect.y += self.padding_y + _height

        # Draw dashed.
        dash_line_width = 1
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*color_hex_to_cairo("#D6D6D6"))
            cr.set_line_width(dash_line_width)
            cr.set_dash([4.0, 4.0])
            cr.move_to(rect.x, rect.y)
            cr.rel_line_to(rect.width, 0)
            cr.stroke()

        rect.y += self.padding_y + dash_line_width

        # Draw plugin name.
        if self.plugin_info:
            plugin_name = "%s: %s" % (
                _("Name"), utils.xmlescape(self.plugin_info.get("Name", "")))
            _width, _height = get_content_size(plugin_name)
            draw_text(cr, plugin_name, rect.x, rect.y, rect.width, _height)

            rect.y += self.padding_y + _height

            # Draw plugin Authors.
            plugin_authors = plugin_authors = "%s: %s" % (
                _("Author(s)"),
                utils.xmlescape(self.plugin_info.get("Authors", "")))
            _width, _height = get_content_size(plugin_authors)
            draw_text(cr, plugin_authors, rect.x, rect.y, rect.width, _height)

            rect.y += self.padding_y + _height

            # Draw plugin description
            plugin_description = self.plugin_info.get("Description", "")
            _width, _height = get_content_size(plugin_description)
            draw_text(cr, plugin_description, rect.x, rect.y, rect.width,
                      _height)

        return True
Exemple #10
0
    def update_size(self):
        self.channel_name = utils.xmlescape(self.channel_info.get("name", ""))
        __, self.name_h = get_content_size(self.channel_name, text_size=9)

        self.detail_info = "%s首歌曲 %s制作" % (
            self.channel_info.get("song_num"),
            utils.xmlescape(
                self.channel_info.get("creator", {}).get("name", "")))
        __, self.detail_h = get_content_size(self.detail_info, text_size=8)

        intro = utils.xmlescape(self.channel_info.get("intro", "").strip())
        hotsongs = utils.xmlescape(" ".join(
            self.channel_info.get("hot_songs")))
        self.channel_intro = intro or hotsongs
        __, self.intro_h = get_content_size(self.channel_intro, text_size=8)
Exemple #11
0
def render_item_text2(cr,
                      content,
                      rect,
                      in_select,
                      in_highlight,
                      align=pango.ALIGN_LEFT,
                      font_size=9,
                      error=False):
    if in_select:
        color = app_theme.get_color("simpleSelectItem").get_color()
    else:
        # color = app_theme.get_color("labelText").get_color()
        color = "#707070"

    if error:
        color = "#ff0000"

    content = utils.xmlescape(content)
    draw_text(cr,
              content,
              rect.x,
              rect.y,
              rect.width,
              rect.height,
              font_size,
              color,
              alignment=align)
Exemple #12
0
 def expose_button(self, widget, event):    
     
     cr = widget.window.cairo_create()
     rect = widget.allocation
     
     if widget.state == gtk.STATE_NORMAL:
         bg_pixbuf = self.normal_bg.get_pixbuf()
     elif widget.state == gtk.STATE_PRELIGHT:    
         bg_pixbuf = self.hover_bg.get_pixbuf()
     elif widget.state == gtk.STATE_ACTIVE:    
         bg_pixbuf = self.press_bg.get_pixbuf()
         
     icon_pixbuf = self.button_icon.get_pixbuf()    
         
     icon_y = rect.y + (rect.height - icon_pixbuf.get_height()) / 2    
     
     # Draw bg.
     draw_pixbuf(cr, bg_pixbuf, rect.x, rect.y)
     
     # Draw icon.
     draw_pixbuf(cr, icon_pixbuf, rect.x + self.left_padding, icon_y)
     
     # Draw label.
     draw_text(cr, utils.xmlescape(self.content), rect.x + self.left_padding + self.label_padding + icon_pixbuf.get_width(),
               rect.y, rect.width - self.left_padding - self.label_padding - icon_pixbuf.get_width(), rect.height,
               self.font_size, text_color="#FFFFFF")
     
     return True
Exemple #13
0
    def on_expose_event(self, widget, event):    
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        rect.x += self.padding_x
        rect.width -= self.padding_x * 2
        
        # Draw title.
        # _width, _height = get_content_size(self.title)
        # draw_text(cr, self.title, rect.x, rect.y, rect.width, _height)
        # rect.y += self.padding_y + _height
        
        # Draw dashed.
        dash_line_width = 1
        with cairo_disable_antialias(cr):
            cr.set_source_rgb(*color_hex_to_cairo("#D6D6D6"))            
            cr.set_line_width(dash_line_width)
            cr.set_dash([4.0, 4.0])
            cr.move_to(rect.x, rect.y)
            cr.rel_line_to(rect.width, 0)
            cr.stroke()
            
        rect.y += self.padding_y + dash_line_width    
        
        # Draw plugin name.
        if self.plugin_info:
            plugin_name = "%s: %s" % (_("Add-on"), utils.xmlescape(self.plugin_info.get("Name", "")))    
            _width, _height = get_content_size(plugin_name)
            draw_text(cr, plugin_name, rect.x, rect.y, rect.width, _height)        
            
            rect.y += self.padding_y + _height
            

            # Draw plugin Authors.
            plugin_authors = plugin_authors = "%s: %s" % (_("Author(s)"), 
                                                         utils.xmlescape(self.plugin_info.get("Authors", "")))
            _width, _height = get_content_size(plugin_authors)            
            draw_text(cr, plugin_authors, rect.x, rect.y, rect.width, _height)
            
            rect.y += self.padding_y + _height
            
            # Draw plugin description
            plugin_description = self.plugin_info.get("Description", "")            
            _width, _height = get_content_size(plugin_description)            
            draw_text(cr, plugin_description, rect.x, rect.y, rect.width, _height)
            
        return True    
 def __init__(self, title, value, is_select=False):
     self.hover_flag = False
     self.highlight_flag = False
     self.title = utils.xmlescape(title)
     self.genre_id = value
     self.underline_flag = False
     self.redraw_request_callback = None
     self.is_select = is_select
Exemple #15
0
 def __init__(self, parent, title, allocation_widget):
     gobject.GObject.__init__(self)
     self.hover_flag = False
     self.allocation_widget = allocation_widget
     self.highlight_flag = False
     self.owner_key = self.title = utils.xmlescape(title)
     self.parent_key = parent
     self.has_underline = True
 def __init__(self, parent, title, allocation_widget):
     gobject.GObject.__init__(self)
     self.hover_flag = False
     self.allocation_widget = allocation_widget
     self.highlight_flag = False
     self.owner_key = self.title = utils.xmlescape(title)
     self.parent_key = parent
     self.has_underline = True
Exemple #17
0
 def update(self, lrc_list):    
     self.__url = lrc_list[2]
     self.title  = utils.xmlescape(lrc_list[1])
     self.artist = utils.xmlescape(lrc_list[0])
     
     if len(lrc_list) > 3:
         self.netcode = lrc_list[3]
     else:    
         self.netcode = "utf-8"
     
     # Calculate item size.
     self.title_padding_x = 10
     self.title_padding_y = 5
     (self.title_width, self.title_height) = get_content_size(self.title, DEFAULT_FONT_SIZE)
     
     self.artist_padding_x = 10
     self.artist_padding_y = 5
     (self.artist_width, self.artist_height) = get_content_size(self.artist, DEFAULT_FONT_SIZE)
def render_item_text(cr, content, rect, in_select, in_highlight, align=pango.ALIGN_LEFT, font_size=9, error=False):
    if in_highlight:
        color = app_theme.get_color("simpleSelectItem").get_color()
    else:    
        # color = app_theme.get_color("labelText").get_color()
        color = "#707070"

    if error:    
        color = "#ff0000"        
        
    content = utils.xmlescape(content)    
    draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)    
 def __init__(self, title, callback=None):
     TreeItem.__init__(self)
     self.column_index = 0
     self.side_padding = 5
     self.item_height = 37
     self.title = utils.xmlescape(title)
     self.item_width = 121
     self.hover_bg = app_theme.get_pixbuf("webcast/categroy_bg.png").get_pixbuf()
     self.press_callback = callback
     
     self.parent_widget = None
     self.item_index = -1
     self.has_icon = False
     self.webcast_key = ""
Exemple #20
0
 def init_size(self):    
     tw = self.default_width - self.padding_x * 2
     intro = self.channel_info.get("intro", "").strip()
     intro = utils.xmlescape(intro)
     intro_text = "<b>%s:</b> %s" % ("简介", intro)
     intro_th = 0
     if intro:
         intro_tw, intro_th = get_content_size(intro_text, wrap_width=tw,text_size=9)
         if intro_th > self.line_height * 2:
             intro_th = self.line_height * 2
             
     hotsongs =  " / ".join(self.channel_info.get("hot_songs", [])).strip()
     hotsongs = utils.xmlescape(hotsongs)
     hotsongs_text = "<b>%s:</b> %s" % ("热门歌曲", hotsongs)
     hotsongs_tw, hotsongs_th = get_content_size(hotsongs_text, wrap_width=tw,text_size=9)
     if hotsongs_th > self.line_height * 2:
         hotsongs_th = self.line_height * 2
     
     if intro_th == 0:    
         height = hotsongs_th + self.line_height * 2
     else:    
         height = hotsongs_th + intro_th + self.line_height * 4
     self.set_size_request(self.default_width, height)    
Exemple #21
0
    def __init__(self, title, callback=None):
        TreeItem.__init__(self)
        self.column_index = 0
        self.side_padding = 5
        self.item_height = 37
        self.title = utils.xmlescape(title)
        self.item_width = 121
        self.hover_bg = app_theme.get_pixbuf(
            "webcast/categroy_bg.png").get_pixbuf()
        self.press_callback = callback

        self.parent_widget = None
        self.item_index = -1
        self.has_icon = False
        self.webcast_key = ""
 def render_title(self, cr, rect, in_select, in_highlight):    
     rect.x += self.title_padding_x
     rect.width -= self.title_padding_x * 2
     
     if in_highlight:
         color = app_theme.get_color("simpleSelectItem").get_color()
     else:    
         color = app_theme.get_color("labelText").get_color()
     
     # if error:    
     #     color = "#ff0000"        
         
     content = utils.xmlescape(self.title)    
     draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, 
               text_size=9, text_color=color, alignment=pango.ALIGN_LEFT)    
 def __bind(self, raw_key, field):
     key = deepin_to_keybinder(raw_key)
     try:
         self.__try_unbind(key)
     except:    
         pass
     
     try:
         result = keybinder.bind(key, lambda : self.__handle_callback(key, self.func[field]))
     except:    
         result = False
     else:    
         if not result:
             dbus_notify.set_summary(PROGRAM_NAME_LONG)
             dbus_notify.set_body(_("Failed to bind %s !") % utils.xmlescape(raw_key))
             dbus_notify.notify()
     return result    
 def __bind(self, raw_key, field):
     key = deepin_to_keybinder(raw_key)
     try:
         self.__try_unbind(key)
     except:    
         pass
     
     try:
         result = keybinder.bind(key, lambda : self.__handle_callback(key, self.func[field]))
     except:    
         result = False
     else:    
         if not result:
             dbus_notify.set_summary(_("DMusic"))
             dbus_notify.set_body(_("Failed to bind %s !") % utils.xmlescape(raw_key))
             dbus_notify.notify()
     return result    
 def update(self, song , buffering = None):
     if not song: return
     self.song = song
     title = song.get_str("title")
     if song.get_str("artist"):
         title = "%s - %s" % (title, song.get_str("artist"))
     title = utils.xmlescape(title)    
         
     if buffering is not None:    
         if buffering >= 0 and buffering <= 98:
             buffering_title = "%s(%d%%) - %s" % (_("buffering..."), buffering, title)
         else:    
             buffering_title = title
         self.set_text(buffering_title)    
         
     else:    
         self.set_text(title)
 def update(self, song , buffering = None):
     if not song: return
     self.song = song
     title = song.get_str("title")
     if song.get_str("artist"):
         title = "%s - %s" % (title, song.get_str("artist"))
     title = utils.xmlescape(title)    
         
     if buffering is not None:    
         if buffering >= 0 and buffering <= 98:
             buffering_title = "%s(%d%%) - %s" % (_("buffering"), buffering, title)
         else:    
             buffering_title = title
         self.set_text(buffering_title)    
         
     else:    
         self.set_text(title)
 def __init__(self, title, webcast_key, sourcebar, index, show_icon=False):
     TreeItem.__init__(self)
     self.column_index = 0
     self.side_padding = 5
     self.item_height = 37
     self.title = utils.xmlescape(title)
     self.item_width = 121
     self.webcast_key = webcast_key
     self.hover_bg = app_theme.get_pixbuf("webcast/categroy_bg.png").get_pixbuf()
     self.selected_pixbuf = app_theme.get_pixbuf("webcast/source_sselect.png").get_pixbuf()
     owner_keys = WebcastsDB.get_keys_from_categroy(webcast_key)
     panel_items = [PanelItem(webcast_key, key, sourcebar) for key in owner_keys]
     self.popup_panel = PopupPanel()
     self.popup_panel.add_items(panel_items)
     self.parent_widget = sourcebar
     self.item_index = index
     self.has_icon = show_icon
Exemple #28
0
 def __init__(self, title, webcast_key, sourcebar, index, show_icon=False):
     TreeItem.__init__(self)
     self.column_index = 0
     self.side_padding = 5
     self.item_height = 37
     self.title = utils.xmlescape(title)
     self.item_width = 121
     self.webcast_key = webcast_key
     self.hover_bg = app_theme.get_pixbuf(
         "webcast/categroy_bg.png").get_pixbuf()
     self.selected_pixbuf = app_theme.get_pixbuf(
         "webcast/source_sselect.png").get_pixbuf()
     owner_keys = WebcastsDB.get_keys_from_categroy(webcast_key)
     panel_items = [
         PanelItem(webcast_key, key, sourcebar) for key in owner_keys
     ]
     self.popup_panel = PopupPanel()
     self.popup_panel.add_items(panel_items)
     self.parent_widget = sourcebar
     self.item_index = index
     self.has_icon = show_icon
Exemple #29
0
    def render_title(self, cr, rect, in_select, in_highlight):
        rect.x += self.title_padding_x
        rect.width -= self.title_padding_x * 2

        if in_highlight:
            color = app_theme.get_color("simpleSelectItem").get_color()
        else:
            color = app_theme.get_color("labelText").get_color()

        # if error:
        #     color = "#ff0000"

        content = utils.xmlescape(self.title)
        draw_text(cr,
                  content,
                  rect.x,
                  rect.y,
                  rect.width,
                  rect.height,
                  text_size=9,
                  text_color=color,
                  alignment=pango.ALIGN_LEFT)
Exemple #30
0
    def on_panel_expose_event(self, widget, event):    
        cr  = widget.window.cairo_create()
        rect = widget.allocation

        
        # Clear color to transparent window.
        if self.is_composited():
            cr.rectangle(*rect)
            cr.set_source_rgba(1, 1, 1, 0.95)
            cr.set_operator(cairo.OPERATOR_SOURCE)
            cr.paint()

        else:    
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)            
            cr.set_operator(cairo.OPERATOR_SOURCE)
            cr.set_source_rgb(0.9, 0.9, 0.9)
            cr.fill()
         
        cr  = widget.window.cairo_create()
        rect = widget.allocation
        
        with cairo_disable_antialias(cr):    
            cr.rectangle(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1)
            cr.set_line_width(1)
            cr.set_source_rgb(*color_hex_to_cairo("#D6D6D6"))
            cr.stroke()
            
        if not self.song:
            return True
        
        dash_y = rect.y + self.cover_height + self.cover_up_offset + self.cover_bottom_offset + 1
        dash_x = rect.x
        dash_width = rect.width
                
        cover_pixbuf = self.get_song_cover()
        
        rect.x += self.cover_padding_x
        rect.width -= self.cover_padding_x * 2
        
        # rect.y += (rect.height - self.cover_height) / 2
        rect.y += self.cover_up_offset
        draw_pixbuf(cr, cover_pixbuf, rect.x, rect.y)
        
        rect.x += self.cover_width + self.text_padding_x
        rect.width -= (self.cover_width + self.text_padding_x)
        
        title = utils.xmlescape(self.song.get_str("title"))
        artist = utils.xmlescape(self.song.get_str("artist"))        
        album = utils.xmlescape(self.song.get_str("album"))
        
        _width, _height = get_content_size(title, text_size=self.title_text_size)                
        if not artist and not album:
            _height = self.cover_height
        draw_text(cr, title, rect.x, rect.y, rect.width, _height, 
                  text_color=self.other_text_color, 
                  text_size=self.title_text_size)        
        
        if artist:
            rect.y += _height + self.text_padding_y
            _width, _height = get_content_size(artist, text_size=self.other_text_size)
            draw_text(cr, artist, rect.x, rect.y, rect.width, _height,
                      text_size=self.other_text_size,
                      text_color=self.other_text_color)
            
        if album:    
            rect.y += _height + self.text_padding_y
            _width, _height = get_content_size(artist, text_size=self.other_text_size)
            draw_text(cr, album, rect.x, rect.y, rect.width, _height,
                      text_size=self.other_text_size,
                      text_color=self.other_text_color)
            
        # draw dash    
        with cairo_disable_antialias(cr):    
            cr.set_source_rgb(*color_hex_to_cairo("#D6D6D6"))
            cr.set_line_width(1)            
            cr.move_to(dash_x, dash_y)
            cr.rel_line_to(dash_width, 0)
            # cr.set_dash([2.0, 2.0])
            cr.stroke()
            
            
        other_width = (dash_width - self.cover_padding_x * 2) / 2 - self.cover_padding_x / 2
        other_left_x = dash_x + self.cover_padding_x
        other_right_x = dash_x + dash_width / 2 + self.cover_padding_x / 2
        
        # draw size and format    
        other_y = dash_y + self.other_up_offset
        song_size = "%s: %s" % (_("Size"), utils.xmlescape(self.song.get_str("#size")))
        song_format = "%s: %s" % (_("Type"), utils.get_song_attr(self.song))
        _width, _height = get_content_size(song_size, text_size=self.other_text_size)
        draw_text(cr, song_size, other_left_x, other_y, other_width, _height, 
                  text_size=self.other_text_size,
                  text_color=self.other_text_color
                  )
        draw_text(cr, song_format, other_right_x, other_y, other_width, _height,
                  text_size=self.other_text_size,
                  text_color=self.other_text_color
                  )
        
        # draw playcount and duration.
        other_y += _height + self.other_text_padding_y
        playcount = self.song.get_str("#playcount")
        if playcount == "Never" or not playcount: playcount = "0"
        song_playcount = "%s: %s" % (_("Playcount"), playcount)
        duration = "%s: %s" % (_("Duration"), self.song.get_str("#duration"))
        
        draw_text(cr, song_playcount, other_left_x, other_y, other_width, _height, 
                  text_size=self.other_text_size,
                  text_color=self.other_text_color
                  )
        draw_text(cr, duration, other_right_x, other_y, other_width, _height,
                  text_size=self.other_text_size,
                  text_color=self.other_text_color
                  )
        return True
Exemple #31
0
 def __init__(self, _tuple):
     
     # Init gobject.
     gobject.GObject.__init__(self)
     # MissionThread.__init__(self)
     
     # Get tuple values.
     self.key_name, self.value_name, nums, self.tag = _tuple
     
     # Set cell size.
     self.cell_width = 84                
     if self.tag == "folder": self.cell_width = 67
     
     # Set display label.
     if not self.key_name:
         self.name_label= _("Unknown")
     elif self.key_name == "deepin-all-songs":    
         self.name_label = _("All Tracks")
     else:    
         self.name_label = utils.xmlescape(self.key_name)
     
     # Just create pixbuf when need render it to save memory.
     self.pixbuf = None
     
     # Display track number 
     self.labels = "%d %s" % (nums, _("Track(s)"))
     
     self.pixbuf_offset_x = 4
     self.pixbuf_offset_y = 4
     self.padding_x = 6
     self.border_size = 4
     self.padding_y = 20
     self.hover_flag = False
     self.highlight_flag = False
     self.draw_side_flag = True        
     self.__draw_play_hover_flag = False
     self.__draw_play_press_flag = False
     
     self.cover_dpixbuf = app_theme.get_pixbuf("cover/default_cover.png")
     
     # normal side pixbuf
     if self.tag == "folder":
         self.__normal_side_pixbuf = app_theme.get_pixbuf("local/side_normal.png").get_pixbuf()
     else:    
         self.__normal_side_pixbuf =  app_theme.get_pixbuf("filter/side_normal.png").get_pixbuf()
         
     # normal play 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()
         )
     
     try:
         self.retrieve = TransforDB.convert(self.name_label.lower().replace(" ", "")) \
             + self.name_label.lower().replace(" ", "")
     except:    
         self.retrieve = ""
Exemple #32
0
class XMLFromPattern(Pattern):
    _formatters = [lambda k, s: utils.xmlescape(s)]
 def get_channel_contents(self, channel_info):    
     name = utils.xmlescape(channel_info.get("name", ""))
     intro = utils.xmlescape(channel_info.get("intro", ""))
     hot_songs = "%s: %s" % ("热门歌曲", utils.xmlescape(" / ".join(channel_info.get("hot_songs", []))))
     songs = "%s%s" % (str(channel_info.get("song_num", "0")), "首歌曲")
     return (name, intro, hot_songs, songs)