QGtkStyle: use gtk_widget_get_style()
[profile/ivi/qtbase.git] / src / widgets / styles / qgtkstyle_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QGTKSTYLE_P_H
43 #define QGTKSTYLE_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include <QtCore/qglobal.h>
57 #if !defined(QT_NO_STYLE_GTK)
58
59 #include <QtCore/qstring.h>
60 #include <QtCore/qstringbuilder.h>
61 #include <QtCore/qcoreapplication.h>
62
63 #include <QtWidgets/QFileDialog>
64
65 #include <QtWidgets/QGtkStyle>
66 #include <private/qwindowsstyle_p.h>
67
68 #undef signals // Collides with GTK symbols
69 #include <gtk/gtk.h>
70
71 typedef unsigned long XID;
72
73 #undef GTK_OBJECT_FLAGS
74 #define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
75 #define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
76
77 #define QLS(x) QLatin1String(x)
78
79 QT_BEGIN_NAMESPACE
80
81 class QHashableLatin1Literal
82 {
83 public:
84     int size() const { return m_size; }
85     const char *data() const { return m_data; }
86
87 #ifdef __SUNPRO_CC
88         QHashableLatin1Literal(const char* str)
89         : m_size(strlen(str)), m_data(str) {}
90 #else
91     template <int N>
92         QHashableLatin1Literal(const char (&str)[N])
93         : m_size(N - 1), m_data(str) {}
94 #endif
95
96     QHashableLatin1Literal(const QHashableLatin1Literal &other)
97         : m_size(other.m_size), m_data(other.m_data)
98     {}
99
100     QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
101     {
102         if (this == &other)
103             return *this;
104         *const_cast<int *>(&m_size) = other.m_size;
105         *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
106         return *this;
107     }
108
109     QString toString() const { return QString::fromLatin1(m_data, m_size); }
110
111     static QHashableLatin1Literal fromData(const char *str)
112     {
113         return QHashableLatin1Literal(str, qstrlen(str));
114     }
115
116 private:
117     QHashableLatin1Literal(const char *str, int length)
118         : m_size(length), m_data(str)
119     {}
120
121     const int m_size;
122     const char *m_data;
123 };
124
125 bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
126 inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
127 uint qHash(const QHashableLatin1Literal &key);
128
129 QT_END_NAMESPACE
130
131 class GConf;
132 class GConfClient;
133 typedef struct _XDisplay Display;
134
135 typedef GConfClient* (*Ptr_gconf_client_get_default)();
136 typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
137 typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **);
138
139 typedef void (*Ptr_gtk_init)(int *, char ***);
140 typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType);
141 typedef GtkStyle* (*Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *);
142 typedef void (*Ptr_gtk_widget_destroy) (GtkWidget *);
143 typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
144 typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
145 typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
146 typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
147 typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
148 typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
149 typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
150 typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
151 typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
152 typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
153 typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
154 typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
155 typedef GtkWidget* (*Ptr_gtk_button_new)(void);
156 typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
157 typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
158 typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
159 typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
160 typedef GtkWidget* (*Ptr_gtk_notebook_new)(void);
161 typedef GtkWidget* (*Ptr_gtk_progress_bar_new)(void);
162 typedef GtkWidget* (*Ptr_gtk_hscale_new)(GtkAdjustment*);
163 typedef GtkWidget* (*Ptr_gtk_vscale_new)(GtkAdjustment*);
164 typedef GtkWidget* (*Ptr_gtk_hscrollbar_new)(GtkAdjustment*);
165 typedef GtkWidget* (*Ptr_gtk_vscrollbar_new)(GtkAdjustment*);
166 typedef GtkWidget* (*Ptr_gtk_scrolled_window_new)(GtkAdjustment*, GtkAdjustment*);
167 typedef gchar* (*Ptr_gtk_check_version)(guint, guint, guint);
168 typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
169 typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
170 typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
171 typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
172 typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
173 typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
174 typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
175 typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
176 typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
177 typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
178 typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
179 typedef void (*Ptr_gtk_progress_configure)(GtkProgress *, double, double, double);
180 typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
181 typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
182 typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
183 typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
184 typedef GtkStyle* (*Ptr_gtk_widget_get_style)(GtkWidget *);
185 typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
186 typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
187 typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
188 typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
189 typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
190 typedef void  (*Ptr_gtk_paint_check) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
191 typedef void  (*Ptr_gtk_paint_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
192 typedef void  (*Ptr_gtk_paint_box_gap) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint gap_x, gint gap_width);
193 typedef void  (*Ptr_gtk_paint_resize_grip) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
194 typedef void  (*Ptr_gtk_paint_focus) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
195 typedef void  (*Ptr_gtk_paint_shadow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
196 typedef void  (*Ptr_gtk_paint_slider) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
197 typedef void  (*Ptr_gtk_paint_expander) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
198 typedef void  (*Ptr_gtk_paint_handle) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
199 typedef void  (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
200 typedef void  (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
201 typedef void  (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
202 typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
203 typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
204 typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
205 typedef void   (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
206 typedef void   (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
207 typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
208 typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
209 typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
210 typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
211 typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
212 typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
213
214 typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
215 typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
216 typedef GtkType (*Ptr_gtk_container_get_type) (void);
217 typedef GtkType (*Ptr_gtk_window_get_type) (void);
218 typedef GtkType (*Ptr_gtk_widget_get_type) (void);
219 typedef GtkWidget* (*Ptr_gtk_widget_get_parent) (GtkWidget *);
220 typedef gboolean (*Ptr_gtk_widget_is_toplevel) (GtkWidget *);
221 typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
222 typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
223 typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
224 typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
225 typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
226 typedef gboolean (*Ptr_gtk_file_chooser_set_current_folder)(GtkFileChooser *, const gchar *);
227 typedef GtkFileFilter* (*Ptr_gtk_file_filter_new)(void);
228 typedef void (*Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *);
229 typedef void (*Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern);
230 typedef void (*Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
231 typedef void (*Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
232 typedef GtkFileFilter* (*Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser);
233 typedef gchar*  (*Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
234 typedef GSList* (*Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
235 typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
236                                                 GtkWindow *parent,
237                                                 GtkFileChooserAction action,
238                                                 const gchar *first_button_text,
239                                                 ...);
240 typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
241 typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
242 typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
243 typedef void (*Ptr_gtk_border_free)(GtkBorder *);
244 typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
245 typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
246
247 typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
248 typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
249 typedef void (*Ptr_gdk_color_free) (const GdkColor *);
250 typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
251 typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *dest, GdkDrawable *src,
252                                                          GdkColormap *cmap, int src_x,
253                                                          int src_y, int dest_x, int dest_y,
254                                                          int width, int height);
255 typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *drawable, gint width, gint height, gint depth);
256 typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
257                                          int bits_per_sample, int width, int height);
258 typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *drawable, GdkGC *gc,
259                                         gboolean filled, gint x, gint y, gint width, gint height);
260 typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
261 typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
262 typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
263 typedef XID  (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
264 typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
265
266
267 QT_BEGIN_NAMESPACE
268
269 #ifndef QT_NO_FILEDIALOG
270 typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
271                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
272 typedef QString (*_qt_filedialog_open_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
273                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
274 typedef QString (*_qt_filedialog_save_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
275                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
276 typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
277                                                           QFileDialog::Options options);
278
279 extern Q_WIDGETS_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
280 extern Q_WIDGETS_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
281 extern Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
282 extern Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
283 #endif //!QT_NO_FILEDIALOG
284
285 class QGtkStylePrivate;
286
287 class QGtkStyleFilter : public QObject
288 {
289 public:
290     QGtkStyleFilter(QGtkStylePrivate* sp)
291         : stylePrivate(sp)
292     {}
293 private:
294     QGtkStylePrivate* stylePrivate;
295     bool eventFilter(QObject *obj, QEvent *e);
296 };
297
298 typedef enum {
299   GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
300   GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
301   GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
302   GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
303 } GnomeIconLookupFlags;
304
305 typedef enum {
306   GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
307   GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
308 } GnomeIconLookupResultFlags;
309
310 struct GnomeThumbnailFactory;
311 typedef gboolean (*Ptr_gnome_vfs_init) (void);
312 typedef char* (*Ptr_gnome_icon_lookup_sync)  (
313         GtkIconTheme *icon_theme,
314         GnomeThumbnailFactory *,
315         const char *file_uri,
316         const char *custom_icon,
317         GnomeIconLookupFlags flags,
318         GnomeIconLookupResultFlags *result);
319
320 class QGtkStylePrivate : public QWindowsStylePrivate
321 {
322     Q_DECLARE_PUBLIC(QGtkStyle)
323 public:
324     QGtkStylePrivate();
325     ~QGtkStylePrivate();
326
327     QGtkStyleFilter filter;
328
329     static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
330     static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
331
332     virtual void resolveGtk() const;
333     virtual void initGtkMenu() const;
334     virtual void initGtkTreeview() const;
335     virtual void initGtkWidgets() const;
336
337     static void cleanupGtkWidgets();
338
339     static bool isKDE4Session();
340     void applyCustomPaletteHash();
341     static QFont getThemeFont();
342     static bool isThemeAvailable() { return gtkStyle() != 0; }
343
344     static bool getGConfBool(const QString &key, bool fallback = 0);
345     static QString getGConfString(const QString &key, const QString &fallback = QString());
346
347     static QString getThemeName();
348     virtual int getSpinboxArrowSize() const;
349
350 #ifndef QT_NO_FILEDIALOG
351     static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
352             const QString &dir, const QString &filter, QString *selectedFilter,
353             QFileDialog::Options options, bool isSaveDialog = false,
354             QHash<GtkFileFilter *, QString> *filterMap = 0);
355
356     static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
357                                 QString *selectedFilter, QFileDialog::Options options);
358     static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
359                                 QString *selectedFilter, QFileDialog::Options options);
360     static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
361     static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
362                                     QString *selectedFilter, QFileDialog::Options options);
363 #endif
364     static QIcon getFilesystemIcon(const QFileInfo &);
365
366     static Ptr_gtk_container_forall gtk_container_forall;
367     static Ptr_gtk_init gtk_init;
368     static Ptr_gtk_style_attach gtk_style_attach;
369     static Ptr_gtk_window_new gtk_window_new;
370     static Ptr_gtk_widget_destroy gtk_widget_destroy;
371     static Ptr_gtk_widget_realize gtk_widget_realize;
372     static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
373     static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
374     static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
375     static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
376     static Ptr_gtk_arrow_new gtk_arrow_new;
377     static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
378     static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
379     static Ptr_gtk_menu_new gtk_menu_new;
380     static Ptr_gtk_expander_new gtk_expander_new;
381     static Ptr_gtk_button_new gtk_button_new;
382     static Ptr_gtk_tool_button_new gtk_tool_button_new;
383     static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
384     static Ptr_gtk_check_button_new gtk_check_button_new;
385     static Ptr_gtk_radio_button_new gtk_radio_button_new;
386     static Ptr_gtk_spin_button_new gtk_spin_button_new;
387     static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
388     static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
389     static Ptr_gtk_frame_new gtk_frame_new;
390     static Ptr_gtk_statusbar_new gtk_statusbar_new;
391     static Ptr_gtk_entry_new gtk_entry_new;
392     static Ptr_gtk_hscale_new gtk_hscale_new;
393     static Ptr_gtk_vscale_new gtk_vscale_new;
394     static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
395     static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
396     static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
397     static Ptr_gtk_notebook_new gtk_notebook_new;
398     static Ptr_gtk_toolbar_new gtk_toolbar_new;
399     static Ptr_gtk_tree_view_new gtk_tree_view_new;
400     static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
401     static Ptr_gtk_combo_box_new gtk_combo_box_new;
402     static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
403     static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
404     static Ptr_gtk_container_add gtk_container_add;
405     static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
406     static Ptr_gtk_progress_configure gtk_progress_configure;
407     static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
408     static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
409     static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
410     static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
411     static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
412     static Ptr_gtk_widget_get_style gtk_widget_get_style;
413     static Ptr_gtk_widget_style_get gtk_widget_style_get;
414     static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
415     static Ptr_gtk_fixed_new gtk_fixed_new;
416     static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
417     static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
418     static Ptr_gtk_paint_check gtk_paint_check;
419     static Ptr_gtk_paint_box gtk_paint_box;
420     static Ptr_gtk_paint_box_gap gtk_paint_box_gap;
421     static Ptr_gtk_paint_flat_box gtk_paint_flat_box;
422     static Ptr_gtk_paint_option gtk_paint_option;
423     static Ptr_gtk_paint_extension gtk_paint_extension;
424     static Ptr_gtk_paint_slider gtk_paint_slider;
425     static Ptr_gtk_paint_shadow gtk_paint_shadow;
426     static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip;
427     static Ptr_gtk_paint_focus gtk_paint_focus;
428     static Ptr_gtk_paint_arrow gtk_paint_arrow;
429     static Ptr_gtk_paint_handle gtk_paint_handle;
430     static Ptr_gtk_paint_expander gtk_paint_expander;
431     static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
432     static Ptr_gtk_adjustment_new gtk_adjustment_new;
433     static Ptr_gtk_paint_vline gtk_paint_vline;
434     static Ptr_gtk_paint_hline gtk_paint_hline;
435     static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
436     static Ptr_gtk_settings_get_default gtk_settings_get_default;
437     static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
438     static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
439     static Ptr_gtk_widget_size_request gtk_widget_size_request;
440     static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
441     static Ptr_gtk_widget_path gtk_widget_path;
442     static Ptr_gtk_container_get_type gtk_container_get_type;
443     static Ptr_gtk_window_get_type gtk_window_get_type;
444     static Ptr_gtk_widget_get_type gtk_widget_get_type;
445     static Ptr_gtk_widget_get_parent gtk_widget_get_parent;
446     static Ptr_gtk_widget_is_toplevel gtk_widget_is_toplevel;
447     static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
448     static Ptr_gtk_check_version gtk_check_version;
449     static Ptr_gtk_border_free gtk_border_free;
450     static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
451     static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
452
453     static Ptr_pango_font_description_get_size pango_font_description_get_size;
454     static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
455     static Ptr_pango_font_description_get_family pango_font_description_get_family;
456     static Ptr_pango_font_description_get_style pango_font_description_get_style;
457
458     static Ptr_gtk_file_filter_new gtk_file_filter_new;
459     static Ptr_gtk_file_filter_set_name gtk_file_filter_set_name;
460     static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern;
461     static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter;
462     static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter;
463     static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter;
464     static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new;
465     static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder;
466     static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename;
467     static Ptr_gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames;
468     static Ptr_gtk_file_chooser_set_current_name gtk_file_chooser_set_current_name;
469     static Ptr_gtk_dialog_run gtk_dialog_run;
470     static Ptr_gtk_file_chooser_set_filename gtk_file_chooser_set_filename;
471
472     static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
473     static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
474     static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
475     static Ptr_gdk_pixmap_new gdk_pixmap_new;
476     static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
477     static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable;
478     static Ptr_gdk_draw_rectangle gdk_draw_rectangle;
479     static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
480     static Ptr_gdk_drawable_unref gdk_drawable_unref;
481     static Ptr_gdk_color_free gdk_color_free;
482     static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
483     static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
484     static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
485
486     static Ptr_gconf_client_get_default gconf_client_get_default;
487     static Ptr_gconf_client_get_string gconf_client_get_string;
488     static Ptr_gconf_client_get_bool gconf_client_get_bool;
489
490     static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
491     static Ptr_gnome_vfs_init gnome_vfs_init;
492
493     virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
494
495 protected:
496     typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
497
498     static inline void destroyWidgetMap()
499     {
500         cleanupGtkWidgets();
501         delete widgetMap;
502         widgetMap = 0;
503     }
504
505     static inline WidgetMap *gtkWidgetMap()
506     {
507         if (!widgetMap) {
508             widgetMap = new WidgetMap();
509             qAddPostRoutine(destroyWidgetMap);
510         }
511         return widgetMap;
512     }
513
514     static QStringList extract_filter(const QString &rawFilter);
515
516     virtual GtkWidget* getTextColorWidget() const;
517     static void setupGtkWidget(GtkWidget* widget);
518     static void addWidgetToMap(GtkWidget* widget);
519     static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
520     static void addWidget(GtkWidget *widget);
521     static void removeWidgetFromMap(const QHashableLatin1Literal &path);
522
523     virtual void init();
524
525 private:
526     static QList<QGtkStylePrivate *> instances;
527     static WidgetMap *widgetMap;
528     friend class QGtkStyleUpdateScheduler;
529 };
530
531 // Helper to ensure that we have polished all our gtk widgets
532 // before updating our own palettes
533 class QGtkStyleUpdateScheduler : public QObject
534 {
535     Q_OBJECT
536 public slots:
537     void updateTheme();
538 };
539
540 QT_END_NAMESPACE
541
542 #endif // !QT_NO_STYLE_GTK
543 #endif // QGTKSTYLE_P_H