]> Pileus Git - ~andy/gtk/blob - modules/engines/ms-windows/msw_theme_main.c
Make the ms-windows theme engine build with mingw.
[~andy/gtk] / modules / engines / ms-windows / msw_theme_main.c
1 /* MS-Windows Engine (aka GTK-Wimp)\r
2  *\r
3  * Copyright (C) 2003, 2004 Raymond Penners <raymond@dotsphinx.com>\r
4  * Includes code adapted from redmond95 by Owen Taylor, and\r
5  * gtk-nativewin by Evan Martin\r
6  *\r
7  * This library is free software; you can redistribute it and/or\r
8  * modify it under the terms of the GNU Library General Public\r
9  * License as published by the Free Software Foundation; either\r
10  * version 2 of the License, or (at your option) any later version.\r
11  *\r
12  * This library is distributed in the hope that it will be useful,\r
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
15  * Library General Public License for more details.\r
16  *\r
17  * You should have received a copy of the GNU Library General Public\r
18  * License along with this library; if not, write to the\r
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
20  * Boston, MA 02111-1307, USA.\r
21  */\r
22 \r
23 #include <windows.h>\r
24 \r
25 #include <gmodule.h>\r
26 \r
27 #include "gtk/gtk.h"\r
28 \r
29 #include "msw_style.h"\r
30 #include "msw_rc_style.h"\r
31 \r
32 #ifndef WM_THEMECHANGED\r
33 #define WM_THEMECHANGED 0x031A /* winxp only */\r
34 #endif\r
35 \r
36 static GModule * this_module = NULL;\r
37 static void (*msw_rc_reset_styles) (GtkSettings * settings) = NULL;\r
38 \r
39 static GdkFilterReturn\r
40 global_filter_func (void     *xevent,\r
41                     GdkEvent *event,\r
42                     gpointer  data)\r
43 {\r
44   MSG *msg = (MSG *) xevent;\r
45 \r
46   switch (msg->message)\r
47     {\r
48       /* catch theme changes */\r
49     case WM_THEMECHANGED:\r
50     case WM_SYSCOLORCHANGE:\r
51 \r
52       if(msw_rc_reset_styles != NULL) {\r
53                 xp_theme_reset ();\r
54                 msw_style_init ();\r
55 \r
56                 /* force all gtkwidgets to redraw */\r
57                 (*msw_rc_reset_styles) (gtk_settings_get_default());\r
58           }\r
59 \r
60       return GDK_FILTER_REMOVE;\r
61 \r
62     case WM_SETTINGCHANGE:\r
63       /* catch cursor blink, etc... changes */\r
64       msw_style_setup_system_settings ();\r
65       return GDK_FILTER_REMOVE;\r
66 \r
67     default:\r
68       return GDK_FILTER_CONTINUE;\r
69     }\r
70 }\r
71 \r
72 G_MODULE_EXPORT void\r
73 theme_init (GTypeModule *module)\r
74 {\r
75   msw_rc_style_register_type (module);\r
76   msw_style_register_type (module);\r
77 \r
78   /* this craziness is required because only gtk 2.4.x and later have\r
79      gtk_rc_reset_styles(). But we want to be able to run acceptly well\r
80      on any GTK 2.x.x platform. */\r
81   if(gtk_check_version(2,4,0) == NULL) {\r
82     this_module = g_module_open(NULL, 0);\r
83 \r
84     if(this_module)\r
85       g_module_symbol (this_module, "gtk_rc_reset_styles",\r
86                        (gpointer *)(&msw_rc_reset_styles));\r
87   }\r
88 \r
89   msw_style_init ();\r
90   gdk_window_add_filter (NULL, global_filter_func, NULL);\r
91 }\r
92 \r
93 G_MODULE_EXPORT void\r
94 theme_exit (void)\r
95 {\r
96   gdk_window_remove_filter (NULL, global_filter_func, NULL);\r
97 \r
98   if(this_module) {\r
99     g_module_close(this_module);\r
100     this_module = NULL;\r
101   }\r
102 }\r
103 \r
104 G_MODULE_EXPORT GtkRcStyle *\r
105 theme_create_rc_style (void)\r
106 {\r
107   return GTK_RC_STYLE (g_object_new (MSW_TYPE_RC_STYLE, NULL));\r
108 }\r
109 \r
110 /* The following function will be called by GTK+ when the module\r
111  * is loaded and checks to see if we are compatible with the\r
112  * version of GTK+ that loads us.\r
113  */\r
114 G_MODULE_EXPORT const gchar*\r
115 g_module_check_init (GModule *module)\r
116 {\r
117   return gtk_check_version (2,0,0);\r
118 }\r