1 From f3c37838ab149a8a570b7f1df987705815ae45c0 Mon Sep 17 00:00:00 2001
2 From: Robert Griebl <rgriebl@trolltech.com>
3 Date: Tue, 8 Dec 2009 17:10:57 +0100
4 Subject: [PATCH 0991/1244] QGtkStyle: support for the inner-border property in GtkButtons
6 This additional padding was not taken into account up to now. It didn't
7 matter for desktop themes, but Maemo5 uses a large (8pix) padding that can
12 src/gui/styles/qgtkstyle.cpp | 16 ++++++++++++++++
13 src/gui/styles/qgtkstyle_p.cpp | 2 ++
14 src/gui/styles/qgtkstyle_p.h | 2 ++
15 3 files changed, 20 insertions(+), 0 deletions(-)
17 diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
18 index afa3325..097a2b5 100644
19 --- a/src/gui/styles/qgtkstyle.cpp
20 +++ b/src/gui/styles/qgtkstyle.cpp
21 @@ -3375,12 +3375,28 @@ QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
23 QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
25 + Q_D(const QGtkStyle);
27 QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
29 case SE_ProgressBarLabel:
30 case SE_ProgressBarContents:
31 case SE_ProgressBarGroove:
33 + case SE_PushButtonContents:
34 + if (!d->gtk_check_version(2, 10, 0)) {
35 + GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
36 + GtkBorder *border = 0;
37 + d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
39 + r = option->rect.adjusted(border->left, border->top, -border->right, -border->top);
40 + d->gtk_border_free(border);
42 + r = option->rect.adjusted(1, 1, -1, -1);
44 + r = visualRect(option->direction, option->rect, r);
50 diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
51 index 22dfc62..a644a5b 100644
52 --- a/src/gui/styles/qgtkstyle_p.cpp
53 +++ b/src/gui/styles/qgtkstyle_p.cpp
54 @@ -158,6 +158,7 @@ Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
55 Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
56 Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
57 Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
58 +Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
60 Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
61 Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
62 @@ -416,6 +417,7 @@ void QGtkStylePrivate::resolveGtk() const
63 gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
64 gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
65 gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
66 + gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
67 pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
68 pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
69 pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
70 diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
71 index f6ab8a3..c27308f 100644
72 --- a/src/gui/styles/qgtkstyle_p.h
73 +++ b/src/gui/styles/qgtkstyle_p.h
74 @@ -176,6 +176,7 @@ typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
75 typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
76 typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
77 typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
78 +typedef void (*Ptr_gtk_border_free)(GtkBorder *);
80 typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
81 typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
82 @@ -371,6 +372,7 @@ public:
83 static Ptr_gtk_widget_get_type gtk_widget_get_type;
84 static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
85 static Ptr_gtk_check_version gtk_check_version;
86 + static Ptr_gtk_border_free gtk_border_free;
88 static Ptr_pango_font_description_get_size pango_font_description_get_size;
89 static Ptr_pango_font_description_get_weight pango_font_description_get_weight;