Commit 1c55bed8 authored by Ignacio Casal Quinteiro's avatar Ignacio Casal Quinteiro Committed by Christian Persch
Browse files

Add RGBA variants to set colors.

parent 0ac349af
......@@ -30,12 +30,19 @@ vte_terminal_get_allow_bold
vte_terminal_set_scroll_on_output
vte_terminal_set_scroll_on_keystroke
vte_terminal_set_color_bold
vte_terminal_set_color_bold_rgba
vte_terminal_set_color_foreground
vte_terminal_set_color_foreground_rgba
vte_terminal_set_color_background
vte_terminal_set_color_background_rgba
vte_terminal_set_color_dim
vte_terminal_set_color_dim_rgba
vte_terminal_set_color_cursor
vte_terminal_set_color_cursor_rgba
vte_terminal_set_color_highlight
vte_terminal_set_color_highlight_rgba
vte_terminal_set_colors
vte_terminal_set_colors_rgba
vte_terminal_set_default_colors
vte_terminal_set_opacity
vte_terminal_set_background_image
......
......@@ -2855,6 +2855,213 @@ vte_terminal_set_colors(VteTerminal *terminal,
terminal->pvt->palette_initialized = TRUE;
}
#if GTK_CHECK_VERSION (2, 99, 0)
static GdkColor *
gdk_color_from_rgba (GdkColor *color,
const GdkRGBA *rgba)
{
if (rgba == NULL)
return NULL;
color->red = rgba->red * 65535.;
color->green = rgba->green * 65535.;
color->blue = rgba->blue * 65535.;
color->pixel = 0;
return color;
}
/**
* vte_terminal_set_color_bold_rgba:
* @terminal: a #VteTerminal
* @bold: (allow-none): the new bold color or %NULL
*
* Sets the color used to draw bold text in the default foreground color.
* If @bold is %NULL then the default color is used.
*/
void
vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
const GdkRGBA *bold)
{
GdkColor color;
if (bold == NULL)
{
vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG],
&terminal->pvt->palette[VTE_DEF_BG],
1.8,
&color);
}
else
{
gdk_color_from_rgba(&color, bold);
}
vte_terminal_set_color_bold(terminal, &color);
}
/**
* vte_terminal_set_color_dim_rgba:
* @terminal: a #VteTerminal
* @dim: (allow-none): the new dim color or %NULL
*
* Sets the color used to draw dim text in the default foreground color.
* If @dim is %NULL then the default color is used.
*
* Since: 0.28
*/
void
vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
const GdkRGBA *dim)
{
GdkColor color;
if (dim == NULL)
{
vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG],
&terminal->pvt->palette[VTE_DEF_BG],
0.5,
&color);
}
else
{
gdk_color_from_rgba(&color, dim);
}
vte_terminal_set_color_dim(terminal, &color);
}
/**
* vte_terminal_set_color_foreground_rgba:
* @terminal: a #VteTerminal
* @foreground: the new foreground color
*
* Sets the foreground color used to draw normal text.
*
* Since: 0.28
*/
void
vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
const GdkRGBA *foreground)
{
GdkColor color;
vte_terminal_set_color_foreground(terminal,
gdk_color_from_rgba(&color, foreground));
}
/**
* vte_terminal_set_color_background_rgba:
* @terminal: a #VteTerminal
* @background: the new background color
*
* Sets the background color for text which does not have a specific background
* color assigned. Only has effect when no background image is set and when
* the terminal is not transparent.
*
* Since: 0.28
*/
void
vte_terminal_set_color_background_rgba(VteTerminal *terminal,
const GdkRGBA *background)
{
GdkColor color;
vte_terminal_set_color_background(terminal,
gdk_color_from_rgba (&color, background));
}
/**
* vte_terminal_set_color_cursor_rgba:
* @terminal: a #VteTerminal
* @cursor_background: (allow-none): the new color to use for the text cursor, or %NULL
*
* Sets the background color for text which is under the cursor. If %NULL, text
* under the cursor will be drawn with foreground and background colors
* reversed.
*
* Since: 0.28
*/
void
vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
const GdkRGBA *cursor_background)
{
GdkColor color;
vte_terminal_set_color_cursor(terminal,
gdk_color_from_rgba(&color, cursor_background));
}
/**
* vte_terminal_set_color_highlight_rgba:
* @terminal: a #VteTerminal
* @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
*
* Sets the background color for text which is highlighted. If %NULL,
* highlighted text (which is usually highlighted because it is selected) will
* be drawn with foreground and background colors reversed.
*
* Since: 0.28
*/
void
vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
const GdkRGBA *highlight_background)
{
GdkColor color;
vte_terminal_set_color_highlight(terminal,
gdk_color_from_rgba(&color, highlight_background));
}
/**
* vte_terminal_set_colors_rgba:
* @terminal: a #VteTerminal
* @foreground: (allow-none): the new foreground color, or %NULL
* @background: (allow-none): the new background color, or %NULL
* @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA): the color palette
* @palette_size: the number of entries in @palette
*
* The terminal widget uses a 28-color model comprised of the default foreground
* and background colors, the bold foreground color, the dim foreground
* color, an eight color palette, bold versions of the eight color palette,
* and a dim version of the the eight color palette.
*
* @palette_size must be either 0, 8, 16, or 24, or between 25 and 255 inclusive.
* If @foreground is %NULL and
* @palette_size is greater than 0, the new foreground color is taken from
* @palette[7]. If @background is %NULL and @palette_size is greater than 0,
* the new background color is taken from @palette[0]. If
* @palette_size is 8 or 16, the third (dim) and possibly the second (bold)
* 8-color palettes are extrapolated from the new background color and the items
* in @palette.
*
* Since: 0.28
*/
void
vte_terminal_set_colors_rgba(VteTerminal *terminal,
const GdkRGBA *foreground,
const GdkRGBA *background,
const GdkRGBA *palette,
gsize palette_size)
{
GdkColor fg, bg, *pal;
gsize i;
pal = g_new (GdkColor, palette_size);
for (i = 0; i < palette_size; ++i)
gdk_color_from_rgba(&pal[i], &palette[i]);
vte_terminal_set_colors(terminal,
gdk_color_from_rgba(&fg, foreground),
gdk_color_from_rgba(&bg, background),
pal, palette_size);
g_free (pal);
}
#endif /* GTK 3.0 */
/**
* vte_terminal_set_opacity:
* @terminal: a #VteTerminal
......
......@@ -329,6 +329,27 @@ void vte_terminal_set_colors(VteTerminal *terminal,
const GdkColor *background,
const GdkColor *palette,
glong palette_size);
#if GTK_CHECK_VERSION (2, 99, 0)
void vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
const GdkRGBA *bold);
void vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
const GdkRGBA *dim);
void vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
const GdkRGBA *foreground);
void vte_terminal_set_color_background_rgba(VteTerminal *terminal,
const GdkRGBA *background);
void vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
const GdkRGBA *cursor_background);
void vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
const GdkRGBA *highlight_background);
void vte_terminal_set_colors_rgba(VteTerminal *terminal,
const GdkRGBA *foreground,
const GdkRGBA *background,
const GdkRGBA *palette,
gsize palette_size);
#endif
void vte_terminal_set_default_colors(VteTerminal *terminal);
/* Background effects. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment