Re-indented to GNU style to be consistent with the rest of Gtk - Federico

This commit is contained in:
Arturo Espinosa
1998-01-13 07:00:52 +00:00
parent 139026de73
commit 4da8e492f7

View File

@ -33,13 +33,15 @@ enum {
};
typedef enum {
typedef enum
{
CHILD_SPACE,
CHILD_BUTTON,
CHILD_WIDGET
} ChildType;
typedef struct {
typedef struct
{
ChildType type;
GtkWidget *widget;
GtkWidget *icon;
@ -93,8 +95,10 @@ gtk_toolbar_get_type(void)
{
static guint toolbar_type = 0;
if (!toolbar_type) {
GtkTypeInfo toolbar_info = {
if (!toolbar_type)
{
GtkTypeInfo toolbar_info =
{
"GtkToolbar",
sizeof (GtkToolbar),
sizeof (GtkToolbarClass),
@ -187,7 +191,6 @@ gtk_toolbar_new(GtkOrientation orientation,
return GTK_WIDGET (toolbar);
}
static void
gtk_toolbar_destroy (GtkObject *object)
{
@ -202,10 +205,12 @@ gtk_toolbar_destroy(GtkObject *object)
gtk_tooltips_unref (toolbar->tooltips);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if (child->type != CHILD_SPACE) {
if (child->type != CHILD_SPACE)
{
child->widget->parent = NULL;
gtk_object_unref (GTK_OBJECT (child->widget));
gtk_widget_destroy (child->widget);
@ -233,7 +238,8 @@ gtk_toolbar_map(GtkWidget *widget)
toolbar = GTK_TOOLBAR (widget);
GTK_WIDGET_SET_FLAGS (toolbar, GTK_MAPPED);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != CHILD_SPACE)
@ -255,7 +261,8 @@ gtk_toolbar_unmap(GtkWidget *widget)
toolbar = GTK_TOOLBAR (widget);
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_MAPPED);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != CHILD_SPACE)
@ -276,10 +283,12 @@ gtk_toolbar_draw(GtkWidget *widget,
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (widget));
if (GTK_WIDGET_DRAWABLE(widget)) {
if (GTK_WIDGET_DRAWABLE (widget))
{
toolbar = GTK_TOOLBAR (widget);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != CHILD_SPACE)
@ -302,12 +311,14 @@ gtk_toolbar_expose(GtkWidget *widget,
g_return_val_if_fail (GTK_IS_TOOLBAR (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE(widget)) {
if (GTK_WIDGET_DRAWABLE (widget))
{
toolbar = GTK_TOOLBAR (widget);
child_event = *event;
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != CHILD_SPACE)
@ -345,10 +356,12 @@ gtk_toolbar_size_request(GtkWidget *widget,
widget_maxw = 0;
widget_maxh = 0;
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
switch (child->type) {
switch (child->type)
{
case CHILD_SPACE:
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
requisition->width += toolbar->space_size;
@ -358,7 +371,8 @@ gtk_toolbar_size_request(GtkWidget *widget,
break;
case CHILD_BUTTON:
if (GTK_WIDGET_VISIBLE(child->widget)) {
if (GTK_WIDGET_VISIBLE (child->widget))
{
gtk_widget_size_request (child->widget, &child->widget->requisition);
nbuttons++;
@ -369,7 +383,8 @@ gtk_toolbar_size_request(GtkWidget *widget,
break;
case CHILD_WIDGET:
if (GTK_WIDGET_VISIBLE(child->widget)) {
if (GTK_WIDGET_VISIBLE (child->widget))
{
gtk_widget_size_request (child->widget, &child->widget->requisition);
widget_maxw = MAX (widget_maxw, child->widget->requisition.width);
@ -388,10 +403,13 @@ gtk_toolbar_size_request(GtkWidget *widget,
}
}
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) {
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
requisition->width += nbuttons * button_maxw;
requisition->height += MAX (button_maxh, widget_maxh);
} else {
}
else
{
requisition->width += MAX (button_maxw, widget_maxw);
requisition->height += nbuttons * button_maxh;
}
@ -424,10 +442,12 @@ gtk_toolbar_size_allocate(GtkWidget *widget,
else
alloc.y = allocation->y + border_width;
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
switch (child->type) {
switch (child->type)
{
case CHILD_SPACE:
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.x += toolbar->space_size;
@ -441,11 +461,9 @@ gtk_toolbar_size_allocate(GtkWidget *widget,
alloc.height = toolbar->button_maxh;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.y = (allocation->y
+ (allocation->height - toolbar->button_maxh) / 2);
alloc.y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
else
alloc.x = (allocation->x
+ (allocation->width - toolbar->button_maxw) / 2);
alloc.x = allocation->x + (allocation->width - toolbar->button_maxw) / 2;
gtk_widget_size_allocate (child->widget, &alloc);
@ -461,13 +479,9 @@ gtk_toolbar_size_allocate(GtkWidget *widget,
alloc.height = child->widget->requisition.height;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.y = (allocation->y
+ (allocation->height
- child->widget->requisition.height) / 2);
alloc.y = allocation->y + (allocation->height - child->widget->requisition.height) / 2;
else
alloc.x = (allocation->x
+ (allocation->width
- child->widget->requisition.width) / 2);
alloc.x = allocation->x + (allocation->width - child->widget->requisition.width) / 2;
gtk_widget_size_allocate (child->widget, &alloc);
@ -509,10 +523,12 @@ gtk_toolbar_remove(GtkContainer *container,
toolbar = GTK_TOOLBAR (container);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != CHILD_SPACE) && (child->widget == widget)) {
if ((child->type != CHILD_SPACE) && (child->widget == widget))
{
gtk_widget_unparent (widget);
toolbar->children = g_list_remove_link (toolbar->children, children);
@ -543,7 +559,8 @@ gtk_toolbar_foreach(GtkContainer *container,
toolbar = GTK_TOOLBAR (container);
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if (child->type != CHILD_SPACE)
@ -622,7 +639,8 @@ gtk_toolbar_insert_item(GtkToolbar *toolbar,
if (child->label)
gtk_box_pack_start (GTK_BOX (vbox), child->label, FALSE, FALSE, 0);
switch (toolbar->style) {
switch (toolbar->style)
{
case GTK_TOOLBAR_ICONS:
if (child->icon)
gtk_widget_show (child->icon);
@ -653,7 +671,8 @@ gtk_toolbar_insert_item(GtkToolbar *toolbar,
gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
if (GTK_WIDGET_VISIBLE(toolbar)) {
if (GTK_WIDGET_VISIBLE (toolbar))
{
if (GTK_WIDGET_REALIZED (toolbar)
&& !GTK_WIDGET_REALIZED (child->widget))
gtk_widget_realize (child->widget);
@ -744,7 +763,8 @@ gtk_toolbar_insert_widget(GtkToolbar *toolbar,
gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
if (GTK_WIDGET_VISIBLE(toolbar)) {
if (GTK_WIDGET_VISIBLE (toolbar))
{
if (GTK_WIDGET_REALIZED (toolbar)
&& !GTK_WIDGET_REALIZED (child->widget))
gtk_widget_realize (child->widget);
@ -779,7 +799,8 @@ gtk_toolbar_set_space_size(GtkToolbar *toolbar,
g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
if (toolbar->space_size != space_size) {
if (toolbar->space_size != space_size)
{
toolbar->space_size = space_size;
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
}
@ -818,7 +839,8 @@ gtk_real_toolbar_orientation_changed(GtkToolbar *toolbar,
g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
if (toolbar->orientation != orientation) {
if (toolbar->orientation != orientation)
{
toolbar->orientation = orientation;
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
}
@ -834,14 +856,17 @@ gtk_real_toolbar_style_changed(GtkToolbar *toolbar,
g_return_if_fail (toolbar != NULL);
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
if (toolbar->style != style) {
if (toolbar->style != style)
{
toolbar->style = style;
for (children = toolbar->children; children; children = children->next) {
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if (child->type == CHILD_BUTTON)
switch (style) {
switch (style)
{
case GTK_TOOLBAR_ICONS:
if (child->icon && !GTK_WIDGET_VISIBLE (child->icon))
gtk_widget_show (child->icon);