1 /* MS-Windows Engine (aka GTK-Wimp)
3 * Copyright (C) 2003, 2004 Raymond Penners <raymond@dotsphinx.com>
4 * Includes code adapted from redmond95 by Owen Taylor, and
5 * gtk-nativewin by Evan Martin
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
27 #include "msw_style.h"
28 #include "msw_rc_style.h"
31 #ifndef WM_THEMECHANGED
32 #define WM_THEMECHANGED 0x031A /* winxp only */
35 static GModule *this_module = NULL;
36 static void (*msw_rc_reset_styles) (GtkSettings *settings) = NULL;
37 static GdkWindow *hidden_msg_window = NULL;
40 create_hidden_msg_window (void)
42 GdkWindowAttr attributes;
47 attributes.width = 10;
48 attributes.height = 10;
49 attributes.window_type = GDK_WINDOW_TEMP;
50 attributes.wclass = GDK_INPUT_ONLY;
51 attributes.override_redirect = TRUE;
52 attributes.event_mask = 0;
54 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
56 return gdk_window_new (gdk_get_default_root_window (),
57 &attributes, attributes_mask);
60 static GdkFilterReturn
61 global_filter_func (void *xevent, GdkEvent *event, gpointer data)
63 MSG *msg = (MSG *) xevent;
67 /* catch theme changes */
69 case WM_SYSCOLORCHANGE:
71 if (msw_rc_reset_styles != NULL)
76 /* force all gtkwidgets to redraw */
77 (*msw_rc_reset_styles) (gtk_settings_get_default ());
80 return GDK_FILTER_REMOVE;
82 case WM_SETTINGCHANGE:
83 /* catch cursor blink, etc... changes */
84 msw_style_setup_system_settings ();
85 return GDK_FILTER_REMOVE;
88 return GDK_FILTER_CONTINUE;
93 theme_init (GTypeModule * module)
95 msw_rc_style_register_type (module);
96 msw_style_register_type (module);
98 /* this craziness is required because only gtk 2.4.x and later have
99 gtk_rc_reset_styles(). But we want to be able to run acceptly well on
100 any GTK 2.x.x platform. */
101 if (gtk_check_version (2, 4, 0) == NULL)
103 this_module = g_module_open (NULL, 0);
106 g_module_symbol (this_module, "gtk_rc_reset_styles",
107 (gpointer *) (&msw_rc_reset_styles));
111 hidden_msg_window = create_hidden_msg_window ();
112 gdk_window_add_filter (hidden_msg_window, global_filter_func, NULL);
118 gdk_window_remove_filter (hidden_msg_window, global_filter_func, NULL);
119 gdk_window_destroy (hidden_msg_window);
120 hidden_msg_window = NULL;
121 msw_style_finalize ();
125 g_module_close (this_module);
130 G_MODULE_EXPORT GtkRcStyle *
131 theme_create_rc_style (void)
133 return g_object_new (MSW_TYPE_RC_STYLE, NULL);
136 /* The following function will be called by GTK+ when the module
137 * is loaded and checks to see if we are compatible with the
138 * version of GTK+ that loads us.
140 G_MODULE_EXPORT const gchar *
141 g_module_check_init (GModule *module)
143 return gtk_check_version (2, 0, 0);