~mmcg069/software-center/Bug846204

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/cellrenderers.py

  • Committer: Matthew McGowan
  • Date: 2011-09-20 20:53:11 UTC
  • mfrom: (2362.10.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20110920205311-lrdoiz3l4su2wu44
merge w trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
# custom cell renderer to support dynamic grow
34
34
class CellRendererAppView(Gtk.CellRendererText):
35
35
 
36
 
    # offset of the install overlay icon
37
 
    OFFSET_X = 20
38
 
    OFFSET_Y = 20
 
36
    # x, y offsets for the overlay icon
 
37
    OVERLAY_XO = OVERLAY_YO = 2
39
38
 
40
39
    # size of the install overlay icon
41
40
    OVERLAY_SIZE = 16
121
120
        if not is_rtl:
122
121
            x = cell_area.x + xo + xpad
123
122
        else:
124
 
            x = cell_area.x + cell_area.width+xo - self.pixbuf_width - xpad
 
123
            x = cell_area.x + cell_area.width + xo - self.pixbuf_width - xpad
 
124
        y = cell_area.y + ypad
125
125
 
126
126
        # draw appicon pixbuf
127
 
        Gdk.cairo_set_source_pixbuf(cr, icon, x, cell_area.y+ypad)
 
127
        Gdk.cairo_set_source_pixbuf(cr, icon, x, y)
128
128
        cr.paint()
129
129
 
130
130
        # draw overlay if application is installed
131
131
        if self.model.is_installed(app):
132
132
            if not is_rtl:
133
 
                x = cell_area.x + xpad + self.OFFSET_X
 
133
                x += (self.pixbuf_width - self.OVERLAY_SIZE + self.OVERLAY_XO)
134
134
            else:
135
 
                x = cell_area.x+cell_area.width-xpad-self.OFFSET_X
136
 
 
137
 
            y = cell_area.y + ypad + self.OFFSET_Y
 
135
                x -= self.OVERLAY_XO
 
136
            y += (self.pixbuf_width - self.OVERLAY_SIZE + self.OVERLAY_YO)
138
137
            Gdk.cairo_set_source_pixbuf(cr, self._installed, x, y)
139
138
            cr.paint()
140
139
        return
219
218
        return
220
219
 
221
220
    def _render_progress(self, context, cr, progress, cell_area, ypad, is_rtl):
222
 
        #FIXME: progress bar presumably needs reversing for rtl
223
 
        # as seen in gtk's cellprogress.c
224
221
        percent = progress * 0.01
225
222
        # per the spec, the progressbar should be the width of the action button
226
223
        action_btn = self.get_button_by_name(CellButtonIDs.ACTION)
229
226
        # shift the bar to the top edge
230
227
        y = cell_area.y + ypad
231
228
 
232
 
        #context = widget.get_style_context()
233
229
        context.save()
234
230
        context.add_class("trough")
235
231
 
239
235
        context.restore ()
240
236
 
241
237
        bar_size = w * percent
242
 
        #~ if not is_rtl:
243
 
        #~ else:
244
 
            #~ pass
245
238
 
246
239
        context.save ()
247
240
        context.add_class ("progressbar")
248
241
 
249
242
        if (bar_size > 0):
 
243
            if is_rtl:
 
244
                x += (w - bar_size)
250
245
            Gtk.render_activity(context, cr, x, y, bar_size, h)
251
246
 
252
247
        context.restore ()
536
531
        x, y, width, height = self.allocation
537
532
 
538
533
        context.save()
539
 
        context.add_class("button")
540
534
        context.add_class("cellrenderer-button")
541
 
        context.set_state(self.state)
542
 
 
 
535
 
 
536
        if self.has_focus:
 
537
            context.set_state(self.state | Gtk.StateFlags.FOCUSED)
 
538
        else:
 
539
            context.set_state(self.state)
 
540
 
 
541
        # render background and focal frame if has-focus
 
542
        context.save()
 
543
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
543
544
        Gtk.render_background(context, cr, x, y, width, height)
544
 
        #~ Gtk.render_frame(context, cr, x, y, width, height)
545
 
 
 
545
        context.restore()
 
546
 
 
547
        if self.has_focus:
 
548
            Gtk.render_focus(context, cr, x+3, y+3, width-6, height-6)
 
549
 
 
550
        # position and render layout markup
 
551
        context.save()
 
552
        context.add_class(Gtk.STYLE_CLASS_BUTTON)
546
553
        layout.set_markup(self.markup_variants[self.current_variant], -1)
547
554
        layout_width = layout.get_pixel_extents()[1].width
548
555
        x = x + (width - layout_width)/2
549
556
        y += self.ypad
550
557
        Gtk.render_layout(context, cr, x, y, layout)
 
558
        context.restore()
551
559
 
552
560
        context.restore()
553
561
        return