Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

gtklib: define and use common colors

Changeset aec85547f364

Parent eb33ba1bbf91

by Yuki KODAMA

Changes to 13 files · Browse files at aec85547f364 Showing diff from parent eb33ba1bbf91 Diff from another changeset...

 
570
571
572
573
 
574
575
576
 
583
584
585
586
 
587
588
589
 
570
571
572
 
573
574
575
576
 
583
584
585
 
586
587
588
589
@@ -570,7 +570,7 @@
  def widget_func(widget, item, markups):   def linkwidget(revnum, revid, summary, highlight=None, branch=None):   # revision label - opts = dict(underline='single', foreground='#0000FF') + opts = dict(underline='single', color='blue')   if highlight:   opts['weight'] = 'bold'   rev = '%s (%s)' % (gtklib.markup(revnum, **opts), @@ -583,7 +583,7 @@
  sum = gtklib.markup(summary)   if branch:   sum = gtklib.markup(branch, color='black', - background='#aaffaa') + ' ' + sum + background=gtklib.PGREEN) + ' ' + sum   sumlabel = gtk.Label()   sumlabel.set_markup(sum)   sumlabel.set_selectable(True)
 
408
409
410
411
 
412
413
414
 
408
409
410
 
411
412
413
414
@@ -408,7 +408,7 @@
  def markup_func(widget, item, value):   if item == 'athead' and value is False:   text = '[%s]' % _('Not at head') - return gtklib.markup(text, weight='bold', color='#880000') + return gtklib.markup(text, weight='bold', color=gtklib.DRED)   raise csinfo.UnknownItem(item)   custom = csinfo.custom(data=data_func, markup=markup_func)   factory = csinfo.factory(self.repo, custom, style)
 
337
338
339
340
 
341
342
 
343
344
345
 
337
338
339
 
340
341
 
342
343
344
345
@@ -337,9 +337,9 @@
  return str(value)   elif item in ('rawbranch', 'branch'):   return gtklib.markup(' %s ' % value, color='black', - background='#aaffaa') + background=gtklib.PGREEN)   elif item in ('rawtags', 'tags'): - opts = dict(color='black', background='#ffffaa') + opts = dict(color='black', background=gtklib.PYELLOW)   tags = [gtklib.markup(' %s ' % tag, **opts) for tag in value]   return ' '.join(tags)   elif item in ('desc', 'summary', 'user', 'date', 'age'):
 
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@@ -29,6 +29,18 @@
  # http://www.mail-archive.com/tortoisehg-develop@lists.sourceforge.net/msg06900.html   raise Exception('incompatible version of gobject')   +# common colors + +DRED = '#900000' +DGREEN = '#006400' +DBLUE = '#000090' + +PRED = '#ffcccc' +PGREEN = '#aaffaa' +PBLUE = '#aaddff' +PYELLOW = '#ffffaa' +PORANGE = '#ffddaa' +  def set_tortoise_icon(window, thgicon):   ico = paths.get_tortoise_icon(thgicon)   if ico: window.set_icon_from_file(ico)
 
194
195
196
197
198
 
 
199
200
 
201
202
203
 
194
195
196
 
 
197
198
199
 
200
201
202
203
@@ -194,10 +194,10 @@
    #$$ text view for diff   self.buf = gtk.TextBuffer() - self.buf.create_tag('removed', foreground='#900000') - self.buf.create_tag('added', foreground='#006400') + self.buf.create_tag('removed', foreground=gtklib.DRED) + self.buf.create_tag('added', foreground=gtklib.DGREEN)   self.buf.create_tag('position', foreground='#FF8000') - self.buf.create_tag('header', foreground='#000090') + self.buf.create_tag('header', foreground=gtklib.DBLUE)   diffview = gtk.TextView(self.buf)   scroller.add(diffview)   diffview.modify_font(pango.FontDescription('monospace'))
 
88
89
90
91
 
92
93
94
 
384
385
386
387
 
388
389
390
 
391
392
393
 
394
395
396
 
566
567
568
569
 
570
571
572
 
88
89
90
 
91
92
93
94
 
384
385
386
 
387
388
389
 
390
391
392
 
393
394
395
396
 
566
567
568
 
