~mmcg069/software-center/Bug830691

« back to all changes in this revision

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

  • Committer: Matthew McGowan
  • Date: 2011-08-22 09:26:30 UTC
  • mfrom: (2131.1.28 software-center)
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20110822092630-yqbaa7zhljgo4zqe
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
        self.selection = sel = SelectionCursor(self.cursor)
380
380
        self.clipboard = None
381
381
 
 
382
        self._test_layout = self.create_pango_layout('')
382
383
        #self._xterm = Gdk.Cursor.new(Gdk.XTERM)
383
 
        self.connect('size-allocate', self._on_size_allocate)
384
384
 
385
385
        self.connect('button-press-event', self._on_press, event_helper, cur, sel)
386
386
        self.connect('button-release-event', self._on_release, event_helper, cur, sel)
390
390
        self.connect('key-release-event', self._on_key_release, cur, sel)
391
391
 
392
392
#        self.connect('drag-begin', self._on_drag_begin)
393
 
        self.connect('drag-data-get', self._on_drag_data_get, sel)
 
393
        #~ self.connect('drag-data-get', self._on_drag_data_get, sel)
394
394
 
395
395
        self.connect('focus-in-event', self._on_focus_in)
396
396
        self.connect('focus-out-event', self._on_focus_out)
397
397
 
398
398
        self.connect('style-updated', self._on_style_updated)
399
 
        self.connect('draw', self._on_draw)
400
399
        return
401
400
 
402
 
    def _on_size_allocate(self, *args):
403
 
        allocation = self.get_allocation()
 
401
    def do_size_allocate(self, allocation):
 
402
        old = self.get_allocation()
 
403
        if old.width == allocation.width and old.height == allocation.height:
 
404
            return
 
405
 
404
406
        width = allocation.width
405
407
 
406
408
        x = y = 0
407
409
        for layout in self.order:
 
410
            layout.set_width(_PS*(width-layout.indent))
408
411
            if layout.index > 0:
409
412
                y += (layout.vspacing or self.line_height)
410
413
 
417
420
                                      width-layout.indent, e.height)
418
421
 
419
422
            y += e.y + e.height
 
423
 
 
424
        self.set_allocation(allocation)
420
425
        return
421
426
 
422
427
    # overrides
424
429
        return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
425
430
 
426
431
    def do_get_preferred_height_for_width(self, width):
427
 
        if not self.order:
428
 
            a = self.get_allocation()
429
 
            return a.height, a.height
430
 
 
431
432
        height = 0
432
 
        for layout in self.order:
433
 
            layout.set_width(_PS*(width-layout.indent))
434
 
            lh = layout.get_pixel_extents().height
435
 
            height += lh + (layout.vspacing or self.line_height)
 
433
        layout = self._test_layout
 
434
        for l in self.order:
 
435
            layout.set_text(l.get_text(), -1)
 
436
            layout.set_width(_PS*(width-l.indent))
 
437
            lh = layout.get_pixel_extents()[1].height
 
438
            height += lh + (l.vspacing or self.line_height)
436
439
 
437
440
        height = min(1000, max(50, height))
438
 
 
439
441
        return height, height
440
442
 
441
 
    def _on_draw(self, widget, cr):
442
 
        self.render(widget, cr)
 
443
    def do_draw(self, cr):
 
444
        self.render(self, cr)
443
445
        return
444
446
 
445
447
    def _on_style_updated(self, widget):
991
993
    def render(self, widget, cr):
992
994
        if not self.order: return
993
995
 
994
 
        a = self.get_allocation()
995
 
 
996
996
        for layout in self.order:
997
997
            lx, ly = layout.get_position()
998
998