Do grayscale "pill" instead of theme-based colors (for bad themes)
git-svn-id: svn://svn.berlios.de/gpodder/trunk@479 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
3106589993
commit
753706b3c9
|
@ -1,3 +1,9 @@
|
|||
Tue, 04 Dec 2007 23:28:27 +0100 <thp@perli.net>
|
||||
Do grayscale "pill" instead of theme-based colors (for bad themes)
|
||||
|
||||
* src/gpodder/draw.py: Always draw the "pill" in semi-transparent
|
||||
black/grey shades so it will work for all GTK themes (even Ubuntu's)
|
||||
|
||||
Mon, 03 Dec 2007 21:35:56 +0100 <thp@perli.net>
|
||||
Update channel navigator when iPod/MP3 player sync has finished
|
||||
|
||||
|
|
|
@ -60,14 +60,6 @@ def draw_rounded_rectangle(ctx, x, y, w, h, r=10, left_side_width = None, sides_
|
|||
ctx.line_to(x+left_side_width, y+h)
|
||||
|
||||
|
||||
def set_gtk_color(ctx, col, opacity=1.0, invert=False):
|
||||
# Convert color values 0..65535 -> 0.0..1.0
|
||||
(r, g, b) = map(lambda c: c/65535.0, (col.red, col.green, col.blue))
|
||||
if invert == True:
|
||||
(r, g, b) = (1.0-r, 1.0-g, 1.0-b)
|
||||
ctx.set_source_rgba( r, g, b, opacity)
|
||||
|
||||
|
||||
def draw_text_pill(left_text, right_text, x=0, y=0, border=3, radius=11):
|
||||
# Create temporary context to calculate the text size
|
||||
ctx = cairo.Context(cairo.ImageSurface(cairo.FORMAT_ARGB32, 1, 1))
|
||||
|
@ -76,9 +68,6 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=3, radius=11):
|
|||
widget = gtk.ProgressBar()
|
||||
style = widget.rc_get_style()
|
||||
|
||||
bg_color = style.bg[gtk.STATE_SELECTED]
|
||||
text_color = style.text[gtk.STATE_SELECTED]
|
||||
|
||||
font_desc = style.font_desc
|
||||
font_size = float(font_desc.get_size())/float(pango.SCALE)
|
||||
font_name = font_desc.get_family()
|
||||
|
@ -110,26 +99,26 @@ def draw_text_pill(left_text, right_text, x=0, y=0, border=3, radius=11):
|
|||
rect_height = text_height + border*2
|
||||
if left_text is not None:
|
||||
draw_rounded_rectangle(ctx,x,y,rect_width,rect_height,radius, left_side_width, RRECT_LEFT_SIDE)
|
||||
set_gtk_color(ctx, bg_color, 0.5)
|
||||
ctx.set_source_rgba( 0, 0, 0, 0.5)
|
||||
ctx.fill()
|
||||
|
||||
ctx.move_to(x+1+border-left_text_e.x_bearing, y+1+border+text_height)
|
||||
set_gtk_color(ctx, text_color, invert=True)
|
||||
ctx.set_source_rgba( 0, 0, 0, 1)
|
||||
ctx.show_text(left_text)
|
||||
ctx.move_to(x+border-left_text_e.x_bearing, y+border+text_height)
|
||||
set_gtk_color(ctx, text_color)
|
||||
ctx.set_source_rgba( 1, 1, 1, 1)
|
||||
ctx.show_text(left_text)
|
||||
|
||||
if right_text is not None:
|
||||
draw_rounded_rectangle(ctx, x, y, rect_width, rect_height, radius, left_side_width, RRECT_RIGHT_SIDE)
|
||||
set_gtk_color(ctx, bg_color)
|
||||
ctx.set_source_rgba( 0, 0, 0, 0.7)
|
||||
ctx.fill()
|
||||
|
||||
ctx.move_to(x+1+border*3+left_text_e.width-right_text_e.x_bearing, y+1+border+text_height)
|
||||
set_gtk_color(ctx, text_color, invert=True)
|
||||
ctx.set_source_rgba( 0, 0, 0, 1)
|
||||
ctx.show_text(right_text)
|
||||
ctx.move_to(x+border*3+left_text_e.width-right_text_e.x_bearing, y+border+text_height)
|
||||
set_gtk_color(ctx, text_color)
|
||||
ctx.set_source_rgba( 1, 1, 1, 1)
|
||||
ctx.show_text(right_text)
|
||||
|
||||
return surface
|
||||
|
|
Loading…
Reference in a new issue