示例#1
0
    def __init__(self, detail_page, pkg_name, alias_name, star):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)
        self.star = star
        self.pkg_name = pkg_name

        v_box = gtk.VBox()
        pkg_icon_image = gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(
                get_icon_pixbuf_path(pkg_name), 32, 32))
        pkg_alias_label = Label(
            alias_name, hover_color=app_theme.get_color("homepage_hover"))
        pkg_alias_label.set_clickable()
        pkg_alias_label.connect(
            "button-press-event",
            lambda w, e: detail_page.update_pkg_info(pkg_name))

        self.pkg_star_box = gtk.HBox()

        self.pkg_star_view = StarView()
        self.pkg_star_view.star_buffer.star_level = int(star)
        self.pkg_star_view.connect("clicked", lambda w: self.grade_pkg())

        self.pkg_star_mark = StarMark(self.star, self.MARK_SIZE,
                                      self.MARK_PADDING_X, self.MARK_PADDING_Y)

        self.pack_start(pkg_icon_image, False, False)
        self.pack_start(v_box, True, True, 8)
        v_box.pack_start(pkg_alias_label, False, False, 2)
        v_box.pack_start(self.pkg_star_box, False, False, 2)
        self.pkg_star_box.pack_start(self.pkg_star_view, False, False)
        self.pkg_star_box.pack_start(self.pkg_star_mark, False, False)
 def render(self, cr, rect):
     '''
     Render item.
     
     This is IconView interface, you should implement it.
     '''
     if self.icon_pixbuf == None:
         self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.desktop_icon_name))
         
     draw_pixbuf(
         cr,
         self.icon_pixbuf,
         rect.x + (rect.width - self.icon_pixbuf.get_width()) / 2,
         rect.y + self.DESKTOP_ICON_PADDING_Y)    
     
     text_width = rect.width - self.DESKTOP_TEXT_PADDING_X * 2
     draw_text(
         cr,
         self.desktop_display_name,
         rect.x + self.DESKTOP_TEXT_PADDING_X,
         rect.y + self.DESKTOP_TEXT_PADDING_Y,
         text_width,
         DEFAULT_FONT_SIZE,
         alignment=pango.ALIGN_CENTER,
         wrap_width=text_width)
示例#3
0
 def init_pkg_icon_pixbuf(self):
     if self.pkg_icon_pixbuf == None:
         self.pkg_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
             get_icon_pixbuf_path(self.pkg_name))
         if self.pkg_icon_pixbuf:
             self.pkg_icon_width = self.pkg_icon_pixbuf.get_width()
             self.pkg_icon_height = self.pkg_icon_pixbuf.get_height()
示例#4
0
    def __init__(self, detail_page, pkg_name, alias_name, star):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)
        self.star = star
        self.pkg_name = pkg_name

        v_box = gtk.VBox()
        pkg_icon_image = gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(get_icon_pixbuf_path(pkg_name), 32, 32))
        pkg_alias_label = Label(alias_name,
                                hover_color=app_theme.get_color("homepage_hover"))
        pkg_alias_label.set_clickable()
        pkg_alias_label.connect("button-press-event", lambda w, e: detail_page.update_pkg_info(pkg_name))

        self.pkg_star_box = gtk.HBox()

        self.pkg_star_view = StarView()
        self.pkg_star_view.star_buffer.star_level = int(star)
        self.pkg_star_view.connect("clicked", lambda w: self.grade_pkg())

        self.pkg_star_mark = StarMark(self.star, self.MARK_SIZE, self.MARK_PADDING_X, self.MARK_PADDING_Y)

        self.pack_start(pkg_icon_image, False, False)
        self.pack_start(v_box, True, True, 8)
        v_box.pack_start(pkg_alias_label, False, False, 2)
        v_box.pack_start(self.pkg_star_box, False, False, 2)
        self.pkg_star_box.pack_start(self.pkg_star_view, False, False)
        self.pkg_star_box.pack_start(self.pkg_star_mark, False, False)
 def is_in_icon_area(self, x, y):
     if self.pkg_icon_pixbuf == None:
         self.pkg_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        
         
     return is_in_rect((x, y),
                       (self.DRAW_PADDING_LEFT,
                        self.DRAW_PADDING_Y,
                        self.pkg_icon_pixbuf.get_width(),
                        self.pkg_icon_pixbuf.get_height()))
 def render_pkg_info(self, cr, rect):
     if self.row_index % 2 == 1:
         cr.set_source_rgba(1, 1, 1, 0.5)
         cr.rectangle(rect.x, rect.y, rect.width, rect.height)
         cr.fill()
     
     if self.icon_pixbuf == None:
         self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        
         
     render_pkg_info(cr, rect, self.alias_name, self.pkg_name, self.icon_pixbuf, self.pkg_version, self.short_desc, ITEM_PKG_OFFSET_X)
 def expose_left_logo_box(self, widget, event):
     if self.pkg_name != None:
         # Init.
         cr = widget.window.cairo_create()
         rect = widget.allocation
         
         # Draw pkg icon.
         self.pkg_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(get_icon_pixbuf_path(self.pkg_name), self.ICON_SIZE, self.ICON_SIZE)
         draw_pixbuf(cr,
                     self.pkg_pixbuf,
                     rect.x + self.ICON_PADDING_X + (self.ICON_SIZE - self.pkg_pixbuf.get_width()) / 2,
                     rect.y + self.PADDING_Y)
