[gimp] Don't access GtkAdjustment's members directly
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Don't access GtkAdjustment's members directly
- Date: Fri, 9 Oct 2009 07:59:57 +0000 (UTC)
commit 23955439d6540ca77a0274be331adce712f5b267
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 9 09:54:27 2009 +0200
Don't access GtkAdjustment's members directly
but also don't use its accessors because doing that would emit
"changed" multiple times when setting up an adjustment with multiple
utility functions. Instead, use g_object_set() and freeze/thaw
notification around all calls. g_object_thaw_notify() will make sure
"changed" is emitted if anything has changed since freezing.
app/display/gimpdisplayshell-callbacks.c | 8 +++-
app/display/gimpdisplayshell-scale.c | 24 +++++++++----
app/display/gimpdisplayshell-scroll.c | 52 ++++++++++++++++--------------
3 files changed, 50 insertions(+), 34 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index bd86d6b..18359ec 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -2007,9 +2007,11 @@ gimp_display_shell_hscrollbar_update_range (GtkRange *range,
(scroll == GTK_SCROLL_PAGE_FORWARD))
return FALSE;
+ g_object_freeze_notify (G_OBJECT (shell->hsbdata));
+
gimp_display_shell_scroll_setup_hscrollbar (shell, value);
- gtk_adjustment_changed (shell->hsbdata);
+ g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
return FALSE;
}
@@ -2028,9 +2030,11 @@ gimp_display_shell_vscrollbar_update_range (GtkRange *range,
(scroll == GTK_SCROLL_PAGE_FORWARD))
return FALSE;
+ g_object_freeze_notify (G_OBJECT (shell->vsbdata));
+
gimp_display_shell_scroll_setup_vscrollbar (shell, value);
- gtk_adjustment_changed (shell->vsbdata);
+ g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
return FALSE;
}
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index 816b9a0..8522919 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -134,24 +134,32 @@ gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell)
/* Horizontal scrollbar */
- shell->hsbdata->value = shell->offset_x;
- shell->hsbdata->page_size = shell->disp_width;
- shell->hsbdata->page_increment = shell->disp_width / 2;
+ g_object_freeze_notify (G_OBJECT (shell->hsbdata));
+
+ g_object_set (shell->hsbdata,
+ "value", (gdouble) shell->offset_x,
+ "page-size", (gdouble) shell->disp_width,
+ "page-increment", (gdouble) shell->disp_width / 2,
+ NULL);
gimp_display_shell_scroll_setup_hscrollbar (shell, shell->offset_x);
- gtk_adjustment_changed (shell->hsbdata);
+ g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
/* Vertcal scrollbar */
- shell->vsbdata->value = shell->offset_y;
- shell->vsbdata->page_size = shell->disp_height;
- shell->vsbdata->page_increment = shell->disp_height / 2;
+ g_object_freeze_notify (G_OBJECT (shell->vsbdata));
+
+ g_object_set (shell->vsbdata,
+ "value", (gdouble) shell->offset_y,
+ "page-size", (gdouble) shell->disp_height,
+ "page-increment", (gdouble) shell->disp_height / 2,
+ NULL);
gimp_display_shell_scroll_setup_vscrollbar (shell, shell->offset_y);
- gtk_adjustment_changed (shell->vsbdata);
+ g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
}
/**
diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c
index 3429fb5..7cc4869 100644
--- a/app/display/gimpdisplayshell-scroll.c
+++ b/app/display/gimpdisplayshell-scroll.c
@@ -546,7 +546,9 @@ void
gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
gdouble value)
{
- gint sw;
+ gint sw;
+ gdouble lower;
+ gdouble upper;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -558,22 +560,22 @@ gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
if (shell->disp_width < sw)
{
- shell->hsbdata->lower = MIN (value,
- 0);
-
- shell->hsbdata->upper = MAX (value + shell->disp_width,
- sw);
+ lower = MIN (value, 0);
+ upper = MAX (value + shell->disp_width, sw);
}
else
{
- shell->hsbdata->lower = MIN (value,
- -(shell->disp_width - sw) / 2);
-
- shell->hsbdata->upper = MAX (value + shell->disp_width,
- sw + (shell->disp_width - sw) / 2);
+ lower = MIN (value, -(shell->disp_width - sw) / 2);
+ upper = MAX (value + shell->disp_width,
+ sw + (shell->disp_width - sw) / 2);
}
- shell->hsbdata->step_increment = MAX (shell->scale_x, MINIMUM_STEP_AMOUNT);
+ g_object_set (shell->hsbdata,
+ "lower", lower,
+ "upper", upper,
+ "step-increment", (gdouble) MAX (shell->scale_x,
+ MINIMUM_STEP_AMOUNT),
+ NULL);
}
/**
@@ -588,7 +590,9 @@ void
gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
gdouble value)
{
- gint sh;
+ gint sh;
+ gdouble lower;
+ gdouble upper;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -600,20 +604,20 @@ gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
if (shell->disp_height < sh)
{
- shell->vsbdata->lower = MIN (value,
- 0);
-
- shell->vsbdata->upper = MAX (value + shell->disp_height,
- sh);
+ lower = MIN (value, 0);
+ upper = MAX (value + shell->disp_height, sh);
}
else
{
- shell->vsbdata->lower = MIN (value,
- -(shell->disp_height - sh) / 2);
-
- shell->vsbdata->upper = MAX (value + shell->disp_height,
- sh + (shell->disp_height - sh) / 2);
+ lower = MIN (value, -(shell->disp_height - sh) / 2);
+ upper = MAX (value + shell->disp_height,
+ sh + (shell->disp_height - sh) / 2);
}
- shell->vsbdata->step_increment = MAX (shell->scale_y, MINIMUM_STEP_AMOUNT);
+ g_object_set (shell->vsbdata,
+ "lower", lower,
+ "upper", upper,
+ "step-increment", (gdouble) MAX (shell->scale_y,
+ MINIMUM_STEP_AMOUNT),
+ NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]