/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 18:00:39 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110903180039-c1z6lzeso7xywcfz
Hacked missing cairo constants. Used PangoCairo lib to show tags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
just be for the background.
11
11
"""
12
12
 
13
 
__copyright__ = "Copyright © 2005 Canonical Ltd."
 
13
__copyright__ = "Copyright © 2005-2011 Canonical Ltd."
14
14
__author__    = "Scott James Remnant <scott@ubuntu.com>"
15
15
 
16
16
 
19
19
from gi.repository import Gtk
20
20
from gi.repository import GObject
21
21
from gi.repository import Pango
 
22
from gi.repository import PangoCairo
22
23
from gi.repository import cairo
23
24
 
24
25
 
 
26
# Cairo constants are not exported yet. These are taken from documentation.
 
27
CAIRO_LINE_CAP_BUTT = 0
 
28
CAIRO_LINE_CAP_ROUND = 1
 
29
CAIRO_LINE_CAP_SQUARE = 2
 
30
 
 
31
 
 
32
CAIRO_FILL_RULE_WINDING = 0
 
33
CAIRO_FILL_RULE_EVEN_ODD = 1
 
34
 
 
35
 
25
36
class CellRendererGraph(Gtk.CellRendererPixbuf):
26
37
    """Cell renderer for directed graph.
27
38
 
131
142
 
132
143
        ctx.set_source_rgb(red, green, blue)
133
144
 
134
 
    def do_activate(event, widget, path, background_area, cell_area, flags):
 
145
    def do_activate(event, widget, path, bg_area, cell_area, flags):
135
146
        return True
136
147
 
137
 
    def do_editing_started(event, widget, path, background_area, cell_area,
138
 
                           flags):
 
148
    def do_editing_started(event, widget, path, fb_area, cell_area, flags):
139
149
        return None
140
150
 
141
151
    def do_get_size(self, widget, cell_area):
209
219
    def render_line(self, ctx, cell_area, box_size,
210
220
                    mid, height, start, end, colour, flags):
211
221
        if start is None:
212
 
            #ctx.set_line_cap(cairo.LINE_CAP_ROUND)
 
222
            ctx.set_line_cap(CAIRO_LINE_CAP_ROUND)
213
223
            x = cell_area.x + box_size * end + box_size / 2
214
224
            ctx.move_to(x, mid + height / 3)
215
225
            ctx.line_to(x, mid + height / 3)
217
227
            ctx.line_to(x, mid + height / 6)
218
228
 
219
229
        elif end is None:
220
 
            #ctx.set_line_cap(cairo.LINE_CAP_ROUND)
 
230
            ctx.set_line_cap(CAIRO_LINE_CAP_ROUND)
221
231
            x = cell_area.x + box_size * start + box_size / 2
222
232
            ctx.move_to(x, mid - height / 3)
223
233
            ctx.line_to(x, mid - height / 3)
225
235
            ctx.line_to(x, mid - height / 6)
226
236
 
227
237
        else:
228
 
            #ctx.set_line_cap(cairo.LINE_CAP_BUTT)
 
238
            ctx.set_line_cap(CAIRO_LINE_CAP_BUTT)
229
239
            startx = cell_area.x + box_size * start + box_size / 2
230
240
            endx = cell_area.x + box_size * end + box_size / 2
231
241
 
297
307
            self.set_colour(ctx, TAG_COLOUR_ID, 0.0, 0.5)
298
308
            ctx.stroke_preserve()
299
309
 
300
 
            ctx.set_fill_rule (cairo.FILL_RULE_EVEN_ODD)
 
310
            ctx.set_fill_rule (CAIRO_FILL_RULE_EVEN_ODD)
301
311
            self.set_colour(ctx, TAG_COLOUR_ID, 0.5, 1.0)
302
312
            ctx.fill()
303
313
 
304
314
            # Draw the tag text
305
315
            self.set_colour(ctx, 0, 0.0, 0.0)
306
316
            ctx.move_to(x0, y0)
307
 
            ctx.show_layout(tag_layout)
308
 
 
 
317
            PangoCairo.show_layout(ctx, tag_layout)