示例#8
0
    def render_pkg_info(self, cr, rect):
        if self.row_index % 2 == 1:
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
                get_icon_pixbuf_path(self.pkg_name))

        render_pkg_info(cr, rect, self.alias_name, self.pkg_name,
                        self.icon_pixbuf, self.pkg_version, self.short_desc,
                        ITEM_PKG_OFFSET_X)
示例#9
0
    def expose_left_logo_box(self, widget, event):
        if self.pkg_name != None:
            # Init.
            cr = widget.window.cairo_create()
            rect = widget.allocation

            # Draw pkg icon.
            self.pkg_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                get_icon_pixbuf_path(utils.get_origin_name(self.pkg_name)),
                self.ICON_SIZE, self.ICON_SIZE)
            draw_pixbuf(
                cr, self.pkg_pixbuf, rect.x + self.ICON_PADDING_X +
                (self.ICON_SIZE - self.pkg_pixbuf.get_width()) / 2,
                rect.y + self.PADDING_Y)
 def render(self, cr, rect):
     '''
     Render item.
     
     This is IconView interface, you should implement it.
     '''
     if self.icon_pixbuf == None:
         self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        
     
     draw_pixbuf(cr,
                 self.icon_pixbuf,
                 rect.x + self.ICON_PADDING_X,
                 rect.y + self.ICON_PADDING_TOP)
     
     draw_text(cr, 
               self.alias_name,
               rect.x,
               rect.y + self.icon_padding_y + self.icon_pixbuf.get_height() + self.name_padding_y - 3,
               rect.width,
               DEFAULT_FONT_SIZE,
               alignment=pango.ALIGN_CENTER)
     
     render_star(cr,
                 gtk.gdk.Rectangle(rect.x + (rect.width - STAR_SIZE * 5) / 2,
                                   rect.y + self.icon_padding_y + self.icon_pixbuf.get_height() + self.name_padding_y + DEFAULT_FONT_SIZE + self.star_padding_y,
                                   STAR_SIZE * 5,
                                   STAR_SIZE
                                   ),
                 self.star_buffer)
     if self.is_installed != None:
         if self.is_installed:
             name = "button/start_small"
         else:
             name = "button/install_small"
         
         if self.button_status == BUTTON_NORMAL:
             status = "normal"
         elif self.button_status == BUTTON_HOVER:
             status = "hover"
         elif self.button_status == BUTTON_PRESS:
             status = "press"
             
         pixbuf = app_theme.get_pixbuf("%s_%s.png" % (name, status)).get_pixbuf()
         draw_pixbuf(
             cr,
             pixbuf,
             rect.x + self.BUTTON_PADDING_X,
             rect.y + rect.height - self.BUTTON_PADDING_BOTTOM - pixbuf.get_height())
