mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-07-07 04:29:24 +00:00
Theme: Color mapping improvements/no theme defaults
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3388,10 +3388,19 @@ mg_topicbar_update_height (GtkWidget *topic)
|
|||||||
|
|
||||||
if (parent && GTK_IS_SCROLLED_WINDOW (parent))
|
if (parent && GTK_IS_SCROLLED_WINDOW (parent))
|
||||||
{
|
{
|
||||||
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), -1);
|
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW (parent);
|
||||||
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), -1);
|
int max_height = gtk_scrolled_window_get_max_content_height (scrolled);
|
||||||
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);
|
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);
|
gtk_widget_set_size_request (parent, -1, target_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,6 +267,21 @@ test_access_xtext_palette_forwarding (void)
|
|||||||
g_assert_cmpuint (palette[3].blue, ==, 6);
|
g_assert_cmpuint (palette[3].blue, ==, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_access_xtext_palette_default_99_preserves_base (void)
|
||||||
|
{
|
||||||
|
XTextColor palette[99] = { 0 };
|
||||||
|
|
||||||
|
reset_stubs ();
|
||||||
|
theme_get_xtext_colors (palette, G_N_ELEMENTS (palette));
|
||||||
|
g_assert_cmpint (stub_runtime_xtext_calls, ==, 1);
|
||||||
|
g_assert_cmpfloat_with_epsilon (palette[0].red, 1.0, 0.0001);
|
||||||
|
g_assert_cmpfloat_with_epsilon (palette[31].blue, 34.0, 0.0001);
|
||||||
|
g_assert_cmpfloat_with_epsilon (palette[32].red, 0.0, 0.0001);
|
||||||
|
g_assert_cmpfloat_with_epsilon (palette[32].green, 0x74 / 255.0, 0.0001);
|
||||||
|
g_assert_cmpfloat_with_epsilon (palette[32].blue, 0.0, 0.0001);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_access_widget_style_forwarding (void)
|
test_access_widget_style_forwarding (void)
|
||||||
@@ -361,6 +376,8 @@ main (int argc, char **argv)
|
|||||||
g_test_add_func ("/theme/access/semantic_token_routes_directly", test_access_semantic_token_routes_directly);
|
g_test_add_func ("/theme/access/semantic_token_routes_directly", test_access_semantic_token_routes_directly);
|
||||||
g_test_add_func ("/theme/access/token_routes_without_legacy_accessor", test_access_token_routes_without_legacy_accessor);
|
g_test_add_func ("/theme/access/token_routes_without_legacy_accessor", test_access_token_routes_without_legacy_accessor);
|
||||||
g_test_add_func ("/theme/access/xtext_palette_forwarding", test_access_xtext_palette_forwarding);
|
g_test_add_func ("/theme/access/xtext_palette_forwarding", test_access_xtext_palette_forwarding);
|
||||||
|
g_test_add_func ("/theme/access/xtext_palette_default_99_preserves_base",
|
||||||
|
test_access_xtext_palette_default_99_preserves_base);
|
||||||
g_test_add_func ("/theme/access/xtext_palette_widget_mapping_when_gtk3_active",
|
g_test_add_func ("/theme/access/xtext_palette_widget_mapping_when_gtk3_active",
|
||||||
test_access_xtext_palette_widget_mapping_when_gtk3_active);
|
test_access_xtext_palette_widget_mapping_when_gtk3_active);
|
||||||
g_test_add_func ("/theme/access/widget_style_forwarding", test_access_widget_style_forwarding);
|
g_test_add_func ("/theme/access/widget_style_forwarding", test_access_widget_style_forwarding);
|
||||||
|
|||||||
@@ -52,14 +52,13 @@ static const guint8 theme_default_99_mirc_colors[THEME_XTEXT_MIRC_COLS][3] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
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 i;
|
||||||
size_t start = apply_base ? 0 : 32;
|
|
||||||
|
|
||||||
if (palette_len == 0)
|
if (palette_len == 0)
|
||||||
return;
|
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].red = theme_default_99_mirc_colors[i][0] / 255.0;
|
||||||
palette[i].green = theme_default_99_mirc_colors[i][1] / 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)
|
theme_get_mirc_color (unsigned int mirc_index, GdkRGBA *out_rgba)
|
||||||
{
|
{
|
||||||
ThemeSemanticToken token = (ThemeSemanticToken) (THEME_TOKEN_MIRC_0 + (int) mirc_index);
|
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)
|
if (mirc_index >= THEME_XTEXT_MIRC_COLS)
|
||||||
return FALSE;
|
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->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->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)
|
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);
|
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)
|
if (mirc_index >= THEME_XTEXT_MIRC_COLS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!has_user_colors || mirc_index >= 32)
|
if (mirc_index >= 32)
|
||||||
{
|
{
|
||||||
*red = (guint16) (theme_default_99_mirc_colors[mirc_index][0] * 257);
|
*red = (guint16) (theme_default_99_mirc_colors[mirc_index][0] * 257);
|
||||||
*green = (guint16) (theme_default_99_mirc_colors[mirc_index][1] * 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)
|
theme_get_xtext_colors_for_widget (GtkWidget *widget, XTextColor *palette, size_t palette_len)
|
||||||
{
|
{
|
||||||
ThemeWidgetStyleValues style_values;
|
ThemeWidgetStyleValues style_values;
|
||||||
gboolean has_user_colors;
|
|
||||||
GdkRGBA marker_color;
|
GdkRGBA marker_color;
|
||||||
|
|
||||||
if (!palette)
|
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_get_widget_style_values_for_widget (widget, &style_values);
|
||||||
theme_runtime_get_xtext_colors (palette, palette_len);
|
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)
|
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)
|
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].red = style_values.selection_foreground.red;
|
||||||
|
|||||||
Reference in New Issue
Block a user