4 Commits

Author SHA1 Message Date
d0034cd112 Fixed missing comma in color tooltips 2026-07-07 14:14:36 -06:00
ae6d5ebeef Add mouse over tooltips for each color selection. 2026-07-07 09:08:00 -06:00
deepend-tildeclub
8466e70424 Merge pull request #329 from ZoiteChat/implement-issue-326
Adjust default text-event colors
2026-07-06 23:46:48 -06:00
b85229f1a1 Adjust default text-event colors 2026-07-05 23:54:49 -06:00
8 changed files with 324 additions and 168 deletions

View File

@@ -1695,6 +1695,117 @@ pevent_load (char *filename)
return 0;
}
static gboolean
text_event_uses_color (const char *text, int color)
{
const char *p;
if (!text || color < 0 || color > 31)
return FALSE;
for (p = text; *p; p++)
{
int value;
int digits;
if ((unsigned char) *p == 3)
p++;
else if (*p == '%' && p[1] == 'C')
p += 2;
else
continue;
if (!g_ascii_isdigit (*p))
{
p--;
continue;
}
value = *p - '0';
digits = 1;
if (g_ascii_isdigit (p[1]))
{
value = value * 10 + p[1] - '0';
digits = 2;
}
if (value == color)
return TRUE;
p += digits - 1;
if (*p == ',' && g_ascii_isdigit (p[1]))
{
p++;
value = *p - '0';
if (g_ascii_isdigit (p[1]))
{
value = value * 10 + p[1] - '0';
p++;
}
if (value == color)
return TRUE;
}
}
return FALSE;
}
char *
text_color_event_list (int color)
{
GString *events;
GString *tip;
int count = 0;
int line_len = 0;
int i;
events = g_string_new (NULL);
for (i = 0; i < NUM_XP; i++)
{
const char *name;
const char *text = pntevts_text[i] ? pntevts_text[i] : te[i].def;
int name_len;
if (!text_event_uses_color (text, color))
continue;
name = _(te[i].name);
name_len = strlen (name);
if (count)
{
if (line_len + name_len + 2 > 76)
{
g_string_append (events, ",\n");
line_len = 0;
}
else
{
g_string_append (events, ", ");
line_len += 2;
}
}
g_string_append (events, name);
line_len += name_len;
count++;
}
if (!count)
{
g_string_free (events, TRUE);
return g_strdup (_("No text events use this color."));
}
tip = g_string_new (NULL);
g_string_append_printf (tip, _("Text events using this color (%d):"), count);
g_string_append_c (tip, '\n');
g_string_append (tip, events->str);
g_string_free (events, TRUE);
return g_string_free (tip, FALSE);
}
static void
pevent_check_all_loaded (void)
{

View File

@@ -53,6 +53,7 @@ int pevt_build_string (const char *input, char **output, int *max_arg);
int pevent_load (char *filename);
void pevent_make_pntevts (void);
int text_color_of (char *name);
char *text_color_event_list (int color);
void text_emit (int index, session *sess, char *a, char *b, char *c, char *d,
time_t timestamp);
int text_emit_by_name (char *name, session *sess, time_t timestamp,

File diff suppressed because it is too large Load Diff

View File

@@ -3388,10 +3388,19 @@ mg_topicbar_update_height (GtkWidget *topic)
if (parent && GTK_IS_SCROLLED_WINDOW (parent))
{
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (parent);
int max_height = gtk_scrolled_window_get_max_content_height (scrolled);
if (max_height != -1 && target_height > max_height)
{
gtk_scrolled_window_set_max_content_height (scrolled, target_height);
gtk_scrolled_window_set_min_content_height (scrolled, target_height);
}
else
{
gtk_scrolled_window_set_min_content_height (scrolled, target_height);
gtk_scrolled_window_set_max_content_height (scrolled, target_height);
}
gtk_widget_set_size_request (parent, -1, target_height);
}
}

View File

@@ -50,7 +50,7 @@ zoitechat_gtk_deps = [
gtk_dep = dependency('gtk+-3.0', version: '>= 3.22')
zoitechat_theme_deps = [gtk_dep]
zoitechat_theme_deps = [gtk_dep, zoitechat_common_dep]
if host_machine.system() != 'windows'
appindicator_opt = get_option('appindicator')

View File

@@ -70,6 +70,13 @@ load_text_events (void)
{
}
char *
text_color_event_list (int color)
{
(void)color;
return g_strdup ("No text events use this color.");
}
gboolean
theme_get_color (ThemeSemanticToken token, GdkRGBA *color)
{

View File

@@ -52,14 +52,13 @@ static const guint8 theme_default_99_mirc_colors[THEME_XTEXT_MIRC_COLS][3] = {
};
static void
theme_access_apply_default_99_palette (XTextColor *palette, size_t palette_len, gboolean apply_base)
theme_access_apply_default_99_palette (XTextColor *palette, size_t palette_len)
{
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++)
for (i = 32; 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;
@@ -148,11 +147,10 @@ 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 >= THEME_XTEXT_MIRC_COLS)
return FALSE;
if (!has_user_colors || mirc_index >= 32)
if (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;
@@ -173,11 +171,10 @@ 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 >= THEME_XTEXT_MIRC_COLS)
return FALSE;
if (!has_user_colors || mirc_index >= 32)
if (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);
@@ -227,7 +224,6 @@ 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)
@@ -235,9 +231,8 @@ theme_get_xtext_colors_for_widget (GtkWidget *widget, XTextColor *palette, size_
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 ());
if (palette_len >= THEME_XTEXT_MIRC_COLS)
theme_access_apply_default_99_palette (palette, palette_len, !has_user_colors);
theme_access_apply_default_99_palette (palette, palette_len);
if (palette_len > THEME_XTEXT_MARK_FG_INDEX)
{
palette[THEME_XTEXT_MARK_FG_INDEX].red = style_values.selection_foreground.red;

View File

@@ -38,6 +38,7 @@
#include "theme-runtime.h"
extern void load_text_events (void);
extern char *text_color_event_list (int color);
typedef struct
{
@@ -268,6 +269,15 @@ theme_preferences_manager_ui_free (gpointer data)
g_free (ui);
}
static char *
theme_preferences_color_events_tooltip (ThemeSemanticToken token)
{
if (token < THEME_TOKEN_MIRC_0 || token > THEME_TOKEN_MIRC_31)
return NULL;
return text_color_event_list (token - THEME_TOKEN_MIRC_0);
}
static void
theme_preferences_manager_update_preview (theme_color_manager_ui *ui)
{
@@ -884,6 +894,20 @@ theme_preferences_create_color_manager_dialog (GtkWindow *parent, gboolean *colo
if (theme_preferences_staged_get_color (token, &rgba))
theme_preferences_manager_row_apply (row, &rgba);
{
char *tip = theme_preferences_color_events_tooltip (token);
if (tip)
{
gtk_widget_set_tooltip_text (list_row, tip);
gtk_widget_set_tooltip_text (hbox, tip);
gtk_widget_set_tooltip_text (name, tip);
gtk_widget_set_tooltip_text (preview, tip);
gtk_widget_set_tooltip_text (button, tip);
gtk_widget_set_tooltip_text (entry, tip);
g_free (tip);
}
}
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (theme_preferences_manager_pick_cb), row);
g_object_set_data (G_OBJECT (button), "zoitechat-theme-color-manager-ui", ui);
@@ -1198,6 +1222,15 @@ theme_preferences_create_color_button (GtkWidget *table,
g_object_set_data (G_OBJECT (but), "zoitechat-color-box", box);
g_object_set_data (G_OBJECT (but), "zoitechat-theme-token", GINT_TO_POINTER (token));
g_object_set_data (G_OBJECT (but), "zoitechat-theme-color-change", color_change_flag);
{
char *tip = theme_preferences_color_events_tooltip (token);
if (tip)
{
gtk_widget_set_tooltip_text (but, tip);
gtk_widget_set_tooltip_text (box, tip);
g_free (tip);
}
}
gtk_grid_attach (GTK_GRID (table), but, col, row, 1, 1);
g_signal_connect (G_OBJECT (but), "clicked", G_CALLBACK (theme_preferences_color_cb), parent);
if (theme_preferences_staged_get_color (token, &color))