summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2012-10-08 11:45:23 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-10 14:43:59 +0200
commitc0893962ef94f12594f936ef2a50db6d0328eca0 (patch)
tree1052f7b5e5b442cf9230609b2449acfed33e5ac4 /src/widgets/styles
parent9f96bf20238a21b62c34261d8dc5a0ad0bfdc789 (diff)
QGtkStyle: use gtk_widget_get_style()
Do not access GtkWidget::style directly, it doesn't exist in GTK3. Change-Id: I947776848f5dd64011a40446fcdb9079f295f182 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qgtkstyle.cpp201
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp14
-rw-r--r--src/widgets/styles/qgtkstyle_p.h2
3 files changed, 118 insertions, 99 deletions
diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp
index 31bda752c3..552e2354c5 100644
--- a/src/widgets/styles/qgtkstyle.cpp
+++ b/src/widgets/styles/qgtkstyle.cpp
@@ -325,18 +325,19 @@ QPalette QGtkStyle::standardPalette() const
GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg;
QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt;
gdkBg = style->bg[GTK_STATE_NORMAL];
- gdkForeground = gtkButton->style->fg[GTK_STATE_NORMAL];
+ gdkForeground = d->gtk_widget_get_style(gtkButton)->fg[GTK_STATE_NORMAL];
// Our base and selected color is primarily used for text
// so we assume a gtkEntry will have the most correct value
- gdkBase = gtkEntry->style->base[GTK_STATE_NORMAL];
- gdkText = gtkEntry->style->text[GTK_STATE_NORMAL];
- gdkSbg = gtkEntry->style->base[GTK_STATE_SELECTED];
- gdkSfg = gtkEntry->style->text[GTK_STATE_SELECTED];
+ GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
+ gdkBase = gtkEntryStyle->base[GTK_STATE_NORMAL];
+ gdkText = gtkEntryStyle->text[GTK_STATE_NORMAL];
+ gdkSbg = gtkEntryStyle->base[GTK_STATE_SELECTED];
+ gdkSfg = gtkEntryStyle->text[GTK_STATE_SELECTED];
// The ACTIVE base color is really used for inactive windows
- gdkaSbg = gtkEntry->style->base[GTK_STATE_ACTIVE];
- gdkaSfg = gtkEntry->style->text[GTK_STATE_ACTIVE];
+ gdkaSbg = gtkEntryStyle->base[GTK_STATE_ACTIVE];
+ gdkaSfg = gtkEntryStyle->text[GTK_STATE_ACTIVE];
bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
@@ -558,7 +559,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
// horizontal-padding is used by Maemo to get thicker borders
if (!d->gtk_check_version(2, 10, 0))
d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
- int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
+ int padding = qMax<int>(d->gtk_widget_get_style(gtkMenu)->xthickness, horizontal_padding);
return padding;
}
@@ -614,7 +615,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
gint val;
d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
if (metric == PM_SliderControlThickness)
- return val + 2*gtkScale->style->ythickness;
+ return val + 2*d->gtk_widget_get_style(gtkScale)->ythickness;
return val;
}
@@ -649,7 +650,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_MenuBarVMargin: {
GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- return qMax(0, gtkMenubar->style->ythickness);
+ return qMax(0, d->gtk_widget_get_style(gtkMenubar)->ythickness);
}
case PM_ScrollView_ScrollBarSpacing:
{
@@ -955,7 +956,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
d->gtk_widget_style_get(d->gtk_widget_get_parent(gtkStatusbarFrame), "shadow-type", &shadow_type, NULL);
gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
- shadow_type, gtkStatusbarFrame->style);
+ shadow_type, d->gtk_widget_get_style(gtkStatusbarFrame));
}
break;
@@ -963,7 +964,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
GtkStateType state = gtkPainter.gtkState(option);
- style = gtkTreeHeader->style;
+ style = d->gtk_widget_get_style(gtkTreeHeader);
GtkArrowType type = GTK_ARROW_UP;
// This sorting indicator inversion is intentional, and follows the GNOME HIG.
// See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
@@ -1013,7 +1014,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
state = GTK_STATE_PRELIGHT;
gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
- option->state & State_Open ? openState : closedState , gtkTreeView->style);
+ option->state & State_Open ? openState : closedState , d->gtk_widget_get_style(gtkTreeView));
}
break;
@@ -1060,7 +1061,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
option->state & State_Selected ? GTK_STATE_SELECTED :
isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_OUT, gtkTreeView->style, key);
+ GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkTreeView), key);
if (isActive )
GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
}
@@ -1075,14 +1076,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
painter->setPen(QPen(option->palette.background().color().darker(110)));
gtkPainter.paintVline( gtkSeparator, "vseparator",
- rect, GTK_STATE_NORMAL, gtkSeparator->style,
+ rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
0, rect.height(), 0);
} else { //Draw vertical separator
const int offset = option->rect.height()/2;
QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
painter->setPen(QPen(option->palette.background().color().darker(110)));
gtkPainter.paintHline( gtkSeparator, "hseparator",
- rect, GTK_STATE_NORMAL, gtkSeparator->style,
+ rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
0, rect.width(), 0);
}
}
@@ -1096,7 +1097,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
painter->setClipRect(option->rect);
gtkPainter.paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, gtkToolbar->style);
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, d->gtk_widget_get_style(gtkToolbar));
}
break;
@@ -1141,7 +1142,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GdkColor color = fromQColor(arrowColor);
d->gtk_widget_modify_fg (gtkArrow, state, &color);
gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
- type, state, shadow, false, gtkArrow->style,
+ type, state, shadow, false, d->gtk_widget_get_style(gtkArrow),
QString::number(arrowColor.rgba(), 16));
// Passing NULL will revert the color change
d->gtk_widget_modify_fg (gtkArrow, state, NULL);
@@ -1155,7 +1156,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_PanelMenu: {
GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
- gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
+ gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkMenu), QString());
}
break;
@@ -1194,12 +1195,12 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, gtkEntry->style,
+ GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry),
option->state & State_HasFocus ? QLS("focus") : QString());
if (!interior_focus && option->state & State_HasFocus)
gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
+ GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry), QLS("GtkEntryShadowIn"));
if (option->state & State_HasFocus)
GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
@@ -1212,15 +1213,16 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (panel->lineWidth > 0)
proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
uint resolve_mask = option->palette.resolve();
- QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness,
- -gtkEntry->style->xthickness, -gtkEntry->style->ythickness);
+ GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
+ QRect textRect = option->rect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness,
+ -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness);
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
painter->fillRect(textRect, option->palette.base());
else
gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntryStyle);
}
break;
@@ -1282,7 +1284,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
"focus-padding", &focusPad,
"interior-focus", &interiorFocus, NULL);
- style = gtkButton->style;
+ style = d->gtk_widget_get_style(gtkButton);
QRect buttonRect = option->rect;
@@ -1343,7 +1345,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
key += QLatin1Char('f');
GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
}
- gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key);
+ gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, d->gtk_widget_get_style(gtkRadioButton), key);
if (option->state & State_HasFocus)
GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
}
@@ -1379,7 +1381,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
- gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style,
+ gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, d->gtk_widget_get_style(gtkCheckButton),
key);
if (option->state & State_HasFocus)
GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
@@ -1768,7 +1770,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (option->state & State_MouseOver) {
QRect bgRect = textRect | checkBoxRect;
gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkCheckButton->style);
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkCheckButton));
}
if (!groupBox->text.isEmpty()) {
@@ -1781,7 +1783,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (option->state & State_Enabled)
labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GdkColor gdkText = gtkCheckButton->style->fg[labelState];
+ GdkColor gdkText = d->gtk_widget_get_style(gtkCheckButton)->fg[labelState];
textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
painter->setPen(textColor);
QFont font = painter->font();
@@ -1862,9 +1864,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
// Fill the line edit background
// We could have used flat_box with "entry_bg" but that is probably not worth the overhead
uint resolve_mask = option->palette.resolve();
- int xt = gtkEntry->style->xthickness;
- int yt = gtkEntry->style->ythickness;
- QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
+ GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
+ QRect contentRect = frameRect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness,
+ -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness);
// Required for inner blue highlight with clearlooks
if (focus)
GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
@@ -1875,11 +1877,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else {
gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus));
+ GTK_SHADOW_NONE, gtkEntryStyle, entryPath.toString() + QString::number(focus));
}
gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
- GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() +
+ GTK_SHADOW_IN, gtkEntryStyle, entryPath.toString() +
QString::number(focus) + QString::number(comboBox->editable) +
QString::number(option->direction));
if (focus)
@@ -1897,19 +1899,20 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
Q_ASSERT(gtkToggleButton);
gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
- shadow, gtkToggleButton->style, buttonPath.toString() +
+ shadow, d->gtk_widget_get_style(gtkToggleButton), buttonPath.toString() +
QString::number(focus) + QString::number(option->direction));
if (focus)
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
} else {
// Draw combo box as a button
QRect buttonRect = option->rect;
+ GtkStyle *gtkToggleButtonStyle = d->gtk_widget_get_style(gtkToggleButton);
if (focus) // Clearlooks actually check the widget for the default state
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
gtkCachedPainter.paintBox(gtkToggleButton, "button",
buttonRect, state,
- shadow, gtkToggleButton->style,
+ shadow, gtkToggleButtonStyle,
buttonPath.toString() + QString::number(focus));
if (focus)
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
@@ -1926,19 +1929,20 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QRect vLineRect(allocation.x, allocation.y, allocation.width, allocation.height);
gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
- vLineRect, state, gtkVSeparator->style,
+ vLineRect, state, d->gtk_widget_get_style(gtkVSeparator),
0, vLineRect.height(), 0, vSeparatorPath.toString());
gint interiorFocus = true;
d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
- int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
- int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
+ GtkStyle *gtkToggleButtonStyle = gtkToggleButtonStyle;
+ int xt = interiorFocus ? gtkToggleButtonStyle->xthickness : 0;
+ int yt = interiorFocus ? gtkToggleButtonStyle->ythickness : 0;
if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
gtkCachedPainter.paintFocus(gtkToggleButton, "button",
option->rect.adjusted(xt, yt, -xt, -yt),
option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkToggleButton->style);
+ gtkToggleButtonStyle);
}
}
@@ -1978,12 +1982,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GtkAllocation allocation;
d->gtk_widget_get_allocation(gtkArrow, &allocation);
arrowWidgetRect = QRect(allocation.x, allocation.y, allocation.width, allocation.height);
- style = gtkArrow->style;
+ style = d->gtk_widget_get_style(gtkArrow);
}
// Note that for some reason the arrow-size is not properly respected with Hildon
// Hence we enforce the minimum "arrow-size" ourselves
- int arrowSize = qMax(qMin(rect.height() - gtkCombo->style->ythickness * 2, minSize),
+ int arrowSize = qMax(qMin(rect.height() - d->gtk_widget_get_style(gtkCombo)->ythickness * 2, minSize),
qMin(arrowWidgetRect.width(), arrowWidgetRect.height()));
QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale));
@@ -2072,7 +2076,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QPalette pal = toolbutton->palette;
if (option->state & State_Enabled &&
option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
- GdkColor gdkText = gtkButton->style->fg[GTK_STATE_PRELIGHT];
+ GdkColor gdkText = d->gtk_widget_get_style(gtkButton)->fg[GTK_STATE_PRELIGHT];
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
label.palette = pal;
@@ -2116,7 +2120,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
bool horizontal = scrollBar->orientation == Qt::Horizontal;
GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
- style = scrollbarWidget->style;
+ style = d->gtk_widget_get_style(scrollbarWidget);
gboolean trough_under_steppers = true;
gboolean trough_side_details = false;
gboolean activate_slider = false;
@@ -2338,7 +2342,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
option->state & State_Enabled ?
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
- gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key);
+ gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkSpinButton), key);
if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
@@ -2442,7 +2446,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ?
GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget;
- style = scaleWidget->style;
+ style = d->gtk_widget_get_style(scaleWidget);
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
@@ -2645,9 +2649,10 @@ void QGtkStyle::drawControl(ControlElement element,
QRect leftRect;
QRect rect = bar->rect;
- GdkColor gdkText = gtkProgressBar->style->fg[GTK_STATE_NORMAL];
+ GtkStyle *gtkProgressBarStyle = d->gtk_widget_get_style(gtkProgressBar);
+ GdkColor gdkText = gtkProgressBarStyle->fg[GTK_STATE_NORMAL];
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- gdkText = gtkProgressBar->style->fg[GTK_STATE_PRELIGHT];
+ gdkText = gtkProgressBarStyle->fg[GTK_STATE_PRELIGHT];
QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
painter->save();
@@ -2749,7 +2754,7 @@ void QGtkStyle::drawControl(ControlElement element,
labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ?
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GdkColor gdkText = gtkButton->style->fg[labelState];
+ GdkColor gdkText = d->gtk_widget_get_style(gtkButton)->fg[labelState];
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
pal.setBrush(QPalette::ButtonText, textColor);
proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
@@ -2767,7 +2772,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (option->state & State_MouseOver) {
gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkRadioButton->style);
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkRadioButton));
}
QStyleOptionButton subopt = *btn;
@@ -2783,7 +2788,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (option->state & State_Enabled)
labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GdkColor gdkText = gtkRadioButton->style->fg[labelState];
+ GdkColor gdkText = d->gtk_widget_get_style(gtkRadioButton)->fg[labelState];
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
pal.setBrush(QPalette::WindowText, textColor);
subopt.palette = pal;
@@ -2838,7 +2843,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (option->state & State_Enabled)
labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GdkColor gdkText = gtkCombo->style->fg[labelState];
+ GdkColor gdkText = d->gtk_widget_get_style(gtkCombo)->fg[labelState];
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
@@ -2920,7 +2925,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (option->state & State_Sunken)
shadow = GTK_SHADOW_IN;
- gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtkTreeHeader->style);
+ gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, d->gtk_widget_get_style(gtkTreeHeader));
}
painter->restore();
@@ -2930,11 +2935,12 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_SizeGrip: {
GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
- QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
+ GtkStyle *gtkStatusbarStyle = d->gtk_widget_get_style(gtkStatusbar);
+ QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbarStyle->xthickness, -gtkStatusbarStyle->ythickness);
gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
- gtkStatusbar->style);
+ gtkStatusbarStyle);
}
break;
@@ -2942,7 +2948,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_MenuBarEmptyArea: {
GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
+ GdkColor gdkBg = d->gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
if (widget) { // See CE_MenuBarItem
QRect menuBarRect = widget->rect();
@@ -2953,7 +2959,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkShadowType shadow_type;
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
+ GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
pmPainter.end();
painter->drawPixmap(option->rect, pixmap, option->rect);
}
@@ -2967,7 +2973,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- style = gtkMenubarItem->style;
+ style = d->gtk_widget_get_style(gtkMenubarItem);
if (widget) {
// Since Qt does not currently allow filling the entire background
@@ -2981,10 +2987,10 @@ void QGtkStyle::drawControl(ControlElement element,
QGtkPainter menubarPainter(&pmPainter);
GtkShadowType shadow_type;
d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
+ GdkColor gdkBg = d->gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
+ GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
pmPainter.end();
painter->drawPixmap(option->rect, pixmap, option->rect);
}
@@ -2993,8 +2999,8 @@ void QGtkStyle::drawControl(ControlElement element,
bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
bool dis = !(mbi->state & State_Enabled);
item.rect = mbi->rect;
- GdkColor gdkText = gtkMenubarItem->style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
- GdkColor gdkHText = gtkMenubarItem->style->fg[GTK_STATE_PRELIGHT];
+ GdkColor gdkText = style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
+ GdkColor gdkHText = style->fg[GTK_STATE_PRELIGHT];
QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor);
@@ -3006,7 +3012,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkShadowType shadowType = GTK_SHADOW_NONE;
d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
- GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style);
+ GTK_STATE_PRELIGHT, shadowType, style);
//draw text
QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
@@ -3045,7 +3051,7 @@ void QGtkStyle::drawControl(ControlElement element,
GtkShadowType shadow_type = GTK_SHADOW_NONE;
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
- GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
+ GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkToolbar));
}
break;
@@ -3080,15 +3086,16 @@ void QGtkStyle::drawControl(ControlElement element,
"horizontal-padding", &horizontal_padding,
NULL);
}
- separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness);
- separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness));
+ GtkStyle *gtkMenuSeparatorStyle = d->gtk_widget_get_style(gtkMenuSeparator);
+ separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparatorStyle->ythickness);
+ separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparatorStyle->xthickness));
separatorRect.moveCenter(option->rect.center());
if (wide_separators)
gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style);
+ separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparatorStyle);
else
gtkPainter.paintHline( gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style,
+ separatorRect, GTK_STATE_NORMAL, gtkMenuSeparatorStyle,
0, option->rect.right() - 1, 1);
painter->restore();
break;
@@ -3142,7 +3149,7 @@ void QGtkStyle::drawControl(ControlElement element,
gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- gtkMenuItem->style, QLS("option"));
+ style, QLS("option"));
gtkPainter.setClipRect(QRect());
} else {
@@ -3158,7 +3165,7 @@ void QGtkStyle::drawControl(ControlElement element,
gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- gtkMenuItem->style, QLS("check"));
+ style, QLS("check"));
gtkPainter.setClipRect(QRect());
}
}
@@ -3221,9 +3228,9 @@ void QGtkStyle::drawControl(ControlElement element,
painter->drawPixmap(pmr.topLeft(), pixmap);
}
- GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
- GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
+ GdkColor gdkText = style->fg[GTK_STATE_NORMAL];
+ GdkColor gdkDText = style->fg[GTK_STATE_INSENSITIVE];
+ GdkColor gdkHText = style->fg[GTK_STATE_PRELIGHT];
uint resolve_mask = option->palette.resolve();
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
@@ -3290,7 +3297,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
QFontMetrics fm(menuitem->font);
- int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
+ int arrow_size = fm.ascent() + fm.descent() - 2 * style->ythickness;
gfloat arrow_scaling = 0.8;
int extra = 0;
if (!d->gtk_check_version(2, 16, 0)) {
@@ -3298,7 +3305,7 @@ void QGtkStyle::drawControl(ControlElement element,
// though the current documentation states otherwise
d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
// in versions < 2.16 ythickness was previously subtracted from the arrow_size
- extra = 2 * gtkMenuItem->style->ythickness;
+ extra = 2 * style->ythickness;
}
int horizontal_padding;
@@ -3326,8 +3333,9 @@ void QGtkStyle::drawControl(ControlElement element,
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
gint interiorFocus = true;
d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
- int xt = interiorFocus ? gtkButton->style->xthickness : 0;
- int yt = interiorFocus ? gtkButton->style->ythickness : 0;
+ GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
+ int xt = interiorFocus ? gtkButtonStyle->xthickness : 0;
+ int yt = interiorFocus ? gtkButtonStyle->ythickness : 0;
if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
// The normal button focus rect does not work well for flat buttons in Clearlooks
@@ -3336,7 +3344,7 @@ void QGtkStyle::drawControl(ControlElement element,
gtkPainter.paintFocus(gtkButton, "button",
option->rect.adjusted(xt, yt, -xt, -yt),
btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkButton->style);
+ gtkButtonStyle);
proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
}
@@ -3415,7 +3423,7 @@ void QGtkStyle::drawControl(ControlElement element,
Q_UNUSED(bar);
GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
GtkStateType state = gtkPainter.gtkState(option);
- gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
+ gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkProgressBar));
}
break;
@@ -3424,7 +3432,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- style = gtkProgressBar->style;
+ style = d->gtk_widget_get_style(gtkProgressBar);
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
int xt = style->xthickness;
int yt = style->ythickness;
@@ -3621,8 +3629,9 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
int center = spinbox->rect.height() / 2;
- int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
- int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
+ GtkStyle *gtkSpinButtonStyle = d->gtk_widget_get_style(gtkSpinButton);
+ int xt = spinbox->frame ? gtkSpinButtonStyle->xthickness : 0;
+ int yt = spinbox->frame ? gtkSpinButtonStyle->ythickness : 0;
int y = yt;
QSize bs;
@@ -3786,10 +3795,11 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
case SC_ComboBoxEditField: {
rect = visualRect(option->direction, option->rect, rect);
int xMargin = box->editable ? 1 : 4, yMargin = 2;
- rect.setRect(option->rect.left() + gtkCombo->style->xthickness + xMargin,
- option->rect.top() + gtkCombo->style->ythickness + yMargin,
- option->rect.width() - buttonRect.width() - 2*(gtkCombo->style->xthickness + xMargin),
- option->rect.height() - 2*(gtkCombo->style->ythickness + yMargin));
+ GtkStyle *gtkComboStyle = d->gtk_widget_get_style(gtkCombo);
+ rect.setRect(option->rect.left() + gtkComboStyle->xthickness + xMargin,
+ option->rect.top() + gtkComboStyle->ythickness + yMargin,
+ option->rect.width() - buttonRect.width() - 2*(gtkComboStyle->xthickness + xMargin),
+ option->rect.height() - 2*(gtkComboStyle->ythickness + yMargin));
rect = visualRect(option->direction, option->rect, rect);
break;
}
@@ -3840,7 +3850,8 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ToolButton:
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
- newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
+ GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
+ newSize = size + QSize(2 * gtkButtonStyle->xthickness, 2 + 2 * gtkButtonStyle->ythickness);
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
QSize minSize(0, 25);
if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
@@ -3865,7 +3876,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
}
GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
- GtkStyle* style = gtkMenuItem->style;
+ GtkStyle* style = d->gtk_widget_get_style(gtkMenuItem);
// Note we get the perfect height for the default font since we
// set a fake text label on the gtkMenuItem
@@ -3882,7 +3893,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
case CT_SpinBox:
// QSpinBox does some nasty things that depends on CT_LineEdit
- newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2);
+ newSize = size + QSize(0, -d->gtk_widget_get_style(d->gtkWidget("GtkSpinButton"))->ythickness * 2);
break;
case CT_RadioButton:
case CT_CheckBox:
@@ -3898,7 +3909,8 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
newSize = size;
- newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
+ GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
+ newSize += QSize(2*gtkButtonStyle->xthickness + 4, 2*gtkButtonStyle->ythickness);
newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
@@ -3913,11 +3925,13 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
case CT_Slider: {
GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
- newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness); }
+ GtkStyle *gtkSliderStyle = d->gtk_widget_get_style(gtkSlider);
+ newSize = size + QSize(2*gtkSliderStyle->xthickness, 2*gtkSliderStyle->ythickness); }
break;
case CT_LineEdit: {
GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
- newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness); }
+ GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
+ newSize = size + QSize(2*gtkEntryStyle->xthickness, 2 + 2*gtkEntryStyle->ythickness); }
break;
case CT_ItemViewItem:
newSize += QSize(0, 2);
@@ -3926,7 +3940,8 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
- newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
+ GtkStyle *gtkComboStyle = d->gtk_widget_get_style(gtkCombo);
+ newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkComboStyle->xthickness, 4 + 2*gtkComboStyle->ythickness);
if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
newSize += QSize(0, 2);
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index 42d669e8cf..85b645c71c 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -139,6 +139,7 @@ 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;
@@ -318,7 +319,7 @@ GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
{
if (GtkWidget *w = gtkWidgetMap()->value(path))
- return w->style;
+ return QGtkStylePrivate::gtk_widget_get_style(w);
return 0;
}
@@ -400,6 +401,7 @@ void QGtkStylePrivate::resolveGtk() const
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");
@@ -708,7 +710,7 @@ int QGtkStylePrivate::getSpinboxArrowSize() const
{
const int MIN_ARROW_WIDTH = 6;
GtkWidget *spinButton = gtkWidget("GtkSpinButton");
- GtkStyle *style = spinButton->style;
+ 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;
@@ -728,7 +730,7 @@ bool QGtkStylePrivate::isKDE4Session()
void QGtkStylePrivate::applyCustomPaletteHash()
{
QPalette menuPal = gtkWidgetPalette("GtkMenu");
- GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL];
+ 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);
@@ -803,9 +805,9 @@ QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWid
GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
Q_ASSERT(gtkWidget);
QPalette pal = QApplication::palette();
- GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
- GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
+ 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);
diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h
index 9ed32bd97b..009d49ecbe 100644
--- a/src/widgets/styles/qgtkstyle_p.h
+++ b/src/widgets/styles/qgtkstyle_p.h
@@ -181,6 +181,7 @@ 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);
@@ -408,6 +409,7 @@ public:
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;