- Added a shared XTextColor definition and a palette conversion helper for Cairo-ready colors, decoupling renderer palettes from GdkColor usage in the API surface.

- Updated xtext palette APIs to accept internal color arrays directly for rendering setup.
- Wired xtext palette creation through UI entry points to use the new palette helper when constructing or refreshing text views.
This commit is contained in:
2026-01-17 21:39:45 -07:00
parent 5986e6a78b
commit 4ac836fc66
9 changed files with 71 additions and 32 deletions

View File

@@ -150,19 +150,6 @@ static void gtk_xtext_search_fini (xtext_buffer *);
static gboolean gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr);
static char * gtk_xtext_get_word (GtkXText * xtext, int x, int y, textentry ** ret_ent, int *ret_off, int *ret_len, GSList **slp);
static inline XTextColor
xtext_color_from_gdk (const GdkColor *color)
{
XTextColor result;
result.red = color->red / 65535.0;
result.green = color->green / 65535.0;
result.blue = color->blue / 65535.0;
result.alpha = 1.0;
return result;
}
static inline void
xtext_set_source_color (cairo_t *cr, const XTextColor *color, gdouble alpha)
{
@@ -619,7 +606,7 @@ gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext)
}
GtkWidget *
gtk_xtext_new (GdkColor palette[], int separator)
gtk_xtext_new (const XTextColor *palette, int separator)
{
GtkXText *xtext;
@@ -3472,13 +3459,13 @@ gtk_xtext_render_line (GtkXText * xtext, textentry * ent, int line,
}
void
gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[])
gtk_xtext_set_palette (GtkXText * xtext, const XTextColor *palette)
{
int i;
for (i = (XTEXT_COLS-1); i >= 0; i--)
{
xtext->palette[i] = xtext_color_from_gdk (&palette[i]);
xtext->palette[i] = palette[i];
}
if (gtk_widget_get_realized (GTK_WIDGET(xtext)))