/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-08-01 20:28:54 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110801202854-eybt6inxyjg7shz6
Added a very rough fix to see gannontation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import time
18
18
 
19
19
from gi.repository import GObject
 
20
from gi.repository import Gdk
20
21
from gi.repository import Gtk
21
22
from gi.repository import Pango
22
23
import re
50
51
 
51
52
        Window.__init__(self, parent)
52
53
 
53
 
        self.set_icon(self.render_icon(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON))
 
54
        self.set_icon(
 
55
            self.render_icon_pixbuf(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON))
54
56
        self.annotate_colormap = AnnotateColorSaturation()
55
57
 
56
58
        self._create()
127
129
        else:
128
130
            row = lineno - 1
129
131
 
130
 
        self.annoview.set_cursor(row)
131
 
        self.annoview.scroll_to_cell(row, use_align=True)
 
132
        tree_path = Gtk.TreePath.new_from_string(str(row))
 
133
        self.annoview.set_cursor(tree_path, None, None)
 
134
        self.annoview.scroll_to_cell(tree_path, use_align=True)
132
135
 
133
136
 
134
137
    def _annotate(self, tree, file_id):
191
194
        self.revisionview = self._create_log_view()
192
195
        self.annoview = self._create_annotate_view()
193
196
 
194
 
        vbox = Gtk.VBox(False)
 
197
        vbox = Gtk.VBox(homogeneous=False, spacing=0)
195
198
        vbox.show()
196
199
 
197
200
        sw = Gtk.ScrolledWindow()
205
208
        swbox.pack_start(sw, True, True, 0)
206
209
        swbox.show()
207
210
 
208
 
        hbox = Gtk.HBox(False, 6)
 
211
        hbox = Gtk.HBox(homogeneous=False, spacing=6)
209
212
        self.back_button = self._create_back_button()
210
 
        hbox.pack_start(self.back_button, expand=False, fill=True)
 
213
        hbox.pack_start(self.back_button, False, True, 0)
211
214
        self.forward_button = self._create_forward_button()
212
 
        hbox.pack_start(self.forward_button, expand=False, fill=True)
 
215
        hbox.pack_start(self.forward_button, False, True, 0)
213
216
        self.find_button = self._create_find_button()
214
 
        hbox.pack_start(self.find_button, expand=False, fill=True)
 
217
        hbox.pack_start(self.find_button, False, True, 0)
215
218
        self.goto_button = self._create_goto_button()
216
 
        hbox.pack_start(self.goto_button, expand=False, fill=True)
 
219
        hbox.pack_start(self.goto_button, False, True, 0)
217
220
        hbox.show()
218
 
        vbox.pack_start(hbox, expand=False, fill=True)
 
221
        vbox.pack_start(hbox, False, True, 0)
219
222
 
220
223
        self.pane = pane = Gtk.VPaned()
221
224
        pane.add1(swbox)
222
225
        pane.add2(self.revisionview)
223
226
        pane.show()
224
 
        vbox.pack_start(pane, expand=True, fill=True)
 
227
        vbox.pack_start(pane, True, True, 0)
225
228
 
226
229
        self._search = SearchBox()
227
 
        swbox.pack_start(self._search, expand=False, fill=True)
 
230
        swbox.pack_start(self._search, False, True, 0)
228
231
        accels = Gtk.AccelGroup()
229
 
        accels.connect_group(Gdk.KEY_f, Gdk.EventMask.CONTROL_MASK,
230
 
                             Gtk.ACCEL_LOCKED,
 
232
        accels.connect(Gdk.KEY_f, Gdk.ModifierType.CONTROL_MASK,
 
233
                             Gtk.AccelFlags.LOCKED,
231
234
                             self._search_by_text)
232
 
        accels.connect_group(Gdk.KEY_g, Gdk.EventMask.CONTROL_MASK,
233
 
                             Gtk.ACCEL_LOCKED,
 
235
        accels.connect(Gdk.KEY_g, Gdk.ModifierType.CONTROL_MASK,
 
236
                             Gtk.AccelFlags.LOCKED,
234
237
                             self._search_by_line)
235
238
        self.add_accel_group(accels)
236
239
 
279
282
                          tv.get_style().bg[Gtk.StateType.NORMAL])
280
283
        col = Gtk.TreeViewColumn()
281
284
        col.set_resizable(False)
282
 
        col.pack_start(cell, True, True, 0)
 
285
        col.pack_start(cell, True)
283
286
        col.add_attribute(cell, "text", LINE_NUM_COL)
284
287
        tv.append_column(col)
285
288
 
290
293
                          self.get_style().bg[Gtk.StateType.NORMAL])