示例#11
0
    def __init__(self, pkg_name):
        '''
        init docs
        '''
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.set_colormap(gtk.gdk.Screen().get_rgba_colormap())
        self.set_decorated(False)
        self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
            get_icon_pixbuf_path(pkg_name))
        self.window_width = self.icon_pixbuf.get_width()
        self.window_height = self.icon_pixbuf.get_height()
        self.set_geometry_hints(None, self.window_width, self.window_height,
                                self.window_width, self.window_height, -1, -1,
                                -1, -1, -1, -1)

        self.connect("expose-event", self.expose_icon_window)
示例#12
0
    def __init__(self, pkg_name):
        '''
        init docs
        '''
        gtk.Window.__init__(self, gtk.WINDOW_POPUP)

        self.set_colormap(gtk.gdk.Screen().get_rgba_colormap())
        self.set_decorated(False)
        self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(pkg_name))
        self.window_width = self.icon_pixbuf.get_width()
        self.window_height = self.icon_pixbuf.get_height()
        self.set_geometry_hints(
            None,
            self.window_width,
            self.window_height,
            self.window_width,
            self.window_height,
            -1, -1, -1, -1, -1, -1)

        self.connect("expose-event", self.expose_icon_window)
    def render(self, cr, rect):
        '''
        Render item.

        This is IconView interface, you should implement it.
        '''
        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
                get_icon_pixbuf_path(self.desktop_icon_name))

        draw_pixbuf(cr, self.icon_pixbuf,
                    rect.x + (rect.width - self.icon_pixbuf.get_width()) / 2,
                    rect.y + self.DESKTOP_ICON_PADDING_Y)

        text_width = rect.width - self.DESKTOP_TEXT_PADDING_X * 2
        draw_text(cr,
                  self.desktop_display_name,
                  rect.x + self.DESKTOP_TEXT_PADDING_X,
                  rect.y + self.DESKTOP_TEXT_PADDING_Y,
                  text_width,
                  DEFAULT_FONT_SIZE,
                  alignment=pango.ALIGN_CENTER,
                  wrap_width=text_width)
