/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 annotate/gannotate.py

  • Committer: Curtis Hovey
  • Date: 2011-07-31 15:52:43 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110731155243-ln8istmxbryhb4pz
Mechanical changes made by pygi.convert.sh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import pygtk
20
20
pygtk.require("2.0")
21
 
import gobject
22
 
import gtk
23
 
import pango
 
21
from gi.repository import GObject
 
22
from gi.repository import Gtk
 
23
from gi.repository import Pango
24
24
import re
25
25
 
26
26
from bzrlib import patiencediff
52
52
 
53
53
        Window.__init__(self, parent)
54
54
 
55
 
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
 
55
        self.set_icon(self.render_icon(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON))
56
56
        self.annotate_colormap = AnnotateColorSaturation()
57
57
 
58
58
        self._create()
70
70
                                   lambda: CURRENT_REVISION)()
71
71
 
72
72
        # [revision id, line number, author, revno, highlight color, line]
73
 
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
74
 
                                       gobject.TYPE_INT,
75
 
                                       gobject.TYPE_STRING,
76
 
                                       gobject.TYPE_STRING,
77
 
                                       gobject.TYPE_STRING,
78
 
                                       gobject.TYPE_STRING)
 
73
        self.annomodel = Gtk.ListStore(GObject.TYPE_STRING,
 
74
                                       GObject.TYPE_INT,
 
75
                                       GObject.TYPE_STRING,
 
76
                                       GObject.TYPE_STRING,
 
77
                                       GObject.TYPE_STRING,
 
78
                                       GObject.TYPE_STRING)
79
79
 
80
80
        last_seen = None
81
81
        try:
193
193
        self.revisionview = self._create_log_view()
194
194
        self.annoview = self._create_annotate_view()
195
195
 
196
 
        vbox = gtk.VBox(False)
 
196
        vbox = Gtk.VBox(False)
197
197
        vbox.show()
198
198
 
199
 
        sw = gtk.ScrolledWindow()
200
 
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
201
 
        sw.set_shadow_type(gtk.SHADOW_IN)
 
199
        sw = Gtk.ScrolledWindow()
 
200
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
201
        sw.set_shadow_type(Gtk.ShadowType.IN)
202
202
        sw.add(self.annoview)
203
203
        self.annoview.gwindow = self
204
204
        sw.show()
205
205
 
206
 
        swbox = gtk.VBox()
207
 
        swbox.pack_start(sw)
 
206
        swbox = Gtk.VBox()
 
207
        swbox.pack_start(sw, True, True, 0)
208
208
        swbox.show()
209
209
 
210
 
        hbox = gtk.HBox(False, 6)
 
210
        hbox = Gtk.HBox(False, 6)
211
211
        self.back_button = self._create_back_button()
212
212
        hbox.pack_start(self.back_button, expand=False, fill=True)
213
213
        self.forward_button = self._create_forward_button()
219
219
        hbox.show()
220
220
        vbox.pack_start(hbox, expand=False, fill=True)
221
221
 
222
 
        self.pane = pane = gtk.VPaned()
 
222
        self.pane = pane = Gtk.VPaned()
223
223
        pane.add1(swbox)
224
224
        pane.add2(self.revisionview)
225
225
        pane.show()
227
227
 
228
228
        self._search = SearchBox()
229
229
        swbox.pack_start(self._search, expand=False, fill=True)
230
 
        accels = gtk.AccelGroup()
