summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2000-09-24 03:57:49 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2000-09-24 03:57:49 +0000
commita9397fa18bc6d884614eafccf859880aae3ac34d (patch)
tree4ef1e64963766a2c9a2f38f08d0eb6f80f207626
parent4f9e7f2b4d16b2a58521c9348e61e6a623f0360f (diff)
downloadnautilus-a9397fa18bc6d884614eafccf859880aae3ac34d.tar.gz
fixed bug 3186 and assorted other problems involving the throbber messing
fixed bug 3186 and assorted other problems involving the throbber messing up toolbar resizing, by implementing nautilus_toolbar_size_request. Now it sizes correctly when you pull it out of the window.
-rw-r--r--ChangeLog9
-rw-r--r--src/nautilus-toolbar.c109
2 files changed, 116 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e65598d0a..86b80da4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2000-09-23 Andy Hertzfeld <andy@eazel.com>
+ * src/nautilus-toolbar.c: (nautilus_toolbar_initialize_class),
+ (nautilus_toolbar_size_allocate), (nautilus_toolbar_size_request):
+ fixed bug 3186 and assorted other problems involving the throbber
+ messing up toolbar resizing, by implementing
+ nautilus_toolbar_size_request. Now it sizes correctly when you
+ pull it out of the window.
+
+2000-09-23 Andy Hertzfeld <andy@eazel.com>
+
* src/nautilus-window-toolbars.c: (set_up_button):
fixed bug where toolbar icon theme indirection was broken,
so now the new ardmore theme uses the blue toolbar icons like
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index b055a4e6b..69faf9e0a 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -45,6 +45,8 @@ static void nautilus_toolbar_initialize_class (NautilusToolbarClass *class);
static void nautilus_toolbar_initialize (NautilusToolbar *bar);
static void nautilus_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+static void nautilus_toolbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusToolbar, nautilus_toolbar, GTK_TYPE_TOOLBAR)
@@ -63,6 +65,8 @@ nautilus_toolbar_initialize_class (NautilusToolbarClass *klass)
widget_class = (GtkWidgetClass *) klass;
widget_class->size_allocate = nautilus_toolbar_size_allocate;
+ widget_class->size_request = nautilus_toolbar_size_request;
+
}
static void
@@ -97,6 +101,7 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
int spacing, save_x;
int item_width, item_height;
int width_to_use, height_to_use;
+ gboolean is_throbber;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
@@ -192,7 +197,9 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
/* special case the throbber, so it's positioned at the far right */
- if (child->widget == nautilus_toolbar->throbber) {
+ is_throbber = child->widget == nautilus_toolbar->throbber &&
+ toolbar->orientation == GTK_ORIENTATION_HORIZONTAL;
+ if (is_throbber) {
save_x = alloc.x;
alloc.x = widget->allocation.width - alloc.width;
}
@@ -204,7 +211,7 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
else
alloc.y += child_requisition.height;
- if (child->widget == nautilus_toolbar->throbber) {
+ if (is_throbber ) {
alloc.x = save_x;
}
@@ -215,3 +222,101 @@ nautilus_toolbar_size_allocate (GtkWidget *widget,
}
}
}
+
+static void
+nautilus_toolbar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ GtkToolbar *toolbar;
+ NautilusToolbar *nautilus_toolbar;
+
+ GList *children;
+ GtkToolbarChild *child;
+ gint nbuttons, spacing;
+ gint button_maxw, button_maxh;
+ gint widget_maxw, widget_maxh;
+ GtkRequisition child_requisition;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_TOOLBAR (widget));
+ g_return_if_fail (requisition != NULL);
+
+ toolbar = GTK_TOOLBAR (widget);
+ nautilus_toolbar = NAUTILUS_TOOLBAR (widget);
+ spacing = nautilus_toolbar->button_spacing;
+
+ requisition->width = GTK_CONTAINER (toolbar)->border_width * 2;
+ requisition->height = GTK_CONTAINER (toolbar)->border_width * 2;
+ nbuttons = 0;
+ button_maxw = 0;
+ button_maxh = 0;
+ widget_maxw = 0;
+ widget_maxh = 0;
+
+ for (children = toolbar->children; children; children = children->next)
+ {
+ child = children->data;
+
+ switch (child->type)
+ {
+ case GTK_TOOLBAR_CHILD_SPACE:
+ if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
+ requisition->width += toolbar->space_size;
+ else
+ requisition->height += toolbar->space_size;
+
+ break;
+
+ case GTK_TOOLBAR_CHILD_BUTTON:
+ case GTK_TOOLBAR_CHILD_RADIOBUTTON:
+ case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
+ if (GTK_WIDGET_VISIBLE (child->widget))
+ {
+ gtk_widget_size_request (child->widget, &child_requisition);
+
+ if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ requisition->width += (child_requisition.width > spacing) ? child_requisition.width : spacing;
+
+ } else {
+ requisition->height += (child_requisition.height > spacing) ? child_requisition.height : spacing;
+ }
+
+ nbuttons++;
+
+ button_maxw = MAX (button_maxw, child_requisition.width);
+ button_maxh = MAX (button_maxh, child_requisition.height);
+ }
+
+ break;
+
+ case GTK_TOOLBAR_CHILD_WIDGET:
+ if (GTK_WIDGET_VISIBLE (child->widget))
+ {
+ gtk_widget_size_request (child->widget, &child_requisition);
+
+ if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
+ requisition->width += child_requisition.width + toolbar->space_size ;
+ else
+ requisition->height += child_requisition.height + toolbar->space_size;
+ }
+
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ requisition->height += MAX (button_maxh, widget_maxh);
+ }
+ else
+ {
+ requisition->width += MAX (button_maxw, widget_maxw);
+ }
+
+ toolbar->button_maxw = button_maxw;
+ toolbar->button_maxh = button_maxh;
+}
+