summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-generous-bin.c
blob: e845b4452d0c09ecd61a0071268eb1169c882be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

/* nautilus-generous-bin.c: Subclass of GtkVBox that clips off
 				      items that don't fit, except the last one.

   Copyright (C) 2000 Eazel, Inc.

   The Gnome Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Gnome Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Author: John Sullivan <sullivan@eazel.com>,
 */

#include <config.h>
#include "nautilus-generous-bin.h"

#include <eel/eel-gtk-macros.h>

static void nautilus_generous_bin_initialize_class (NautilusGenerousBinClass *class);
static void nautilus_generous_bin_initialize       (NautilusGenerousBin      *box);
static void nautilus_generous_bin_size_request     (GtkWidget                *widget,
						    GtkRequisition           *requisition);
static void nautilus_generous_bin_size_allocate    (GtkWidget                *widget,
						    GtkAllocation            *allocation);

EEL_DEFINE_CLASS_BOILERPLATE (NautilusGenerousBin, nautilus_generous_bin, GTK_TYPE_BIN)

static void
nautilus_generous_bin_initialize_class (NautilusGenerousBinClass *klass)
{
	GTK_WIDGET_CLASS (klass)->size_request = nautilus_generous_bin_size_request;
	GTK_WIDGET_CLASS (klass)->size_allocate = nautilus_generous_bin_size_allocate;
}

static void
nautilus_generous_bin_initialize (NautilusGenerousBin *bin)
{
}

static void
nautilus_generous_bin_size_request (GtkWidget *widget,
				    GtkRequisition *requisition)
{
	GtkBin *bin;
	GtkRequisition child_requisition;
	
	bin = GTK_BIN (widget);
	
	requisition->width = 0;
	requisition->height = 0;
	
	if (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)) {
		gtk_widget_size_request (bin->child, &child_requisition);
		
		requisition->width += child_requisition.width;
		requisition->height += child_requisition.height;
	}
}

static void
nautilus_generous_bin_size_allocate (GtkWidget *widget,
				     GtkAllocation *allocation)
{
	GtkBin *bin;
	GtkAllocation child_allocation;
	
	bin = GTK_BIN (widget);
	
	widget->allocation = *allocation;

	if (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)) {
		child_allocation = *allocation;
		gtk_widget_size_allocate (bin->child, &child_allocation);
	}
}