Remove fill options from GtkWrapBox

GtkWidget alignment properties make this unnecessary in new containers.
This commit is contained in:
Matthias Clasen 2010-09-13 18:36:51 -04:00
parent 0e484a83d1
commit b64e91adf0
3 changed files with 8 additions and 88 deletions

View File

@ -591,19 +591,15 @@ typedef enum {
/**
* GtkWrapBoxPacking:
* @GTK_WRAP_BOX_H_EXPAND: Whether the child expands horizontally.
* @GTK_WRAP_BOX_H_FILL: Whether the child fills its allocated horizontal space.
* @GTK_WRAP_BOX_V_EXPAND: Whether the child expands vertically.
* @GTK_WRAP_BOX_V_FILL: Whether the child fills its allocated vertical space.
*
* Specifies how widgets will expand/fill vertically and
* Specifies how widgets will expand vertically and
* horizontally when placed inside a #GtkWrapBox.
*/
typedef enum
{
GTK_WRAP_BOX_H_EXPAND = 1 << 0,
GTK_WRAP_BOX_H_FILL = 1 << 1,
GTK_WRAP_BOX_V_EXPAND = 1 << 2,
GTK_WRAP_BOX_V_FILL = 1 << 3
GTK_WRAP_BOX_V_EXPAND = 1 << 1
} GtkWrapBoxPacking;

View File

@ -781,54 +781,13 @@ allocate_child (GtkWrapBox *box,
child_allocation.height = item_size;
}
request_mode = gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (child->widget));
if (!(child->packing & GTK_WRAP_BOX_H_FILL))
{
gint width, height;
if (!(child->packing & GTK_WRAP_BOX_V_FILL) && request_mode == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
{
gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), NULL, &height);
height = MIN (child_allocation.height, height);
}
else
height = child_allocation.height;
if (request_mode == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
height, NULL, &width);
else
gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget), NULL, &width);
width = MIN (child_allocation.width, width);
child_allocation.x = child_allocation.x + (child_allocation.width - width) / 2;
child_allocation.width = width;
}
if (!(child->packing & GTK_WRAP_BOX_V_FILL))
{
gint height;
/* Note here child_allocation.width is already changed if (!(child->packing & GTK_WRAP_BOX_H_FILL)) */
if (request_mode == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
child_allocation.width, NULL, &height);
else
gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget), NULL, &height);
height = MIN (child_allocation.height, height);
child_allocation.y = child_allocation.y + (child_allocation.height - height) / 2;
child_allocation.height = height;
}
gtk_widget_size_allocate (child->widget, &child_allocation);
}
/* fit_aligned_item_requests() helper */
static gint
gather_aligned_item_requests (GtkWrapBox *box,
GtkOrientation orientation,
gather_aligned_item_requests (GtkWrapBox *box,
GtkOrientation orientation,
gint line_length,
gint item_spacing,
gint n_children,

View File

@ -39,8 +39,6 @@ static gint items_type = SIMPLE_ITEMS;
static GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
static gboolean items_xexpand = TRUE;
static gboolean items_yexpand = TRUE;
static gboolean items_xfill = TRUE;
static gboolean items_yfill = TRUE;
static void
@ -65,9 +63,7 @@ populate_wrapbox_simple (GtkWrapBox *wrapbox)
gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), frame, -1,
(items_xexpand ? GTK_WRAP_BOX_H_EXPAND : 0) |
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0) |
(items_xfill ? GTK_WRAP_BOX_H_FILL : 0) |
(items_yfill ? GTK_WRAP_BOX_V_FILL : 0));
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0));
g_free (text);
}
@ -106,9 +102,7 @@ populate_wrapbox_wrappy (GtkWrapBox *wrapbox)
gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), frame, -1,
(items_xexpand ? GTK_WRAP_BOX_H_EXPAND : 0) |
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0) |
(items_xfill ? GTK_WRAP_BOX_H_FILL : 0) |
(items_yfill ? GTK_WRAP_BOX_V_FILL : 0));
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0));
}
}
@ -133,9 +127,7 @@ populate_wrapbox_stock (GtkWrapBox *wrapbox)
gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), widget, -1,
(items_xexpand ? GTK_WRAP_BOX_H_EXPAND : 0) |
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0) |
(items_xfill ? GTK_WRAP_BOX_H_FILL : 0) |
(items_yfill ? GTK_WRAP_BOX_V_FILL : 0));
(items_yexpand ? GTK_WRAP_BOX_V_EXPAND : 0));
}
}
@ -421,7 +413,7 @@ create_window (void)
G_CALLBACK (text_orientation_changed), wrapbox);
/* Add expand/fill options */
/* Add expand options */
hbox = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox);
@ -436,22 +428,6 @@ create_window (void)
G_CALLBACK (child_option_toggled), &items_xexpand);
widget = gtk_check_button_new_with_label ("X Fill");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_widget_show (widget);
gtk_widget_set_tooltip_text (widget, "Set whether the items fill their allotted size horizontally");
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (widget), "toggled",
G_CALLBACK (child_option_toggled), &items_xfill);
gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox);
widget = gtk_check_button_new_with_label ("Y Expand");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_widget_show (widget);
@ -462,17 +438,6 @@ create_window (void)
g_signal_connect (G_OBJECT (widget), "toggled",
G_CALLBACK (child_option_toggled), &items_yexpand);
widget = gtk_check_button_new_with_label ("Y Fill");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_widget_show (widget);
gtk_widget_set_tooltip_text (widget, "Set whether the items fill their allotted size vertically");
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (widget), "toggled",
G_CALLBACK (child_option_toggled), &items_yfill);
gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
populate_items (GTK_WRAP_BOX (wrapbox));