restructured toolbox to use a single gtk_hwrap_box with the added "forced

2000-02-07  Kelly Lynn Martin  <kelly@poverty.bloomington.in.us>

	* app/interface.c: restructured toolbox to use a single
	gtk_hwrap_box with the added "forced break" functionality to make
	the selector boxes not run in with the rest of the tool buttons.
	The toolbox should now not cut things off, although if the user
	selects a really small toolbox the buttons or selectors may be,
	um, difficult to use...

	* app/gtkwrapbox.h:
	* app/gtkwrapbox.c:
	* app/gtkvwrapbox.c (reverse_list_col_children):
	* app/gtkhwrapbox.c (reverse_list_row_children): support for
	"forced break" functionality needed for toolbox -- will forward
	patches to Tim Janik as well
This commit is contained in:
Kelly Lynn Martin
2000-02-07 10:51:08 +00:00
committed by Kelly Martin
parent 827e9ddad7
commit 77c44b21e1
12 changed files with 185 additions and 38 deletions

View File

@ -1,3 +1,19 @@
2000-02-07 Kelly Lynn Martin <kelly@poverty.bloomington.in.us>
* app/interface.c: restructured toolbox to use a single
gtk_hwrap_box with the added "forced break" functionality to make
the selector boxes not run in with the rest of the tool buttons.
The toolbox should now not cut things off, although if the user
selects a really small toolbox the buttons or selectors may be,
um, difficult to use...
* app/gtkwrapbox.h:
* app/gtkwrapbox.c:
* app/gtkvwrapbox.c (reverse_list_col_children):
* app/gtkhwrapbox.c (reverse_list_row_children): support for
"forced break" functionality needed for toolbox -- will forward
patches to Tim Janik as well
Mon Feb 7 05:04:28 2000 Tim Janik <timj@gtk.org>
* app/gtkhwrapbox.c:

View File

@ -256,7 +256,7 @@ create_indicator_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -290,7 +290,8 @@ create_color_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -346,11 +347,7 @@ create_tools (GtkWidget *parent)
GSList *group;
gint i, j;
/*create_logo (parent);*/
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), wbox, TRUE, TRUE, TRUE, TRUE);
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
@ -368,7 +365,7 @@ create_tools (GtkWidget *parent)
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
FALSE, TRUE, FALSE, TRUE);
FALSE, FALSE, FALSE, FALSE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 0);
@ -592,16 +589,20 @@ create_toolbox (void)
gimp_standard_help_func,
"toolbox/toolbox.html");
wbox = gtk_vwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL);
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_LEFT);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 20);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
gtk_widget_show (wbox);
create_tools (wbox);
create_color_area (wbox);
if (show_indicators)
create_indicator_area (wbox);
gtk_widget_show (window);
toolbox_set_drag_dest (window);

View File

@ -256,7 +256,7 @@ create_indicator_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -290,7 +290,8 @@ create_color_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -346,11 +347,7 @@ create_tools (GtkWidget *parent)
GSList *group;
gint i, j;
/*create_logo (parent);*/
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), wbox, TRUE, TRUE, TRUE, TRUE);
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
@ -368,7 +365,7 @@ create_tools (GtkWidget *parent)
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
FALSE, TRUE, FALSE, TRUE);
FALSE, FALSE, FALSE, FALSE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 0);
@ -592,16 +589,20 @@ create_toolbox (void)
gimp_standard_help_func,
"toolbox/toolbox.html");
wbox = gtk_vwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL);
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_LEFT);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 20);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
gtk_widget_show (wbox);
create_tools (wbox);
create_color_area (wbox);
if (show_indicators)
create_indicator_area (wbox);
gtk_widget_show (window);
toolbox_set_drag_dest (window);

View File

