8 Commits

Author SHA1 Message Date
7a1317a803 Fix Ctrl+K color entry caret visibility 2026-03-26 08:35:20 -06:00
dac1cbfe30 Make GTK3 theme selector text-only 2026-03-26 08:28:07 -06:00
deepend-tildeclub
0ca099c1a0 Merge pull request #161 from ZoiteChat/99-colors-support
feat: add support for 99 colors.
2026-03-26 01:12:13 -06:00
deepend-tildeclub
f01211ae2e Merge pull request #160 from ZoiteChat/xtext-link-hit-fix
Fix xtext link hit-testing coords
2026-03-26 01:11:51 -06:00
7c23a48ef8 feat: add support for 99 colors. 2026-03-26 00:45:03 -06:00
89f20a93e0 Fix xtext link hit-testing coords 2026-03-26 00:14:16 -06:00
f3fd7fd2b3 fixed new logo image sizes. 2026-03-25 23:45:16 -06:00
10940a37dd new logo 2026-03-25 22:53:43 -06:00
11 changed files with 157 additions and 200 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -1136,7 +1136,6 @@ check_color:
{
if (text[i] == ',' && parsing_color <= 3)
{
insert_hiddenchar (entry, i, i + 1);
parsing_color = 3;
offset++;
continue;
@@ -1153,25 +1152,21 @@ check_color:
{
case 1:
fg_color[0] = text[i];
insert_hiddenchar (entry, i, i + 1);
parsing_color++;
offset++;
continue;
case 2:
fg_color[1] = text[i];
insert_hiddenchar (entry, i, i + 1);
parsing_color++;
offset++;
continue;
case 3:
bg_color[0] = text[i];
insert_hiddenchar (entry, i, i + 1);
parsing_color++;
offset++;
continue;
case 4:
bg_color[1] = text[i];
insert_hiddenchar (entry, i, i + 1);
parsing_color++;
offset++;
continue;
@@ -1206,17 +1201,14 @@ check_color:
{
if (bg_color[0] != 0)
{
insert_hiddenchar (entry, len - offset, len);
insert_color (entry, len, atoi (fg_color), atoi (bg_color));
}
else if (fg_color[0] != 0)
{
insert_hiddenchar (entry, len - offset, len);
insert_color (entry, len, atoi (fg_color), -1);
}
else
{
insert_hiddenchar (entry, len - offset, len - offset + 1);
insert_color (entry, len, -1, -1);
}
}

View File

@@ -27,10 +27,47 @@
enum
{
THEME_XTEXT_FG_INDEX = 34,
THEME_XTEXT_BG_INDEX = 35
THEME_XTEXT_MIRC_COLS = 99,
THEME_XTEXT_MARK_FG_INDEX = 99,
THEME_XTEXT_MARK_BG_INDEX = 100,
THEME_XTEXT_FG_INDEX = 101,
THEME_XTEXT_BG_INDEX = 102,
THEME_XTEXT_MARKER_INDEX = 103
};
static const guint8 theme_default_99_mirc_colors[THEME_XTEXT_MIRC_COLS][3] = {
{ 0xff, 0xff, 0xff }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x7f }, { 0x00, 0x93, 0x00 }, { 0xff, 0x00, 0x00 }, { 0x7f, 0x00, 0x00 }, { 0x9c, 0x00, 0x9c }, { 0xfc, 0x7f, 0x00 },
{ 0xff, 0xff, 0x00 }, { 0x00, 0xfc, 0x00 }, { 0x00, 0x93, 0x93 }, { 0x00, 0xff, 0xff }, { 0x00, 0x00, 0xfc }, { 0xff, 0x00, 0xff }, { 0x7f, 0x7f, 0x7f }, { 0xd2, 0xd2, 0xd2 },
{ 0x47, 0x00, 0x00 }, { 0x47, 0x21, 0x00 }, { 0x47, 0x47, 0x00 }, { 0x32, 0x47, 0x00 }, { 0x00, 0x47, 0x00 }, { 0x00, 0x47, 0x2c }, { 0x00, 0x47, 0x47 }, { 0x00, 0x2f, 0x47 },
{ 0x00, 0x00, 0x47 }, { 0x2e, 0x00, 0x47 }, { 0x47, 0x00, 0x47 }, { 0x47, 0x00, 0x2a }, { 0x74, 0x00, 0x00 }, { 0x74, 0x3a, 0x00 }, { 0x74, 0x74, 0x00 }, { 0x51, 0x74, 0x00 },
{ 0x00, 0x74, 0x00 }, { 0x00, 0x74, 0x49 }, { 0x00, 0x74, 0x74 }, { 0x00, 0x4d, 0x74 }, { 0x00, 0x00, 0x74 }, { 0x4b, 0x00, 0x74 }, { 0x74, 0x00, 0x74 }, { 0x74, 0x00, 0x45 },
{ 0xb5, 0x00, 0x00 }, { 0xb5, 0x63, 0x00 }, { 0xb5, 0xb5, 0x00 }, { 0x7d, 0xb5, 0x00 }, { 0x00, 0xb5, 0x00 }, { 0x00, 0xb5, 0x71 }, { 0x00, 0xb5, 0xb5 }, { 0x00, 0x75, 0xb5 },
{ 0x00, 0x00, 0xb5 }, { 0x75, 0x00, 0xb5 }, { 0xb5, 0x00, 0xb5 }, { 0xb5, 0x00, 0x6b }, { 0xff, 0x00, 0x00 }, { 0xff, 0x8c, 0x00 }, { 0xff, 0xff, 0x00 }, { 0xb2, 0xff, 0x00 },
{ 0x00, 0xff, 0x00 }, { 0x00, 0xff, 0xa0 }, { 0x00, 0xff, 0xff }, { 0x00, 0xa9, 0xff }, { 0x00, 0x00, 0xff }, { 0xa5, 0x00, 0xff }, { 0xff, 0x00, 0xff }, { 0xff, 0x00, 0x98 },
{ 0xff, 0x59, 0x59 }, { 0xff, 0xb4, 0x59 }, { 0xff, 0xff, 0x71 }, { 0xcf, 0xff, 0x60 }, { 0x6f, 0xff, 0x6f }, { 0x65, 0xff, 0xc9 }, { 0x6d, 0xff, 0xff }, { 0x59, 0xcd, 0xff },
{ 0x59, 0x59, 0xff }, { 0xc4, 0x59, 0xff }, { 0xff, 0x66, 0xff }, { 0xff, 0x59, 0xbc }, { 0xff, 0x9c, 0x9c }, { 0xff, 0xd3, 0x9c }, { 0xff, 0xff, 0x9c }, { 0xe2, 0xff, 0x9c },
{ 0x9c, 0xff, 0x9c }, { 0x9c, 0xff, 0xdb }, { 0x9c, 0xff, 0xff }, { 0x9c, 0xe2, 0xff }, { 0x9c, 0x9c, 0xff }, { 0xdc, 0x9c, 0xff }, { 0xff, 0x9c, 0xff }, { 0xff, 0x94, 0xd3 },
{ 0x00, 0x00, 0x00 }, { 0x13, 0x13, 0x13 }, { 0x28, 0x28, 0x28 }, { 0x36, 0x36, 0x36 }, { 0x4d, 0x4d, 0x4d }, { 0x65, 0x65, 0x65 }, { 0x81, 0x81, 0x81 }, { 0x9f, 0x9f, 0x9f },
{ 0xbc, 0xbc, 0xbc }, { 0xe2, 0xe2, 0xe2 }, { 0xff, 0xff, 0xff }
};
static void
theme_access_apply_default_99_palette (XTextColor *palette, size_t palette_len, gboolean apply_base)
{
size_t i;
size_t start = apply_base ? 0 : 32;
if (palette_len == 0)
return;
for (i = start; i < THEME_XTEXT_MIRC_COLS && i < palette_len; i++)
{
palette[i].red = theme_default_99_mirc_colors[i][0] / 255.0;
palette[i].green = theme_default_99_mirc_colors[i][1] / 255.0;
palette[i].blue = theme_default_99_mirc_colors[i][2] / 255.0;
palette[i].alpha = 1.0;
}
}
static gboolean
theme_token_to_rgb16 (ThemeSemanticToken token, guint16 *red, guint16 *green, guint16 *blue)
{
@@ -83,9 +120,18 @@ gboolean
theme_get_mirc_color (unsigned int mirc_index, GdkRGBA *out_rgba)
{
ThemeSemanticToken token = (ThemeSemanticToken) (THEME_TOKEN_MIRC_0 + (int) mirc_index);
gboolean has_user_colors = theme_runtime_mode_has_user_colors (theme_runtime_is_dark_active ());
if (mirc_index >= 32)
if (mirc_index >= THEME_XTEXT_MIRC_COLS)
return FALSE;
if (!has_user_colors || mirc_index >= 32)
{
out_rgba->red = theme_default_99_mirc_colors[mirc_index][0] / 255.0;
out_rgba->green = theme_default_99_mirc_colors[mirc_index][1] / 255.0;
out_rgba->blue = theme_default_99_mirc_colors[mirc_index][2] / 255.0;
out_rgba->alpha = 1.0;
return TRUE;
}
return theme_runtime_get_color (token, out_rgba);
}
@@ -99,9 +145,17 @@ gboolean
theme_get_mirc_color_rgb16 (unsigned int mirc_index, guint16 *red, guint16 *green, guint16 *blue)
{
ThemeSemanticToken token = (ThemeSemanticToken) (THEME_TOKEN_MIRC_0 + (int) mirc_index);
gboolean has_user_colors = theme_runtime_mode_has_user_colors (theme_runtime_is_dark_active ());
if (mirc_index >= 32)
if (mirc_index >= THEME_XTEXT_MIRC_COLS)
return FALSE;
if (!has_user_colors || mirc_index >= 32)
{
*red = (guint16) (theme_default_99_mirc_colors[mirc_index][0] * 257);
*green = (guint16) (theme_default_99_mirc_colors[mirc_index][1] * 257);
*blue = (guint16) (theme_default_99_mirc_colors[mirc_index][2] * 257);
return TRUE;
}
return theme_token_to_rgb16 (token, red, green, blue);
}
@@ -145,12 +199,39 @@ void
theme_get_xtext_colors_for_widget (GtkWidget *widget, XTextColor *palette, size_t palette_len)
{
ThemeWidgetStyleValues style_values;
gboolean has_user_colors;
GdkRGBA marker_color;
if (!palette)
return;
theme_get_widget_style_values_for_widget (widget, &style_values);
theme_runtime_get_xtext_colors (palette, palette_len);
has_user_colors = theme_runtime_mode_has_user_colors (theme_runtime_is_dark_active ());
theme_access_apply_default_99_palette (palette, palette_len, !has_user_colors);
if (palette_len > THEME_XTEXT_MARK_FG_INDEX)
{
palette[THEME_XTEXT_MARK_FG_INDEX].red = style_values.selection_foreground.red;
palette[THEME_XTEXT_MARK_FG_INDEX].green = style_values.selection_foreground.green;
palette[THEME_XTEXT_MARK_FG_INDEX].blue = style_values.selection_foreground.blue;
palette[THEME_XTEXT_MARK_FG_INDEX].alpha = style_values.selection_foreground.alpha;
}
if (palette_len > THEME_XTEXT_MARK_BG_INDEX)
{
palette[THEME_XTEXT_MARK_BG_INDEX].red = style_values.selection_background.red;
palette[THEME_XTEXT_MARK_BG_INDEX].green = style_values.selection_background.green;
palette[THEME_XTEXT_MARK_BG_INDEX].blue = style_values.selection_background.blue;
palette[THEME_XTEXT_MARK_BG_INDEX].alpha = style_values.selection_background.alpha;
}
if (palette_len > THEME_XTEXT_MARKER_INDEX)
{
if (!theme_runtime_get_color (THEME_TOKEN_MARKER, &marker_color))
marker_color = style_values.selection_background;
palette[THEME_XTEXT_MARKER_INDEX].red = marker_color.red;
palette[THEME_XTEXT_MARKER_INDEX].green = marker_color.green;
palette[THEME_XTEXT_MARKER_INDEX].blue = marker_color.blue;
palette[THEME_XTEXT_MARKER_INDEX].alpha = marker_color.alpha;
}
if (palette_len > THEME_XTEXT_FG_INDEX)
{
palette[THEME_XTEXT_FG_INDEX].red = style_values.foreground.red;

View File

@@ -427,7 +427,6 @@ enum
GTK3_THEME_COL_ID = 0,
GTK3_THEME_COL_LABEL,
GTK3_THEME_COL_SOURCE,
GTK3_THEME_COL_THUMBNAIL,
GTK3_THEME_COL_COUNT
};
@@ -1403,25 +1402,6 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
g_free (id);
}
static GdkPixbuf *
theme_preferences_load_thumbnail (const char *path)
{
GError *error = NULL;
GdkPixbuf *pixbuf;
if (!path)
return NULL;
pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 48, 48, TRUE, &error);
if (!pixbuf)
{
g_clear_error (&error);
return NULL;
}
return pixbuf;
}
static int
theme_preferences_gtk3_find_system_theme_index (GPtrArray *themes)
{
@@ -1480,22 +1460,15 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
ZoitechatGtk3Theme *theme = g_ptr_array_index (themes, i);
char *label = g_strdup_printf ("%s (%s)", theme->display_name,
theme->source == ZOITECHAT_GTK3_THEME_SOURCE_USER ? _("user") : _("system"));
GdkPixbuf *thumbnail = NULL;
if (theme->thumbnail_path && g_file_test (theme->thumbnail_path, G_FILE_TEST_IS_REGULAR))
thumbnail = theme_preferences_load_thumbnail (theme->thumbnail_path);
gtk_tree_store_append (store, &iter, NULL);
gtk_tree_store_set (store, &iter,
GTK3_THEME_COL_ID, theme->id,
GTK3_THEME_COL_LABEL, label,
GTK3_THEME_COL_SOURCE, theme->source,
GTK3_THEME_COL_THUMBNAIL, thumbnail,
-1);
if (g_strcmp0 (prefs.hex_gui_gtk3_theme, theme->id) == 0)
active = i;
if (thumbnail)
g_object_unref (thumbnail);
g_free (label);
}
if (active < 0 && using_system_default)
@@ -1680,13 +1653,9 @@ theme_preferences_create_page (GtkWindow *parent,
gtk3_store = gtk_tree_store_new (GTK3_THEME_COL_COUNT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INT,
GDK_TYPE_PIXBUF);
G_TYPE_INT);
ui->gtk3_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (gtk3_store));
g_object_unref (gtk3_store);
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ui->gtk3_combo), renderer, FALSE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (ui->gtk3_combo), renderer, "pixbuf", GTK3_THEME_COL_THUMBNAIL);
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ui->gtk3_combo), renderer, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (ui->gtk3_combo), renderer, "text", GTK3_THEME_COL_LABEL);

