Qt 4.8
qgtkstyle_p.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 #include "qgtkstyle_p.h"
43 
44 // This file is responsible for resolving all GTK functions we use
45 // dynamically. This is done to avoid link-time dependancy on GTK
46 // as well as crashes occurring due to usage of the GTK_QT engines
47 //
48 // Additionally we create a map of common GTK widgets that we can pass
49 // to the GTK theme engine as many engines resort to querying the
50 // actual widget pointers for details that are not covered by the
51 // state flags
52 
53 #include <QtCore/qglobal.h>
54 #if !defined(QT_NO_STYLE_GTK)
55 
56 #include <QtCore/QEvent>
57 #include <QtCore/QFile>
58 #include <QtCore/QStringList>
59 #include <QtCore/QTextStream>
60 #include <QtCore/QHash>
61 #include <QtCore/QUrl>
62 #include <QtCore/QLibrary>
63 #include <QtCore/QDebug>
64 
65 #include <private/qapplication_p.h>
66 #include <private/qiconloader_p.h>
67 
68 #include <QtGui/QMenu>
69 #include <QtGui/QStyle>
70 #include <QtGui/QApplication>
71 #include <QtGui/QPixmapCache>
72 #include <QtGui/QStatusBar>
73 #include <QtGui/QMenuBar>
74 #include <QtGui/QToolBar>
75 #include <QtGui/QToolButton>
76 #include <QtGui/QX11Info>
77 
78 #include <private/qt_x11_p.h>
79 
81 
82 static bool displayDepth = -1;
84 
170 
184 
199 
203 
206 
207 typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
208 
210 
212 
214 
215 static void gtkStyleSetCallback(GtkWidget*)
216 {
217  qRegisterMetaType<QGtkStylePrivate *>();
218 
219  // We have to let this function return and complete the event
220  // loop to ensure that all gtk widgets have been styled before
221  // updating
222  QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
223 }
224 
225 static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
226 {
227  GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
228  g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL);
230  for (int i = 0; i < widgets.size(); ++i) {
231  QWidget *widget = widgets.at(i);
232  if (qobject_cast<QToolButton*>(widget)) {
234  QApplication::sendEvent(widget, &event);
235  }
236  }
237 }
238 
240 {
241  char *class_path;
242  QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
243 
244  char *copy = class_path;
245  if (strncmp(copy, "GtkWindow.", 10) == 0)
246  copy += 10;
247  if (strncmp(copy, "GtkFixed.", 9) == 0)
248  copy += 9;
249 
250  copy = strdup(copy);
251 
252  g_free(class_path);
253 
255 }
256 
257 
258 
260 {
262  // Only do this the first time since this will also
263  // generate applicationPaletteChange events
266  }
267  }
268  return QObject::eventFilter(obj, e);
269 }
270 
273 
276  , filter(this)
277 {
278  instances.append(this);
279 }
280 
282 {
283  instances.removeOne(this);
284 }
285 
287 {
288  resolveGtk();
289  initGtkWidgets();
290 }
291 
293 {
294  GtkWidget *widget = gtkWidgetMap()->value(path);
295  if (!widget) {
296  // Theme might have rearranged widget internals
297  widget = gtkWidgetMap()->value(path);
298  }
299  return widget;
300 }
301 
303 {
304  if (GtkWidget *w = gtkWidgetMap()->value(path))
305  return w->style;
306  return 0;
307 }
308 
313 {
314  // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
315  QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
317 
318  gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
319  gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
320  gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
321  gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
322  gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
323 
324  gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
325  gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new");
326  gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name");
327  gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern");
328  gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter");
329  gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter");
330  gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter");
331  gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new");
332  gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
333  gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename");
334  gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames");
335  gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name");
336  gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run");
337  gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename");
338 
339  gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
340  gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
341  gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
342  gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
343  gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
344  gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
345  gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
346  gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
347  gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
348  gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth");
349  gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
350  gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
351  gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
352  gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
353 
354  gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
355  gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
356  gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
357  gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
358  gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
359  gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
360  gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
361  gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
362  gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
363  gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
364  gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
365  gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
366  gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
367  gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
368  gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
369  gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
370  gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
371  gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
372  gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
373  gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
374  gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
375  gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
376  gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
377  gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
378  gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
379  gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
380  gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
381  gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
382  gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
383  gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
384  gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
385  gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
386  gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
387  gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
388  gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
389  gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
390  gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
391  gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
392  gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
393  gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
394  gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
395  gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
396  gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
397  gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
398  gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
399  gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
400  gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
401  gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
402  gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
403  gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
404  gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
405  gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
406  gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
407  gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
408  gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
409  gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
410  gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
411  gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
412  gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
413  gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
414  gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
415  gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
416  gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
417  gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
418  gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
419  gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
420  gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
421  gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
422  gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
423  gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
424  gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
425  gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
426  gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
427  gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
428  gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
429 
430  gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
431  gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
432  gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
433  pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
434  pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
435  pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
436  pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
437 
438  gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
439  gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
440 }
441 
442 /* \internal
443  * Initializes a number of gtk menu widgets.
444  * The widgets are cached.
445  */
447 {
448  // Create menubar
449  GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
450  setupGtkWidget(gtkMenuBar);
451 
452  GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
453  gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
454  gtk_widget_realize(gtkMenuBarItem);
455 
456  // Create menu
457  GtkWidget *gtkMenu = QGtkStylePrivate::gtk_menu_new();
458  gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
459  gtk_widget_realize(gtkMenu);
460 
461  GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
462  gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
463  gtk_widget_realize(gtkMenuItem);
464 
465  GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
466  gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
467  gtk_widget_realize(gtkCheckMenuItem);
468 
469  GtkWidget *gtkMenuSeparator = QGtkStylePrivate::gtk_separator_menu_item_new();
470  gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
471 
472  addAllSubWidgets(gtkMenuBar);
473  addAllSubWidgets(gtkMenu);
474 }
475 
476 
478 {
479  GtkWidget *gtkTreeView = gtk_tree_view_new();
480  gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
481  gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
482  gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
483  addWidget(gtkTreeView);
484 }
485 
486 
487 /* \internal
488  * Initializes a number of gtk widgets that we can later on use to determine some of our styles.
489  * The widgets are cached.
490  */
492 {
493  // From gtkmain.c
494  uid_t ruid = getuid ();
495  uid_t rgid = getgid ();
496  uid_t euid = geteuid ();
497  uid_t egid = getegid ();
498  if (ruid != euid || rgid != egid) {
499  qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
500  "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
501  "\'kdesudo\' or a similar tool.\n\n"
502  "See http://www.gtk.org/setuid.html for more information.\n");
503  return;
504  }
505 
506  static QString themeName;
507  if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) {
508  themeName = getThemeName();
509 
510  if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
511  // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
512  // we cannot support the GTK_Qt Gtk engine
513  qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
514  return;
515  }
516  }
517 
519  // Gtk will set the Qt error handler so we have to reset it afterwards
520  x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
521  QGtkStylePrivate::gtk_init (NULL, NULL);
522  XSetErrorHandler(qt_x_errhandler);
523 
524  // make a window
525  GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
527  if (displayDepth == -1)
529  QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
530  removeWidgetFromMap(widgetPath);
531  gtkWidgetMap()->insert(widgetPath, gtkWindow);
532 
533 
534  // Make all other widgets. respect the text direction
535  if (qApp->layoutDirection() == Qt::RightToLeft)
537 
538  if (!gtkWidgetMap()->contains("GtkButton")) {
539  GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
540  addWidget(gtkButton);
541  g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
543  addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
556 
557  initGtkMenu();
561  (QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
562  GtkWidget *toolbar = gtk_toolbar_new();
563  g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
564  gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
565  addWidget(toolbar);
566  initGtkTreeview();
567  addWidget(gtk_vscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
569  }
570  else // Rebuild map
571  {
572  // When styles change subwidgets can get rearranged
573  // as with the combo box. We need to update the widget map
574  // to reflect this;
576  gtkWidgetMap()->clear();
577  QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
578  while (it.hasNext()) {
579  it.next();
580  if (!strchr(it.key().data(), '.')) {
581  addAllSubWidgets(it.value());
582  }
583  free(const_cast<char *>(it.key().data()));
584  }
585  }
586  } else {
587  qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
588  }
589 }
590 
595 {
596  if (!widgetMap)
597  return;
598  if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
599  gtk_widget_destroy(widgetMap->value("GtkWindow"));
601  it != widgetMap->constEnd(); ++it)
602  free(const_cast<char *>(it.key().data()));
603 }
604 
605 static bool resolveGConf()
606 {
611  }
613 }
614 
616 {
617  QString retVal = fallback;
618  if (resolveGConf()) {
619  g_type_init();
620  GConfClient* client = gconf_client_get_default();
621  GError *err = 0;
622  char *str = gconf_client_get_string(client, qPrintable(value), &err);
623  if (!err) {
624  retVal = QString::fromUtf8(str);
625  g_free(str);
626  }
627  g_object_unref(client);
628  if (err)
629  g_error_free (err);
630  }
631  return retVal;
632 }
633 
635 {
636  bool retVal = fallback;
637  if (resolveGConf()) {
638  g_type_init();
639  GConfClient* client = gconf_client_get_default();
640  GError *err = 0;
641  bool result = gconf_client_get_bool(client, qPrintable(key), &err);
642  g_object_unref(client);
643  if (!err)
644  retVal = result;
645  else
646  g_error_free (err);
647  }
648  return retVal;
649 }
650 
652 {
653  QString themeName;
654  // We try to parse the gtkrc file first
655  // primarily to avoid resolving Gtk functions if
656  // the KDE 3 "Qt" style is currently in use
657  QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
658  if (!rcPaths.isEmpty()) {
659  QStringList paths = rcPaths.split(QLS(":"));
660  foreach (const QString &rcPath, paths) {
661  if (!rcPath.isEmpty()) {
662  QFile rcFile(rcPath);
663  if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
664  QTextStream in(&rcFile);
665  while(!in.atEnd()) {
666  QString line = in.readLine();
667  if (line.contains(QLS("gtk-theme-name"))) {
668  line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
669  line.remove(QLatin1Char('\"'));
670  line = line.trimmed();
671  themeName = line;
672  break;
673  }
674  }
675  }
676  }
677  if (!themeName.isEmpty())
678  break;
679  }
680  }
681 
682  // Fall back to gconf
683  if (themeName.isEmpty() && resolveGConf())
684  themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
685 
686  return themeName;
687 }
688 
691  // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
692  QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
694  gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
695  gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
696  }
698  return QString();
699  }
700  x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
701  gtk_init(NULL, NULL);
702  XSetErrorHandler(qt_x_errhandler);
703  GtkSettings *settings = gtk_settings_get_default();
704  gchararray value;
705  g_object_get(settings, "gtk-icon-theme-name", &value, NULL);
706  QString result = QString::fromUtf8(value);
707  g_free(value);
708  return result;
709 }
710 
711 // Get size of the arrow controls in a GtkSpinButton
713 {
714  const int MIN_ARROW_WIDTH = 6;
715  GtkWidget *spinButton = gtkWidget("GtkSpinButton");
716  GtkStyle *style = spinButton->style;
717  gint size = pango_font_description_get_size (style->font_desc);
718  gint arrow_size;
719  arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
720  arrow_size += arrow_size%2 + 1;
721  return arrow_size;
722 }
723 
724 
726 {
727  static int version = -1;
728  if (version == -1)
729  version = qgetenv("KDE_SESSION_VERSION").toInt();
730  return (version == 4);
731 }
732 
734 {
735  QPalette menuPal = gtkWidgetPalette("GtkMenu");
736  GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL];
737  QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
738  menuPal.setBrush(QPalette::Base, bgColor);
739  menuPal.setBrush(QPalette::Window, bgColor);
740  qApp->setPalette(menuPal, "QMenu");
741 
742  QPalette toolbarPal = gtkWidgetPalette("GtkToolbar");
743  qApp->setPalette(toolbarPal, "QToolBar");
744 
745  QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
746  qApp->setPalette(menuBarPal, "QMenuBar");
747 }
748 
753 {
754  return gtkWidget("GtkEntry");
755 }
756 
758 {
759  if (Q_GTK_IS_WIDGET(widget)) {
760  static GtkWidget* protoLayout = 0;
761  if (!protoLayout) {
762  protoLayout = QGtkStylePrivate::gtk_fixed_new();
763  QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
764  }
765  Q_ASSERT(protoLayout);
766 
767  if (!widget->parent && !GTK_WIDGET_TOPLEVEL(widget))
768  QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
770  }
771 }
772 
774 {
776  WidgetMap::iterator it = map->find(path);
777  if (it != map->end()) {
778  free(const_cast<char *>(it.key().data()));
779  map->erase(it);
780  }
781 }
782 
784 {
785  if (Q_GTK_IS_WIDGET(widget)) {
786  gtk_widget_realize(widget);
787  QHashableLatin1Literal widgetPath = classPath(widget);
788 
789  removeWidgetFromMap(widgetPath);
790  gtkWidgetMap()->insert(widgetPath, widget);
791 #ifdef DUMP_GTK_WIDGET_TREE
792  qWarning("Inserted Gtk Widget: %s", widgetPath.data());
793 #endif
794  }
795  }
796 
797 void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
798 {
799  Q_UNUSED(v);
800  addWidgetToMap(widget);
801  if (GTK_CHECK_TYPE ((widget), gtk_container_get_type()))
802  gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
803 }
804 
805 // Updates window/windowtext palette based on the indicated gtk widget
807 {
808  GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
809  Q_ASSERT(gtkWidget);
811  GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
812  GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
813  GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
814  QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
815  QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
816  QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8);
817  pal.setBrush(QPalette::Window, bgColor);
818  pal.setBrush(QPalette::Button, bgColor);
820  pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
822  pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
823  return pal;
824 }
825 
826 
828 {
829  static QString oldTheme(QLS("qt_not_set"));
831 
833  if (QApplication::font() != font)
834  qApp->setFont(font);
835 
836  if (oldTheme != QGtkStylePrivate::getThemeName()) {
837  oldTheme = QGtkStylePrivate::getThemeName();
838  QPalette newPalette = qApp->style()->standardPalette();
840  QApplication::setPalette(newPalette);
841  if (!QGtkStylePrivate::instances.isEmpty()) {
842  QGtkStylePrivate::instances.last()->initGtkWidgets();
843  QGtkStylePrivate::instances.last()->applyCustomPaletteHash();
844  }
846  // Notify all widgets that size metrics might have changed
847  foreach (QWidget *widget, widgets) {
849  QApplication::sendEvent(widget, &e);
850  }
851  }
853 }
854 
856 {
857  if (widget) {
858  setupGtkWidget(widget);
859  addAllSubWidgets(widget);
860  }
861 }
862 
863 
864 // Fetch the application font from the pango font description
865 // contained in the theme.
867 {
868  QFont font;
869  GtkStyle *style = gtkStyle();
870  if (style && qApp->desktopSettingsAware())
871  {
872  PangoFontDescription *gtk_font = style->font_desc;
873  font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE);
874 
876  if (!family.isEmpty())
877  font.setFamily(family);
878 
879  int weight = pango_font_description_get_weight(gtk_font);
880  if (weight >= PANGO_WEIGHT_HEAVY)
881  font.setWeight(QFont::Black);
882  else if (weight >= PANGO_WEIGHT_BOLD)
883  font.setWeight(QFont::Bold);
884  else if (weight >= PANGO_WEIGHT_SEMIBOLD)
886  else if (weight >= PANGO_WEIGHT_NORMAL)
887  font.setWeight(QFont::Normal);
888  else
889  font.setWeight(QFont::Light);
890 
891  PangoStyle fontstyle = pango_font_description_get_style(gtk_font);
892  if (fontstyle == PANGO_STYLE_ITALIC)
894  else if (fontstyle == PANGO_STYLE_OBLIQUE)
896  else
898  }
899  return font;
900 }
901 
902 
903 // ----------- Native file dialogs -----------
904 
905 // Extract filter list from expressions of type: foo (*.a *.b *.c)"
907 {
908  QString result = rawFilter;
909  QRegExp r(QString::fromLatin1("^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"));
910  int index = r.indexIn(result);
911  if (index >= 0)
912  result = r.cap(2);
913  return result.split(QLatin1Char(' '));
914 }
915 
917 
918 void QGtkStylePrivate::setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
919  const QString &dir, const QString &filter, QString *selectedFilter,
920  QFileDialog::Options options, bool isSaveDialog,
922 {
923  g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL);
924  g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL);
925  if (!filter.isEmpty()) {
927  foreach (const QString &rawfilter, filters) {
928  GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_filter_new ();
929  QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
931  QGtkStylePrivate::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
932 
933  foreach (const QString &fileExtension, extensions) {
934  // Note Gtk file dialogs are by default case sensitive
935  // and only supports basic glob syntax so we
936  // rewrite .xyz to .[xX][yY][zZ]
937  QString caseInsensitive;
938  for (int i = 0 ; i < fileExtension.length() ; ++i) {
939  QChar ch = fileExtension.at(i);
940  if (ch.isLetter()) {
941  caseInsensitive.append(
942  QLatin1Char('[') +
943  ch.toLower() +
944  ch.toUpper() +
945  QLatin1Char(']'));
946  } else {
947  caseInsensitive.append(ch);
948  }
949  }
950  QGtkStylePrivate::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
951 
952  }
953  if (filterMap)
954  filterMap->insert(gtkFilter, rawfilter);
955  QGtkStylePrivate::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
956  if (selectedFilter && (rawfilter == *selectedFilter))
957  QGtkStylePrivate::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
958  }
959  }
960 
961  // Using the currently active window is not entirely correct, however
962  // it gives more sensible behavior for applications that do not provide a
963  // parent
964  QWidget *modalFor = parent ? parent->window() : qApp->activeWindow();
965  if (modalFor) {
966  QGtkStylePrivate::gtk_widget_realize(gtkFileChooser); // Creates X window
967  XSetTransientForHint(QGtkStylePrivate::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
968  QGtkStylePrivate::gdk_x11_drawable_get_xid(gtkFileChooser->window),
969  modalFor->winId());
971 
972  }
973 
974  QFileInfo fileinfo(dir);
975  if (dir.isEmpty())
976  fileinfo.setFile(QDir::currentPath());
977  fileinfo.makeAbsolute();
978  if (fileinfo.isDir()) {
979  QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
980  } else if (isSaveDialog) {
981  QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.absolutePath()));
982  QGtkStylePrivate::gtk_file_chooser_set_current_name((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.fileName()));
983  } else {
984  QGtkStylePrivate::gtk_file_chooser_set_filename((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
985  }
986 }
987 
988 QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
989  QString *selectedFilter, QFileDialog::Options options)
990 {
992  GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
993  NULL,
994  GTK_FILE_CHOOSER_ACTION_OPEN,
995  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
996  GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
997  NULL);
998 
999  setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
1000 
1001  QWidget modal_widget;
1002  modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
1003  modal_widget.setParent(parent, Qt::Window);
1004  QApplicationPrivate::enterModal(&modal_widget);
1005 
1006  QString filename;
1007  if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
1008  char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
1009  filename = QString::fromUtf8(gtk_filename);
1010  g_free (gtk_filename);
1011  if (selectedFilter) {
1012  GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
1013  *selectedFilter = filterMap.value(gtkFilter);
1014  }
1015  }
1016 
1017  QApplicationPrivate::leaveModal(&modal_widget);
1018  gtk_widget_destroy (gtkFileChooser);
1019  return filename;
1020 }
1021 
1022 
1023 QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
1024 {
1026  GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
1027  NULL,
1028  GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1029  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1030  GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1031  NULL);
1032 
1033  setupGtkFileChooser(gtkFileChooser, parent, dir, QString(), 0, options);
1034  QWidget modal_widget;
1035  modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
1036  modal_widget.setParent(parent, Qt::Window);
1037  QApplicationPrivate::enterModal(&modal_widget);
1038 
1039  QString filename;
1040  if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
1041  char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
1042  filename = QString::fromUtf8(gtk_filename);
1043  g_free (gtk_filename);
1044  }
1045 
1046  QApplicationPrivate::leaveModal(&modal_widget);
1047  gtk_widget_destroy (gtkFileChooser);
1048  return filename;
1049 }
1050 
1052  QString *selectedFilter, QFileDialog::Options options)
1053 {
1054  QStringList filenames;
1056  GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
1057  NULL,
1058  GTK_FILE_CHOOSER_ACTION_OPEN,
1059  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1060  GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1061  NULL);
1062 
1063  setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
1064  g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL);
1065 
1066  QWidget modal_widget;
1067  modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
1068  modal_widget.setParent(parent, Qt::Window);
1069  QApplicationPrivate::enterModal(&modal_widget);
1070 
1071  if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
1072  GSList *gtk_file_names = QGtkStylePrivate::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
1073  for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next)
1074  filenames << QString::fromUtf8((const char*)iterator->data);
1075  g_slist_free(gtk_file_names);
1076  if (selectedFilter) {
1077  GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
1078  *selectedFilter = filterMap.value(gtkFilter);
1079  }
1080  }
1081 
1082  QApplicationPrivate::leaveModal(&modal_widget);
1083  gtk_widget_destroy (gtkFileChooser);
1084  return filenames;
1085 }
1086 
1087 QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
1088  QString *selectedFilter, QFileDialog::Options options)
1089 {
1091  GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
1092  NULL,
1093  GTK_FILE_CHOOSER_ACTION_SAVE,
1094  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1095  GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
1096  NULL);
1097  setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap);
1098 
1099  QWidget modal_widget;
1100  modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
1101  modal_widget.setParent(parent, Qt::Window);
1102  QApplicationPrivate::enterModal(&modal_widget);
1103 
1104  QString filename;
1105  if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
1106  char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
1107  filename = QString::fromUtf8(gtk_filename);
1108  g_free (gtk_filename);
1109  if (selectedFilter) {
1110  GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
1111  *selectedFilter = filterMap.value(gtkFilter);
1112  }
1113  }
1114 
1115  QApplicationPrivate::leaveModal(&modal_widget);
1116  gtk_widget_destroy (gtkFileChooser);
1117  return filename;
1118 }
1119 
1121 {
1122  QIcon icon;
1124  gnome_vfs_init();
1125  GtkIconTheme *theme = gtk_icon_theme_get_default();
1126  QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
1127  char * icon_name = gnome_icon_lookup_sync(theme,
1128  NULL,
1129  fileurl.data(),
1130  NULL,
1132  NULL);
1133  QString iconName = QString::fromUtf8(icon_name);
1134  g_free(icon_name);
1135  if (iconName.startsWith(QLatin1Char('/')))
1136  return QIcon(iconName);
1137  return QIcon::fromTheme(iconName);
1138  }
1139  return icon;
1140 }
1141 
1143 {
1144  return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
1145 }
1146 
1147 // copied from qHash.cpp
1149 {
1150  int n = key.size();
1151  const uchar *p = reinterpret_cast<const uchar *>(key.data());
1152  uint h = 0;
1153  uint g;
1154 
1155  while (n--) {
1156  h = (h << 4) + *p++;
1157  if ((g = (h & 0xf0000000)) != 0)
1158  h ^= g >> 23;
1159  h &= ~g;
1160  }
1161  return h;
1162 }
1163 
1165 
1166 #endif // !defined(QT_NO_STYLE_GTK)
static Ptr_gdk_drawable_get_depth gdk_drawable_get_depth
Definition: qgtkstyle_p.h:469
static Ptr_gtk_widget_path gtk_widget_path
Definition: qgtkstyle_p.h:433
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
#define Q_GTK_IS_WIDGET(widget)
Definition: qgtkstyle_p.h:75
static Ptr_gtk_window_new gtk_window_new
Definition: qgtkstyle_p.h:362
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
Q_DECLARE_METATYPE(QGtkStylePrivate *)
char *(* Ptr_gnome_icon_lookup_sync)(GtkIconTheme *icon_theme, GnomeThumbnailFactory *, const char *file_uri, const char *custom_icon, GnomeIconLookupFlags flags, GnomeIconLookupResultFlags *result)
Definition: qgtkstyle_p.h:306
int(* Ptr_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf)
Definition: qgtkstyle_p.h:245
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
GdkPixbuf *(* Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *, const char *)
Definition: qgtkstyle_p.h:187
static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter
Definition: qgtkstyle_p.h:451
PangoWeight(* Ptr_pango_font_description_get_weight)(const PangoFontDescription *)
Definition: qgtkstyle_p.h:220
static Ptr_gdk_draw_rectangle gdk_draw_rectangle
Definition: qgtkstyle_p.h:466
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
void(* Ptr_gdk_draw_rectangle)(GdkDrawable *drawable, GdkGC *gc, gboolean filled, gint x, gint y, gint width, gint height)
Definition: qgtkstyle_p.h:253
static bool displayDepth
Definition: qgtkstyle_p.cpp:82
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
bool isLetter() const
Returns true if the character is a letter (Letter_* categories); otherwise returns false...
Definition: qchar.cpp:653
static QList< QGtkStylePrivate * > instances
Definition: qgtkstyle_p.h:515
static Ptr_gtk_widget_get_type gtk_widget_get_type
Definition: qgtkstyle_p.h:436
static Ptr_gtk_entry_new gtk_entry_new
Definition: qgtkstyle_p.h:384
static mach_timebase_info_data_t info
XID(* Ptr_gdk_x11_drawable_get_xid)(GdkDrawable *)
Definition: qgtkstyle_p.h:259
GtkStyle *(* Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *)
Definition: qgtkstyle_p.h:141
static Ptr_pango_font_description_get_style pango_font_description_get_style
Definition: qgtkstyle_p.h:444
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
Definition: qregexp.cpp:4310
static Ptr_gconf_client_get_string gconf_client_get_string
Definition: qgtkstyle_p.h:476
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
GtkObject *(* Ptr_gtk_adjustment_new)(double, double, double, double, double, double)
Definition: qgtkstyle_p.h:203
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
static Ptr_gconf_client_get_default gconf_client_get_default
Definition: qgtkstyle_p.h:475
QString readLine(qint64 maxlen=0)
Reads one line of text from the stream, and returns it as a QString.
EventRef event
QPointer< QWidget > widget
void(* Ptr_gtk_paint_box)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:190
gchar *(* Ptr_gtk_check_version)(guint, guint, guint)
Definition: qgtkstyle_p.h:167
void clear()
Removes all items from the hash.
Definition: qhash.h:574
void(* Ptr_gtk_widget_size_allocate)(GtkWidget *, GtkAllocation *)
Definition: qgtkstyle_p.h:208
void(* Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter)
Definition: qgtkstyle_p.h:228
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static Ptr_gtk_file_filter_new gtk_file_filter_new
Definition: qgtkstyle_p.h:446
static WidgetMap * widgetMap
Definition: qgtkstyle_p.h:516
static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new
Definition: qgtkstyle_p.h:395
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
static unsigned long appUserTime()
Returns the X11 user time.
static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new
Definition: qgtkstyle_p.h:389
static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid
Definition: qgtkstyle_p.h:472
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
void(* Ptr_gtk_paint_slider)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkOrientation)
Definition: qgtkstyle_p.h:195
static Ptr_gtk_style_attach gtk_style_attach
Definition: qgtkstyle_p.h:361
static Ptr_gtk_expander_new gtk_expander_new
Definition: qgtkstyle_p.h:373
static Ptr_gtk_paint_check gtk_paint_check
Definition: qgtkstyle_p.h:410
static Ptr_gtk_widget_set_direction gtk_widget_set_direction
Definition: qgtkstyle_p.h:432
#define it(className, varName)
GtkWidget *(* Ptr_gtk_vscale_new)(GtkAdjustment *)
Definition: qgtkstyle_p.h:163
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
GtkWidget *(* Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType)
Definition: qgtkstyle_p.h:146
static Ptr_gtk_range_set_inverted gtk_range_set_inverted
Definition: qgtkstyle_p.h:402
static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
static Ptr_gtk_progress_bar_new gtk_progress_bar_new
Definition: qgtkstyle_p.h:396
static QIcon fromTheme(const QString &name, const QIcon &fallback=QIcon())
Returns the QIcon corresponding to name in the current icon theme.
Definition: qicon.cpp:1039
void(* Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern)
Definition: qgtkstyle_p.h:226
GtkWidget *(* Ptr_gtk_combo_box_entry_new)(void)
Definition: qgtkstyle_p.h:152
static Ptr_gtk_menu_new gtk_menu_new
Definition: qgtkstyle_p.h:372
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void(* Ptr_gdk_drawable_unref)(GdkDrawable *)
Definition: qgtkstyle_p.h:256
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate
Definition: qgtkstyle_p.h:430
virtual int getSpinboxArrowSize() const
static Ptr_gtk_widget_destroy gtk_widget_destroy
Definition: qgtkstyle_p.h:363
bool eventFilter(QObject *obj, QEvent *e)
Filters events if this object has been installed as an event filter for the watched object...
PangoStyle(* Ptr_pango_font_description_get_style)(const PangoFontDescription *desc)
Definition: qgtkstyle_p.h:222
void(* Ptr_gtk_paint_option)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:199
GtkWidget *(* Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *)
Definition: qgtkstyle_p.h:156
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
GtkWidget *(* Ptr_gtk_file_chooser_dialog_new)(const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *first_button_text,...)
Definition: qgtkstyle_p.h:232
static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename
Definition: qgtkstyle_p.h:454
char *(* Ptr_gconf_client_get_string)(GConfClient *, const char *, GError **)
Definition: qgtkstyle_p.h:136
static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width
Definition: qgtkstyle_p.h:461
static Ptr_gtk_fixed_new gtk_fixed_new
Definition: qgtkstyle_p.h:407
static Ptr_gtk_paint_vline gtk_paint_vline
Definition: qgtkstyle_p.h:425
static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment
Definition: qgtkstyle_p.h:400
void(* Ptr_gdk_color_free)(const GdkColor *)
Definition: qgtkstyle_p.h:244
GtkWidget *(* Ptr_gtk_menu_item_new_with_label)(const gchar *)
Definition: qgtkstyle_p.h:147
static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new
Definition: qgtkstyle_p.h:429
static Ptr_gtk_container_get_type gtk_container_get_type
Definition: qgtkstyle_p.h:434
virtual void initGtkWidgets() const
static Ptr_gconf_client_get_bool gconf_client_get_bool
Definition: qgtkstyle_p.h:477
GtkFileFilter *(* Ptr_gtk_file_filter_new)(void)
Definition: qgtkstyle_p.h:224
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
static Ptr_gtk_widget_modify_color gtk_widget_modify_bg
Definition: qgtkstyle_p.h:367
static Ptr_gdk_pixmap_new gdk_pixmap_new
Definition: qgtkstyle_p.h:463
static Ptr_gtk_file_filter_set_name gtk_file_filter_set_name
Definition: qgtkstyle_p.h:447
static QPalette palette()
Returns the application palette.
GtkIconTheme *(* Ptr_gtk_icon_theme_get_default)(void)
Definition: qgtkstyle_p.h:183
void(* Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter)
Definition: qgtkstyle_p.h:227
static bool isKDE4Session()
static Ptr_gtk_paint_arrow gtk_paint_arrow
Definition: qgtkstyle_p.h:420
static Ptr_gtk_paint_option gtk_paint_option
Definition: qgtkstyle_p.h:414
static Ptr_gtk_menu_bar_new gtk_menu_bar_new
Definition: qgtkstyle_p.h:371
GtkWidget *(* Ptr_gtk_statusbar_new)(void)
Definition: qgtkstyle_p.h:175
void * resolve(const char *symbol)
Returns the address of the exported symbol symbol.
Definition: qlibrary.cpp:1155
static Ptr_gtk_menu_shell_append gtk_menu_shell_append
Definition: qgtkstyle_p.h:398
static Ptr_gtk_window_get_type gtk_window_get_type
Definition: qgtkstyle_p.h:435
const char * data() const
Definition: qgtkstyle_p.h:86
void(* Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *)
Definition: qgtkstyle_p.h:214
static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
The QString class provides a Unicode character string.
Definition: qstring.h:83
gint(* Ptr_pango_font_description_get_size)(const PangoFontDescription *)
Definition: qgtkstyle_p.h:219
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
GtkAdjustment *(* Ptr_gtk_range_get_adjustment)(GtkRange *)
Definition: qgtkstyle_p.h:177
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void(* Ptr_gtk_progress_configure)(GtkProgress *, double, double, double)
Definition: qgtkstyle_p.h:179
static void setupGtkFileChooser(GtkWidget *gtkFileChooser, QWidget *parent, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, bool isSaveDialog=false, QMap< GtkFileFilter *, QString > *filterMap=0)
static Ptr_gtk_toolbar_insert gtk_toolbar_insert
Definition: qgtkstyle_p.h:381
Q_GUI_EXPORT QString extensions()
Definition: qegl.cpp:785
void(* Ptr_gtk_paint_hline)(GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y)
Definition: qgtkstyle_p.h:204
GtkType(* Ptr_gtk_window_get_type)(void)
Definition: qgtkstyle_p.h:216
static void addWidgetToMap(GtkWidget *widget)
GtkType(* Ptr_gtk_container_get_type)(void)
Definition: qgtkstyle_p.h:215
static Ptr_gtk_paint_box gtk_paint_box
Definition: qgtkstyle_p.h:411
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new
Definition: qgtkstyle_p.h:408
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static GtkWidget * gtkWidget(const QHashableLatin1Literal &path)
QGtkStylePrivate * stylePrivate
Definition: qgtkstyle_p.h:288
static Ptr_gtk_paint_handle gtk_paint_handle
Definition: qgtkstyle_p.h:421
static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern
Definition: qgtkstyle_p.h:448
NSToolbar * toolbar
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QGtkStyleFilter filter
Definition: qgtkstyle_p.h:321
static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay
Definition: qgtkstyle_p.h:473
static QHashableLatin1Literal fromData(const char *str)
Definition: qgtkstyle_p.h:112
GtkTreeViewColumn *(* Ptr_gtk_tree_view_column_new)(void)
Definition: qgtkstyle_p.h:185
static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label
Definition: qgtkstyle_p.h:368
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void(* Ptr_gtk_paint_shadow)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:194
static Ptr_gtk_widget_style_get gtk_widget_style_get
Definition: qgtkstyle_p.h:405
static Ptr_gtk_paint_extension gtk_paint_extension
Definition: qgtkstyle_p.h:415
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
GtkWidget *(* Ptr_gtk_hscrollbar_new)(GtkAdjustment *)
Definition: qgtkstyle_p.h:164
const char *(* Ptr_pango_font_description_get_family)(const PangoFontDescription *)
Definition: qgtkstyle_p.h:221
static Ptr_pango_font_description_get_size pango_font_description_get_size
Definition: qgtkstyle_p.h:441
static QString getIconThemeName()
static QFont font()
Returns the default application font.
GtkWidget *(* Ptr_gtk_menu_new)(void)
Definition: qgtkstyle_p.h:151
virtual void init()
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
static Ptr_gtk_combo_box_new gtk_combo_box_new
Definition: qgtkstyle_p.h:394
gboolean(* Ptr_gnome_vfs_init)(void)
Definition: qgtkstyle_p.h:305
void(* Ptr_gtk_file_chooser_set_current_name)(GtkFileChooser *, const gchar *)
Definition: qgtkstyle_p.h:237
static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height
Definition: qgtkstyle_p.h:462
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
GtkWidget *(* Ptr_gtk_frame_new)(const gchar *)
Definition: qgtkstyle_p.h:173
static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
GtkWidget *(* Ptr_gtk_expander_new)(const gchar *)
Definition: qgtkstyle_p.h:174
unsigned char uchar
Definition: qglobal.h:994
static Ptr_gtk_dialog_run gtk_dialog_run
Definition: qgtkstyle_p.h:457
static Ptr_gdk_pixbuf_new gdk_pixbuf_new
Definition: qgtkstyle_p.h:464
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static Ptr_gtk_paint_expander gtk_paint_expander
Definition: qgtkstyle_p.h:422
GtkWidget *(* Ptr_gtk_radio_button_new)(GSList *)
Definition: qgtkstyle_p.h:159
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static Ptr_gtk_file_chooser_set_filename gtk_file_chooser_set_filename
Definition: qgtkstyle_p.h:458
static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
void(* Ptr_gtk_paint_vline)(GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint)
Definition: qgtkstyle_p.h:205
static bool isEmpty(const char *str)
static Ptr_gdk_color_free gdk_color_free
Definition: qgtkstyle_p.h:470
static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon
Definition: qgtkstyle_p.h:406
static QStringList extract_filter(const QString &rawFilter)
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
Definition: qregexp.cpp:4136
void(* Ptr_gtk_paint_arrow)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:198
static void removeWidgetFromMap(const QHashableLatin1Literal &path)
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
Definition: qfileinfo.cpp:990
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column
Definition: qgtkstyle_p.h:393
static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths
Definition: qgtkstyle_p.h:437
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
GtkIconSet *(* Ptr_gtk_icon_factory_lookup_default)(const gchar *)
Definition: qgtkstyle_p.h:182
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
#define QLS(x)
Definition: qgtkstyle_p.h:77
static Ptr_gtk_spin_button_new gtk_spin_button_new
Definition: qgtkstyle_p.h:379
static Ptr_gtk_paint_focus gtk_paint_focus
Definition: qgtkstyle_p.h:419
void(* Ptr_gtk_widget_set_default_direction)(GtkTextDirection)
Definition: qgtkstyle_p.h:144
GtkSettings *(* Ptr_gtk_settings_get_default)(void)
Definition: qgtkstyle_p.h:176
void(* Ptr_gtk_paint_resize_grip)(GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:192
const char * name
static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new
Definition: qgtkstyle_p.h:376
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
GtkWidget *(* Ptr_gtk_window_new)(GtkWindowType)
Definition: qgtkstyle_p.h:140
static Ptr_gtk_notebook_new gtk_notebook_new
Definition: qgtkstyle_p.h:390
void(* Ptr_gtk_border_free)(GtkBorder *)
Definition: qgtkstyle_p.h:240
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
GtkType(* Ptr_gtk_widget_get_type)(void)
Definition: qgtkstyle_p.h:217
static void gtkStyleSetCallback(GtkWidget *)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
bool makeAbsolute()
Converts the file&#39;s path to an absolute path if it is not already in that form.
Definition: qfileinfo.cpp:659
void(* Ptr_gdk_x11_window_set_user_time)(GdkWindow *window, guint32)
Definition: qgtkstyle_p.h:258
static void clear()
Removes all pixmaps from the cache.
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468
GtkWidget *(* Ptr_gtk_vscrollbar_new)(GtkAdjustment *)
Definition: qgtkstyle_p.h:165
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
void(* Ptr_gtk_paint_handle)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkOrientation)
Definition: qgtkstyle_p.h:197
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
uint qHash(const QHashableLatin1Literal &key)
static Ptr_gtk_button_new gtk_button_new
Definition: qgtkstyle_p.h:374
Q_CORE_EXPORT void qWarning(const char *,...)
GtkWidget *(* Ptr_gtk_check_menu_item_new_with_label)(const gchar *)
Definition: qgtkstyle_p.h:149
GtkWidget *(* Ptr_gtk_progress_bar_new)(void)
Definition: qgtkstyle_p.h:161
unsigned int uint
Definition: qglobal.h:996
static void addWidget(GtkWidget *widget)
static QString getGConfString(const QString &key, const QString &fallback=QString())
static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels
Definition: qgtkstyle_p.h:460
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static Ptr_gtk_paint_shadow gtk_paint_shadow
Definition: qgtkstyle_p.h:417
GSList *(* Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser)
Definition: qgtkstyle_p.h:231
int(* Ptr_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf)
Definition: qgtkstyle_p.h:243
void(* Ptr_gtk_container_forall)(GtkContainer *, GtkCallback, gpointer)
Definition: qgtkstyle_p.h:207
static Ptr_gtk_adjustment_new gtk_adjustment_new
Definition: qgtkstyle_p.h:424
GdkPixbuf *(* Ptr_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
Definition: qgtkstyle_p.h:246
void(* Ptr_gtk_tree_view_append_column)(GtkTreeView *, GtkTreeViewColumn *)
Definition: qgtkstyle_p.h:188
static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time
Definition: qgtkstyle_p.h:471
void(* Ptr_gtk_menu_item_set_submenu)(GtkMenuItem *, GtkWidget *)
Definition: qgtkstyle_p.h:206
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static Ptr_gtk_widget_realize gtk_widget_realize
Definition: qgtkstyle_p.h:364
bool(* Ptr_gconf_client_get_bool)(GConfClient *, const char *, GError **)
Definition: qgtkstyle_p.h:137
static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new
Definition: qgtkstyle_p.h:387
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
virtual GtkWidget * getTextColorWidget() const
static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column
Definition: qgtkstyle_p.h:409
void(* Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name,...)
Definition: qgtkstyle_p.h:184
int(* x11ErrorHandler)(Display *, XErrorEvent *)
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
void(* Ptr_gtk_paint_check)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:189
virtual void resolveGtk() const
gboolean(* Ptr_gtk_file_chooser_set_current_folder)(GtkFileChooser *, const gchar *)
Definition: qgtkstyle_p.h:223
static Ptr_gtk_widget_size_request gtk_widget_size_request
Definition: qgtkstyle_p.h:431
static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter
Definition: qgtkstyle_p.h:449
virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
static Ptr_gtk_radio_button_new gtk_radio_button_new
Definition: qgtkstyle_p.h:378
static Ptr_gtk_statusbar_new gtk_statusbar_new
Definition: qgtkstyle_p.h:383
static Ptr_gtk_check_version gtk_check_version
Definition: qgtkstyle_p.h:438
static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment
Definition: qgtkstyle_p.h:401
static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new
Definition: qgtkstyle_p.h:388
static Ptr_gtk_paint_flat_box gtk_paint_flat_box
Definition: qgtkstyle_p.h:413
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
static Ptr_gtk_paint_box_gap gtk_paint_box_gap
Definition: qgtkstyle_p.h:412
static Ptr_gtk_paint_hline gtk_paint_hline
Definition: qgtkstyle_p.h:426
gboolean(* Ptr_gtk_file_chooser_set_filename)(GtkFileChooser *chooser, const gchar *name)
Definition: qgtkstyle_p.h:238
static QIcon getFilesystemIcon(const QFileInfo &)
static QIconLoader * instance()
static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new
Definition: qgtkstyle_p.h:380
GtkWidget *(* Ptr_gtk_separator_menu_item_new)(void)
Definition: qgtkstyle_p.h:148
static Ptr_gtk_border_free gtk_border_free
Definition: qgtkstyle_p.h:439
static void cleanupGtkWidgets()
static Ptr_gtk_container_forall gtk_container_forall
Definition: qgtkstyle_p.h:359
void(* Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *)
Definition: qgtkstyle_p.h:178
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default
Definition: qgtkstyle_p.h:403
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip
Definition: qgtkstyle_p.h:418
GtkTreeViewColumn *(* Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint)
Definition: qgtkstyle_p.h:171
static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction
Definition: qgtkstyle_p.h:365
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
gchar *(* Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser)
Definition: qgtkstyle_p.h:230
void(* Ptr_gdk_pixbuf_unref)(GdkPixbuf *)
Definition: qgtkstyle_p.h:255
static const char *const filters[3]
struct _XDisplay Display
Definition: qwindowdefs.h:115
static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label
Definition: qgtkstyle_p.h:370
static QFont getThemeFont()
static Ptr_gtk_frame_new gtk_frame_new
Definition: qgtkstyle_p.h:382
GtkWidget *(* Ptr_gtk_hbutton_box_new)(void)
Definition: qgtkstyle_p.h:157
void(* Ptr_gtk_paint_flat_box)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:200
QString & append(QChar c)
Definition: qstring.cpp:1777
GtkWidget *(* Ptr_gtk_combo_box_new)(void)
Definition: qgtkstyle_p.h:172
GtkWidget *(* Ptr_gtk_spin_button_new)(GtkAdjustment *, double, int)
Definition: qgtkstyle_p.h:154
static Ptr_gtk_check_button_new gtk_check_button_new
Definition: qgtkstyle_p.h:377
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
static Ptr_gtk_settings_get_default gtk_settings_get_default
Definition: qgtkstyle_p.h:428
static Ptr_gtk_widget_modify_color gtk_widget_modify_fg
Definition: qgtkstyle_p.h:366
static Ptr_gtk_adjustment_configure gtk_adjustment_configure
Definition: qgtkstyle_p.h:423
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter
Definition: qgtkstyle_p.h:450
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync
Definition: qgtkstyle_p.h:479
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void updateSystemTheme()
void(* Ptr_gtk_paint_expander)(GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, GtkExpanderStyle)
Definition: qgtkstyle_p.h:196
GtkStyle *(* Ptr_gtk_rc_get_style_by_paths)(GtkSettings *, const char *, const char *, GType)
Definition: qgtkstyle_p.h:218
GtkWidget *(* Ptr_gtk_tree_view_new)(void)
Definition: qgtkstyle_p.h:170
static Ptr_gtk_vscale_new gtk_vscale_new
Definition: qgtkstyle_p.h:386
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
GtkWidget *(* Ptr_gtk_scrolled_window_new)(GtkAdjustment *, GtkAdjustment *)
Definition: qgtkstyle_p.h:166
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static GtkStyle * gtkStyle(const QHashableLatin1Literal &path=QHashableLatin1Literal("GtkWindow"))
int key
static Ptr_gtk_progress_configure gtk_progress_configure
Definition: qgtkstyle_p.h:399
static QString getThemeName()
void(* Ptr_gtk_init)(int *, char ***)
Definition: qgtkstyle_p.h:139
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static void addAllSubWidgets(GtkWidget *widget, gpointer v=0)
gint(* Ptr_gtk_dialog_run)(GtkDialog *)
Definition: qgtkstyle_p.h:239
GtkWidget *(* Ptr_gtk_toolbar_new)(void)
Definition: qgtkstyle_p.h:153
static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
void setWeight(int)
Sets the weight the font to weight, which should be a value from the QFont::Weight enumeration...
Definition: qfont.cpp:1278
void(* Ptr_gtk_paint_extension)(GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType)
Definition: qgtkstyle_p.h:201
static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder
Definition: qgtkstyle_p.h:453
static Ptr_pango_font_description_get_weight pango_font_description_get_weight
Definition: qgtkstyle_p.h:442
GtkToolItem *(* Ptr_gtk_separator_tool_item_new)(void)
Definition: qgtkstyle_p.h:168
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
static bool resolveGConf()
void(* Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget)
Definition: qgtkstyle_p.h:181
static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref
Definition: qgtkstyle_p.h:467
static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
static void setSystemPalette(const QPalette &pal)
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
void setLoadHints(LoadHints hints)
Definition: qlibrary.cpp:1304
quint16 index
static Ptr_gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames
Definition: qgtkstyle_p.h:455
void(* Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color)
Definition: qgtkstyle_p.h:145
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
Display *(* Ptr_gdk_x11_drawable_get_xdisplay)(GdkDrawable *)
Definition: qgtkstyle_p.h:260
GtkWidget *(* Ptr_gtk_entry_new)(void)
Definition: qgtkstyle_p.h:169
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374
GtkWidget *(* Ptr_gtk_button_new)(void)
Definition: qgtkstyle_p.h:155
virtual void initGtkTreeview() const
static Ptr_gtk_tool_button_new gtk_tool_button_new
Definition: qgtkstyle_p.h:375
static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu
Definition: qgtkstyle_p.h:427
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
GtkFileFilter *(* Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser)
Definition: qgtkstyle_p.h:229
static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable
Definition: qgtkstyle_p.h:465
static Ptr_gtk_hscale_new gtk_hscale_new
Definition: qgtkstyle_p.h:385
virtual void initGtkMenu() const
GdkPixmap *(* Ptr_gdk_pixmap_new)(GdkDrawable *drawable, gint width, gint height, gint depth)
Definition: qgtkstyle_p.h:250
static Ptr_gdk_drawable_unref gdk_drawable_unref
Definition: qgtkstyle_p.h:468
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
static Ptr_gtk_toolbar_new gtk_toolbar_new
Definition: qgtkstyle_p.h:391
GtkWidget *(* Ptr_gtk_check_button_new)(void)
Definition: qgtkstyle_p.h:158
static Ptr_gtk_init gtk_init
Definition: qgtkstyle_p.h:360
bool atEnd() const
Returns true if there is no more data to be read from the QTextStream; otherwise returns false...
static Ptr_gtk_paint_slider gtk_paint_slider
Definition: qgtkstyle_p.h:416
static Ptr_gnome_vfs_init gnome_vfs_init
Definition: qgtkstyle_p.h:480
static QHashableLatin1Literal classPath(GtkWidget *widget)
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
QStringList qt_make_filter_list(const QString &filter)
void applyCustomPaletteHash()
void(* Ptr_gtk_widget_set_direction)(GtkWidget *, GtkTextDirection)
Definition: qgtkstyle_p.h:210
static Ptr_gtk_container_add gtk_container_add
Definition: qgtkstyle_p.h:397
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)
Definition: qgtkstyle_p.h:191
void(* Ptr_gtk_toolbar_insert)(GtkToolbar *toolbar, GtkToolItem *item, int pos)
Definition: qgtkstyle_p.h:213
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
PaletteHash * qt_app_palettes_hash()
void(* Ptr_gtk_paint_focus)(GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint)
Definition: qgtkstyle_p.h:193
static Ptr_gtk_arrow_new gtk_arrow_new
Definition: qgtkstyle_p.h:369
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
gint(* Ptr_gdk_drawable_get_depth)(GdkDrawable *)
Definition: qgtkstyle_p.h:257
#define qPrintable(string)
Definition: qglobal.h:1750
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
GtkWidget *(* Ptr_gtk_fixed_new)(void)
Definition: qgtkstyle_p.h:186
GdkPixbuf *(* Ptr_gdk_pixbuf_new)(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height)
Definition: qgtkstyle_p.h:251
static void leaveModal(QWidget *)
static WidgetMap * gtkWidgetMap()
Definition: qgtkstyle_p.h:494
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void(* Ptr_gtk_widget_size_request)(GtkWidget *widget, GtkRequisition *requisition)
Definition: qgtkstyle_p.h:209
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
QString absolutePath() const
Returns a file&#39;s path absolute path.
Definition: qfileinfo.cpp:577
GtkWidget *(* Ptr_gtk_notebook_new)(void)
Definition: qgtkstyle_p.h:160
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827
static bool getGConfBool(const QString &key, bool fallback=0)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void setStyle(Style style)
Sets the style of the font to style.
Definition: qfont.cpp:1234
static void enterModal(QWidget *)
void(* Ptr_gtk_widget_destroy)(GtkWidget *)
Definition: qgtkstyle_p.h:142
static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default
Definition: qgtkstyle_p.h:404
static void setupGtkWidget(GtkWidget *widget)
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
void(* Ptr_gtk_range_set_inverted)(GtkRange *, bool)
Definition: qgtkstyle_p.h:180
static Ptr_gtk_file_chooser_set_current_name gtk_file_chooser_set_current_name
Definition: qgtkstyle_p.h:456
guchar *(* Ptr_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf)
Definition: qgtkstyle_p.h:242
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62
void(* Ptr_gtk_widget_path)(GtkWidget *, guint *, gchar **, gchar **)
Definition: qgtkstyle_p.h:211
GConfClient *(* Ptr_gconf_client_get_default)()
Definition: qgtkstyle_p.h:135
GtkWidget *(* Ptr_gtk_hscale_new)(GtkAdjustment *)
Definition: qgtkstyle_p.h:162
static QMenuBar * fallback
Definition: qmenu_mac.mm:1617
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static Ptr_pango_font_description_get_family pango_font_description_get_family
Definition: qgtkstyle_p.h:443
static Ptr_gtk_tree_view_new gtk_tree_view_new
Definition: qgtkstyle_p.h:392
static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new
Definition: qgtkstyle_p.h:452
GtkWidget *(* Ptr_gtk_menu_bar_new)(void)
Definition: qgtkstyle_p.h:150
void(* Ptr_gtk_widget_realize)(GtkWidget *)
Definition: qgtkstyle_p.h:143
void(* Ptr_gtk_adjustment_configure)(GtkAdjustment *, double, double, double, double, double, double)
Definition: qgtkstyle_p.h:202
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
void(* Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *)
Definition: qgtkstyle_p.h:225