From f8cdf240fe25cfb3ad491a960229cada635226fa Mon Sep 17 00:00:00 2001 From: cinamod Date: Fri, 21 May 2004 18:35:56 +0000 Subject: [PATCH] win32 color changes work, xp style changes work --- modules/engines/ms-windows/ChangeLog.old | 1 + modules/engines/ms-windows/msw_theme_main.c | 40 +++++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/modules/engines/ms-windows/ChangeLog.old b/modules/engines/ms-windows/ChangeLog.old index 64eb054e26..edc5a5206a 100755 --- a/modules/engines/ms-windows/ChangeLog.old +++ b/modules/engines/ms-windows/ChangeLog.old @@ -1,6 +1,7 @@ 2004-05-21 Dom Lachowicz * src/Theme/gtk-2.0/gtkrc: Better icon sizes + * src/msw_theme_main.c: Enable XP theme switching 2004-03-20 Raymond Penners diff --git a/modules/engines/ms-windows/msw_theme_main.c b/modules/engines/ms-windows/msw_theme_main.c index 72c523f3d1..1e6ce9003d 100755 --- a/modules/engines/ms-windows/msw_theme_main.c +++ b/modules/engines/ms-windows/msw_theme_main.c @@ -31,6 +31,9 @@ #define WM_THEMECHANGED 0x031A /* winxp only */ #endif +static GModule * this_module = NULL; +static void (*msw_reset_rc_styles) (GtkSettings * settings) = NULL; + /* TODO - look into whether we need to handle these: * * WM_STYLECHANGED @@ -45,21 +48,26 @@ global_filter_func (void *xevent, switch (msg->message) { -#if ENABLE_THEME_CHANGING + /* We need to do something better than this check - if a theme builder has GTK 2.4.x + but the user has 2.2.x, he/she will run into trouble wrt unresolved symbols */ + /* catch theme changes */ case WM_THEMECHANGED: case WM_SYSCOLORCHANGE: - xp_theme_reset (); - msw_style_init (); - /* force all gtkwidgets to redraw */ - gtk_rc_reparse_all_for_settings (gtk_settings_get_default(), TRUE); + if(msw_reset_rc_styles != NULL) { + xp_theme_reset (); + msw_style_init (); + + /* force all gtkwidgets to redraw */ + (*msw_reset_rc_styles) (gtk_settings_get_default()); + } + return GDK_FILTER_REMOVE; -#endif case WM_SETTINGCHANGE: /* catch cursor blink, etc... changes */ - msw_style_setup_system_settings (); + msw_style_setup_system_settings (); return GDK_FILTER_REMOVE; default: @@ -72,6 +80,19 @@ theme_init (GTypeModule *module) { msw_rc_style_register_type (module); msw_style_register_type (module); + + /* this craziness is required because only gtk 2.4.x and later have + gtk_rc_reset_styles(). But we want to be able to run acceptly well + on any GTK 2.x.x platform. */ + if(gtk_check_version(2,4,0) == NULL) { + /* dlopen(this) */ + this_module = g_module_open(NULL, 0); + + if(this_module) + g_module_symbol (this_module, "gtk_rc_reset_styles", + (gpointer *)(&msw_reset_rc_styles)); + } + msw_style_init (); gdk_window_add_filter (NULL, global_filter_func, NULL); } @@ -80,6 +101,11 @@ G_MODULE_EXPORT void theme_exit (void) { gdk_window_remove_filter (NULL, global_filter_func, NULL); + + if(this_module) { + g_module_close(this_module); + this_module = NULL; + } } G_MODULE_EXPORT GtkRcStyle *