Changeset 81e9adc8efb2…
Parent 0bfd2f6747ac…
by
Changes to 9 files · Browse files at 81e9adc8efb2 Showing diff from parent 0bfd2f6747ac Diff from another changeset...
@@ -340,7 +340,6 @@ tags, lines = self.prepare_diff(lines, offset, wfile)
for l in lines:
buf.insert(eob, l)
-
# inserts the tags
for name, p0, p1 in tags:
i0 = buf.get_iter_at_offset(p0)
@@ -419,7 +418,7 @@ tag = 'red'
l = hglib.diffexpand(l)
else:
- tag = 'black'
+ tag = 'normal'
l = hglib.diffexpand(l)
l = l+"\n"
length = len(l.decode('utf-8'))
@@ -570,7 +569,7 @@ def widget_func(widget, item, markups):
def linkwidget(revnum, revid, summary, highlight=None, branch=None):
# revision label
- opts = dict(underline='single', color='blue')
+ opts = dict(underline='single', color=gtklib.BLUE)
if highlight:
opts['weight'] = 'bold'
rev = '%s (%s)' % (gtklib.markup(revnum, **opts),
@@ -582,7 +581,7 @@ # summary & branch label
sum = gtklib.markup(summary)
if branch:
- sum = gtklib.markup(branch, color='black',
+ sum = gtklib.markup(branch, color=gtklib.NORMAL,
background=gtklib.PGREEN) + ' ' + sum
sumlabel = gtk.Label()
sumlabel.set_markup(sum)
@@ -785,7 +784,7 @@ tag_table = self._buffer.get_tag_table()
tag_table.add(make_texttag('diff', font=self.rawfonts['fontdiff']))
- tag_table.add(make_texttag('blue', foreground='blue'))
+ tag_table.add(make_texttag('blue', foreground=gtklib.BLUE))
if self.colorstyle == 'background':
tag_table.add(make_texttag('red',
paragraph_background=gtklib.PRED))
@@ -797,21 +796,21 @@ else:
tag_table.add(make_texttag('red', foreground=gtklib.DRED))
tag_table.add(make_texttag('green', foreground=gtklib.DGREEN))
- tag_table.add(make_texttag('black', foreground='black'))
+ tag_table.add(make_texttag('normal', foreground=gtklib.NORMAL))
tag_table.add(make_texttag('greybg',
- paragraph_background='grey',
+ paragraph_background=gtklib.CHANGE_HEADER,
weight=pango.WEIGHT_BOLD))
- tag_table.add(make_texttag('yellowbg', background='yellow'))
+ tag_table.add(make_texttag('yellowbg', background=gtklib.YELLOW))
- issuelink_tag = make_texttag('issuelink', foreground='blue',
+ issuelink_tag = make_texttag('issuelink', foreground=gtklib.BLUE,
underline=pango.UNDERLINE_SINGLE)
issuelink_tag.connect('event', self.issuelink_event)
tag_table.add(issuelink_tag)
- urllink_tag = make_texttag('urllink', foreground='blue',
+ urllink_tag = make_texttag('urllink', foreground=gtklib.BLUE,
underline=pango.UNDERLINE_SINGLE)
urllink_tag.connect('event', self.urllink_event)
tag_table.add(urllink_tag)
- csetlink_tag = make_texttag('csetlink', foreground='blue',
+ csetlink_tag = make_texttag('csetlink', foreground=gtklib.BLUE,
underline=pango.UNDERLINE_SINGLE)
csetlink_tag.connect('event', self.csetlink_event)
tag_table.add(csetlink_tag)
|
@@ -349,10 +349,10 @@ elif item in ('revnum', 'p4', 'svn'):
return str(value)
elif item in ('rawbranch', 'branch'):
- return gtklib.markup(' %s ' % value, color='black',
+ return gtklib.markup(' %s ' % value, color=gtklib.BLACK,
background=gtklib.PGREEN)
elif item in ('rawtags', 'tags'):
- opts = dict(color='black', background=gtklib.PYELLOW)
+ opts = dict(color=gtklib.BLACK, background=gtklib.PYELLOW)
tags = [gtklib.markup(' %s ' % tag, **opts) for tag in value]
return ' '.join(tags)
elif item in ('desc', 'summary', 'user', 'shortuser',
|
|
@@ -37,6 +37,9 @@ DRED = '#900000'
DGREEN = '#006400'
DBLUE = '#000090'
+DYELLOW = '#6A6A00'
+DORANGE = '#AA5000'
+# DORANGE = '#FF8000'
PRED = '#ffcccc'
PGREEN = '#aaffaa'
@@ -44,6 +47,102 @@PYELLOW = '#ffffaa'
PORANGE = '#ffddaa'
+RED = 'red'
+GREEN = 'green'
+BLUE = 'blue'
+YELLOW = 'yellow'
+BLACK = 'black'
+WHITE = 'white'
+GREY = 'grey'
+
+NORMAL = BLACK
+NEW_REV_COLOR = DGREEN
+CHANGE_HEADER = GREY
+
+UP_ARROW_COLOR = '#feaf3e'
+DOWN_ARROW_COLOR = '#8ae234'
+STAR_COLOR = '#fce94f'
+CELL_GREY = '#2e3436'
+STATUS_HEADER = '#DDDDDD'
+STATUS_REJECT_BACKGROUND = '#EEEEEE'
+STATUS_REJECT_FOREGROUND = '#888888'
+
+# line colors
+MAINLINE_COLOR = ( 0.0, 0.0, 0.0 )
+LINE_COLORS = [
+ ( 1.0, 0.0, 0.0 ),
+ ( 1.0, 1.0, 0.0 ),
+ ( 0.0, 1.0, 0.0 ),
+ ( 0.0, 1.0, 1.0 ),
+ ( 0.0, 0.0, 1.0 ),
+ ( 1.0, 0.0, 1.0 ),
+ ]
+
+def get_gtk_colors():
+ color_scheme = gtk.settings_get_default().get_property('gtk-color-scheme')
+ colors = {}
+ for color in color_scheme.split('\n'):
+ color = color.strip()
+ if color:
+ name, color = color.split(':')
+ colors[name.strip()] = gtk.gdk.color_parse(color.strip())
+ return colors
+
+def _init_colors():
+ global NORMAL, MAINLINE_COLOR
+
+ gtk_colors = get_gtk_colors()
+
+ try:
+ normal = gtk_colors['fg_color']
+ except KeyError:
+ # TODO: find out how to log such errors
+ pass
+ else:
+ NORMAL = str(normal)
+ MAINLINE_COLOR = (
+ normal.red_float,
+ normal.green_float,
+ normal.blue_float
+ )
+
+ # adjust colors for a dark color scheme:
+ if normal.value > 0.5:
+ global RED, GREEN, BLUE, BLACK, WHITE, \
+ DRED, DGREEN, DBLUE, DYELLOW, DORANGE, \
+ PRED, PGREEN, PBLUE, PYELLOW, PORANGE, \
+ NEW_REV_COLOR, LINE_COLORS, CHANGE_HEADER
+
+ RED = PRED
+ GREEN = NEW_REV_COLOR = PGREEN
+ BLUE = PBLUE
+ PRED = DRED
+ DRED = '#FF6161'
+# DRED, PRED = PRED, DRED
+ DGREEN, PGREEN = PGREEN, DGREEN
+ DBLUE, PBLUE = PBLUE, DBLUE
+ DYELLOW, PYELLOW = PYELLOW, DYELLOW
+ DORANGE, PORANGE = PORANGE, DORANGE
+ BLACK, WHITE = WHITE, BLACK
+
+ CHANGE_HEADER = '#404040'
+
+ LINE_COLORS = [
+ ( 1.0, 0.3804, 0.3804 ),
+ ( 1.0, 1.0, 0.0 ),
+ ( 0.0, 1.0, 0.0 ),
+ ( 0.0, 1.0, 1.0 ),
+ ( 0.2902, 0.4863, 0.851 ),
+ ( 1.0, 0.3882, 1.0 ),
+ ]
+
+ # TODO: dark color scheme for:
+ # UP_ARROW_COLOR, DOWN_ARROW_COLOR, STAR_COLOR,
+ # CELL_GREY, STATUS_HEADER, STATUS_REJECT_BACKGROUND,
+ # STATUS_REJECT_FOREGROUND
+
+_init_colors()
+
def set_tortoise_icon(window, thgicon):
ico = paths.get_tortoise_icon(thgicon)
if ico: window.set_icon_from_file(ico)
|
@@ -196,7 +196,7 @@ self.buf = gtk.TextBuffer()
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('position', foreground=gtklib.DORANGE)
self.buf.create_tag('header', foreground=gtklib.DBLUE)
diffview = gtk.TextView(self.buf)
scroller.add(diffview)
|
@@ -402,7 +402,7 @@ markup = markup % (gtklib.DRED, 'bold')
icons = {'error': True}
else:
- markup = markup % ('black', 'normal')
+ markup = markup % (gtklib.NORMAL, 'normal')
icons = {}
text = gtklib.markup_escape_text(text)
self.rlabel.set_markup(markup % text)
|
@@ -19,6 +19,8 @@ import pango
import cairo
+from tortoisehg.hgtk import gtklib
+
# Styles used when rendering revision graph edges
style_SOLID = 0
style_DASHED = 1
@@ -87,24 +89,15 @@ colours and the fg parameter provides the multiplier that should be
applied to the foreground colours.
"""
- mainline_color = ( 0.0, 0.0, 0.0 )
- colours = [
- ( 1.0, 0.0, 0.0 ),
- ( 1.0, 1.0, 0.0 ),
- ( 0.0, 1.0, 0.0 ),
- ( 0.0, 1.0, 1.0 ),
- ( 0.0, 0.0, 1.0 ),
- ( 1.0, 0.0, 1.0 ),
- ]
if isinstance(colour, str):
r, g, b = colour[1:3], colour[3:5], colour[5:7]
colour_rgb = int(r, 16) / 255., int(g, 16) / 255., int(b, 16) / 255.
else:
if colour == 0:
- colour_rgb = mainline_color
+ colour_rgb = gtklib.MAINLINE_COLOR
else:
- colour_rgb = colours[colour % len(colours)]
+ colour_rgb = gtklib.LINE_COLORS[colour % len(gtklib.LINE_COLORS)]
red = (colour_rgb[0] * fg) or bg
green = (colour_rgb[1] * fg) or bg
@@ -187,7 +180,7 @@ # Possible node status
if status != 0:
def draw_arrow(x, y, dir):
- self.set_colour(ctx, '#2e3436', 0.0, 1.0)
+ self.set_colour(ctx, gtklib.CELL_GREY, 0.0, 1.0)
ctx.rectangle(x, y, 2, 5)
ax, ay = x, y + (dir == 'down' and 5 or 0)
inc = 3 * (dir == 'up' and -1 or 1)
@@ -196,12 +189,12 @@ ctx.line_to(ax + 1, ay + inc)
ctx.line_to(ax - 2, ay)
ctx.stroke_preserve()
- fillcolor = dir == 'up' and '#feaf3e' or '#8ae234'
+ fillcolor = dir == 'up' and gtklib.UP_ARROW_COLOR or gtklib.DOWN_ARROW_COLOR
self.set_colour(ctx, fillcolor, 0.0, 1.0)
ctx.fill()
def draw_star(x, y, radius, nodes, offset=False):
- self.set_colour(ctx, '#2e3436', 0.0, 1.0)
+ self.set_colour(ctx, gtklib.CELL_GREY, 0.0, 1.0)
total_nodes = nodes * 2 #inner + outer nodes
angle = 2 * math.pi / total_nodes;
offset = offset and angle / 2 or 0
@@ -216,7 +209,7 @@ else:
ctx.line_to(arc_x, arc_y)
ctx.stroke_preserve()
- self.set_colour(ctx, '#fce94f', 0.0, 1.0)
+ self.set_colour(ctx, gtklib.STAR_COLOR, 0.0, 1.0)
ctx.fill()
arrow_y = arc_start_position_y - box_size / 4
|
@@ -179,7 +179,7 @@ if parent is None:
parent = ctx.parents()[0].node()
M, A, R = self.repo.status(parent, ctx.node())[:3]
- common = dict(color='black')
+ common = dict(color=gtklib.BLACK)
M = M and gtklib.markup(' %s ' % len(M),
background=gtklib.PORANGE, **common) or ''
A = A and gtklib.markup(' %s ' % len(A),
@@ -217,13 +217,13 @@ bg = gtklib.PORANGE
elif tag in self.mqpatches:
bg = gtklib.PBLUE
- style = {'color': 'black', 'background': bg}
+ style = {'color': gtklib.BLACK, 'background': bg}
tstr += gtklib.markup(' %s ' % tag, **style) + ' '
branch = ctx.branch()
bstr = ''
if self.branchtags.get(branch) == node:
- bstr += gtklib.markup(' %s ' % branch, color='black',
+ bstr += gtklib.markup(' %s ' % branch, color=gtklib.BLACK,
background=gtklib.PGREEN) + ' '
if revid in self.wcparents:
@@ -295,7 +295,7 @@ self.color_func = self.text_color_author
def text_color_default(self, rev, author):
- return int(rev) >= self.origtip and 'darkgreen' or 'black'
+ return int(rev) >= self.origtip and gtklib.NEW_REV_COLOR or gtklib.NORMAL
colors = '''black blue deeppink mediumorchid blue burlywood4 goldenrod
slateblue red2 navy dimgrey'''.split()
@@ -303,7 +303,7 @@
def text_color_author(self, rev, author):
if int(rev) >= self.origtip:
- return 'darkgreen'
+ return gtklib.NEW_REV_COLOR
for re, v in self.author_pats:
if (re.search(author)):
return v
|
@@ -53,7 +53,7 @@ elif line.startswith('+'):
hunk += gtklib.markup(line, color=gtklib.DGREEN)
elif line.startswith('@@'):
- hunk = gtklib.markup(line, color='#FF8000')
+ hunk = gtklib.markup(line, color=gtklib.DORANGE)
else:
hunk += gtklib.markup(line)
return hunk
@@ -411,7 +411,7 @@ diffcol.add_attribute(cell, 'markup', DM_DISP_TEXT)
# differentiate header chunks
- cell.set_property('cell-background', '#DDDDDD')
+ cell.set_property('cell-background', gtklib.STATUS_HEADER)
diffcol.add_attribute(cell, 'cell_background_set', DM_IS_HEADER)
self.headerfont = self.difffont.copy()
self.headerfont.set_weight(pango.WEIGHT_HEAVY)
@@ -420,8 +420,8 @@ self.rejfont = self.difffont.copy()
self.rejfont.set_weight(pango.WEIGHT_LIGHT)
diffcol.add_attribute(cell, 'font-desc', DM_FONT)
- cell.set_property('background', '#EEEEEE')
- cell.set_property('foreground', '#888888')
+ cell.set_property('background', gtklib.STATUS_REJECT_BACKGROUND)
+ cell.set_property('foreground', gtklib.STATUS_REJECT_FOREGROUND)
diffcol.add_attribute(cell, 'background-set', DM_REJECTED)
diffcol.add_attribute(cell, 'foreground-set', DM_REJECTED)
difftree.append_column(diffcol)
@@ -869,7 +869,8 @@ sel = lambda x: x >= lasthunk or not dmodel[hc+x+1][DM_REJECTED]
newtext = chunks[0].selpretty(sel)
if not selected:
- newtext = "<span foreground='#888888'>" + newtext + "</span>"
+ newtext = "<span foreground='" + gtklib.STATUS_REJECT_FOREGROUND + \
+ "'>" + newtext + "</span>"
dmodel[hc][DM_DISP_TEXT] = newtext
def updated_codes(self):
@@ -919,15 +920,15 @@ elif stat == 'R':
text_renderer.set_property('foreground', gtklib.DRED)
elif stat == 'C':
- text_renderer.set_property('foreground', 'black')
+ text_renderer.set_property('foreground', gtklib.NORMAL)
elif stat == '!':
- text_renderer.set_property('foreground', 'red')
+ text_renderer.set_property('foreground', gtklib.RED)
elif stat == '?':
- text_renderer.set_property('foreground', '#AA5000')
+ text_renderer.set_property('foreground', gtklib.DORANGE)
elif stat == 'I':
- text_renderer.set_property('foreground', 'black')
+ text_renderer.set_property('foreground', gtklib.NORMAL)
else:
- text_renderer.set_property('foreground', 'black')
+ text_renderer.set_property('foreground', gtklib.NORMAL)
def rename_file(self, wfile):
@@ -1095,7 +1096,7 @@ else:
buf.create_tag('removed', foreground=gtklib.DRED)
buf.create_tag('added', foreground=gtklib.DGREEN)
- buf.create_tag('position', foreground='#FF8000')
+ buf.create_tag('position', foreground=gtklib.DORANGE)
buf.create_tag('header', foreground=gtklib.DBLUE)
bufiter = buf.get_start_iter()
|
@@ -721,11 +721,11 @@
stat = row[MQ_STATUS]
if stat == 'A':
- cell.set_property('foreground', 'blue')
+ cell.set_property('foreground', gtklib.BLUE)
elif stat == 'U':
- cell.set_property('foreground', '#909090')
+ cell.set_property('foreground', gtklib.GREY)
else:
- cell.set_property('foreground', 'black')
+ cell.set_property('foreground', gtklib.NORMAL)
patchname = row[MQ_NAME]
if self.is_qtip(patchname):
|
Loading...