231
 
        accels.connect_group(gtk.keysyms.f, gtk.gdk.CONTROL_MASK,
232
 
                             gtk.ACCEL_LOCKED,
 
230
        accels = Gtk.AccelGroup()
 
231
        accels.connect_group(Gdk.KEY_f, Gdk.EventMask.CONTROL_MASK,
 
232
                             Gtk.ACCEL_LOCKED,
233
233
                             self._search_by_text)
234
 
        accels.connect_group(gtk.keysyms.g, gtk.gdk.CONTROL_MASK,
235
 
                             gtk.ACCEL_LOCKED,
 
234
        accels.connect_group(Gdk.KEY_g, Gdk.EventMask.CONTROL_MASK,
 
235
                             Gtk.ACCEL_LOCKED,
236
236
                             self._search_by_line)
237
237
        self.add_accel_group(accels)
238
238
 
267
267
 
268
268
 
269
269
    def _create_annotate_view(self):
270
 
        tv = gtk.TreeView()
 
270
        tv = Gtk.TreeView()
271
271
        tv.set_rules_hint(False)
272
272
        tv.connect("cursor-changed", self._activate_selected_revision)
273
273
        tv.show()
274
274
        tv.connect("row-activated", self.line_diff)
275
275
 
276
 
        cell = gtk.CellRendererText()
 
276
        cell = Gtk.CellRendererText()
277
277
        cell.set_property("xalign", 1.0)
278
278
        cell.set_property("ypad", 0)
279
279
        cell.set_property("family", "Monospace")
280
280
        cell.set_property("cell-background-gdk",
281
 
                          tv.get_style().bg[gtk.STATE_NORMAL])
282
 
        col = gtk.TreeViewColumn()
 
281
                          tv.get_style().bg[Gtk.StateType.NORMAL])
 
282
        col = Gtk.TreeViewColumn()
283
283
        col.set_resizable(False)
284
 
        col.pack_start(cell, expand=True)
 
284
        col.pack_start(cell, True, True, 0)
285
285
        col.add_attribute(cell, "text", LINE_NUM_COL)
286
286
        tv.append_column(col)
287
287
 
288
 
        cell = gtk.CellRendererText()
 
288
        cell = Gtk.CellRendererText()
289
289
        cell.set_property("ypad", 0)
290
 
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
 
290
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
291
291
        cell.set_property("cell-background-gdk",
292
 
                          self.get_style().bg[gtk.STATE_NORMAL])
293
 
        col = gtk.TreeViewColumn("Committer")
 
292
                          self.get_style().bg[Gtk.StateType.NORMAL])
 
293
        col = Gtk.TreeViewColumn("Committer")
294
294
        col.set_resizable(True)
295
 
        col.pack_start(cell, expand=True)
 
295
        col.pack_start(cell, True, True, 0)
296
296
        col.add_attribute(cell, "text", COMMITTER_COL)
297
297
        tv.append_column(col)
298
298
 
299
 
        cell = gtk.CellRendererText()
 
299
        cell = Gtk.CellRendererText()
300
300
        cell.set_property("xalign", 1.0)
301
301
        cell.set_property("ypad", 0)
302
302
        cell.set_property("cell-background-gdk",
303
 
                          self.get_style().bg[gtk.STATE_NORMAL])
304
 
        col = gtk.TreeViewColumn("Revno")
 
303
                          self.get_style().bg[Gtk.StateType.NORMAL])
 
304
        col = Gtk.TreeViewColumn("Revno")
305
305
        col.set_resizable(False)
306
 
        col.pack_start(cell, expand=True)
 
306
        col.pack_start(cell, True, True, 0)
307
307
        col.add_attribute(cell, "markup", REVNO_COL)
308
308
        tv.append_column(col)
309
309
 
310
 
        cell = gtk.CellRendererText()
 
310
        cell = Gtk.CellRendererText()
311
311
        cell.set_property("ypad", 0)
312
312
        cell.set_property("family", "Monospace")
313
 
        col = gtk.TreeViewColumn()
 
313
        col = Gtk.TreeViewColumn()
314
314
        col.set_resizable(False)
315
 
        col.pack_start(cell, expand=True)
 
315
        col.pack_start(cell, True, True, 0)
316
316
#        col.add_attribute(cell, "foreground", HIGHLIGHT_COLOR_COL)
317
317
        col.add_attribute(cell, "background", HIGHLIGHT_COLOR_COL)
318
318
        col.add_attribute(cell, "text", TEXT_LINE_COL)
333
333
        return lv
334
334
 
335
335
    def _create_back_button(self):
336
 
        button = gtk.Button()
 
336
        button = Gtk.Button()
337
337
        button.set_use_stock(True)
338
338
        button.set_label("gtk-go-back")
339
339
        button.connect("clicked", lambda w: self.go_back())
340
 
        button.set_relief(gtk.RELIEF_NONE)
 
340
        button.set_relief(Gtk.ReliefStyle.NONE)
341
341
        button.show()
342
342
        return button
343
343
 
344
344
    def _create_forward_button(self):
345
 
        button = gtk.Button()
 
345
        button = Gtk.Button()
346
346
        button.set_use_stock(True)
347
347
        button.set_label("gtk-go-forward")
348
348
        button.connect("clicked", lambda w: self.go_forward())
349
 
        button.set_relief(gtk.RELIEF_NONE)
 
349
        button.set_relief(Gtk.ReliefStyle.NONE)
350
350
        button.show()