@ -324,7 +324,8 @@ reverse_list_row_children (GtkWrapBox *wbox,
if (GTK_WIDGET_VISIBLE (child->widget))
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (width + wbox->hspacing + child_requisition.width > row_width)
if (width + wbox->hspacing + child_requisition.width > row_width ||
child->forced_break)
break;
width += wbox->hspacing + child_requisition.width;
*max_child_size = MAX (*max_child_size, child_requisition.height);
@ -620,7 +621,7 @@ layout_rows (GtkWrapBox *wbox,
line->children,
children_per_line,
line->expand);
g_slist_free (line->children);
g_free (line);
line = next_line;

View File

@ -324,7 +324,8 @@ reverse_list_col_children (GtkWrapBox *wbox,
if (GTK_WIDGET_VISIBLE (child->widget))
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (height + wbox->vspacing + child_requisition.height > col_height)
if (height + wbox->vspacing + child_requisition.height > col_height ||
child->forced_break)
break;
height += wbox->vspacing + child_requisition.height;
*max_child_size = MAX (*max_child_size, child_requisition.width);

View File

@ -42,7 +42,8 @@ enum {
CHILD_ARG_HEXPAND,
CHILD_ARG_HFILL,
CHILD_ARG_VEXPAND,
CHILD_ARG_VFILL
CHILD_ARG_VFILL,
CHILD_ARG_FORCED_BREAK
};
@ -166,6 +167,8 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VEXPAND);
gtk_container_add_child_arg_type ("GtkWrapBox::vfill",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VFILL);
gtk_container_add_child_arg_type ("GtkWrapBox::forcebreak",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FORCED_BREAK);
}
static void
@ -299,6 +302,10 @@ gtk_wrap_box_set_child_arg (GtkContainer *container,
hexpand, hfill,
vexpand, GTK_VALUE_BOOL (*arg));
break;
case CHILD_ARG_FORCED_BREAK:
gtk_wrap_box_set_child_forced_break (wbox, child,
GTK_VALUE_BOOL (*arg));
break;
default:
break;
}
@ -457,6 +464,7 @@ gtk_wrap_box_pack (GtkWrapBox *wbox,
child_info->hfill = hfill ? TRUE : FALSE;
child_info->vexpand = vexpand ? TRUE : FALSE;
child_info->vfill = vfill ? TRUE : FALSE;
child_info->forced_break = FALSE;
child_info->next = NULL;
if (wbox->children)
{
@ -565,6 +573,27 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
}
}
void
gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean *forced_break)
{
GtkWrapBoxChild *child_info;
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
if (child_info)
{
if (forced_break)
*forced_break = child_info->forced_break;
}
}
void
gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
@ -601,6 +630,32 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
}
}
void
gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean forced_break)
{
GtkWrapBoxChild *child_info;
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
forced_break = forced_break != FALSE;
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
if (child_info &&
(child_info->forced_break != forced_break))
{
child_info->forced_break = forced_break;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
gtk_widget_queue_resize (child);
}
}
guint*
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *_n_lines)

View File

@ -78,6 +78,7 @@ struct _GtkWrapBoxChild
guint hfill : 1;
guint vexpand : 1;
guint vfill : 1;
guint forced_break : 1;
GtkWrapBoxChild *next;
};
@ -114,12 +115,18 @@ void gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
gboolean *hfill,
gboolean *vexpand,
gboolean *vfill);
void gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean *forced_break);
void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
gboolean hexpand,
gboolean hfill,
gboolean vexpand,
gboolean vfill);
void gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean forced_break);
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *n_lines);

View File

@ -256,7 +256,7 @@ create_indicator_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -290,7 +290,8 @@ create_color_area (GtkWidget *parent)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, FALSE, TRUE, FALSE, TRUE);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@ -346,11 +347,7 @@ create_tools (GtkWidget *parent)
GSList *group;
gint i, j;
/*create_logo (parent);*/
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), .36);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), wbox, TRUE, TRUE, TRUE, TRUE);
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
@ -368,7 +365,7 @@ create_tools (GtkWidget *parent)
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
FALSE, TRUE, FALSE, TRUE);
FALSE, FALSE, FALSE, FALSE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 0);
@ -592,16 +589,20 @@ create_toolbox (void)
gimp_standard_help_func,
"toolbox/toolbox.html");
wbox = gtk_vwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_FILL);
wbox = gtk_hwrap_box_new (FALSE);
gtk_wrap_box_set_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_TOP);
gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wbox), GTK_JUSTIFY_LEFT);
gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wbox), 20);
gtk_container_set_border_width (GTK_CONTAINER (wbox), 0);
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
gtk_widget_show (wbox);
create_tools (wbox);
create_color_area (wbox);
if (show_indicators)
create_indicator_area (wbox);
gtk_widget_show (window);
toolbox_set_drag_dest (window);

