From 63f37a9ef608c27f617ab3ea64e7ccb8d0a10852 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Sat, 24 Jan 2004 22:29:18 +0000 Subject: [PATCH] Only try to pack icon if there actually is one. Sat Jan 24 23:17:27 2004 Soeren Sandmann * 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. --- ChangeLog | 13 +++++++++ ChangeLog.pre-2-10 | 13 +++++++++ ChangeLog.pre-2-4 | 13 +++++++++ ChangeLog.pre-2-6 | 13 +++++++++ ChangeLog.pre-2-8 | 13 +++++++++ gtk/gtktoolbar.c | 68 +++++++++++++++++++++++++++++++++++---------- gtk/gtktoolbutton.c | 3 +- 7 files changed, 120 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c4ba995bf..9fa316b817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Jan 24 23:17:27 2004 Soeren Sandmann + + * 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 * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7c4ba995bf..9fa316b817 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Sat Jan 24 23:17:27 2004 Soeren Sandmann + + * 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 * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7c4ba995bf..9fa316b817 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +Sat Jan 24 23:17:27 2004 Soeren Sandmann + + * 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 * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7c4ba995bf..9fa316b817 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Sat Jan 24 23:17:27 2004 Soeren Sandmann + + * 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 * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7c4ba995bf..9fa316b817 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Sat Jan 24 23:17:27 2004 Soeren Sandmann + + * 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 * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init): diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index b1b004092a..2141880a51 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -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 || - goal_allocation.y != allocation.y || - goal_allocation.width != allocation.width || - goal_allocation.height != allocation.height))) || - (toolbar_content_is_placeholder (content) && + 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)) + { + /* 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 { @@ -1500,7 +1538,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, { alloc = allocations[i]; } - + if (alloc.width == 0 || alloc.height == 0) { toolbar_content_set_child_visible (content, toolbar, FALSE); @@ -1511,7 +1549,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, toolbar_content_size_allocate (content, &alloc); } } - + toolbar_content_set_state (content, new_states[i]); } diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index 91f5a7c23f..516f93c3b7 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -387,7 +387,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) case GTK_TOOLBAR_BOTH_HORIZ: box = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 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); gtk_container_add (GTK_CONTAINER (button->priv->button), box);