/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to branchview/graphcell.py

  • Committer: Curtis Hovey
  • Date: 2011-09-03 01:25:04 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110903012504-0jr4diz9033g5df2
Menu fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import math
18
18
 
19
 
import gtk
20
 
import gobject
21
 
import pango
22
 
import cairo
23
 
 
24
 
 
25
 
class CellRendererGraph(gtk.GenericCellRenderer):
 
19
from gi.repository import Gtk
 
20
from gi.repository import GObject
 
21
from gi.repository import Pango
 
22
from gi.repository import cairo
 
23
 
 
24
 
 
25
class CellRendererGraph(Gtk.CellRenderer):
26
26
    """Cell renderer for directed graph.
27
27
 
28
28
    Properties:
34
34
    columns_len = 0
35
35
 
36
36
    __gproperties__ = {
37
 
        "node":         ( gobject.TYPE_PYOBJECT, "node",
 
37
        "node":         ( GObject.TYPE_PYOBJECT, "node",
38
38
                          "revision node instruction",
39
 
                          gobject.PARAM_WRITABLE
 
39
                          GObject.PARAM_WRITABLE
40
40
                        ),
41
 
        "tags":         ( gobject.TYPE_PYOBJECT, "tags",
 
41
        "tags":         ( GObject.TYPE_PYOBJECT, "tags",
42
42
                          "list of tags associated with the node",
43
 
                          gobject.PARAM_WRITABLE
 
43
                          GObject.PARAM_WRITABLE
44
44
                        ),
45
 
        "in-lines":     ( gobject.TYPE_PYOBJECT, "in-lines",
 
45
        "in-lines":     ( GObject.TYPE_PYOBJECT, "in-lines",
46
46
                          "instructions to draw lines into the cell",
47
 
                          gobject.PARAM_WRITABLE
 
47
                          GObject.PARAM_WRITABLE
48
48
                        ),
49
 
        "out-lines":    ( gobject.TYPE_PYOBJECT, "out-lines",
 
49
        "out-lines":    ( GObject.TYPE_PYOBJECT, "out-lines",
50
50
                          "instructions to draw lines out of the cell",
51
 
                          gobject.PARAM_WRITABLE
 
51
                          GObject.PARAM_WRITABLE
52
52
                        ),
53
53
        }
54
54
 
76
76
        except AttributeError:
77
77
            pango_ctx = widget.get_pango_context()
78
78
            font_desc = widget.get_style().font_desc
79
 
            metrics = pango_ctx.get_metrics(font_desc)
80
 
 
81
 
            ascent = pango.PIXELS(metrics.get_ascent())
82
 
            descent = pango.PIXELS(metrics.get_descent())
 
79
            metrics = pango_ctx.get_metrics(font_desc, None)
 
80
 
 
81
            def PANGO_PIXELS(d):
 
82
                # Macro from  Pango header.
 
83
                return (d + 512) / 1000
 
84
 
 
85
            ascent = PANGO_PIXELS(metrics.get_ascent())
 
86
            descent = PANGO_PIXELS(metrics.get_descent())
83
87
 
84
88
            self._box_size = ascent + descent + 6
85
89
            return self._box_size
168
172
                cell_area.y + cell_area.height / 2,
169
173
                box_size / 4, 0, 2 * math.pi)
170
174
 
171
 
        if flags & gtk.CELL_RENDERER_SELECTED:
 
175
        if flags & Gtk.CELL_RENDERER_SELECTED:
172
176
            ctx.set_source_rgb(1.0, 1.0, 1.0)
173
177
            ctx.set_line_width(box_size / 4)
174
178
            ctx.stroke_preserve()
217
221
                             endx, mid + height / 5 ,
218
222
                             endx, mid + height / 2 + 1)
219
223
 
220
 
        if flags & gtk.CELL_RENDERER_SELECTED:
 
224
        if flags & Gtk.CELL_RENDERER_SELECTED:
221
225
            ctx.set_source_rgb(1.0, 1.0, 1.0)
222
226
            ctx.set_line_width(box_size / 5)
223
227
            ctx.stroke_preserve()
233
237
 
234
238
        (column, colour) = self.node
235
239
 
236
 
        font_desc = pango.FontDescription()
237
 
        font_desc.set_size(pango.SCALE * 7)
 
240
        font_desc = Pango.FontDescription()
 
241
        font_desc.set_size(Pango.SCALE * 7)
238
242
 
239
 
        tag_layout = pango.Layout(pango_ctx)
 
243
        tag_layout = Pango.Layout(pango_ctx)
240
244
        tag_layout.set_font_description(font_desc)
241
245
 
242
246
        # The width of the tag label stack