View File

@ -324,7 +324,8 @@ reverse_list_row_children (GtkWrapBox *wbox,
if (GTK_WIDGET_VISIBLE (child->widget))
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (width + wbox->hspacing + child_requisition.width > row_width)
if (width + wbox->hspacing + child_requisition.width > row_width ||
child->forced_break)
break;
width += wbox->hspacing + child_requisition.width;
*max_child_size = MAX (*max_child_size, child_requisition.height);
@ -620,7 +621,7 @@ layout_rows (GtkWrapBox *wbox,
line->children,
children_per_line,
line->expand);
g_slist_free (line->children);
g_free (line);
line = next_line;

View File

@ -324,7 +324,8 @@ reverse_list_col_children (GtkWrapBox *wbox,
if (GTK_WIDGET_VISIBLE (child->widget))
{
get_child_requisition (wbox, child->widget, &child_requisition);
if (height + wbox->vspacing + child_requisition.height > col_height)
if (height + wbox->vspacing + child_requisition.height > col_height ||
child->forced_break)
break;
height += wbox->vspacing + child_requisition.height;
*max_child_size = MAX (*max_child_size, child_requisition.width);

View File

@ -42,7 +42,8 @@ enum {
CHILD_ARG_HEXPAND,
CHILD_ARG_HFILL,
CHILD_ARG_VEXPAND,
CHILD_ARG_VFILL
CHILD_ARG_VFILL,
CHILD_ARG_FORCED_BREAK
};
@ -166,6 +167,8 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VEXPAND);
gtk_container_add_child_arg_type ("GtkWrapBox::vfill",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VFILL);
gtk_container_add_child_arg_type ("GtkWrapBox::forcebreak",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FORCED_BREAK);
}
static void
@ -299,6 +302,10 @@ gtk_wrap_box_set_child_arg (GtkContainer *container,
hexpand, hfill,
vexpand, GTK_VALUE_BOOL (*arg));
break;
case CHILD_ARG_FORCED_BREAK:
gtk_wrap_box_set_child_forced_break (wbox, child,
GTK_VALUE_BOOL (*arg));
break;
default:
break;
}
@ -457,6 +464,7 @@ gtk_wrap_box_pack (GtkWrapBox *wbox,
child_info->hfill = hfill ? TRUE : FALSE;
child_info->vexpand = vexpand ? TRUE : FALSE;
child_info->vfill = vfill ? TRUE : FALSE;
child_info->forced_break = FALSE;
child_info->next = NULL;
if (wbox->children)
{
@ -565,6 +573,27 @@ gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
}
}
void
gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean *forced_break)
{
GtkWrapBoxChild *child_info;
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
if (child_info)
{
if (forced_break)
*forced_break = child_info->forced_break;
}
}
void
gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
@ -601,6 +630,32 @@ gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
}
}
void
gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean forced_break)
{
GtkWrapBoxChild *child_info;
g_return_if_fail (GTK_IS_WRAP_BOX (wbox));
g_return_if_fail (GTK_IS_WIDGET (child));
forced_break = forced_break != FALSE;
for (child_info = wbox->children; child_info; child_info = child_info->next)
if (child_info->widget == child)
break;
if (child_info &&
(child_info->forced_break != forced_break))
{
child_info->forced_break = forced_break;
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox))
gtk_widget_queue_resize (child);
}
}
guint*
gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *_n_lines)

View File

@ -78,6 +78,7 @@ struct _GtkWrapBoxChild
guint hfill : 1;
guint vexpand : 1;
guint vfill : 1;
guint forced_break : 1;
GtkWrapBoxChild *next;
};
@ -114,12 +115,18 @@ void gtk_wrap_box_query_child_packing (GtkWrapBox *wbox,
gboolean *hfill,
gboolean *vexpand,
gboolean *vfill);
void gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean *forced_break);
void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox,
GtkWidget *child,
gboolean hexpand,
gboolean hfill,
gboolean vexpand,
gboolean vfill);
void gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox,
GtkWidget *child,
gboolean forced_break);
guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox,
guint *n_lines);