9ed32bd97b7ad9919053c240c23d8e7000bd641b
[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 void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
185 typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
186 typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
187 typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
188 typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
189 typedef void  (*Ptr_gtk_paint_check) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
190 typedef void  (*Ptr_gtk_paint_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
191 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);
192 typedef void  (*Ptr_gtk_paint_resize_grip) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
193 typedef void  (*Ptr_gtk_paint_focus) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
194 typedef void  (*Ptr_gtk_paint_shadow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
195 typedef void  (*Ptr_gtk_paint_slider) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
196 typedef void  (*Ptr_gtk_paint_expander) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
197 typedef void  (*Ptr_gtk_paint_handle) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
198 typedef void  (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
199 typedef void  (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
200 typedef void  (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
201 typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
202 typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
203 typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
204 typedef void   (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
205 typedef void   (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
206 typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
207 typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
208 typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
209 typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
210 typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
211 typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
212
213 typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
214 typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
215 typedef GtkType (*Ptr_gtk_container_get_type) (void);
216 typedef GtkType (*Ptr_gtk_window_get_type) (void);
217 typedef GtkType (*Ptr_gtk_widget_get_type) (void);
218 typedef GtkWidget* (*Ptr_gtk_widget_get_parent) (GtkWidget *);
219 typedef gboolean (*Ptr_gtk_widget_is_toplevel) (GtkWidget *);
220 typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
221 typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
222 typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
223 typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
224 typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
225 typedef gboolean (*Ptr_gtk_file_chooser_set_current_folder)(GtkFileChooser *, const gchar *);
226 typedef GtkFileFilter* (*Ptr_gtk_file_filter_new)(void);
227 typedef void (*Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *);
228 typedef void (*Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern);
229 typedef void (*Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
230 typedef void (*Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
231 typedef GtkFileFilter* (*Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser);
232 typedef gchar*  (*Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
233 typedef GSList* (*Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
234 typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
235                                                 GtkWindow *parent,
236                                                 GtkFileChooserAction action,
237                                                 const gchar *first_button_text,
238                                                 ...);
239 typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
240 typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
241 typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
242 typedef void (*Ptr_gtk_border_free)(GtkBorder *);
243 typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
244 typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
245
246 typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
247 typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
248 typedef void (*Ptr_gdk_color_free) (const GdkColor *);
249 typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
250 typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *dest, GdkDrawable *src,
251                                                          GdkColormap *cmap, int src_x,
252                                                          int src_y, int dest_x, int dest_y,
253                                                          int width, int height);
254 typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *drawable, gint width, gint height, gint depth);
255 typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
256                                          int bits_per_sample, int width, int height);
257 typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *drawable, GdkGC *gc,
258                                         gboolean filled, gint x, gint y, gint width, gint height);
259 typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
260 typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
261 typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
262 typedef XID  (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
263 typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
264
265
266 QT_BEGIN_NAMESPACE
267
268 #ifndef QT_NO_FILEDIALOG
269 typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
270                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
271 typedef QString (*_qt_filedialog_open_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
272                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
273 typedef QString (*_qt_filedialog_save_filename_hook)     (QWidget * parent, const QString &caption, const QString &dir,
274                                                           const QString &filter, QString *selectedFilter, QFileDialog::Options options);
275 typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
276                                                           QFileDialog::Options options);
277
278 extern Q_WIDGETS_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
279 extern Q_WIDGETS_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
280 extern Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
281 extern Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
282 #endif //!QT_NO_FILEDIALOG
283
284 class QGtkStylePrivate;
285
286 class QGtkStyleFilter : public QObject
287 {
288 public:
289     QGtkStyleFilter(QGtkStylePrivate* sp)
290         : stylePrivate(sp)
291     {}
292 private:
293     QGtkStylePrivate* stylePrivate;
294     bool eventFilter(QObject *obj, QEvent *e);
295 };
296
297 typedef enum {
298   GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
299   GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
300   GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
301   GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
302 } GnomeIconLookupFlags;
303
304 typedef enum {
305   GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
306   GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
307 } GnomeIconLookupResultFlags;
308
309 struct GnomeThumbnailFactory;
310 typedef gboolean (*Ptr_gnome_vfs_init) (void);
311 typedef char* (*Ptr_gnome_icon_lookup_sync)  (
312         GtkIconTheme *icon_theme,
313         GnomeThumbnailFactory *,
314         const char *file_uri,
315         const char *custom_icon,
316         GnomeIconLookupFlags flags,
317         GnomeIconLookupResultFlags *result);
318
319 class QGtkStylePrivate : public QWindowsStylePrivate
320 {
321     Q_DECLARE_PUBLIC(QGtkStyle)
322 public:
323     QGtkStylePrivate();
324     ~QGtkStylePrivate();
325
326     QGtkStyleFilter filter;
327
328     static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
329     static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
330
331     virtual void resolveGtk() const;
332     virtual void initGtkMenu() const;
333     virtual void initGtkTreeview() const;
334     virtual void initGtkWidgets() const;
335
336     static void cleanupGtkWidgets();
337
338     static bool isKDE4Session();
339     void applyCustomPaletteHash();
340     static QFont getThemeFont();
341     static bool isThemeAvailable() { return gtkStyle() != 0; }
342
343     static bool getGConfBool(const QString &key, bool fallback = 0);
344     static QString getGConfString(const QString &key, const QString &fallback = QString());
345
346     static QString getThemeName();
347     virtual int getSpinboxArrowSize() const;
348
349 #ifndef QT_NO_FILEDIALOG
350     static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
351             const QString &dir, const QString &filter, QString *selectedFilter,
352             QFileDialog::Options options, bool isSaveDialog = false,
353             QHash<GtkFileFilter *, QString> *filterMap = 0);
354
355     static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
356                                 QString *selectedFilter, QFileDialog::Options options);
357     static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
358                                 QString *selectedFilter, QFileDialog::Options options);
359     static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
360     static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
361                                     QString *selectedFilter, QFileDialog::Options options);
362 #endif
363     static QIcon getFilesystemIcon(const QFileInfo &);
364
365     static Ptr_gtk_container_forall gtk_container_forall;
366     static Ptr_gtk_init gtk_init;
367     static Ptr_gtk_style_attach gtk_style_attach;
368     static Ptr_gtk_window_new gtk_window_new;
369     static Ptr_gtk_widget_destroy gtk_widget_destroy;
370     static Ptr_gtk_widget_realize gtk_widget_realize;
371     static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
372     static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
373     static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
374     static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
375     static Ptr_gtk_arrow_new gtk_arrow_new;
376     static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
377     static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
378     static Ptr_gtk_menu_new gtk_menu_new;
379     static Ptr_gtk_expander_new gtk_expander_new;
380     static Ptr_gtk_button_new gtk_button_new;
381     static Ptr_gtk_tool_button_new gtk_tool_button_new;
382     static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
383     static Ptr_gtk_check_button_new gtk_check_button_new;
384     static Ptr_gtk_radio_button_new gtk_radio_button_new;
385     static Ptr_gtk_spin_button_new gtk_spin_button_new;
386     static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
387     static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
388     static Ptr_gtk_frame_new gtk_frame_new;
389     static Ptr_gtk_statusbar_new gtk_statusbar_new;
390     static Ptr_gtk_entry_new gtk_entry_new;
391     static Ptr_gtk_hscale_new gtk_hscale_new;
392     static Ptr_gtk_vscale_new gtk_vscale_new;
393     static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
394     static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
395     static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
396     static Ptr_gtk_notebook_new gtk_notebook_new;
397     static Ptr_gtk_toolbar_new gtk_toolbar_new;
398     static Ptr_gtk_tree_view_new gtk_tree_view_new;
399     static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
400     static Ptr_gtk_combo_box_new gtk_combo_box_new;
401     static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
402     static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
403     static Ptr_gtk_container_add gtk_container_add;
404     static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
405     static Ptr_gtk_progress_configure gtk_progress_configure;
406     static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
407     static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
408     static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
409     static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
410     static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
411     static Ptr_gtk_widget_style_get gtk_widget_style_get;
412     static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
413     static Ptr_gtk_fixed_new gtk_fixed_new;
414     static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
415     static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
416     static Ptr_gtk_paint_check gtk_paint_check;
417     static Ptr_gtk_paint_box gtk_paint_box;
418     static Ptr_gtk_paint_box_gap gtk_paint_box_gap;
419     static Ptr_gtk_paint_flat_box gtk_paint_flat_box;
420     static Ptr_gtk_paint_option gtk_paint_option;
421     static Ptr_gtk_paint_extension gtk_paint_extension;
422     static Ptr_gtk_paint_slider gtk_paint_slider;
423     static Ptr_gtk_paint_shadow gtk_paint_shadow;
424     static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip;
425     static Ptr_gtk_paint_focus gtk_paint_focus;
426     static Ptr_gtk_paint_arrow gtk_paint_arrow;
427     static Ptr_gtk_paint_handle gtk_paint_handle;
428     static Ptr_gtk_paint_expander gtk_paint_expander;
429     static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
430     static Ptr_gtk_adjustment_new gtk_adjustment_new;
431     static Ptr_gtk_paint_vline gtk_paint_vline;
432     static Ptr_gtk_paint_hline gtk_paint_hline;
433     static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
434     static Ptr_gtk_settings_get_default gtk_settings_get_default;
435     static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
436     static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
437     static Ptr_gtk_widget_size_request gtk_widget_size_request;
438     static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
439     static Ptr_gtk_widget_path gtk_widget_path;
440     static Ptr_gtk_container_get_type gtk_container_get_type;
441     static Ptr_gtk_window_get_type gtk_window_get_type;
442     static Ptr_gtk_widget_get_type gtk_widget_get_type;
443     static Ptr_gtk_widget_get_parent gtk_widget_get_parent;
444     static Ptr_gtk_widget_is_toplevel gtk_widget_is_toplevel;
445     static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
446     static Ptr_gtk_check_version gtk_check_version;
447     static Ptr_gtk_border_free gtk_border_free;
448     static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
449     static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
450
451     static Ptr_pango_font_description_get_size pango_font_description_get_size;
452     static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
453     static Ptr_pango_font_description_get_family pango_font_description_get_family;
454     static Ptr_pango_font_description_get_style pango_font_description_get_style;
455
456     static Ptr_gtk_file_filter_new gtk_file_filter_new;
457     static Ptr_gtk_file_filter_set_name gtk_file_filter_set_name;
458     static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern;
459     static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter;
460     static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter;
461     static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter;
462     static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new;
463     static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder;
464     static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename;
465     static Ptr_gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames;
466     static Ptr_gtk_file_chooser_set_current_name gtk_file_chooser_set_current_name;
467     static Ptr_gtk_dialog_run gtk_dialog_run;
468     static Ptr_gtk_file_chooser_set_filename gtk_file_chooser_set_filename;
469
470     static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
471     static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
472     static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
473     static Ptr_gdk_pixmap_new gdk_pixmap_new;
474     static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
475     static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable;
476     static Ptr_gdk_draw_rectangle gdk_draw_rectangle;
477     static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
478     static Ptr_gdk_drawable_unref gdk_drawable_unref;
479     static Ptr_gdk_color_free gdk_color_free;
480     static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
481     static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
482     static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
483
484     static Ptr_gconf_client_get_default gconf_client_get_default;
485     static Ptr_gconf_client_get_string gconf_client_get_string;
486     static Ptr_gconf_client_get_bool gconf_client_get_bool;
487
488     static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
489     static Ptr_gnome_vfs_init gnome_vfs_init;
490
491     virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
492
493 protected:
494     typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
495
496     static inline void destroyWidgetMap()
497     {
498         cleanupGtkWidgets();
499         delete widgetMap;
500         widgetMap = 0;
501     }
502
503     static inline WidgetMap *gtkWidgetMap()
504     {
505         if (!widgetMap) {
506             widgetMap = new WidgetMap();
507             qAddPostRoutine(destroyWidgetMap);
508         }
509         return widgetMap;
510     }
511
512     static QStringList extract_filter(const QString &rawFilter);
513
514     virtual GtkWidget* getTextColorWidget() const;
515     static void setupGtkWidget(GtkWidget* widget);
516     static void addWidgetToMap(GtkWidget* widget);
517     static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
518     static void addWidget(GtkWidget *widget);
519     static void removeWidgetFromMap(const QHashableLatin1Literal &path);
520
521     virtual void init();
522
523 private:
524     static QList<QGtkStylePrivate *> instances;
525     static WidgetMap *widgetMap;
526     friend class QGtkStyleUpdateScheduler;
527 };
528
529 // Helper to ensure that we have polished all our gtk widgets
530 // before updating our own palettes
531 class QGtkStyleUpdateScheduler : public QObject
532 {
533     Q_OBJECT
534 public slots:
535     void updateTheme();
536 };
537
538 QT_END_NAMESPACE
539
540 #endif // !QT_NO_STYLE_GTK
541 #endif // QGTKSTYLE_P_H