351
351
        button.set_sensitive(False)
352
352
        return button
353
353
 
354
354
    def _create_find_button(self):
355
 
        button = gtk.Button()
 
355
        button = Gtk.Button()
356
356
        button.set_use_stock(True)
357
357
        button.set_label("gtk-find")
358
358
        button.set_tooltip_text("Search for text (Ctrl+F)")
359
359
        button.connect("clicked", self._search_by_text)
360
 
        button.set_relief(gtk.RELIEF_NONE)
 
360
        button.set_relief(Gtk.ReliefStyle.NONE)
361
361
        button.show()
362
362
        button.set_sensitive(True)
363
363
        return button
364
364
 
365
365
    def _create_goto_button(self):
366
 
        button = gtk.Button()
 
366
        button = Gtk.Button()
367
367
        button.set_label("Goto Line")
368
368
        button.set_tooltip_text("Scroll to a line by entering its number (Ctrl+G)")
369
369
        button.connect("clicked", self._search_by_line)
370
 
        button.set_relief(gtk.RELIEF_NONE)
 
370
        button.set_relief(Gtk.ReliefStyle.NONE)
371
371
        button.show()
372
372
        button.set_sensitive(True)
373
373
        return button
452
452
            self.__cache[revision_id] = revision
453
453
        return self.__cache[revision_id]
454
454
 
455
 
class SearchBox(gtk.HBox):
 
455
class SearchBox(Gtk.HBox):
456
456
    """A button box for searching in text or lines of annotations"""
457
457
    def __init__(self):
458
 
        gtk.HBox.__init__(self, False, 6)
 
458
        GObject.GObject.__init__(self, False, 6)
459
459
 
460
460
        # Close button
461
 
        button = gtk.Button()
462
 
        image = gtk.Image()
463
 
        image.set_from_stock('gtk-stop', gtk.ICON_SIZE_BUTTON)
 
461
        button = Gtk.Button()
 
462
        image = Gtk.Image()
 
463
        image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON)
464
464
        button.set_image(image)
465
 
        button.set_relief(gtk.RELIEF_NONE)
 
465
        button.set_relief(Gtk.ReliefStyle.NONE)
466
466
        button.connect("clicked", lambda w: self.hide_all())
467
467
        self.pack_start(button, expand=False, fill=False)
468
468
 
469
469
        # Search entry
470
 
        label = gtk.Label()
 
470
        label = Gtk.Label()
471
471
        self._label = label
472
472
        self.pack_start(label, expand=False, fill=False)
473
473
 
474
 
        entry = gtk.Entry()
 
474
        entry = Gtk.Entry()
475
475
        self._entry = entry
476
476
        entry.connect("activate", lambda w, d: self._do_search(d),
477
477
                      'forward')
478
478
        self.pack_start(entry, expand=False, fill=False)
479
479
 
480
480
        # Next/previous buttons
481
 
        button = gtk.Button('_Next')
482
 
        image = gtk.Image()
483
 
        image.set_from_stock('gtk-go-forward', gtk.ICON_SIZE_BUTTON)
 
481
        button = Gtk.Button('_Next')
 
482
        image = Gtk.Image()
 
483
        image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON)
484
484
        button.set_image(image)
485
485
        button.connect("clicked", lambda w, d: self._do_search(d),
486
486
                       'forward')
487
487
        self.pack_start(button, expand=False, fill=False)
488
488
 
489
 
        button = gtk.Button('_Previous')
490
 
        image = gtk.Image()
491
 
        image.set_from_stock('gtk-go-back', gtk.ICON_SIZE_BUTTON)
 
489
        button = Gtk.Button('_Previous')
 
490
        image = Gtk.Image()
 
491
        image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON)
492
492
        button.set_image(image)
493
493
        button.connect("clicked", lambda w, d: self._do_search(d),
494
494
                       'backward')
495
495
        self.pack_start(button, expand=False, fill=False)
496
496
 
497
497
        # Search options
498
 
        check = gtk.CheckButton('Match case')
 
498
        check = Gtk.CheckButton('Match case')
499
499
        self._match_case = check
500
500
        self.pack_start(check, expand=False, fill=False)
501
501
 
502
 
        check = gtk.CheckButton('Regexp')
 
502
        check = Gtk.CheckButton('Regexp')
503
503
        check.connect("toggled", lambda w: self._set_label())
504
504
        self._regexp = check
505
505
        self.pack_start(check, expand=False, fill=False)