Only try to pack icon if there actually is one.

Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
	try to pack icon if there actually is one.

	* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
	OVERFLOWN items get an allocation even when they are
	unmapped. This ensures they will slide in properly.

	* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
	when there are overflown items that need to slide in. Also add
	comments and make formatting more readable.
This commit is contained in:
Soeren Sandmann 2004-01-24 22:29:18 +00:00 committed by Søren Sandmann Pedersen
parent c2afbf7955
commit 63f37a9ef6
7 changed files with 120 additions and 16 deletions

View File

@ -1,3 +1,16 @@
Sat Jan 24 23:17:27 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.
* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.
Sat Jan 24 17:38:48 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):

View File

@ -1,3 +1,16 @@
Sat Jan 24 23:17:27 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.
* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.
Sat Jan 24 17:38:48 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):

View File

@ -1,3 +1,16 @@
Sat Jan 24 23:17:27 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.
* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.
Sat Jan 24 17:38:48 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):

View File

@ -1,3 +1,16 @@
Sat Jan 24 23:17:27 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.
* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.
Sat Jan 24 17:38:48 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):

View File

@ -1,3 +1,16 @@
Sat Jan 24 23:17:27 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.
* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.
Sat Jan 24 17:38:48 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):

View File

@ -1051,21 +1051,51 @@ slide_idle_handler (gpointer data)
ItemState state;
GtkAllocation goal_allocation;
GtkAllocation allocation;
gboolean cont;
state = toolbar_content_get_state (content);
toolbar_content_get_goal_allocation (content, &goal_allocation);
toolbar_content_get_allocation (content, &allocation);
if ((state == NOT_ALLOCATED) ||
(state == NORMAL &&
toolbar_content_child_visible (content) &&
((goal_allocation.x != allocation.x ||
cont = FALSE;
if (state == NOT_ALLOCATED)
{
/* an unallocated item means that size allocate has to
* called at least once more
*/
cont = TRUE;
}
if ((state == NORMAL && toolbar_content_child_visible (content)) ||
state == OVERFLOWN)
{
if ((goal_allocation.x != allocation.x ||
goal_allocation.y != allocation.y ||
goal_allocation.width != allocation.width ||
goal_allocation.height != allocation.height))) ||
(toolbar_content_is_placeholder (content) &&
goal_allocation.height != allocation.height))
{
/* An item is simply not in its right position yet. Note
* that OVERFLOWN items still get an allocation in
* gtk_toolbar_size_allocate(). This way you can see
* them slide in when you drag out of the toolbar
*/
cont = TRUE;
}
}
if ((toolbar_content_is_placeholder (content) &&
toolbar_content_disappearing (content) &&
toolbar_content_child_visible (content)))
(state == OVERFLOWN || toolbar_content_child_visible (content))))
{
/* A placeholder is disappearing, and it either hasn't disappeared
* yet, or is outside the toolbar.
*/
cont = TRUE;
}
if (cont)
{
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
@ -1140,8 +1170,9 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
state = toolbar_content_get_state (content);
toolbar_content_get_allocation (content, &item_allocation);
if (state == NORMAL &&
rect_within (&item_allocation, &(widget->allocation)))
if ((state == NORMAL &&
rect_within (&item_allocation, &(widget->allocation))) ||
state == OVERFLOWN)
{
new_start_allocation = item_allocation;
}
@ -1334,6 +1365,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
{
overflowing = TRUE;
new_states[i] = OVERFLOWN;
allocations[i].width = item_size;
}
}
@ -1384,7 +1416,11 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
pos = border_width;
for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
{
if (new_states[i] == NORMAL)
/* both NORMAL and OVERFLOWN items get a position. This ensures
* that sliding will work for OVERFLOWN items too
*/
if (new_states[i] == NORMAL ||
new_states[i] == OVERFLOWN)
{
allocations[i].x = pos;
allocations[i].y = border_width;
@ -1477,6 +1513,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (new_states[i] != NORMAL)
{
toolbar_content_set_child_visible (content, toolbar, FALSE);
if (new_states[i] == OVERFLOWN)
toolbar_content_size_allocate (content, &allocations[i]);
}
else
{

View File

@ -387,6 +387,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
case GTK_TOOLBAR_BOTH_HORIZ:
box = gtk_hbox_new (FALSE, 0);
if (icon)
gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
if (label)
gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);