View File

@@ -326,7 +326,8 @@ theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba)
gboolean
theme_runtime_mode_has_user_colors (gboolean dark_mode)
{
(void) dark_mode;
if (dark_mode)
return dark_user_colors_valid;
return user_colors_valid;
}
@@ -467,7 +468,6 @@ theme_runtime_load (void)
active_palette = light_palette;
dark_mode_active = FALSE;
user_colors_valid = TRUE;
}
static gboolean

View File

@@ -2311,7 +2311,16 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
if (!window)
return FALSE;
if (event->is_hint)
{
gtk_xtext_get_pointer (window, &x, &y, &mask);
}
else
{
x = (int)event->x;
y = (int)event->y;
mask = event->state;
}
if (xtext->moving_separator)
{
@@ -2487,9 +2496,12 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
GtkXText *xtext = GTK_XTEXT (widget);
unsigned char *word;
int old;
int event_x, event_y;
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
event_x = (int)event->x;
event_y = (int)event->y;
if (xtext->moving_separator)
{
@@ -2539,8 +2551,8 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
return FALSE;
}
if (xtext->select_start_x == event->x &&
xtext->select_start_y == event->y &&
if (xtext->select_start_x == event_x &&
xtext->select_start_y == event_y &&
xtext->buffer->last_ent_start)
{
gtk_xtext_unselect (xtext);
@@ -2550,7 +2562,7 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
if (!gtk_xtext_is_selecting (xtext))
{
word = gtk_xtext_get_word (xtext, event->x, event->y, 0, 0, 0, 0);
word = gtk_xtext_get_word (xtext, event_x, event_y, 0, 0, 0, 0);
g_signal_emit (G_OBJECT (xtext), xtext_signals[WORD_CLICK], 0, word ? word : NULL, event);
}
}
@@ -2572,7 +2584,9 @@ gtk_xtext_button_press (GtkWidget * widget, GdkEventButton * event)
if (!window)
return FALSE;
gtk_xtext_get_pointer (window, &x, &y, &mask);
x = (int)event->x;
y = (int)event->y;
mask = event->state;
if (event->button == 3 || event->button == 2) /* right/middle click */
{

View File

@@ -49,14 +49,14 @@ GType gtk_xtext_get_type (void);
#define ATTR_UNDERLINE '\037'
/* these match palette.h */
#define XTEXT_MIRC_COLS 32
#define XTEXT_COLS 37 /* 32 plus 5 for extra stuff below */
#define XTEXT_MARK_FG 32 /* for marking text */
#define XTEXT_MARK_BG 33
#define XTEXT_FG 34
#define XTEXT_BG 35
#define XTEXT_MARKER 36 /* for marker line */
#define XTEXT_MAX_COLOR 41
#define XTEXT_MIRC_COLS 99
#define XTEXT_COLS 104 /* 99 plus 5 for extra stuff below */
#define XTEXT_MARK_FG 99 /* for marking text */
#define XTEXT_MARK_BG 100
#define XTEXT_FG 101
#define XTEXT_BG 102
#define XTEXT_MARKER 103 /* for marker line */
#define XTEXT_MAX_COLOR 98
typedef struct textentry textentry;
/*