Remove gtk2 style from qtbase, it will be moved to qtstyleplugins

This will allow us to drop gtk2 support from qtbase in future,
while still providing the gtk2 style for those who want to use it.

Also with moving to qtstyleplugins, the code can be simplified
because we can directly link to libraries we need, instead of using
QLibrary.

[ChangeLog][QtWidgets] Remove QGtkStyle, it is now provided in
qtstyleplugins repository.

Change-Id: I6221b1a513d7fda32e080f3ca159b0b2f8a8f246
Reviewed-by: Timo Jyrinki <timo.jyrinki@canonical.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com>
This commit is contained in:
Dmitry Shachnev 2015-07-30 21:32:43 +03:00 committed by Simon Hausmann
parent 15c608fb12
commit 899a815414
49 changed files with 19 additions and 7016 deletions

31
configure vendored
View File

@ -700,7 +700,7 @@ CFG_CUPS=auto
CFG_ICONV=auto
CFG_DBUS=auto
CFG_GLIB=auto
CFG_QGTKSTYLE=auto
CFG_GTK=auto
CFG_LARGEFILE=auto
CFG_OPENSSL=auto
CFG_LIBPROXY=auto
@ -1958,9 +1958,9 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
gtkstyle)
gtk)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_QGTKSTYLE="$VAL"
CFG_GTK="$VAL"
else
UNKNOWN_OPT=yes
fi
@ -2553,8 +2553,8 @@ Third Party Libraries:
-no-alsa ............ Do not compile ALSA support.
+ -alsa ............... Compile ALSA support.
-no-gtkstyle ........ Do not compile GTK theme support.
+ -gtkstyle ........... Compile GTK theme support.
-no-gtk ............. Do not compile GTK platform theme support.
+ -gtk ................ Compile GTK platform theme support.
Additional options:
@ -3373,7 +3373,7 @@ fi
# disable XCB and GTK support auto-detection on Mac
if [ "$XPLATFORM_MAC" = "yes" ]; then
[ "$CFG_XCB" = "auto" ] && CFG_XCB=no
[ "$CFG_QGTKSTYLE" = "auto" ] && CFG_QGTKSTYLE=no
[ "$CFG_GTK" = "auto" ] && CFG_GTK=no
fi
QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`
@ -5041,33 +5041,31 @@ if [ "$CFG_GLIB" != "no" ]; then
fi
# auto-detect GTK style support
if [ "$CFG_GLIB" = "yes" -a "$CFG_QGTKSTYLE" != "no" ]; then
if [ "$CFG_GLIB" = "yes" -a "$CFG_GTK" != "no" ]; then
if [ -n "$PKG_CONFIG" ]; then
QT_CFLAGS_QGTK2=`$PKG_CONFIG --cflags gtk+-2.0 ">=" 2.18 atk 2>/dev/null`
QT_LIBS_QGTK2=`$PKG_CONFIG --libs gtk+-2.0 2>/dev/null`
QT_LIBS_QGOBJECT=`$PKG_CONFIG --libs gobject-2.0 2>/dev/null`
fi
if [ -n "$QT_CFLAGS_QGTK2" ] ; then
CFG_QGTKSTYLE=yes
QT_CONFIG="$QT_CONFIG gtk2 gtkstyle"
QMakeVar set QT_CFLAGS_QGTKSTYLE "$QT_CFLAGS_QGTK2"
QMakeVar set QT_LIBS_QGTKSTYLE "$QT_LIBS_QGOBJECT"
CFG_GTK=yes
QT_CONFIG="$QT_CONFIG gtk2"
QMakeVar set QT_CFLAGS_QGTK2 "$QT_CFLAGS_QGTK2"
QMakeVar set QT_LIBS_QGTK2 "$QT_LIBS_QGTK2"
else
if [ "$CFG_QGTKSTYLE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
if [ "$CFG_GTK" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
echo "GTK theme support cannot be enabled due to functionality tests!"
[ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
echo " Turn on verbose messaging (-v) to $0 to see the fin al report."
echo " Turn on verbose messaging (-v) to $0 to see the final report."
echo " If you believe this message is in error you may use the continue"
echo " switch (-continue) to $0 to continue."
exit 101
else
CFG_QGTKSTYLE=no
CFG_GTK=no
fi
fi
elif [ "$CFG_GLIB" = "no" ]; then
CFG_QGTKSTYLE=no
CFG_GTK=no
fi
# auto-detect libicu support
@ -6686,7 +6684,6 @@ QMakeVar set sql-plugins "$SQL_PLUGINS"
[ "$CFG_ICONV" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ICONV"
[ "$CFG_EVDEV" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EVDEV"
[ "$CFG_GLIB" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GLIB"
[ "$CFG_QGTKSTYLE" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_GTK"
[ "$CFG_CLOCK_MONOTONIC" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CLOCK_MONOTONIC"
[ "$CFG_POSIX_FALLOCATE" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_POSIX_FALLOCATE"
[ "$CFG_MREMAP" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MREMAP"
@ -7129,7 +7126,7 @@ report_support " FontConfig ............." "$CFG_FONTCONFIG"
report_support " FreeType ..............." "$CFG_FREETYPE" system "system library" yes "bundled copy"
report_support " Glib ..................." "$CFG_GLIB"
report_support " GStreamer .............." "$CFG_GSTREAMER" yes "$CFG_GSTREAMER_VERSION"
report_support " GTK theme .............." "$CFG_QGTKSTYLE"
report_support " GTK platformtheme ......" "$CFG_GTK"
report_support " HarfBuzz ..............." "$CFG_HARFBUZZ" system "system library" qt "bundled copy"
report_support " Iconv .................." "$CFG_ICONV"
report_support " ICU ...................." "$CFG_ICU"

View File

@ -11,7 +11,7 @@
# export PATH=/opt/imx53qsb/x86_64-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi:$PATH
#
# ./configure -prefix /usr/local/qt5-imx53 -hostprefix /opt/imx53qsb/x86_64-linux/usr/local/qt5-imx53 -release -device linux-imx53qsb-g++
# -opensource -confirm-license -no-gtkstyle -device-option CROSS_COMPILE=arm-poky-linux-gnueabi- -sysroot /opt/imx53qsb/sysroot
# -opensource -confirm-license -device-option CROSS_COMPILE=arm-poky-linux-gnueabi- -sysroot /opt/imx53qsb/sysroot
# -eglfs -no-pch -opengl es2 -no-xcb -silent
include(../common/linux_device_pre.conf)

View File

@ -602,7 +602,7 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(QGenericUnixTheme::xdgIconThemePaths());
case QPlatformTheme::StyleNames: {
QStringList styleNames;
styleNames << QStringLiteral("GTK+") << QStringLiteral("fusion") << QStringLiteral("windows");
styleNames << QStringLiteral("fusion") << QStringLiteral("windows");
return QVariant(styleNames);
}
case QPlatformTheme::KeyboardScheme:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -1,142 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page gallery-gtk.html
\title GTK Style Widget Gallery
\ingroup gallery
This page shows some of the widgets available in Qt
when configured to use the "gtk" style. This style is
only available on desktop environments with GTK runtime
support. This style provides native look'n'feel by
integrating to the GTK platform theme. Thus, the final
appearance varies depending on the active GTK theme.
\section2 Buttons
\table 100%
\row
\li \image gtk-pushbutton.png
\caption The QPushButton widget provides a command button.
\li \image gtk-toolbutton.png
\caption The QToolButton class provides a quick-access button to commands
or options, usually used inside a QToolBar.
\endtable
\table 100%
\row
\li \image gtk-checkbox.png
\caption The QCheckBox widget provides a checkbox with a text label.
\li \image gtk-radiobutton.png
\caption The QRadioButton widget provides a radio button with a text or pixmap label.
\endtable
\section2 Containers
\table 100%
\row
\li \image gtk-groupbox.png
The QGroupBox widget provides a group box frame with a title.
\li \image gtk-tabwidget.png
The QTabWidget class provides a stack of tabbed widgets.
\li \image gtk-frame.png
The QFrame widget provides a simple decorated container for other widgets.
\li \image gtk-toolbox.png
The QToolBox class provides a column of tabbed widget items.
\endtable
\section2 Item Views
\table 100%
\row
\li \image gtk-listview.png
The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
\li \image gtk-treeview.png
The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
\li \image gtk-tableview.png
The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
\li
\endtable
\section2 Display Widgets
\table 100%
\row
\li \image gtk-progressbar.png
The QProgressBar widget provides a horizontal progress bar.
\li \image gtk-label.png
The QLabel widget provides a text or image display.
\li \image gtk-lcdnumber.png
The QLCDNumber widget displays a number with LCD-like digits.
\endtable
\section2 Input Widgets
\table 100%
\row
\li \image gtk-lineedit.png
The QLineEdit widget is a one-line text editor.
\li \image gtk-dateedit.png
The QDateEdit class provides a widget for editing dates.
\li \image gtk-timeedit.png
The QTimeEdit class provides a widget for editing times.
\li \image gtk-datetimeedit.png
The QDateTimeEdit class provides a widget for editing dates and times.
\endtable
\table 100%
\row
\li \image gtk-slider.png
The QSlider widget provides a vertical or horizontal slider.
\li \image gtk-combobox.png
The QComboBox widget is a combined button and pop-up list.
\li \image gtk-spinbox.png
The QSpinBox class provides a spin box widget.
\endtable
\table 100%
\row
\li \image gtk-fontcombobox.png
The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
\li \image gtk-doublespinbox.png
The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
\li \image gtk-horizontalscrollbar.png
The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
\endtable
\table 100%
\row
\li \image gtk-dial.png
The QDial class provides a rounded range control (like a speedometer or potentiometer).
\li \image gtk-textedit.png
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
\li \image gtk-calendarwidget.png
The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
\endtable
*/

View File

@ -54,10 +54,6 @@
\caption \l{Macintosh Style Widget Gallery}
The Macintosh style is provided by QMacStyle.
\li \image gtk-tabwidget.png GTK Style Widget Gallery
\caption \l{GTK Style Widget Gallery}
The GTK style is provided by QGtkStyle.
\li \image fusion-tabwidget.png Fusion Style Widget Gallery
\caption \l{Fusion Style Widget Gallery}

View File

@ -38,7 +38,7 @@
native widgets.
Qt comes with a selection of built-in styles. Some styles are only
available on specific platforms (such as the Mac, GTK+ and Windows
available on specific platforms (such as the Mac and Windows
Vista styles). Custom styles are made available as plugins or by
creating an instance of a specific style class with
QStyleFactory::create() and setting it with QApplication::setStyle().

View File

@ -52,10 +52,6 @@
# endif
#endif
#if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
# include <private/qgtkstyle_p_p.h>
#endif
QT_BEGIN_NAMESPACE
static bool isCacheable(const QFileInfo &fi);
@ -358,15 +354,6 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const
{
Q_D(const QFileIconProvider);
#if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment();
if (desktopEnvironment != QByteArrayLiteral("KDE")) {
QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
if (!gtkIcon.isNull())
return gtkIcon;
}
#endif
QIcon retIcon = d->getIcon(info);
if (!retIcon.isNull())
return retIcon;

View File

@ -1,699 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qgtk2painter_p.h"
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
// This class is primarily a wrapper around the gtk painter functions
// and takes care of converting all such calls into cached Qt pixmaps.
#include <private/qgtkstyle_p_p.h>
#include <private/qhexstring_p.h>
#include <QtWidgets/QWidget>
#include <QtGui/QPixmapCache>
#include <QtCore/QLibrary>
QT_BEGIN_NAMESPACE
typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *, GdkDrawable *, GdkColormap *, int, int, int, int, int, int);
typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *, gint, gint, gint);
typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *, GdkGC *, gboolean, gint, gint, gint, gint);
typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
typedef void (*Ptr_gtk_paint_check) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint, gint);
typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_focus) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_shadow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_slider) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
typedef void (*Ptr_gtk_paint_expander) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
typedef void (*Ptr_gtk_paint_handle) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
typedef void (*Ptr_gtk_paint_arrow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_option) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
namespace QGtk2PainterPrivate {
static Ptr_gdk_pixmap_new gdk_pixmap_new = 0;
static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable = 0;
static Ptr_gdk_draw_rectangle gdk_draw_rectangle = 0;
static Ptr_gdk_drawable_unref gdk_drawable_unref = 0;
static Ptr_gtk_paint_check gtk_paint_check = 0;
static Ptr_gtk_paint_box gtk_paint_box = 0;
static Ptr_gtk_paint_box_gap gtk_paint_box_gap = 0;
static Ptr_gtk_paint_flat_box gtk_paint_flat_box = 0;
static Ptr_gtk_paint_option gtk_paint_option = 0;
static Ptr_gtk_paint_extension gtk_paint_extension = 0;
static Ptr_gtk_paint_slider gtk_paint_slider = 0;
static Ptr_gtk_paint_shadow gtk_paint_shadow = 0;
static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip = 0;
static Ptr_gtk_paint_focus gtk_paint_focus = 0;
static Ptr_gtk_paint_arrow gtk_paint_arrow = 0;
static Ptr_gtk_paint_handle gtk_paint_handle = 0;
static Ptr_gtk_paint_expander gtk_paint_expander = 0;
static Ptr_gtk_paint_vline gtk_paint_vline = 0;
static Ptr_gtk_paint_hline gtk_paint_hline = 0;
}
static void initGtk()
{
#ifndef QT_NO_LIBRARY
static bool initialized = false;
if (!initialized) {
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
QGtk2PainterPrivate::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
QGtk2PainterPrivate::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
QGtk2PainterPrivate::gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
QGtk2PainterPrivate::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
QGtk2PainterPrivate::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
QGtk2PainterPrivate::gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
QGtk2PainterPrivate::gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
QGtk2PainterPrivate::gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
QGtk2PainterPrivate::gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
QGtk2PainterPrivate::gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
QGtk2PainterPrivate::gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
QGtk2PainterPrivate::gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
QGtk2PainterPrivate::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
QGtk2PainterPrivate::gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
QGtk2PainterPrivate::gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
QGtk2PainterPrivate::gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
initialized = true;
}
#endif // !QT_NO_LIBRARY
}
// To recover alpha we apply the gtk painting function two times to
// white, and black window backgrounds. This can be used to
// recover the premultiplied alpha channel
QPixmap QGtk2Painter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const
{
const int bytecount = rect.width() * rect.height() * 4;
for (int index = 0; index < bytecount ; index += 4) {
uchar val = bdata[index + GTK_BLUE];
if (m_alpha) {
int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
bdata[index + QT_ALPHA] = alphaval;
}
bdata[index + QT_RED] = bdata[index + GTK_RED];
bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
bdata[index + QT_BLUE] = val;
}
QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
if (m_hflipped || m_vflipped) {
return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
} else {
// on raster graphicssystem we need to do a copy here, because
// we intend to deallocate the qimage bits shortly after...
return QPixmap::fromImage(converted.copy());
}
}
// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
#define DRAW_TO_CACHE(draw_func) \
if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
return; \
QRect pixmapRect(0, 0, rect.width(), rect.height()); \
{ \
GdkPixmap *pixmap = QGtk2PainterPrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
rect.width(), rect.height(), -1); \
if (!pixmap) \
return; \
style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, \
true, 0, 0, rect.width(), rect.height()); \
draw_func; \
GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
rect.width(), rect.height()); \
if (!imgb) \
return; \
imgb = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
rect.width(), rect.height()); \
uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
if (m_alpha) { \
QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, \
rect.width(), rect.height()); \
draw_func; \
GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
rect.width(), rect.height()); \
if (!imgw) \
return; \
imgw = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0,\
rect.width(), rect.height()); \
uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
cache = renderTheme(bdata, wdata, rect); \
QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
} else { \
cache = renderTheme(bdata, 0, rect); \
} \
QGtk2PainterPrivate::gdk_drawable_unref(pixmap); \
QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
}
QGtk2Painter::QGtk2Painter() : QGtkPainter(), m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
{
initGtk();
}
// Note currently painted without alpha for performance reasons
void QGtk2Painter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
const QRect &paintRect, GtkStateType state,
GtkShadowType shadow, GtkPositionType gap_side,
gint x, gint width,
GtkStyle *style)
{
if (!paintRect.isValid())
return;
QPixmap cache;
QRect rect = paintRect;
// To avoid exhausting cache on large tabframes we cheat a bit by
// tiling the center part.
const int maxHeight = 256;
const int border = 16;
if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
rect.setHeight(2 * border + 1);
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
% HexString<uchar>(gap_side)
% HexString<gint>(width)
% HexString<gint>(x);
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box_gap (style,
pixmap,
state,
shadow,
NULL,
gtkWidget,
(const gchar*)part,
0, 0,
rect.width(),
rect.height(),
gap_side,
x,
width));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
if (rect.size() != paintRect.size()) {
// We assume we can stretch the middle tab part
// Note: the side effect of this is that pinstripe patterns will get fuzzy
const QSize size = cache.size();
// top part
m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
paintRect.width(), border), cache,
QRect(0, 0, size.width(), border));
// tiled center part
QPixmap tilePart(cache.width(), 1);
QPainter scanLinePainter(&tilePart);
scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
scanLinePainter.end();
m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
paintRect.width(), paintRect.height() - 2*border), tilePart);
// bottom part
m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
paintRect.width(), border), cache,
QRect(0, size.height() - border, size.width(), border));
} else
m_painter->drawPixmap(paintRect.topLeft(), cache);
}
void QGtk2Painter::paintBox(GtkWidget *gtkWidget, const gchar* part,
const QRect &paintRect, GtkStateType state,
GtkShadowType shadow, GtkStyle *style,
const QString &pmKey)
{
if (!paintRect.isValid())
return;
QPixmap cache;
QRect rect = paintRect;
// To avoid exhausting cache on large tabframes we cheat a bit by
// tiling the center part.
const int maxHeight = 256;
const int maxArea = 256*512;
const int border = 32;
if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
rect.setHeight(2 * border + 1);
QString pixmapName = uniqueName(QLS(part), state, shadow,
rect.size(), gtkWidget) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box (style,
pixmap,
state,
shadow,
NULL,
gtkWidget,
part,
0, 0,
rect.width(),
rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
if (rect.size() != paintRect.size()) {
// We assume we can stretch the middle tab part
// Note: the side effect of this is that pinstripe patterns will get fuzzy
const QSize size = cache.size();
// top part
m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
paintRect.width(), border), cache,
QRect(0, 0, size.width(), border));
// tiled center part
QPixmap tilePart(cache.width(), 1);
QPainter scanLinePainter(&tilePart);
scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
scanLinePainter.end();
m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
paintRect.width(), paintRect.height() - 2*border), tilePart);
// bottom part
m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
paintRect.width(), border), cache,
QRect(0, size.height() - border, size.width(), border));
} else
m_painter->drawPixmap(paintRect.topLeft(), cache);
}
void QGtk2Painter::paintHline(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkStyle *style, int x1, int x2, int y,
const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
% HexString<int>(x1)
% HexString<int>(x2)
% HexString<int>(y)
% pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_hline (style,
pixmap,
state,
NULL,
gtkWidget,
part,
x1, x2, y));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintVline(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkStyle *style, int y1, int y2, int x,
const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
% HexString<int>(y1)
% HexString<int>(y2)
% HexString<int>(x)
% pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_vline (style,
pixmap,
state,
NULL,
gtkWidget,
part,
y1, y2,
x));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintExpander(GtkWidget *gtkWidget,
const gchar* part, const QRect &rect,
GtkStateType state, GtkExpanderStyle expander_state,
GtkStyle *style, const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
% HexString<uchar>(expander_state)
% pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_expander (style, pixmap,
state, NULL,
gtkWidget, part,
rect.width()/2,
rect.height()/2,
expander_state));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkStyle *style, const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_focus (style, pixmap, state, NULL,
gtkWidget,
part,
0, 0,
rect.width(),
rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkShadowType shadow, GdkWindowEdge edge,
GtkStyle *style, const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_resize_grip (style, pixmap, state,
NULL, gtkWidget,
part, edge, 0, 0,
rect.width(),
rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
const QRect &arrowrect, GtkArrowType arrow_type,
GtkStateType state, GtkShadowType shadow,
gboolean fill, GtkStyle *style, const QString &pmKey)
{
QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
% HexString<uchar>(arrow_type)
% pmKey;
GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_arrow (style, pixmap, state, shadow,
&gtkCliprect,
gtkWidget,
part,
arrow_type, fill,
xOffset, yOffset,
arrowrect.width(),
arrowrect.height()))
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow,
GtkOrientation orientation, GtkStyle *style)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
% HexString<uchar>(orientation);
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_handle (style,
pixmap,
state,
shadow,
NULL,
gtkWidget,
part, 0, 0,
rect.width(),
rect.height(),
orientation));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow,
GtkStyle *style, GtkOrientation orientation,
const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_slider (style,
pixmap,
state,
shadow,
NULL,
gtkWidget,
part,
0, 0,
rect.width(),
rect.height(),
orientation));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkShadowType shadow, GtkStyle *style,
const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
gtkWidget, part, 0, 0, rect.width(), rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state,
GtkShadowType shadow, GtkStyle *style,
const QString &pmKey)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_flat_box (style,
pixmap,
state,
shadow,
NULL,
gtkWidget,
part, 0, 0,
rect.width(),
rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintExtention(GtkWidget *gtkWidget,
const gchar *part, const QRect &rect,
GtkStateType state, GtkShadowType shadow,
GtkPositionType gap_pos, GtkStyle *style)
{
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
% HexString<uchar>(gap_pos);
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_extension (style, pixmap, state, shadow,
NULL, gtkWidget,
(const gchar*)part, 0, 0,
rect.width(),
rect.height(),
gap_pos));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
GtkStateType state, GtkShadowType shadow,
GtkStyle *style, const QString &detail)
{
QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(detail, state, shadow, rect.size());
GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_option(style, pixmap,
state, shadow,
&gtkCliprect,
gtkWidget,
detail.toLatin1(),
xOffset, yOffset,
radiorect.width(),
radiorect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
void QGtk2Painter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
GtkStateType state, GtkShadowType shadow,
GtkStyle *style, const QString &detail)
{
QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
if (!rect.isValid())
return;
QPixmap cache;
QString pixmapName = uniqueName(detail, state, shadow, rect.size());
GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_check (style,
pixmap,
state,
shadow,
&gtkCliprect,
gtkWidget,
detail.toLatin1(),
xOffset, yOffset,
checkrect.width(),
checkrect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
}
m_painter->drawPixmap(rect.topLeft(), cache);
}
QT_END_NAMESPACE
#endif //!defined(QT_NO_STYLE_GTK)

View File

@ -1,100 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGTK2PAINTER_P_H
#define QGTK2PAINTER_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
#include <private/qgtkpainter_p.h>
QT_BEGIN_NAMESPACE
class QGtk2Painter : public QGtkPainter
{
public:
QGtk2Painter();
void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
gint width, GtkStyle *style) Q_DECL_OVERRIDE;
void paintBox(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
int x1, int x2, int y, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
int y1, int y2, int x, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
gboolean fill, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) Q_DECL_OVERRIDE;
void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) Q_DECL_OVERRIDE;
void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkPositionType gap_pos, GtkStyle *style) Q_DECL_OVERRIDE;
void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE;
void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE;
private:
QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const;
GtkWidget *m_window;
};
QT_END_NAMESPACE
#endif //!defined(QT_NO_STYLE_QGTK)
#endif // QGTK2PAINTER_P_H

View File

@ -1,82 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGTKGLOBAL_P_H
#define QGTKGLOBAL_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
#undef signals // Collides with GTK symbols
#include <gtk/gtk.h>
typedef unsigned long XID;
#undef GTK_OBJECT_FLAGS
#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
#define QLS(x) QLatin1String(x)
QT_BEGIN_NAMESPACE
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
# define QT_RED 3
# define QT_GREEN 2
# define QT_BLUE 1
# define QT_ALPHA 0
#else
# define QT_RED 0
# define QT_GREEN 1
# define QT_BLUE 2
# define QT_ALPHA 3
#endif
# define GTK_RED 2
# define GTK_GREEN 1
# define GTK_BLUE 0
# define GTK_ALPHA 3
QT_END_NAMESPACE
#endif // !QT_NO_STYLE_GTK
#endif // QGTKGLOBAL_P_H

View File

@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qgtkpainter_p.h"
#if !defined(QT_NO_STYLE_GTK)
#include <private/qhexstring_p.h>
QT_BEGIN_NAMESPACE
QGtkPainter::QGtkPainter()
{
reset(0);
}
QGtkPainter::~QGtkPainter()
{
}
void QGtkPainter::reset(QPainter *painter)
{
m_painter = painter;
m_alpha = true;
m_hflipped = false;
m_vflipped = false;
m_usePixmapCache = true;
m_cliprect = QRect();
}
QString QGtkPainter::uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
const QSize &size, GtkWidget *widget)
{
// Note the widget arg should ideally use the widget path, though would compromise performance
QString tmp = key
% HexString<uint>(state)
% HexString<uint>(shadow)
% HexString<uint>(size.width())
% HexString<uint>(size.height())
% HexString<quint64>(quint64(widget));
return tmp;
}
QT_END_NAMESPACE
#endif //!defined(QT_NO_STYLE_GTK)

View File

@ -1,119 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGTKPAINTER_H
#define QGTKPAINTER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
#include <private/qgtkglobal_p.h>
#include <QtCore/qsize.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qpainter.h>
QT_BEGIN_NAMESPACE
class QGtkPainter
{
public:
QGtkPainter();
virtual ~QGtkPainter();
void reset(QPainter *painter = 0);
void setAlphaSupport(bool value) { m_alpha = value; }
void setClipRect(const QRect &rect) { m_cliprect = rect; }
void setFlipHorizontal(bool value) { m_hflipped = value; }
void setFlipVertical(bool value) { m_vflipped = value; }
void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
virtual void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
gint width, GtkStyle *style) = 0;
virtual void paintBox(GtkWidget *gtkWidget, const gchar* part,
const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
const QString &pmKey = QString()) = 0;
virtual void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
int x1, int x2, int y, const QString &pmKey = QString()) = 0;
virtual void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
int y1, int y2, int x, const QString &pmKey = QString()) = 0;
virtual void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) = 0;
virtual void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
const QString &pmKey = QString()) = 0;
virtual void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) = 0;
virtual void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
gboolean fill, GtkStyle *style, const QString &pmKey = QString()) = 0;
virtual void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) = 0;
virtual void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) = 0;
virtual void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkStyle *style, const QString &pmKey = QString()) = 0;
virtual void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) = 0;
virtual void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
GtkPositionType gap_pos, GtkStyle *style) = 0;
virtual void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
virtual void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
protected:
static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0);
QPainter *m_painter;
bool m_alpha;
bool m_hflipped;
bool m_vflipped;
bool m_usePixmapCache;
QRect m_cliprect;
};
QT_END_NAMESPACE
#endif //!defined(QT_NO_STYLE_QGTK)
#endif // QGTKPAINTER_H

File diff suppressed because it is too large Load Diff

View File

@ -1,891 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qgtkstyle_p_p.h"
// This file is responsible for resolving all GTK functions we use
// dynamically. This is done to avoid link-time dependancy on GTK
// as well as crashes occurring due to usage of the GTK_QT engines
//
// Additionally we create a map of common GTK widgets that we can pass
// to the GTK theme engine as many engines resort to querying the
// actual widget pointers for details that are not covered by the
// state flags
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
#include <QtCore/QEvent>
#include <QtCore/QFile>
#include <QtCore/QStringList>
#include <QtCore/QTextStream>
#include <QtCore/QHash>
#include <QtCore/QUrl>
#include <QtCore/QLibrary>
#include <QtCore/QDebug>
#include <private/qgtk2painter_p.h>
#include <private/qapplication_p.h>
#include <private/qiconloader_p.h>
#include <qpa/qplatformfontdatabase.h>
#include <QtWidgets/QMenu>
#include <QtWidgets/QStyle>
#include <QtWidgets/QApplication>
#include <QtGui/QPixmapCache>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QToolButton>
#ifndef Q_OS_MAC
// X11 Includes:
// the following is necessary to work around breakage in many versions
// of XFree86's Xlib.h still in use
// ### which versions?
#if defined(_XLIB_H_) // crude hack, but...
#error "cannot include <X11/Xlib.h> before this file"
#endif
#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
#define XSetIMValues qt_XSetIMValues
#include <X11/Xlib.h>
#undef XRegisterIMInstantiateCallback
#undef XUnregisterIMInstantiateCallback
#undef XSetIMValues
#endif
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
Ptr_gtk_container_forall QGtkStylePrivate::gtk_container_forall = 0;
Ptr_gtk_init QGtkStylePrivate::gtk_init = 0;
Ptr_gtk_style_attach QGtkStylePrivate::gtk_style_attach = 0;
Ptr_gtk_window_new QGtkStylePrivate::gtk_window_new = 0;
Ptr_gtk_widget_destroy QGtkStylePrivate::gtk_widget_destroy = 0;
Ptr_gtk_widget_realize QGtkStylePrivate::gtk_widget_realize = 0;
Ptr_gtk_widget_set_default_direction QGtkStylePrivate::gtk_widget_set_default_direction = 0;
Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_fg = 0;
Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_bg = 0;
Ptr_gtk_arrow_new QGtkStylePrivate::gtk_arrow_new = 0;
Ptr_gtk_menu_item_new_with_label QGtkStylePrivate::gtk_menu_item_new_with_label = 0;
Ptr_gtk_check_menu_item_new_with_label QGtkStylePrivate::gtk_check_menu_item_new_with_label = 0;
Ptr_gtk_menu_bar_new QGtkStylePrivate::gtk_menu_bar_new = 0;
Ptr_gtk_menu_new QGtkStylePrivate::gtk_menu_new = 0;
Ptr_gtk_button_new QGtkStylePrivate::gtk_button_new = 0;
Ptr_gtk_tool_button_new QGtkStylePrivate::gtk_tool_button_new = 0;
Ptr_gtk_hbutton_box_new QGtkStylePrivate::gtk_hbutton_box_new = 0;
Ptr_gtk_check_button_new QGtkStylePrivate::gtk_check_button_new = 0;
Ptr_gtk_radio_button_new QGtkStylePrivate::gtk_radio_button_new = 0;
Ptr_gtk_spin_button_new QGtkStylePrivate::gtk_spin_button_new = 0;
Ptr_gtk_frame_new QGtkStylePrivate::gtk_frame_new = 0;
Ptr_gtk_expander_new QGtkStylePrivate::gtk_expander_new = 0;
Ptr_gtk_statusbar_new QGtkStylePrivate::gtk_statusbar_new = 0;
Ptr_gtk_entry_new QGtkStylePrivate::gtk_entry_new = 0;
Ptr_gtk_hscale_new QGtkStylePrivate::gtk_hscale_new = 0;
Ptr_gtk_vscale_new QGtkStylePrivate::gtk_vscale_new = 0;
Ptr_gtk_hscrollbar_new QGtkStylePrivate::gtk_hscrollbar_new = 0;
Ptr_gtk_vscrollbar_new QGtkStylePrivate::gtk_vscrollbar_new = 0;
Ptr_gtk_scrolled_window_new QGtkStylePrivate::gtk_scrolled_window_new = 0;
Ptr_gtk_notebook_new QGtkStylePrivate::gtk_notebook_new = 0;
Ptr_gtk_toolbar_new QGtkStylePrivate::gtk_toolbar_new = 0;
Ptr_gtk_toolbar_insert QGtkStylePrivate::gtk_toolbar_insert = 0;
Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new = 0;
Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
Ptr_gtk_icon_factory_lookup_default QGtkStylePrivate::gtk_icon_factory_lookup_default = 0;
Ptr_gtk_icon_theme_get_default QGtkStylePrivate::gtk_icon_theme_get_default = 0;
Ptr_gtk_widget_get_style QGtkStylePrivate::gtk_widget_get_style = 0;
Ptr_gtk_widget_style_get QGtkStylePrivate::gtk_widget_style_get = 0;
Ptr_gtk_icon_set_render_icon QGtkStylePrivate::gtk_icon_set_render_icon = 0;
Ptr_gtk_fixed_new QGtkStylePrivate::gtk_fixed_new = 0;
Ptr_gtk_tree_view_column_new QGtkStylePrivate::gtk_tree_view_column_new = 0;
Ptr_gtk_tree_view_get_column QGtkStylePrivate::gtk_tree_view_get_column = 0;
Ptr_gtk_tree_view_append_column QGtkStylePrivate::gtk_tree_view_append_column = 0;
Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0;
Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0;
Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0;
Ptr_gtk_widget_size_allocate QGtkStylePrivate::gtk_widget_size_allocate = 0;
Ptr_gtk_widget_size_request QGtkStylePrivate::gtk_widget_size_request = 0;
Ptr_gtk_widget_set_direction QGtkStylePrivate::gtk_widget_set_direction = 0;
Ptr_gtk_widget_path QGtkStylePrivate::gtk_widget_path = 0;
Ptr_gtk_container_get_type QGtkStylePrivate::gtk_container_get_type = 0;
Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
Ptr_gtk_widget_get_parent QGtkStylePrivate::gtk_widget_get_parent = 0;
Ptr_gtk_widget_is_toplevel QGtkStylePrivate::gtk_widget_is_toplevel = 0;
Ptr_gtk_widget_get_toplevel QGtkStylePrivate::gtk_widget_get_toplevel = 0;
Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
Ptr_gtk_widget_get_allocation QGtkStylePrivate::gtk_widget_get_allocation = 0;
Ptr_gtk_widget_set_allocation QGtkStylePrivate::gtk_widget_set_allocation = 0;
Ptr_gtk_widget_set_can_default QGtkStylePrivate::gtk_widget_set_can_default = 0;
Ptr_gtk_window_set_default QGtkStylePrivate::gtk_window_set_default = 0;
Ptr_gdk_event_new QGtkStylePrivate::gdk_event_new = 0;
Ptr_gdk_event_free QGtkStylePrivate::gdk_event_free = 0;
Ptr_gtk_widget_send_focus_change QGtkStylePrivate::gtk_widget_send_focus_change = 0;
Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0;
Ptr_pango_font_description_get_style QGtkStylePrivate::pango_font_description_get_style = 0;
Ptr_gdk_pixbuf_get_pixels QGtkStylePrivate::gdk_pixbuf_get_pixels = 0;
Ptr_gdk_pixbuf_get_width QGtkStylePrivate::gdk_pixbuf_get_width = 0;
Ptr_gdk_pixbuf_get_height QGtkStylePrivate::gdk_pixbuf_get_height = 0;
Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
Ptr_gdk_color_free QGtkStylePrivate::gdk_color_free = 0;
Ptr_gdk_x11_window_set_user_time QGtkStylePrivate::gdk_x11_window_set_user_time = 0;
Ptr_gdk_x11_drawable_get_xid QGtkStylePrivate::gdk_x11_drawable_get_xid = 0;
Ptr_gdk_x11_drawable_get_xdisplay QGtkStylePrivate::gdk_x11_drawable_get_xdisplay = 0;
Ptr_gconf_client_get_default QGtkStylePrivate::gconf_client_get_default = 0;
Ptr_gconf_client_get_string QGtkStylePrivate::gconf_client_get_string = 0;
Ptr_gconf_client_get_bool QGtkStylePrivate::gconf_client_get_bool = 0;
Ptr_gnome_icon_lookup_sync QGtkStylePrivate::gnome_icon_lookup_sync = 0;
Ptr_gnome_vfs_init QGtkStylePrivate::gnome_vfs_init = 0;
#ifndef Q_OS_MAC
typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
#endif
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGtkStylePrivate*);
QT_BEGIN_NAMESPACE
static void gtkStyleSetCallback(GtkWidget*)
{
qRegisterMetaType<QGtkStylePrivate *>();
// We have to let this function return and complete the event
// loop to ensure that all gtk widgets have been styled before
// updating
QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
}
static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
{
GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL);
QWidgetList widgets = QApplication::allWidgets();
for (int i = 0; i < widgets.size(); ++i) {
QWidget *widget = widgets.at(i);
if (qobject_cast<QToolButton*>(widget)) {
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(widget, &event);
}
}
}
static QHashableLatin1Literal classPath(GtkWidget *widget)
{
char *class_path;
QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
char *copy = class_path;
if (strncmp(copy, "GtkWindow.", 10) == 0)
copy += 10;
if (strncmp(copy, "GtkFixed.", 9) == 0)
copy += 9;
copy = strdup(copy);
g_free(class_path);
return QHashableLatin1Literal::fromData(copy);
}
bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
{
if (e->type() == QEvent::ApplicationPaletteChange) {
// Only do this the first time since this will also
// generate applicationPaletteChange events
if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
stylePrivate->applyCustomPaletteHash();
}
}
return QObject::eventFilter(obj, e);
}
QList<QGtkStylePrivate *> QGtkStylePrivate::instances;
QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0;
QGtkStylePrivate::QGtkStylePrivate()
: QCommonStylePrivate()
, filter(this)
{
instances.append(this);
animationFps = 60;
}
QGtkStylePrivate::~QGtkStylePrivate()
{
instances.removeOne(this);
}
void QGtkStylePrivate::init()
{
resolveGtk();
initGtkWidgets();
}
QGtkPainter* QGtkStylePrivate::gtkPainter(QPainter *painter)
{
// TODO: choose between gtk2 and gtk3
static QGtk2Painter instance;
instance.reset(painter);
return &instance;
}
GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
{
GtkWidget *widget = gtkWidgetMap()->value(path);
if (!widget) {
// Theme might have rearranged widget internals
widget = gtkWidgetMap()->value(path);
}
return widget;
}
GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
{
if (GtkWidget *w = gtkWidgetMap()->value(path))
return QGtkStylePrivate::gtk_widget_get_style(w);
return 0;
}
void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus)
{
if (QGtkStylePrivate::gtk_widget_send_focus_change) {
GdkEvent *event = QGtkStylePrivate::gdk_event_new(GDK_FOCUS_CHANGE);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.in = focus;
QGtkStylePrivate::gtk_widget_send_focus_change(widget, event);
QGtkStylePrivate::gdk_event_free(event);
} else {
#if defined(GTK_WIDGET_SET_FLAGS) && defined(GTK_WIDGET_UNSET_FLAGS)
if (focus)
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
#endif
}
}
/*! \internal
* Get references to gtk functions after we dynamically load the library.
*/
void QGtkStylePrivate::resolveGtk() const
{
#ifndef QT_NO_LIBRARY
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
gtk_widget_get_style = (Ptr_gtk_widget_get_style)libgtk.resolve("gtk_widget_get_style");
gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
gtk_widget_get_parent =(Ptr_gtk_widget_get_parent)libgtk.resolve("gtk_widget_get_parent");
gtk_widget_is_toplevel =(Ptr_gtk_widget_is_toplevel)libgtk.resolve("gtk_widget_is_toplevel");
gtk_widget_get_toplevel =(Ptr_gtk_widget_get_toplevel)libgtk.resolve("gtk_widget_get_toplevel");
gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
gtk_widget_get_allocation = (Ptr_gtk_widget_get_allocation)libgtk.resolve("gtk_widget_get_allocation");
gtk_widget_set_allocation = (Ptr_gtk_widget_set_allocation)libgtk.resolve("gtk_widget_set_allocation");
gtk_widget_set_can_default = (Ptr_gtk_widget_set_can_default)libgtk.resolve("gtk_widget_set_can_default");
gtk_window_set_default = (Ptr_gtk_window_set_default)libgtk.resolve("gtk_window_set_default");
gdk_event_new = (Ptr_gdk_event_new)libgtk.resolve("gdk_event_new");
gdk_event_free = (Ptr_gdk_event_free)libgtk.resolve("gdk_event_free");
gtk_widget_send_focus_change = (Ptr_gtk_widget_send_focus_change)libgtk.resolve("gtk_widget_send_focus_change");
pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
#endif // !QT_NO_LIBRARY
}
/* \internal
* Initializes a number of gtk menu widgets.
* The widgets are cached.
*/
void QGtkStylePrivate::initGtkMenu() const
{
// Create menubar
GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
setupGtkWidget(gtkMenuBar);
GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
gtk_widget_realize(gtkMenuBarItem);
// Create menu
GtkWidget *gtkMenu = QGtkStylePrivate::gtk_menu_new();
gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
gtk_widget_realize(gtkMenu);
GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
gtk_widget_realize(gtkMenuItem);
GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
gtk_widget_realize(gtkCheckMenuItem);
GtkWidget *gtkMenuSeparator = QGtkStylePrivate::gtk_separator_menu_item_new();
gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
addAllSubWidgets(gtkMenuBar);
addAllSubWidgets(gtkMenu);
}
void QGtkStylePrivate::initGtkTreeview() const
{
GtkWidget *gtkTreeView = gtk_tree_view_new();
gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
addWidget(gtkTreeView);
}
/* \internal
* Initializes a number of gtk widgets that we can later on use to determine some of our styles.
* The widgets are cached.
*/
void QGtkStylePrivate::initGtkWidgets() const
{
// From gtkmain.c
uid_t ruid = getuid ();
uid_t rgid = getgid ();
uid_t euid = geteuid ();
uid_t egid = getegid ();
if (ruid != euid || rgid != egid) {
qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
"therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
"\'kdesudo\' or a similar tool.\n\n"
"See http://www.gtk.org/setuid.html for more information.\n");
return;
}
if (QGtkStylePrivate::gtk_init) {
#ifndef Q_OS_MAC
// Gtk will set the Qt error handler so we have to reset it afterwards
x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
#endif
QGtkStylePrivate::gtk_init (NULL, NULL);
#ifndef Q_OS_MAC
XSetErrorHandler(qt_x_errhandler);
#endif
// make a window
GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
QGtkStylePrivate::gtk_widget_realize(gtkWindow);
QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
removeWidgetFromMap(widgetPath);
gtkWidgetMap()->insert(widgetPath, gtkWindow);
// Make all other widgets. respect the text direction
if (qApp->layoutDirection() == Qt::RightToLeft)
QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
if (!gtkWidgetMap()->contains("GtkButton")) {
GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
addWidget(gtkButton);
g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, "Qt"));
addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
addWidget(QGtkStylePrivate::gtk_hbutton_box_new());
addWidget(QGtkStylePrivate::gtk_check_button_new());
addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
addWidget(QGtkStylePrivate::gtk_combo_box_new());
addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
GtkWidget *entry = QGtkStylePrivate::gtk_entry_new();
// gtk-im-context-none is supported in gtk+ since 2.19.5
// and also exists in gtk3
// http://git.gnome.org/browse/gtk+/tree/gtk/gtkimmulticontext.c?id=2.19.5#n33
// reason that we don't use gtk-im-context-simple here is,
// gtk-im-context-none has less overhead, and 2.19.5 is
// relatively old. and even for older gtk+, it will fallback
// to gtk-im-context-simple if gtk-im-context-none doesn't
// exists.
g_object_set(entry, "im-module", "gtk-im-context-none", NULL);
addWidget(entry);
addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
addWidget(QGtkStylePrivate::gtk_expander_new(""));
addWidget(QGtkStylePrivate::gtk_statusbar_new());
addWidget(QGtkStylePrivate::gtk_hscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
addWidget(QGtkStylePrivate::gtk_hscrollbar_new(NULL));
addWidget(QGtkStylePrivate::gtk_scrolled_window_new(NULL, NULL));
initGtkMenu();
addWidget(QGtkStylePrivate::gtk_notebook_new());
addWidget(QGtkStylePrivate::gtk_progress_bar_new());
addWidget(QGtkStylePrivate::gtk_spin_button_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
GtkWidget *toolbar = gtk_toolbar_new();
g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
addWidget(toolbar);
initGtkTreeview();
addWidget(gtk_vscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
addWidget(gtk_vscrollbar_new(NULL));
}
else // Rebuild map
{
// When styles change subwidgets can get rearranged
// as with the combo box. We need to update the widget map
// to reflect this;
QHash<QHashableLatin1Literal, GtkWidget*> oldMap = *gtkWidgetMap();
gtkWidgetMap()->clear();
QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
while (it.hasNext()) {
it.next();
if (!strchr(it.key().data(), '.')) {
addAllSubWidgets(it.value());
}
free(const_cast<char *>(it.key().data()));
}
}
} else {
qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
}
}
/*! \internal
* destroys all previously buffered widgets.
*/
void QGtkStylePrivate::cleanupGtkWidgets()
{
if (!widgetMap)
return;
if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
gtk_widget_destroy(widgetMap->value("GtkWindow"));
for (QHash<QHashableLatin1Literal, GtkWidget *>::const_iterator it = widgetMap->constBegin();
it != widgetMap->constEnd(); ++it)
free(const_cast<char *>(it.key().data()));
}
static bool resolveGConf()
{
#ifndef QT_NO_LIBRARY
if (!QGtkStylePrivate::gconf_client_get_default) {
QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
}
#endif // !QT_NO_LIBRARY
return (QGtkStylePrivate::gconf_client_get_default !=0);
}
QString QGtkStylePrivate::getGConfString(const QString &value, const QString &fallback)
{
QString retVal = fallback;
if (resolveGConf()) {
#if !defined(GLIB_VERSION_2_36)
g_type_init();
#endif
GConfClient* client = gconf_client_get_default();
GError *err = 0;
char *str = gconf_client_get_string(client, qPrintable(value), &err);
if (!err) {
retVal = QString::fromUtf8(str);
g_free(str);
}
g_object_unref(client);
if (err)
g_error_free (err);
}
return retVal;
}
bool QGtkStylePrivate::getGConfBool(const QString &key, bool fallback)
{
bool retVal = fallback;
if (resolveGConf()) {
#if !defined(GLIB_VERSION_2_36)
g_type_init();
#endif
GConfClient* client = gconf_client_get_default();
GError *err = 0;
bool result = gconf_client_get_bool(client, qPrintable(key), &err);
g_object_unref(client);
if (!err)
retVal = result;
else
g_error_free (err);
}
return retVal;
}
QString QGtkStylePrivate::getThemeName()
{
QString themeName;
// Read the theme name from GtkSettings
GtkSettings *settings = QGtkStylePrivate::gtk_settings_get_default();
gchararray value;
g_object_get(settings, "gtk-theme-name", &value, NULL);
themeName = QString::fromUtf8(value);
g_free(value);
return themeName;
}
// Get size of the arrow controls in a GtkSpinButton
int QGtkStylePrivate::getSpinboxArrowSize() const
{
const int MIN_ARROW_WIDTH = 6;
GtkWidget *spinButton = gtkWidget("GtkSpinButton");
GtkStyle *style = QGtkStylePrivate::gtk_widget_get_style(spinButton);
gint size = pango_font_description_get_size (style->font_desc);
gint arrow_size;
arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
arrow_size += arrow_size%2 + 1;
return arrow_size;
}
bool QGtkStylePrivate::isKDE4Session()
{
static int version = -1;
if (version == -1)
version = qgetenv("KDE_SESSION_VERSION").toInt();
return (version == 4);
}
void QGtkStylePrivate::applyCustomPaletteHash()
{
QPalette menuPal = gtkWidgetPalette("GtkMenu");
GdkColor gdkBg = QGtkStylePrivate::gtk_widget_get_style(gtkWidget("GtkMenu"))->bg[GTK_STATE_NORMAL];
QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
menuPal.setBrush(QPalette::Base, bgColor);
menuPal.setBrush(QPalette::Window, bgColor);
qApp->setPalette(menuPal, "QMenu");
QPalette toolbarPal = gtkWidgetPalette("GtkToolbar");
qApp->setPalette(toolbarPal, "QToolBar");
QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
qApp->setPalette(menuBarPal, "QMenuBar");
}
/*! \internal
* Returns the gtk Widget that should be used to determine text foreground and background colors.
*/
GtkWidget* QGtkStylePrivate::getTextColorWidget() const
{
return gtkWidget("GtkEntry");
}
void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
{
if (Q_GTK_IS_WIDGET(widget)) {
GtkWidget *protoLayout = gtkWidgetMap()->value("GtkContainer");
if (!protoLayout) {
protoLayout = QGtkStylePrivate::gtk_fixed_new();
QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkContainer"));
gtkWidgetMap()->insert(widgetPath, protoLayout);
}
Q_ASSERT(protoLayout);
if (!QGtkStylePrivate::gtk_widget_get_parent(widget) && !QGtkStylePrivate::gtk_widget_is_toplevel(widget))
QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
QGtkStylePrivate::gtk_widget_realize(widget);
}
}
void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path)
{
WidgetMap *map = gtkWidgetMap();
WidgetMap::iterator it = map->find(path);
if (it != map->end()) {
char* keyData = const_cast<char *>(it.key().data());
map->erase(it);
free(keyData);
}
}
void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
{
if (Q_GTK_IS_WIDGET(widget)) {
gtk_widget_realize(widget);
QHashableLatin1Literal widgetPath = classPath(widget);
removeWidgetFromMap(widgetPath);
gtkWidgetMap()->insert(widgetPath, widget);
#ifdef DUMP_GTK_WIDGET_TREE
qWarning("Inserted Gtk Widget: %s", widgetPath.data());
#endif
}
}
void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
{
Q_UNUSED(v);
addWidgetToMap(widget);
if (G_TYPE_CHECK_INSTANCE_TYPE ((widget), gtk_container_get_type()))
gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
}
// Updates window/windowtext palette based on the indicated gtk widget
QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
{
GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
Q_ASSERT(gtkWidget);
QPalette pal = QApplication::palette();
GdkColor gdkBg = gtk_widget_get_style(gtkWidget)->bg[GTK_STATE_NORMAL];
GdkColor gdkText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_NORMAL];
GdkColor gdkDisabledText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_INSENSITIVE];
QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8);
pal.setBrush(QPalette::Window, bgColor);
pal.setBrush(QPalette::Button, bgColor);
pal.setBrush(QPalette::All, QPalette::WindowText, textColor);
pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
return pal;
}
void QGtkStyleUpdateScheduler::updateTheme()
{
static QString oldTheme(QLS("qt_not_set"));
QPixmapCache::clear();
QFont font = QGtkStylePrivate::getThemeFont();
if (QApplication::font() != font)
qApp->setFont(font);
if (oldTheme != QGtkStylePrivate::getThemeName()) {
oldTheme = QGtkStylePrivate::getThemeName();
QPalette newPalette = qApp->style()->standardPalette();
QApplicationPrivate::setSystemPalette(newPalette);
QApplication::setPalette(newPalette);
if (!QGtkStylePrivate::instances.isEmpty()) {
QGtkStylePrivate::instances.last()->initGtkWidgets();
QGtkStylePrivate::instances.last()->applyCustomPaletteHash();
}
QList<QWidget*> widgets = QApplication::allWidgets();
// Notify all widgets that size metrics might have changed
foreach (QWidget *widget, widgets) {
QEvent e(QEvent::StyleChange);
QApplication::sendEvent(widget, &e);
}
}
QIconLoader::instance()->updateSystemTheme();
}
void QGtkStylePrivate::addWidget(GtkWidget *widget)
{
if (widget) {
setupGtkWidget(widget);
addAllSubWidgets(widget);
}
}
// Fetch the application font from the pango font description
// contained in the theme.
QFont QGtkStylePrivate::getThemeFont()
{
QFont font;
GtkStyle *style = gtkStyle();
if (style && qApp->desktopSettingsAware())
{
PangoFontDescription *gtk_font = style->font_desc;
font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE);
QString family = QString::fromLatin1(pango_font_description_get_family(gtk_font));
if (!family.isEmpty())
font.setFamily(family);
const int weight = pango_font_description_get_weight(gtk_font);
font.setWeight(QPlatformFontDatabase::weightFromInteger(weight));
PangoStyle fontstyle = pango_font_description_get_style(gtk_font);
if (fontstyle == PANGO_STYLE_ITALIC)
font.setStyle(QFont::StyleItalic);
else if (fontstyle == PANGO_STYLE_OBLIQUE)
font.setStyle(QFont::StyleOblique);
else
font.setStyle(QFont::StyleNormal);
}
return font;
}
QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
{
QIcon icon;
if (isThemeAvailable() && gnome_vfs_init && gnome_icon_lookup_sync) {
gnome_vfs_init();
GtkIconTheme *theme = gtk_icon_theme_get_default();
QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
char * icon_name = gnome_icon_lookup_sync(theme,
NULL,
fileurl.data(),
NULL,
GNOME_ICON_LOOKUP_FLAGS_NONE,
NULL);
QString iconName = QString::fromUtf8(icon_name);
g_free(icon_name);
if (iconName.startsWith(QLatin1Char('/')))
return QIcon(iconName);
return QIcon::fromTheme(iconName);
}
return icon;
}
bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
{
return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
}
// copied from qHash.cpp
uint qHash(const QHashableLatin1Literal &key)
{
int n = key.size();
const uchar *p = reinterpret_cast<const uchar *>(key.data());
uint h = 0;
uint g;
while (n--) {
h = (h << 4) + *p++;
if ((g = (h & 0xf0000000)) != 0)
h ^= g >> 23;
h &= ~g;
}
return h;
}
QT_END_NAMESPACE
#endif // !defined(QT_NO_STYLE_GTK)

View File

@ -1,123 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGTKSTYLE_P_H
#define QGTKSTYLE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qwindowsstyle_p.h>
#include <QtGui/QPalette>
#include <QtGui/QFont>
#include <QtWidgets/QFileDialog>
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_STYLE_GTK)
class QPainterPath;
class QGtkStylePrivate;
class QGtkStyle : public QCommonStyle
{
Q_OBJECT
Q_DECLARE_PRIVATE(QGtkStyle)
public:
QGtkStyle();
QGtkStyle(QGtkStylePrivate &dd);
~QGtkStyle();
QPalette standardPalette() const Q_DECL_OVERRIDE;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
void drawControl(ControlElement control, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
const QPixmap &pixmap) const Q_DECL_OVERRIDE;
void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
bool enabled, const QString& text, QPalette::ColorRole textRole) const Q_DECL_OVERRIDE;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
const QWidget *widget = 0) const Q_DECL_OVERRIDE;
int styleHint(StyleHint hint, const QStyleOption *option,
const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE;
QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
const QPoint &pt, const QWidget *w) const Q_DECL_OVERRIDE;
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option,
SubControl subControl, const QWidget *widget) const Q_DECL_OVERRIDE;
QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const Q_DECL_OVERRIDE;
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
const QWidget *widget = 0) const Q_DECL_OVERRIDE;
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
const QWidget *widget) const Q_DECL_OVERRIDE;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const Q_DECL_OVERRIDE;
void polish(QWidget *widget) Q_DECL_OVERRIDE;
void polish(QApplication *app) Q_DECL_OVERRIDE;
void polish(QPalette &palette) Q_DECL_OVERRIDE;
void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
void unpolish(QApplication *app) Q_DECL_OVERRIDE;
static bool getGConfBool(const QString &key, bool fallback = 0);
static QString getGConfString(const QString &key, const QString &fallback = QString());
};
#endif //!defined(QT_NO_STYLE_QGTK)
QT_END_NAMESPACE
#endif //QGTKSTYLE_P_H

View File

@ -1,449 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGTKSTYLE_P_P_H
#define QGTKSTYLE_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
#include <QtCore/qstring.h>
#include <QtCore/qstringbuilder.h>
#include <QtCore/qcoreapplication.h>
#include <QtWidgets/QFileDialog>
#include <private/qgtkstyle_p.h>
#include <private/qcommonstyle_p.h>
#include <private/qgtkglobal_p.h>
#define Q_GTK_IS_WIDGET(widget) widget && G_TYPE_CHECK_INSTANCE_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
QT_BEGIN_NAMESPACE
class QHashableLatin1Literal
{
public:
int size() const { return m_size; }
const char *data() const { return m_data; }
#ifdef __SUNPRO_CC
QHashableLatin1Literal(const char* str)
: m_size(strlen(str)), m_data(str) {}
#else
template <int N>
QHashableLatin1Literal(const char (&str)[N])
: m_size(N - 1), m_data(str) {}
#endif
QHashableLatin1Literal(const QHashableLatin1Literal &other)
: m_size(other.m_size), m_data(other.m_data)
{}
QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
{
if (this == &other)
return *this;
*const_cast<int *>(&m_size) = other.m_size;
*const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
return *this;
}
QString toString() const { return QString::fromLatin1(m_data, m_size); }
static QHashableLatin1Literal fromData(const char *str)
{
return QHashableLatin1Literal(str, qstrlen(str));
}
private:
QHashableLatin1Literal(const char *str, int length)
: m_size(length), m_data(str)
{}
const int m_size;
const char *m_data;
};
bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
uint qHash(const QHashableLatin1Literal &key);
QT_END_NAMESPACE
class GConf;
class GConfClient;
typedef struct _XDisplay Display;
typedef GConfClient* (*Ptr_gconf_client_get_default)();
typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **);
typedef void (*Ptr_gtk_init)(int *, char ***);
typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType);
typedef GtkStyle* (*Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *);
typedef void (*Ptr_gtk_widget_destroy) (GtkWidget *);
typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
typedef GtkWidget* (*Ptr_gtk_button_new)(void);
typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
typedef GtkWidget* (*Ptr_gtk_notebook_new)(void);
typedef GtkWidget* (*Ptr_gtk_progress_bar_new)(void);
typedef GtkWidget* (*Ptr_gtk_hscale_new)(GtkAdjustment*);
typedef GtkWidget* (*Ptr_gtk_vscale_new)(GtkAdjustment*);
typedef GtkWidget* (*Ptr_gtk_hscrollbar_new)(GtkAdjustment*);
typedef GtkWidget* (*Ptr_gtk_vscrollbar_new)(GtkAdjustment*);
typedef GtkWidget* (*Ptr_gtk_scrolled_window_new)(GtkAdjustment*, GtkAdjustment*);
typedef gchar* (*Ptr_gtk_check_version)(guint, guint, guint);
typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
typedef GtkStyle* (*Ptr_gtk_widget_get_style)(GtkWidget *);
typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
typedef GtkAdjustment* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
typedef GType (*Ptr_gtk_container_get_type) (void);
typedef GType (*Ptr_gtk_window_get_type) (void);
typedef GType (*Ptr_gtk_widget_get_type) (void);
typedef GtkWidget* (*Ptr_gtk_widget_get_parent) (GtkWidget *);
typedef gboolean (*Ptr_gtk_widget_is_toplevel) (GtkWidget *);
typedef GtkWidget* (*Ptr_gtk_widget_get_toplevel) (GtkWidget *);
typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
typedef void (*Ptr_gtk_border_free)(GtkBorder *);
typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
typedef void (*Ptr_gtk_widget_set_can_default) (GtkWidget*, gboolean);
typedef void (*Ptr_gtk_window_set_default) (GtkWindow*, GtkWidget*);
typedef GdkEvent* (*Ptr_gdk_event_new) (GdkEventType);
typedef void (*Ptr_gdk_event_free) (GdkEvent*);
typedef void (*Ptr_gtk_widget_send_focus_change) (GtkWidget*, GdkEvent*);
typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
typedef void (*Ptr_gdk_color_free) (const GdkColor *);
typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
int bits_per_sample, int width, int height);
typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
QT_BEGIN_NAMESPACE
class QGtkPainter;
class QGtkStylePrivate;
class QGtkStyleFilter : public QObject
{
public:
QGtkStyleFilter(QGtkStylePrivate* sp)
: stylePrivate(sp)
{}
private:
QGtkStylePrivate* stylePrivate;
bool eventFilter(QObject *obj, QEvent *e) Q_DECL_OVERRIDE;
};
typedef enum {
GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
} GnomeIconLookupFlags;
typedef enum {
GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
} GnomeIconLookupResultFlags;
struct GnomeThumbnailFactory;
typedef gboolean (*Ptr_gnome_vfs_init) (void);
typedef char* (*Ptr_gnome_icon_lookup_sync) (
GtkIconTheme *icon_theme,
GnomeThumbnailFactory *,
const char *file_uri,
const char *custom_icon,
GnomeIconLookupFlags flags,
GnomeIconLookupResultFlags *result);
class QGtkStylePrivate : public QCommonStylePrivate
{
Q_DECLARE_PUBLIC(QGtkStyle)
public:
QGtkStylePrivate();
~QGtkStylePrivate();
QGtkStyleFilter filter;
static QGtkPainter* gtkPainter(QPainter *painter = 0);
static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
static void gtkWidgetSetFocus(GtkWidget *widget, bool focus);
virtual void resolveGtk() const;
virtual void initGtkMenu() const;
virtual void initGtkTreeview() const;
virtual void initGtkWidgets() const;
static void cleanupGtkWidgets();
static bool isKDE4Session();
void applyCustomPaletteHash();
static QFont getThemeFont();
static bool isThemeAvailable() { return gtkStyle() != 0; }
static bool getGConfBool(const QString &key, bool fallback = 0);
static QString getGConfString(const QString &key, const QString &fallback = QString());
static QString getThemeName();
virtual int getSpinboxArrowSize() const;
static QIcon getFilesystemIcon(const QFileInfo &);
static Ptr_gtk_container_forall gtk_container_forall;
static Ptr_gtk_init gtk_init;
static Ptr_gtk_style_attach gtk_style_attach;
static Ptr_gtk_window_new gtk_window_new;
static Ptr_gtk_widget_destroy gtk_widget_destroy;
static Ptr_gtk_widget_realize gtk_widget_realize;
static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
static Ptr_gtk_arrow_new gtk_arrow_new;
static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
static Ptr_gtk_menu_new gtk_menu_new;
static Ptr_gtk_expander_new gtk_expander_new;
static Ptr_gtk_button_new gtk_button_new;
static Ptr_gtk_tool_button_new gtk_tool_button_new;
static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
static Ptr_gtk_check_button_new gtk_check_button_new;
static Ptr_gtk_radio_button_new gtk_radio_button_new;
static Ptr_gtk_spin_button_new gtk_spin_button_new;
static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
static Ptr_gtk_frame_new gtk_frame_new;
static Ptr_gtk_statusbar_new gtk_statusbar_new;
static Ptr_gtk_entry_new gtk_entry_new;
static Ptr_gtk_hscale_new gtk_hscale_new;
static Ptr_gtk_vscale_new gtk_vscale_new;
static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
static Ptr_gtk_notebook_new gtk_notebook_new;
static Ptr_gtk_toolbar_new gtk_toolbar_new;
static Ptr_gtk_tree_view_new gtk_tree_view_new;
static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
static Ptr_gtk_combo_box_new gtk_combo_box_new;
static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
static Ptr_gtk_container_add gtk_container_add;
static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
static Ptr_gtk_widget_get_style gtk_widget_get_style;
static Ptr_gtk_widget_style_get gtk_widget_style_get;
static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
static Ptr_gtk_fixed_new gtk_fixed_new;
static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
static Ptr_gtk_adjustment_new gtk_adjustment_new;
static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
static Ptr_gtk_settings_get_default gtk_settings_get_default;
static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
static Ptr_gtk_widget_size_request gtk_widget_size_request;
static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
static Ptr_gtk_widget_path gtk_widget_path;
static Ptr_gtk_container_get_type gtk_container_get_type;
static Ptr_gtk_window_get_type gtk_window_get_type;
static Ptr_gtk_widget_get_type gtk_widget_get_type;
static Ptr_gtk_widget_get_parent gtk_widget_get_parent;
static Ptr_gtk_widget_is_toplevel gtk_widget_is_toplevel;
static Ptr_gtk_widget_get_toplevel gtk_widget_get_toplevel;
static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
static Ptr_gtk_check_version gtk_check_version;
static Ptr_gtk_border_free gtk_border_free;
static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
static Ptr_gtk_widget_set_can_default gtk_widget_set_can_default;
static Ptr_gtk_window_set_default gtk_window_set_default;
static Ptr_gdk_event_new gdk_event_new;
static Ptr_gdk_event_free gdk_event_free;
static Ptr_gtk_widget_send_focus_change gtk_widget_send_focus_change;
static Ptr_pango_font_description_get_size pango_font_description_get_size;
static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
static Ptr_pango_font_description_get_family pango_font_description_get_family;
static Ptr_pango_font_description_get_style pango_font_description_get_style;
static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
static Ptr_gdk_color_free gdk_color_free;
static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
static Ptr_gconf_client_get_default gconf_client_get_default;
static Ptr_gconf_client_get_string gconf_client_get_string;
static Ptr_gconf_client_get_bool gconf_client_get_bool;
static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
static Ptr_gnome_vfs_init gnome_vfs_init;
virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
protected:
typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
static inline void destroyWidgetMap()
{
cleanupGtkWidgets();
delete widgetMap;
widgetMap = 0;
}
static inline WidgetMap *gtkWidgetMap()
{
if (!widgetMap) {
widgetMap = new WidgetMap();
qAddPostRoutine(destroyWidgetMap);
}
return widgetMap;
}
static QStringList extract_filter(const QString &rawFilter);
virtual GtkWidget* getTextColorWidget() const;
static void setupGtkWidget(GtkWidget* widget);
static void addWidgetToMap(GtkWidget* widget);
static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
static void addWidget(GtkWidget *widget);
static void removeWidgetFromMap(const QHashableLatin1Literal &path);
virtual void init();
enum {
menuItemFrame = 2, // menu item frame width
menuItemHMargin = 3, // menu item hor text margin
menuArrowHMargin = 6, // menu arrow horizontal margin
menuItemVMargin = 2, // menu item ver text margin
menuRightBorder = 15, // right border on menus
menuCheckMarkWidth = 12 // checkmarks width on menus
};
private:
static QList<QGtkStylePrivate *> instances;
static WidgetMap *widgetMap;
friend class QGtkStyleUpdateScheduler;
};
// Helper to ensure that we have polished all our gtk widgets
// before updating our own palettes
class QGtkStyleUpdateScheduler : public QObject
{
Q_OBJECT
public slots:
void updateTheme();
};
QT_END_NAMESPACE
#endif // !QT_NO_STYLE_GTK
#endif // QGTKSTYLE_P_P_H

View File

@ -44,9 +44,6 @@
#include "qandroidstyle_p.h"
#endif
#endif
#ifndef QT_NO_STYLE_GTK
#include "qgtkstyle_p.h"
#endif
#ifndef QT_NO_STYLE_WINDOWSXP
#include "qwindowsxpstyle_p.h"
#endif
@ -86,7 +83,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
The valid keys can be retrieved using the keys()
function. Typically they include "windows" and "fusion".
Depending on the platform, "windowsxp", "windowsvista", "gtk"
Depending on the platform, "windowsxp", "windowsvista"
and "macintosh" may be available.
Note that keys are case insensitive.
@ -143,11 +140,6 @@ QStyle *QStyleFactory::create(const QString& key)
ret = new QAndroidStyle;
else
#endif
#ifndef QT_NO_STYLE_GTK
if (style == QLatin1String("gtk") || style == QLatin1String("gtk+"))
ret = new QGtkStyle;
else
#endif
#ifndef QT_NO_STYLE_MAC
if (style.startsWith(QLatin1String("macintosh"))) {
ret = new QMacStyle;
@ -210,10 +202,6 @@ QStringList QStyleFactory::keys()
if (!list.contains(QLatin1String("Android")))
list << QLatin1String("Android");
#endif
#ifndef QT_NO_STYLE_GTK
if (!list.contains(QLatin1String("GTK+")))
list << QLatin1String("GTK+");
#endif
#ifndef QT_NO_STYLE_FUSION
if (!list.contains(QLatin1String("Fusion")))
list << QLatin1String("Fusion");

View File

@ -149,8 +149,7 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const
// pixmap based style doesn't support any features
bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")
|| baseStyle()->inherits("QWindowsXPStyle")
|| baseStyle()->inherits("QGtkStyle");
|| baseStyle()->inherits("QWindowsXPStyle");
/*QLineEdit {

View File

@ -42,13 +42,6 @@ contains( styles, all ) {
!macx:styles -= mac
contains(QT_CONFIG, gtkstyle) {
QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE
styles += gtk
CONFIG += x11
}
contains( styles, mac ) {
HEADERS += \
styles/qmacstyle_mac_p.h \
@ -90,19 +83,6 @@ contains( styles, windows ) {
DEFINES += QT_NO_STYLE_WINDOWS
}
contains( styles, gtk ) {
HEADERS += styles/qgtkglobal_p.h
HEADERS += styles/qgtkstyle_p.h
HEADERS += styles/qgtkpainter_p.h
HEADERS += styles/qgtk2painter_p.h
HEADERS += styles/qgtkstyle_p_p.h
SOURCES += styles/qgtkstyle.cpp
SOURCES += styles/qgtkpainter.cpp
SOURCES += styles/qgtk2painter.cpp
SOURCES += styles/qgtkstyle_p.cpp
} else {
DEFINES += QT_NO_STYLE_GTK
}
contains( styles, fusion ) {
HEADERS += styles/qfusionstyle_p.h
HEADERS += styles/qfusionstyle_p_p.h

View File

@ -2889,9 +2889,6 @@ void tst_QGraphicsView::scrollBarRanges()
QFETCH(ExpectedValueDescription, vmax);
QFETCH(bool, useStyledPanel);
if (style == QLatin1String("GTK+") && useStyledPanel)
QSKIP("GTK + style test skipped, see QTBUG-29002");
if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX");
QGraphicsScene scene;

View File

@ -537,9 +537,6 @@ void tst_QPushButton::sizeHint_data()
#if !defined(QT_NO_STYLE_WINDOWS)
QTest::newRow("windows") << QString::fromLatin1("windows");
#endif
#if !defined(QT_NO_STYLE_GTK)
QTest::newRow("gtk") << QString::fromLatin1("gtk");
#endif
#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
QTest::newRow("macintosh") << QString::fromLatin1("macintosh");
#endif

View File

@ -280,7 +280,6 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "STYLE_FUSION" ] = "yes";
dictionary[ "STYLE_WINDOWSCE" ] = "no";
dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
dictionary[ "STYLE_GTK" ] = "no";
dictionary[ "SQL_MYSQL" ] = "no";
dictionary[ "SQL_ODBC" ] = "no";
@ -3608,7 +3607,6 @@ void Configure::generateConfigfiles()
if (dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA";
if (dictionary["STYLE_WINDOWSCE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSCE";
if (dictionary["STYLE_WINDOWSMOBILE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSMOBILE";
if (dictionary["STYLE_GTK"] != "yes") qconfigList += "QT_NO_STYLE_GTK";
if (dictionary["GIF"] == "yes") qconfigList += "QT_BUILTIN_GIF_READER=1";
if (dictionary["PNG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_PNG";