1 Commits

Author SHA1 Message Date
ab54d9f782 Bump to 2.18.0~pre5 + changelog/AppStream 2026-03-22 11:45:56 -06:00
7 changed files with 86 additions and 65 deletions

View File

@@ -4206,7 +4206,7 @@ mg_create_menu (session_gui *gui, GtkWidget *table, int away_state)
gui->menu_item);
gtk_widget_set_hexpand (gui->menu, TRUE);
gtk_widget_set_vexpand (gui->menu, FALSE);
gtk_widget_set_halign (gui->menu, GTK_ALIGN_START);
gtk_widget_set_halign (gui->menu, GTK_ALIGN_FILL);
gtk_widget_set_valign (gui->menu, GTK_ALIGN_FILL);
gtk_grid_attach (GTK_GRID (table), gui->menu, 0, 0, 3, 1);
}

View File

@@ -102,12 +102,6 @@ theme_manager_save_preferences (void)
return TRUE;
}
void
theme_manager_dispatch_changed (ThemeChangedReason reasons)
{
(void)reasons;
}
ThemePaletteBehavior
theme_manager_get_userlist_palette_behavior (const PangoFontDescription *font_desc)
{

View File

@@ -26,29 +26,16 @@
#include "theme-runtime.h"
#include "theme-gtk3.h"
#include "../maingui.h"
#ifdef G_OS_WIN32
#include <gtk/gtk.h>
#if defined(__GNUC__) || defined(__clang__)
extern char *theme_css_build_toplevel_classes (void) __attribute__ ((weak));
#else
extern char *theme_css_build_toplevel_classes (void);
#endif
static char *
theme_application_build_toplevel_css (void)
{
if (theme_css_build_toplevel_classes)
return theme_css_build_toplevel_classes ();
return g_strdup ("");
}
static void
theme_application_apply_toplevel_theme (gboolean dark)
theme_application_apply_windows_theme (gboolean dark)
{
GtkSettings *settings = gtk_settings_get_default ();
static GtkCssProvider *theme_provider = NULL;
static gboolean theme_provider_installed = FALSE;
static GtkCssProvider *win_theme_provider = NULL;
static gboolean win_theme_provider_installed = FALSE;
GdkScreen *screen;
gboolean prefer_dark = dark;
char *css;
@@ -69,21 +56,33 @@ theme_application_apply_toplevel_theme (gboolean dark)
if (!screen)
return;
if (!theme_provider)
theme_provider = gtk_css_provider_new ();
if (theme_gtk3_is_active ())
{
if (win_theme_provider_installed && win_theme_provider)
{
gtk_style_context_remove_provider_for_screen (screen,
GTK_STYLE_PROVIDER (win_theme_provider));
win_theme_provider_installed = FALSE;
}
return;
}
css = theme_application_build_toplevel_css ();
gtk_css_provider_load_from_data (theme_provider, css, -1, NULL);
if (!win_theme_provider)
win_theme_provider = gtk_css_provider_new ();
css = theme_css_build_toplevel_classes ();
gtk_css_provider_load_from_data (win_theme_provider, css, -1, NULL);
g_free (css);
if (!theme_provider_installed)
if (!win_theme_provider_installed)
{
gtk_style_context_add_provider_for_screen (screen,
GTK_STYLE_PROVIDER (theme_provider),
GTK_STYLE_PROVIDER (win_theme_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
theme_provider_installed = TRUE;
win_theme_provider_installed = TRUE;
}
}
#endif
gboolean
theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
@@ -92,7 +91,10 @@ theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
theme_runtime_load ();
dark = theme_runtime_apply_mode (mode, palette_changed);
theme_application_apply_toplevel_theme (dark);
#ifdef G_OS_WIN32
theme_application_apply_windows_theme (dark);
#endif
theme_application_reload_input_style ();

View File

@@ -361,22 +361,20 @@ theme_css_build_toplevel_classes (void)
"color: #f0f0f0;"
"border-color: #202020;"
"}"
"window.%s menubar, window.%s menubar:backdrop, window.%s menubar box, window.%s menubar box:backdrop, window.%s menuitem, window.%s menuitem:backdrop {"
"background-color: @theme_bg_color;"
"background-image: none;"
"color: @theme_fg_color;"
"border-color: @theme_bg_color;"
"window.%s menubar, window.%s menubar:backdrop, window.%s menuitem, window.%s menuitem:backdrop {"
"background-color: #202020;"
"color: #f0f0f0;"
"border-color: #202020;"
"}"
"window.%s, window.%s:backdrop, .%s {"
"background-color: #f6f6f6;"
"color: #101010;"
"border-color: #f6f6f6;"
"}"
"window.%s menubar, window.%s menubar:backdrop, window.%s menubar box, window.%s menubar box:backdrop, window.%s menuitem, window.%s menuitem:backdrop {"
"background-color: @theme_bg_color;"
"background-image: none;"
"color: @theme_fg_color;"
"border-color: @theme_bg_color;"
"window.%s menubar, window.%s menubar:backdrop, window.%s menuitem, window.%s menuitem:backdrop {"
"background-color: #f6f6f6;"
"color: #101010;"
"border-color: #f6f6f6;"
"}",
theme_css_selector_dark_class,
theme_css_selector_dark_class,
@@ -385,10 +383,6 @@ theme_css_build_toplevel_classes (void)
theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_light_class,
theme_css_selector_light_class,
theme_css_selector_light_class,
theme_css_selector_light_class,
theme_css_selector_light_class,

View File

@@ -216,6 +216,8 @@ theme_manager_queue_auto_refresh (GtkSettings *settings, GParamSpec *pspec, gpoi
void
theme_manager_init (void)
{
GtkSettings *settings;
if (!theme_manager_listeners)
theme_manager_listeners = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
theme_listener_free);
@@ -223,10 +225,21 @@ theme_manager_init (void)
if (!theme_manager_setup_listener_id)
theme_manager_setup_listener_id = theme_listener_register ("setup.apply", theme_manager_setup_apply_listener, NULL);
fe_set_auto_dark_mode_state (FALSE);
settings = gtk_settings_get_default ();
if (settings)
fe_set_auto_dark_mode_state (theme_policy_system_prefers_dark ());
theme_application_apply_mode (prefs.hex_gui_dark_mode, NULL);
theme_gtk3_init ();
zoitechat_set_theme_post_apply_callback (theme_manager_handle_theme_applied);
if (settings)
{
g_signal_connect (settings, "notify::gtk-application-prefer-dark-theme",
G_CALLBACK (theme_manager_queue_auto_refresh), NULL);
g_signal_connect (settings, "notify::gtk-theme-name",
G_CALLBACK (theme_manager_queue_auto_refresh), NULL);
}
}
gboolean
@@ -481,6 +494,7 @@ theme_manager_apply_wayland_kde_csd (GtkWidget *window)
static void
theme_manager_apply_platform_window_theme (GtkWidget *window)
{
#ifdef G_OS_WIN32
GtkStyleContext *context;
gboolean dark;
@@ -502,7 +516,6 @@ theme_manager_apply_platform_window_theme (GtkWidget *window)
gtk_style_context_remove_class (context, "zoitechat-light");
gtk_style_context_add_class (context, dark ? "zoitechat-dark" : "zoitechat-light");
}
#ifdef G_OS_WIN32
fe_win32_apply_native_titlebar (window, dark);
#else
theme_manager_apply_wayland_kde_csd (window);

View File

@@ -27,7 +27,38 @@
gboolean
theme_policy_system_prefers_dark (void)
{
return FALSE;
GtkSettings *settings = gtk_settings_get_default ();
gboolean prefer_dark = FALSE;
char *theme_name = NULL;
#ifdef G_OS_WIN32
gboolean have_win_pref = FALSE;
if (fe_win32_high_contrast_is_enabled ())
return FALSE;
have_win_pref = fe_win32_try_get_system_dark (&prefer_dark);
if (!have_win_pref)
#endif
if (settings && g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
"gtk-application-prefer-dark-theme"))
{
g_object_get (settings, "gtk-application-prefer-dark-theme", &prefer_dark, NULL);
}
if (settings && !prefer_dark)
{
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
if (theme_name)
{
char *lower = g_ascii_strdown (theme_name, -1);
if (g_str_has_suffix (lower, "-dark") || g_strrstr (lower, "dark"))
prefer_dark = TRUE;
g_free (lower);
g_free (theme_name);
}
}
return prefer_dark;
}
gboolean

View File

@@ -1350,19 +1350,6 @@ theme_preferences_gtk3_sync_remove_state (theme_preferences_ui *ui)
gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER);
}
static gboolean
theme_preferences_gtk3_apply_and_refresh (GError **error)
{
if (!theme_gtk3_apply_current (error))
return FALSE;
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
THEME_CHANGED_REASON_PALETTE |
THEME_CHANGED_REASON_WIDGET_STYLE |
THEME_CHANGED_REASON_USERLIST |
THEME_CHANGED_REASON_MODE);
return TRUE;
}
static void
theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
{
@@ -1393,7 +1380,7 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant;
}
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (&error))
if (selection_changed && !theme_gtk3_apply_current (&error))
{
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
error ? error->message : _("Failed to apply GTK3 theme."));
@@ -1570,7 +1557,7 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
g_free (final_id);
}
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (&error))
if (should_apply && !theme_gtk3_apply_current (&error))
{
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
error ? error->message : _("Failed to apply GTK3 theme."));