source: trunk/src/gui/styles/qgtkstyle_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

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