291
294
        col = Gtk.TreeViewColumn("Committer")
292
295
        col.set_resizable(True)
293
 
        col.pack_start(cell, True, True, 0)
 
296
        col.pack_start(cell, True)
294
297
        col.add_attribute(cell, "text", COMMITTER_COL)
295
298
        tv.append_column(col)
296
299
 
301
304
                          self.get_style().bg[Gtk.StateType.NORMAL])
302
305
        col = Gtk.TreeViewColumn("Revno")
303
306
        col.set_resizable(False)
304
 
        col.pack_start(cell, True, True, 0)
 
307
        col.pack_start(cell, True)
305
308
        col.add_attribute(cell, "markup", REVNO_COL)
306
309
        tv.append_column(col)
307
310
 
310
313
        cell.set_property("family", "Monospace")
311
314
        col = Gtk.TreeViewColumn()
312
315
        col.set_resizable(False)
313
 
        col.pack_start(cell, True, True, 0)
 
316
        col.pack_start(cell, True)
314
317
#        col.add_attribute(cell, "foreground", HIGHLIGHT_COLOR_COL)
315
318
        col.add_attribute(cell, "background", HIGHLIGHT_COLOR_COL)
316
319
        col.add_attribute(cell, "text", TEXT_LINE_COL)
321
324
            return model.get_value(iter, TEXT_LINE_COL).lower().find(key.lower()) == -1
322
325
 
323
326
        tv.set_enable_search(True)
324
 
        tv.set_search_equal_func(search_equal_func)
 
327
        tv.set_search_equal_func(search_equal_func, None)
325
328
 
326
329
        return tv
327
330
 
453
456
class SearchBox(Gtk.HBox):
454
457
    """A button box for searching in text or lines of annotations"""
455
458
    def __init__(self):
456
 
        GObject.GObject.__init__(self, False, 6)
 
459
        Gtk.HBox.__init__(self, homogeneous=False, spacing=6)
457
460
 
458
461
        # Close button
459
462
        button = Gtk.Button()
462
465
        button.set_image(image)
463
466
        button.set_relief(Gtk.ReliefStyle.NONE)
464
467
        button.connect("clicked", lambda w: self.hide_all())
465
 
        self.pack_start(button, expand=False, fill=False)
 
468
        self.pack_start(button, False, False, 0)
466
469
 
467
470
        # Search entry
468
471
        label = Gtk.Label()
469
472
        self._label = label
470
 
        self.pack_start(label, expand=False, fill=False)
 
473
        self.pack_start(label, False, False, 0)
471
474
 
472
475
        entry = Gtk.Entry()
473
476
        self._entry = entry
474
477
        entry.connect("activate", lambda w, d: self._do_search(d),
475
478
                      'forward')
476
 
        self.pack_start(entry, expand=False, fill=False)
 
479
        self.pack_start(entry, False, False, 0)
477
480
 
478
481
        # Next/previous buttons
479
482
        button = Gtk.Button('_Next')
482
485
        button.set_image(image)
483
486
        button.connect("clicked", lambda w, d: self._do_search(d),
484
487
                       'forward')
485
 
        self.pack_start(button, expand=False, fill=False)
 
488
        self.pack_start(button, False, False, 0)
486
489
 
487
490
        button = Gtk.Button('_Previous')
488
491
        image = Gtk.Image()
490
493
        button.set_image(image)
491
494
        button.connect("clicked", lambda w, d: self._do_search(d),
492
495
                       'backward')
493
 
        self.pack_start(button, expand=False, fill=False)
 
496
        self.pack_start(button, False, False, 0)
494
497
 
495
498
        # Search options
496
499
        check = Gtk.CheckButton('Match case')
497
500
        self._match_case = check
498
 
        self.pack_start(check, expand=False, fill=False)
 
501
        self.pack_start(check, False, False, 0)
499
502
 
500
503
        check = Gtk.CheckButton('Regexp')
501
504
        check.connect("toggled", lambda w: self._set_label())
502
505
        self._regexp = check
503
 
        self.pack_start(check, expand=False, fill=False)
 
506
        self.pack_start(check, False, False, 0)
504
507
 
505
508
        self._view = None
506
509
        self._column = None