summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qgtkstyle.cpp
diff options
context:
space:
mode:
authorAndreas Kling <andreas.kling@nokia.com>2010-12-01 10:04:27 (GMT)
committerAndreas Kling <andreas.kling@nokia.com>2010-12-01 10:04:27 (GMT)
commit46de147d71f18dbf81617781ee3056fa9549e553 (patch)
tree9573623828204e746f425d7746f1d8e5907b0993 /src/gui/styles/qgtkstyle.cpp
parentff7df47d6b3a873f37cf8bcdf46e5daa5168a6fc (diff)
downloadQt-46de147d71f18dbf81617781ee3056fa9549e553.zip
Qt-46de147d71f18dbf81617781ee3056fa9549e553.tar.gz
Qt-46de147d71f18dbf81617781ee3056fa9549e553.tar.bz2
QGtkStyle: Don't create new GtkAdjustment objects on every draw
Use gtk_*_get_adjustment() and gtk_adjustment_configure() to re-use the previously set GtkAdjustment on GtkProgress and GtkRange. Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Diffstat (limited to 'src/gui/styles/qgtkstyle.cpp')
-rw-r--r--src/gui/styles/qgtkstyle.cpp54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 9cc64b3..f3ec746 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -1706,12 +1706,17 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
fakePos = maximum;
else if (scrollBar->sliderPosition > scrollBar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- if (horizontal)
- d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
- else
- d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
+
+ GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
if (scrollBar->subControls & SC_ScrollBarGroove) {
GtkStateType state = GTK_STATE_ACTIVE;
@@ -1990,15 +1995,29 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
style = scaleWidget->style;
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
- GtkObject *adjustment = d->gtk_adjustment_new(slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
+
+ GtkRange *range = (GtkRange*)scaleWidget;
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment,
+ slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
+
int outerSize;
- d->gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
- d->gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
+ d->gtk_range_set_inverted(range, !horizontal);
d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
outerSize++;
@@ -2998,8 +3017,13 @@ void QGtkStyle::drawControl(ControlElement element,
else if (bar->progress > bar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
+ GtkAdjustment *adjustment = d->gtk_progress_get_adjustment((GtkProgress*)gtkProgressBar);
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), adjustment);
+ }
QRect progressBar;