示例#14
0
    def render_info(self, cr, rect):
        if self.row_index % 2 == 1:
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        # Render icon.
        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
                    get_icon_pixbuf_path(utils.get_origin_name(self.pkg_name)))

        render_pkg_icon(cr, rect, self.icon_pixbuf)

        # Render name.
        render_pkg_name(cr, rect, get_match_context(self.alias_name, self.keywords), rect.width)

        # Render search result.
        with cairo_state(cr):
            text_padding_left = ITEM_PADDING_X + ICON_SIZE + ITEM_PADDING_MIDDLE
            text_padding_right = 10
            text_padding_y = ITEM_PADDING_Y + DEFAULT_FONT_SIZE * 2
            text_width = rect.width - text_padding_left - text_padding_right
            text_height = 30

            cr.rectangle(rect.x, rect.y + text_padding_y, rect.width, text_height)
            cr.clip()

            draw_text(
                cr,
                self.highlight_string,
                rect.x + text_padding_left,
                rect.y + text_padding_y,
                text_width,
                text_height,
                text_size=DEFAULT_FONT_SIZE,
                wrap_width=text_width,
                )
    def render_info(self, cr, rect):
        if self.row_index % 2 == 1:
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
        
        # Render icon.
        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
                    get_icon_pixbuf_path(utils.get_origin_name(self.pkg_name)))
            
        render_pkg_icon(cr, rect, self.icon_pixbuf)

        # Render name.
        render_pkg_name(cr, rect, get_match_context(self.alias_name, self.keywords), rect.width)
        
        # Render search result.
        with cairo_state(cr):
            text_padding_left = ITEM_PADDING_X + ICON_SIZE + ITEM_PADDING_MIDDLE
            text_padding_right = 10
            text_padding_y = ITEM_PADDING_Y + DEFAULT_FONT_SIZE * 2
            text_width = rect.width - text_padding_left - text_padding_right
            text_height = 30
            
            cr.rectangle(rect.x, rect.y + text_padding_y, rect.width, text_height)
            cr.clip()
            
            draw_text(
                cr, 
                self.highlight_string,
                rect.x + text_padding_left,
                rect.y + text_padding_y,
                text_width,
                text_height,
                text_size=DEFAULT_FONT_SIZE,
                wrap_width=text_width,
                )
    def render(self, cr, rect):
        # Draw icon.
        if self.pkg_icon_pixbuf == None:
            self.pkg_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        

        draw_pixbuf(
            cr,
            self.pkg_icon_pixbuf,
            rect.x + self.DRAW_PADDING_LEFT + (ICON_SIZE - self.pkg_icon_pixbuf.get_width()) / 2,
            rect.y + self.DRAW_PADDING_Y)    
        
        # Draw button.
        if self.is_installed:
            name = "button/start_small"
        else:
            name = "button/install_small"
        
        if self.button_status == BUTTON_NORMAL:
            status = "normal"
        elif self.button_status == BUTTON_HOVER:
            status = "hover"
        elif self.button_status == BUTTON_PRESS:
            status = "press"
            
        pixbuf = app_theme.get_pixbuf("%s_%s.png" % (name, status)).get_pixbuf()
        draw_pixbuf(
            cr,
            pixbuf,
            rect.x + self.DRAW_PADDING_LEFT,
            rect.y + self.DRAW_PADDING_Y + self.DRAW_ICON_SIZE + self.DRAW_BUTTON_PADDING_Y)
        
        # Draw name.
        self.text_width = rect.width - self.DRAW_PADDING_LEFT - self.DRAW_PADDING_RIGHT - self.DRAW_INFO_PADDING_X - self.pkg_icon_pixbuf.get_width()
        self.pkg_name_area.render(
            cr,
            self.alias_name,
            gtk.gdk.Rectangle(
                rect.x + self.DRAW_PADDING_LEFT + ICON_SIZE + self.DRAW_INFO_PADDING_X,
                rect.y + self.DRAW_PADDING_Y,
                self.text_width,
                NAME_SIZE))

        # Draw star.
        self.star_buffer.render(
            cr,
            gtk.gdk.Rectangle(
                rect.x + self.DRAW_PADDING_LEFT + ICON_SIZE + self.DRAW_INFO_PADDING_X,
                rect.y + self.DRAW_STAR_PADDING_Y,
                STAR_SIZE * 5,
                STAR_SIZE
                ))
        
        # Draw long desc.
        long_desc_height = 32
        if self.long_desc == None:
            self.long_desc = "FIX ME"
        #if self.long_desc and len(self.long_desc.split("\n")) == 1:
            #self.long_desc += "\n"
        with cairo_state(cr):
            cr.rectangle(
                rect.x + self.DRAW_PADDING_LEFT + ICON_SIZE + self.DRAW_INFO_PADDING_X,
                rect.y + self.DRAW_LONG_DESC_PADDING_Y,
                self.text_width,
                long_desc_height,
                )
            cr.clip()
            draw_text(
                cr,
                self.long_desc,
                rect.x + self.DRAW_PADDING_LEFT + ICON_SIZE + self.DRAW_INFO_PADDING_X,
                rect.y + self.DRAW_LONG_DESC_PADDING_Y,
                self.text_width,
                long_desc_height,
                wrap_width=self.text_width,
                )
    def render(self, cr, rect):
        '''
        Render item.

        This is IconView interface, you should implement it.
        '''
        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(
                get_icon_pixbuf_path(self.pkg_name))

        draw_pixbuf(cr, self.icon_pixbuf, rect.x + self.ICON_PADDING_X,
                    rect.y + self.ICON_PADDING_TOP)

        draw_text(cr,
                  self.alias_name,
                  rect.x,
                  rect.y + self.icon_padding_y +
                  self.icon_pixbuf.get_height() + self.name_padding_y - 3,
                  rect.width,
                  DEFAULT_FONT_SIZE,
                  alignment=pango.ALIGN_CENTER)

        render_star(
            cr,
            gtk.gdk.Rectangle(
                rect.x + (rect.width - STAR_SIZE * 5) / 2,
                rect.y + self.icon_padding_y + self.icon_pixbuf.get_height() +
                self.name_padding_y + DEFAULT_FONT_SIZE + self.star_padding_y,
                STAR_SIZE * 5, STAR_SIZE), self.star_buffer)

        # render button
        name = ""
        draw_str = ""
        if self.install_status == "uninstalled":
            name = "button/install_small"
        elif self.install_status == "unknown":
            draw_str = _("Not found")
        else:
            if self.desktops:
                name = "button/start_small"
            else:
                draw_str = _("Installed")

        if name:
            if self.button_status == BUTTON_NORMAL:
                status = "normal"
            elif self.button_status == BUTTON_HOVER:
                status = "hover"
            elif self.button_status == BUTTON_PRESS:
                status = "press"

            pixbuf = app_theme.get_pixbuf("%s_%s.png" %
                                          (name, status)).get_pixbuf()
            draw_pixbuf(
                cr, pixbuf, rect.x + self.BUTTON_PADDING_X, rect.y +
                rect.height - self.BUTTON_PADDING_BOTTOM - pixbuf.get_height())
        else:
            str_width, str_height = get_content_size(draw_str, 10)
            draw_text(
                cr,
                draw_str,
                rect.x + self.BUTTON_PADDING_X,
                rect.y + rect.height - self.BUTTON_PADDING_BOTTOM - str_height,
                rect.width,
                str_height,
                wrap_width=rect.width,
            )
    def render(self, cr, rect):
        '''
        Render item.
        
        This is IconView interface, you should implement it.
        '''
        if self.icon_pixbuf == None:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        
        
        draw_pixbuf(cr,
                    self.icon_pixbuf,
                    rect.x + self.ICON_PADDING_X,
                    rect.y + self.ICON_PADDING_TOP)
        
        draw_text(cr, 
                  self.alias_name,
                  rect.x,
                  rect.y + self.icon_padding_y + self.icon_pixbuf.get_height() + self.name_padding_y - 3,
                  rect.width,
                  DEFAULT_FONT_SIZE,
                  alignment=pango.ALIGN_CENTER)
        
        render_star(cr,
                    gtk.gdk.Rectangle(rect.x + (rect.width - STAR_SIZE * 5) / 2,
                                      rect.y + self.icon_padding_y + self.icon_pixbuf.get_height() + self.name_padding_y + DEFAULT_FONT_SIZE + self.star_padding_y,
                                      STAR_SIZE * 5,
                                      STAR_SIZE
                                      ),
                    self.star_buffer)

        # render button
        name = ""
        draw_str = ""
        if self.install_status == "uninstalled":
            name = "button/install_small"
        elif self.install_status == "unknown":
            draw_str = _("Not found")
        else:
            desktops = json.loads(self.install_status)
            if desktops:
                name = "button/start_small"
                self.desktops = self.data_manager.get_pkg_desktop_info(desktops)
            else:
                draw_str = _("Installed")

        if name:
            if self.button_status == BUTTON_NORMAL:
                status = "normal"
            elif self.button_status == BUTTON_HOVER:
                status = "hover"
            elif self.button_status == BUTTON_PRESS:
                status = "press"
                
            pixbuf = app_theme.get_pixbuf("%s_%s.png" % (name, status)).get_pixbuf()
            draw_pixbuf(
                cr,
                pixbuf,
                rect.x + self.BUTTON_PADDING_X,
                rect.y + rect.height - self.BUTTON_PADDING_BOTTOM - pixbuf.get_height())
        else:
            str_width, str_height = get_content_size(draw_str, 10)
            draw_text(
                cr,
                draw_str,
                rect.x + self.BUTTON_PADDING_X,
                rect.y + rect.height - self.BUTTON_PADDING_BOTTOM - str_height,
                rect.width,
                str_height,
                wrap_width=rect.width,
            )
 def init_pkg_icon_pixbuf(self):
     if self.pkg_icon_pixbuf == None:
         self.pkg_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(get_icon_pixbuf_path(self.pkg_name))        
         if self.pkg_icon_pixbuf:
             self.pkg_icon_width = self.pkg_icon_pixbuf.get_width()
             self.pkg_icon_height = self.pkg_icon_pixbuf.get_height()