569
570
571
572
@@ -88,7 +88,7 @@
  scrolledwindow.add(self.textview)   self.textbuffer = self.textview.get_buffer()   self.textbuffer.create_tag('error', weight=pango.WEIGHT_HEAVY, - foreground='#900000') + foreground=gtklib.DRED)     self.vbox.pack_start(scrolledwindow, True, True)   self.connect('map_event', self._on_window_map_event) @@ -384,13 +384,13 @@
  """   markup = '<span foreground="%s" weight="%s">%%s</span>'   if style in ('succeed', 'green', 'ok'): - markup = markup % ('#007700', 'bold') + markup = markup % (gtklib.DGREEN, 'bold')   icons = {'succeed': True}   elif style in ('error', 'failed', 'fail', 'red'): - markup = markup % ('#880000', 'bold') + markup = markup % (gtklib.DRED, 'bold')   icons = {'error': True}   else: - markup = markup % ('#000000', 'normal') + markup = markup % ('black', 'normal')   icons = {}   text = gtklib.markup_escape_text(text)   self.rlabel.set_markup(markup % text) @@ -566,7 +566,7 @@
  # text buffer   self.buffer = self.textview.get_buffer()   self.buffer.create_tag('error', weight=pango.WEIGHT_HEAVY, - foreground='#900000') + foreground=gtklib.DRED)     ### public functions ###  
 
187
188
189
190
 
191
192
 
193
194
195
196
197
198
199
 
200
201
202
 
229
230
231
232
 
233
234
 
235
236
 
237
238
239
 
187
188
189
 
190
191
 
192
193
194
195
196
197
198
 
199
200
201
202
 
229
230
231
 
232
233
 
234
235
 
236
237
238
239
@@ -187,16 +187,16 @@
  tstr = ''   for tag in tags:   if tag not in self.hidetags: - style = {'color':'black', 'background':'#ffffaa'} + style = {'color':'black', 'background':gtklib.PYELLOW}   if tag == currentBookmark: - style['background'] = '#ffcc99' + style['background'] = gtklib.PORANGE   tstr += gtklib.markup(' %s ' % tag, **style) + ' '     branch = ctx.branch()   bstr = ''   if self.branchtags.get(branch) == node:   bstr += gtklib.markup(' %s ' % branch, color='black', - background='#aaffaa') + ' ' + background=gtklib.PGREEN) + ' '     author = hglib.toutf(hglib.username(ctx.user()))   age = hglib.age(ctx.date()) @@ -229,11 +229,11 @@
  M, A, R = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]   common = dict(color='black')   M = M and gtklib.markup(' %s ' % len(M), - background='#ffddaa', **common) or '' + background=gtklib.PORANGE, **common) or ''   A = A and gtklib.markup(' %s ' % len(A), - background='#aaffaa', **common) or '' + background=gtklib.PGREEN, **common) or ''   R = R and gtklib.markup(' %s ' % len(R), - background='#ffcccc', **common) or '' + background=gtklib.PRED, **common) or ''   changes = ''.join((M, A, R))     revision = (sumstr, author, taglist, color, age, changes, status)
 
86
87
88
89
 
90
91
92
 
86
87
88
 
89
90
91
92
@@ -86,7 +86,7 @@
  scrolledwindow.add(self.textview)   self.textbuffer = self.textview.get_buffer()   self.textbuffer.create_tag('error', weight=pango.WEIGHT_HEAVY, - foreground='#900000') + foreground=gtklib.DRED)   vbox.pack_start(scrolledwindow, True, True)     self.stbar = statusbar.StatusBar()
 
41
42
43
44
 
45
46
47
48
 
49
50
 
51
52
 
53
54
 
55
56
 
57
58
59
60
61
62
63
 
64
65
66
67
 
68
69
70
 
833
834
835
836
 
837
838
 
839
840
 
841
842
843
 
1002
1003
1004
1005
1006
 
 
1007
1008
 
1009
1010
1011
 
41
42
43
 
44
45
46
47
 
48
49
 
50
51
 
52
53
 
54
55
 
56
57
58
59
60
61
62
 
63
64
65
66
 
67
68
69
70
 
833
834
835
 
836
837
 
838
839
 
840
841
842
843
 
1002
1003
1004
 
 
1005
1006
1007
 
1008
1009
1010
1011
@@ -41,30 +41,30 @@
   def hunk_markup(text):   'Format a diff hunk for display in a TreeView row with markup' - hunk = "" + hunk = ''   # don't use splitlines, should split with only LF for the patch   lines = hglib.tounicode(text).split(u'\n')   for line in lines: - line = gtklib.markup_escape_text(hglib.toutf(line[:512])) + '\n' + line = hglib.toutf(line[:512]) + '\n'   if line.startswith('---') or line.startswith('+++'): - hunk += '<span foreground="#000090">%s</span>' % line + hunk += gtklib.markup(line, color=gtklib.DBLUE)   elif line.startswith('-'): - hunk += '<span foreground="#900000">%s</span>' % line + hunk += gtklib.markup(line, color=gtklib.DRED)   elif line.startswith('+'): - hunk += '<span foreground="#006400">%s</span>' % line + hunk += gtklib.markup(line, color=gtklib.DGREEN)   elif line.startswith('@@'): - hunk = '<span foreground="#FF8000">%s</span>' % line + hunk = gtklib.markup(line, color='#FF8000')   else:   hunk += line   return hunk    def hunk_unmarkup(text):   'Format a diff hunk for display in a TreeView row without markup' - hunk = "" + hunk = ''   # don't use splitlines, should split with only LF for the patch   lines = hglib.tounicode(text).split(u'\n')   for line in lines: - hunk += gtklib.markup_escape_text(hglib.toutf(line[:512])) + '\n' + hunk += gtklib.markup(hglib.toutf(line[:512])) + '\n'   return hunk    class GStatus(gdialog.GDialog): @@ -833,11 +833,11 @@
  def text_color(self, column, text_renderer, model, row_iter):   stat = model[row_iter][FM_STATUS]   if stat == 'M': - text_renderer.set_property('foreground', '#000090') + text_renderer.set_property('foreground', gtklib.DBLUE)   elif stat == 'A': - text_renderer.set_property('foreground', '#006400') + text_renderer.set_property('foreground', gtklib.DGREEN)   elif stat == 'R': - text_renderer.set_property('foreground', '#900000') + text_renderer.set_property('foreground', gtklib.DRED)   elif stat == 'C':   text_renderer.set_property('foreground', 'black')   elif stat == '!': @@ -1002,10 +1002,10 @@
    def diff_highlight_buffer(self, difftext):   buf = gtk.TextBuffer() - buf.create_tag('removed', foreground='#900000') - buf.create_tag('added', foreground='#006400') + buf.create_tag('removed', foreground=gtklib.DRED) + buf.create_tag('added', foreground=gtklib.DGREEN)   buf.create_tag('position', foreground='#FF8000') - buf.create_tag('header', foreground='#000090') + buf.create_tag('header', foreground=gtklib.DBLUE)     bufiter = buf.get_start_iter()   for line in difftext:
 
245
246
247
248
 
249
250
251
 
245
246
247
 
248
249
250
251
@@ -245,7 +245,7 @@
  self.textview.connect('populate-popup', self.add_to_popup)   self.textbuffer = self.textview.get_buffer()   self.textbuffer.create_tag('error', weight=pango.WEIGHT_HEAVY, - foreground='#900000') + foreground=gtklib.DRED)   basevbox.pack_start(scrolledwindow, True, True)     # statusbar
 
293
294
295
 
296
297
298
 
299
300
301
 
302
303
304
 
 
305
306
307
 
293
294
295
296
297
 
 
298
299
 
 
300
301
 
 
302
303
304
305
306
@@ -293,15 +293,14 @@
    def update_status(self, count):   if count: + inner = gtklib.markup(_('%s patches') % count, weight='bold')   if self.mqloaded: - info = _('<span weight="bold">%s patches</span> will' - ' be imported to the') % count + info = _('%s will be imported to the') % inner   else: - info = _('<span weight="bold">%s patches</span> will' - ' be imported to the repository') % count + info = _('%s will be imported to the repository') % inner   else: - info = '<span weight="bold" foreground="#880000">%s</span>' \ - % _('Nothing to import') + info = gtklib.markup(_('Nothing to import'), + weight='bold', color=gtklib.DRED)   self.infolbl.set_markup(info)   if self.mqloaded:   self.dest_combo.set_property('visible', bool(count))
 
198
199
200
201
202
 
 
203
204
205
 
 
206
207
208
 
198
199
200
 
 
201
202
203
 
 
204
205
206
207
208
@@ -198,11 +198,11 @@
    def preview_updated(self, cslist, total, *args):   if total is None: - info = '<span weight="bold" foreground="#880000">%s</span>' \ - % _('Unknown revision!') + info = gtklib.markup(_('Unknown revision!'), + weight='bold', color=gtklib.DRED)   else: - info = _('<span weight="bold">%s changesets</span> will' - ' be stripped') % total + inner = gtklib.markup(_('%s changesets') % total, weight='bold') + info = _('%s will be stripped') % inner   self.resultlbl.set_markup(info)   self.stripbtn.set_sensitive(bool(total))  
 
130
131
132
133
 
134
135
136
137
 
138
139
140
 
130
131
132
 
133
134
135
136
 
137
138
139
140
@@ -130,11 +130,11 @@
  if selected(i):   shunks += 1   slines += h.added + h.removed - str += "<span foreground='#000088'>" + str += '<span foreground="%s">' % gtklib.DBLUE   str += _('total: %d hunks (%d changed lines); '   'selected: %d hunks (%d changed lines)') % (hunks,   lines, shunks, slines) - str += "</span>" + str += '</span>'   break   str += hglib.toutf(h)   return str