[gtk+/treeview-refactor] gtk: fix C99-style variable declarations in various sources
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] gtk: fix C99-style variable declarations in various sources
- Date: Sat, 13 Nov 2010 06:19:33 +0000 (UTC)
commit 2e0278c7528d162903788f3169542c88b23f7778
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Nov 10 10:08:14 2010 +0800
gtk: fix C99-style variable declarations in various sources
gtk/gtkcontainer.c | 5 +-
gtk/gtkrange.c | 3 +-
gtk/gtkscrolledwindow.c | 303 +++++++++++++++++++++-------------------------
gtk/gtktoolitemgroup.c | 3 +-
gtk/gtktoolpalette.c | 3 +-
gtk/gtkwindow.c | 7 +-
6 files changed, 151 insertions(+), 173 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 024c4fe..a37e361 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2272,12 +2272,13 @@ tab_compare (gconstpointer a,
const GtkWidget *child1 = a;
const GtkWidget *child2 = b;
GtkTextDirection text_direction = GPOINTER_TO_INT (data);
+ gint y1, y2;
gtk_widget_get_allocation ((GtkWidget *) child1, &child1_allocation);
gtk_widget_get_allocation ((GtkWidget *) child2, &child2_allocation);
- gint y1 = child1_allocation.y + child1_allocation.height / 2;
- gint y2 = child2_allocation.y + child2_allocation.height / 2;
+ y1 = child1_allocation.y + child1_allocation.height / 2;
+ y2 = child2_allocation.y + child2_allocation.height / 2;
if (y1 == y2)
{
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 7cd33c8..6cbbdd6 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1911,6 +1911,7 @@ draw_stepper (GtkRange *range,
gint arrow_y;
gint arrow_width;
gint arrow_height;
+ gboolean arrow_sensitive;
switch (stepper)
{
@@ -1930,7 +1931,7 @@ draw_stepper (GtkRange *range,
g_assert_not_reached ();
};
- gboolean arrow_sensitive = TRUE;
+ arrow_sensitive = TRUE;
gtk_widget_get_allocation (widget, &allocation);
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 590d336..bf2065a 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -134,7 +134,7 @@ struct _GtkScrolledWindowPrivate
guint vscrollbar_visible : 1;
guint window_placement : 2;
guint focus_out : 1; /* Flag used by ::move-focus-out implementation */
- guint trust_sb_visibility : 1;
+ guint inside_allocate : 1;
gint min_content_width;
gint min_content_height;
@@ -489,7 +489,6 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
gtk_scrolled_window_update_real_placement (scrolled_window);
priv->min_content_width = -1;
priv->min_content_height = -1;
- priv->trust_sb_visibility = FALSE;
}
/**
@@ -1450,6 +1449,7 @@ static void
gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow,
GtkAllocation *relative_allocation)
{
+ GtkScrolledWindowPrivate *priv = swindow->priv;
GtkWidget *widget = GTK_WIDGET (swindow), *child;
GtkAllocation allocation;
GtkAllocation child_allocation;
@@ -1464,7 +1464,9 @@ gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow,
child_allocation.width = relative_allocation->width;
child_allocation.height = relative_allocation->height;
+ priv->inside_allocate = TRUE;
gtk_widget_size_allocate (child, &child_allocation);
+ priv->inside_allocate = FALSE;
}
static void
@@ -1482,8 +1484,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gint sb_spacing;
gint sb_width;
gint sb_height;
- guint count = 0;
-
+
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
g_return_if_fail (allocation != NULL);
@@ -1517,143 +1518,135 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gint child_scroll_height;
gboolean previous_hvis;
gboolean previous_vvis;
+ guint count = 0;
/* Determine scrollbar visibility first via hfw apis */
- if (!priv->trust_sb_visibility)
- {
- if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
- {
- if (gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
- gtk_widget_get_preferred_width (child, &child_scroll_width, NULL);
- else
- gtk_widget_get_preferred_width (child, NULL, &child_scroll_width);
-
- if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
- {
- /* First try without a vertical scrollbar if the content will
- * fit the height given the extra width of the scrollbar
- */
- if (gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
- gtk_widget_get_preferred_height_for_width (child,
- MAX (allocation->width, child_scroll_width),
- &child_scroll_height, NULL);
- else
- gtk_widget_get_preferred_height_for_width (child,
- MAX (allocation->width, child_scroll_width),
- NULL, &child_scroll_height);
-
- if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
- {
- /* Does the content height fit the allocation height ? */
- priv->vscrollbar_visible = child_scroll_height > allocation->height;
-
- /* Does the content width fit the allocation with minus a possible scrollbar ? */
- priv->hscrollbar_visible =
- child_scroll_width > allocation->width -
- (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
-
- /* Now that we've guessed the hscrollbar, does the
- * content height fit the possible new allocation height ?
- */
- priv->vscrollbar_visible =
- child_scroll_height > allocation->height -
- (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
-
- /* Now that we've guessed the vscrollbar, does the
- * content width fit the possible new allocation width ?
- */
- priv->hscrollbar_visible =
- child_scroll_width > allocation->width -
- (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
- }
- else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
- {
- priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
- priv->vscrollbar_visible = child_scroll_height > allocation->height -
- (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
- }
- }
- else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
- {
- priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
-
- if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
- priv->hscrollbar_visible =
- child_scroll_width > allocation->width -
- (priv->vscrollbar_visible ? 0 : sb_width + sb_spacing);
- else
- priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
- }
- }
- else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
- {
- if (gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
- gtk_widget_get_preferred_height (child, &child_scroll_height, NULL);
- else
- gtk_widget_get_preferred_height (child, NULL, &child_scroll_height);
-
- if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
- {
- /* First try without a horizontal scrollbar if the content
- * will fit the width given the extra height of the scrollbar
- */
- if (gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
- gtk_widget_get_preferred_width_for_height (child,
- MAX (allocation->height, child_scroll_height),
- &child_scroll_width, NULL);
- else
- gtk_widget_get_preferred_width_for_height (child,
- MAX (allocation->height, child_scroll_height),
- NULL, &child_scroll_width);
-
- if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
- {
- /* Does the content width fit the allocation width ? */
- priv->hscrollbar_visible = child_scroll_width > allocation->width;
-
- /* Does the content height fit the allocation with minus a possible scrollbar ? */
- priv->vscrollbar_visible =
- child_scroll_height > allocation->height -
- (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
-
- /* Now that we've guessed the vscrollbar, does the content
- * width fit the possible new allocation width ?
- */
- priv->hscrollbar_visible =
- child_scroll_width > allocation->width -
- (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
-
- /* Now that we've guessed the hscrollbar, does the content
- * height fit the possible new allocation height ?
- */
- priv->vscrollbar_visible =
- child_scroll_height > allocation->height -
- (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
- }
- else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
- {
- priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
- priv->hscrollbar_visible = child_scroll_width > allocation->width -
- (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
- }
- }
- else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
- {
- priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
-
- if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
- priv->vscrollbar_visible =
- child_scroll_height > allocation->height -
- (priv->hscrollbar_visible ? 0 : sb_height + sb_spacing);
- else
- priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
- }
- }
- }
+ if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ {
+ if (gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
+ gtk_widget_get_preferred_width (child, &child_scroll_width, NULL);
+ else
+ gtk_widget_get_preferred_width (child, NULL, &child_scroll_width);
+
+ if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ {
+ /* First try without a vertical scrollbar if the content will fit the height
+ * given the extra width of the scrollbar */
+ if (gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
+ gtk_widget_get_preferred_height_for_width (child,
+ MAX (allocation->width, child_scroll_width),
+ &child_scroll_height, NULL);
+ else
+ gtk_widget_get_preferred_height_for_width (child,
+ MAX (allocation->width, child_scroll_width),
+ NULL, &child_scroll_height);
+
+ if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ {
+ /* Does the content height fit the allocation height ? */
+ priv->vscrollbar_visible = child_scroll_height > allocation->height;
+
+ /* Does the content width fit the allocation with minus a possible scrollbar ? */
+ priv->hscrollbar_visible =
+ child_scroll_width > allocation->width -
+ (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
+
+ /* Now that we've guessed the hscrollbar, does the content height fit
+ * the possible new allocation height ? */
+ priv->vscrollbar_visible =
+ child_scroll_height > allocation->height -
+ (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
+
+ /* Now that we've guessed the vscrollbar, does the content width fit
+ * the possible new allocation width ? */
+ priv->hscrollbar_visible =
+ child_scroll_width > allocation->width -
+ (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
+ }
+ else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
+ {
+ priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
+ priv->vscrollbar_visible = child_scroll_height > allocation->height -
+ (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
+ }
+ }
+ else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
+ {
+ priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
+
+ if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ priv->hscrollbar_visible =
+ child_scroll_width > allocation->width -
+ (priv->vscrollbar_visible ? 0 : sb_width + sb_spacing);
+ else
+ priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
+ }
+ }
+ else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
+ {
+ if (gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
+ gtk_widget_get_preferred_height (child, &child_scroll_height, NULL);
+ else
+ gtk_widget_get_preferred_height (child, NULL, &child_scroll_height);
+
+ if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ {
+ /* First try without a horizontal scrollbar if the content will fit the width
+ * given the extra height of the scrollbar */
+ if (gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child)) == GTK_SCROLL_MINIMUM)
+ gtk_widget_get_preferred_width_for_height (child,
+ MAX (allocation->height, child_scroll_height),
+ &child_scroll_width, NULL);
+ else
+ gtk_widget_get_preferred_width_for_height (child,
+ MAX (allocation->height, child_scroll_height),
+ NULL, &child_scroll_width);
+
+ if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ {
+ /* Does the content width fit the allocation width ? */
+ priv->hscrollbar_visible = child_scroll_width > allocation->width;
+
+ /* Does the content height fit the allocation with minus a possible scrollbar ? */
+ priv->vscrollbar_visible =
+ child_scroll_height > allocation->height -
+ (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
+
+ /* Now that we've guessed the vscrollbar, does the content width fit
+ * the possible new allocation width ? */
+ priv->hscrollbar_visible =
+ child_scroll_width > allocation->width -
+ (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
+
+ /* Now that we've guessed the hscrollbar, does the content height fit
+ * the possible new allocation height ? */
+ priv->vscrollbar_visible =
+ child_scroll_height > allocation->height -
+ (priv->hscrollbar_visible ? sb_height + sb_spacing : 0);
+ }
+ else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */
+ {
+ priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
+ priv->hscrollbar_visible = child_scroll_width > allocation->width -
+ (priv->vscrollbar_visible ? sb_width + sb_spacing : 0);
+ }
+ }
+ else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */
+ {
+ priv->hscrollbar_visible = priv->hscrollbar_policy != GTK_POLICY_NEVER;
+
+ if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
+ priv->vscrollbar_visible =
+ child_scroll_height > allocation->height -
+ (priv->hscrollbar_visible ? 0 : sb_height + sb_spacing);
+ else
+ priv->vscrollbar_visible = priv->vscrollbar_policy != GTK_POLICY_NEVER;
+ }
+ }
- /* Now after guessing scrollbar visibility; fall back on the allocation
- * loop which observes the adjustments to detect scrollbar visibility
- * and also avoids infinite recursion
+ /* Now after guessing scrollbar visibility; fall back on the allocation loop which
+ * observes the adjustments to detect scrollbar visibility and also avoids
+ * infinite recursion
*/
do
{
@@ -1671,13 +1664,9 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
priv->hscrollbar_visible = TRUE;
priv->vscrollbar_visible = TRUE;
- /* Make sure we dont do the height-for-width guess on the
- * next allocate.
- */
- priv->trust_sb_visibility = TRUE;
+ gtk_scrolled_window_allocate_child (scrolled_window, &relative_allocation);
- /* A queue resize is incoming so we will be immediately reinvoked */
- return;
+ break;
}
count++;
@@ -1692,16 +1681,6 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
}
- if (count > 1)
- /* If the scrollbars have flipped visibility, showing/hiding them will
- * cause a resize to be queued, we need to blindly trust those visibility
- * states on the next incoming allocate() and avoid guessing the visibility
- * with height-for-width apis.
- */
- priv->trust_sb_visibility = TRUE;
- else
- priv->trust_sb_visibility = FALSE;
-
if (priv->hscrollbar_visible)
{
if (!gtk_widget_get_visible (priv->hscrollbar))
@@ -1872,7 +1851,7 @@ static void
gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
- GtkScrolledWindowPrivate *priv;;
+ GtkScrolledWindowPrivate *priv;
GtkScrolledWindow *scrolled_window;
g_return_if_fail (adjustment != NULL);
@@ -1891,11 +1870,8 @@ gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
visible = priv->hscrollbar_visible;
priv->hscrollbar_visible = (adjustment->upper - adjustment->lower >
adjustment->page_size);
- if (priv->hscrollbar_visible != visible)
- {
- priv->trust_sb_visibility = TRUE;
- gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
- }
+ if (!priv->inside_allocate && priv->hscrollbar_visible != visible)
+ gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
else if (priv->vscrollbar &&
@@ -1908,11 +1884,8 @@ gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
visible = priv->vscrollbar_visible;
priv->vscrollbar_visible = (adjustment->upper - adjustment->lower >
adjustment->page_size);
- if (priv->vscrollbar_visible != visible)
- {
- priv->trust_sb_visibility = TRUE;
- gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
- }
+ if (!priv->inside_allocate && priv->vscrollbar_visible != visible)
+ gtk_widget_queue_resize (GTK_WIDGET (scrolled_window));
}
}
}
diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c
index f095f80..7983667 100644
--- a/gtk/gtktoolitemgroup.c
+++ b/gtk/gtktoolitemgroup.c
@@ -885,10 +885,11 @@ gtk_tool_item_group_real_size_allocate (GtkWidget *widget,
gint n_columns, n_rows = 1;
gint min_rows;
guint border_width;
+ GtkTextDirection direction;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- GtkTextDirection direction = gtk_widget_get_direction (widget);
+ direction = gtk_widget_get_direction (widget);
orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group));
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 1fb8aee..383d6b5 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -482,9 +482,10 @@ gtk_tool_palette_size_allocate (GtkWidget *widget,
gint x;
gint *group_sizes = g_newa (gint, palette->priv->groups->len);
+ GtkTextDirection direction;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- GtkTextDirection direction = gtk_widget_get_direction (widget);
+ direction = gtk_widget_get_direction (widget);
GTK_WIDGET_CLASS (gtk_tool_palette_parent_class)->size_allocate (widget, allocation);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a61bbcd..0621701 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -7565,10 +7565,11 @@ gtk_window_set_frame_dimensions (GtkWindow *window,
if (gtk_widget_get_realized (widget) && priv->frame)
{
- gtk_widget_get_allocation (widget, &allocation);
+ gint width, height;
+ gtk_widget_get_allocation (widget, &allocation);
- gint width = allocation.width + left + right;
- gint height = allocation.height + top + bottom;
+ width = allocation.width + left + right;
+ height = allocation.height + top + bottom;
gdk_window_resize (priv->frame, width, height);
gtk_decorated_window_move_resize_window (window,
left, top,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]