]> Pileus Git - ~andy/gtk/blob - gtk/gtkcelllayout.c
Landing GtkTreeModelFilter and the completion code. (Test program and
[~andy/gtk] / gtk / gtkcelllayout.c
1 /* gtkcelllayout.c
2  * Copyright (C) 2003  Kristian Rietveld  <kris@gtk.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "gtkcelllayout.h"
21
22 GType
23 gtk_cell_layout_get_type (void)
24 {
25   static GType cell_layout_type = 0;
26
27   if (! cell_layout_type)
28     {
29       static const GTypeInfo cell_layout_info =
30       {
31         sizeof (GtkCellLayoutIface),
32         NULL,
33         NULL,
34         NULL,
35         NULL,
36         NULL,
37         0,
38         0,
39         NULL
40       };
41
42       cell_layout_type =
43         g_type_register_static (G_TYPE_INTERFACE, "GtkCellLayout",
44                                 &cell_layout_info, 0);
45
46       g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT);
47     }
48
49   return cell_layout_type;
50 }
51
52
53 void
54 gtk_cell_layout_pack_start (GtkCellLayout   *cell_layout,
55                             GtkCellRenderer *cell,
56                             gboolean         expand)
57 {
58   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
59   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
60
61   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout,
62                                                            cell,
63                                                            expand);
64 }
65
66 void
67 gtk_cell_layout_pack_end (GtkCellLayout   *cell_layout,
68                           GtkCellRenderer *cell,
69                           gboolean         expand)
70 {
71   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
72   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
73
74   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout,
75                                                          cell,
76                                                          expand);
77 }
78
79 void
80 gtk_cell_layout_clear (GtkCellLayout *cell_layout)
81 {
82   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
83
84   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout);
85 }
86
87 static void
88 gtk_cell_layout_set_attributesv (GtkCellLayout   *cell_layout,
89                                  GtkCellRenderer *cell,
90                                  va_list          args)
91 {
92   gchar *attribute;
93   gint column;
94   GtkCellLayoutIface *iface;
95
96   attribute = va_arg (args, gchar *);
97
98   iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
99
100   (* iface->clear_attributes) (cell_layout, cell);
101
102   while (attribute != NULL)
103     {
104       column = va_arg (args, gint);
105       (* iface->add_attribute) (cell_layout, cell, attribute, column);
106       attribute = va_arg (args, gchar *);
107     }
108 }
109
110 void
111 gtk_cell_layout_set_attributes (GtkCellLayout   *cell_layout,
112                                 GtkCellRenderer *cell,
113                                 ...)
114 {
115   va_list args;
116
117   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
118   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
119
120   va_start (args, cell);
121   gtk_cell_layout_set_attributesv (cell_layout, cell, args);
122   va_end (args);
123 }
124
125 void
126 gtk_cell_layout_add_attribute (GtkCellLayout   *cell_layout,
127                                GtkCellRenderer *cell,
128                                const gchar     *attribute,
129                                gint             column)
130 {
131   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
132   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
133   g_return_if_fail (attribute != NULL);
134   g_return_if_fail (column >= 0);
135
136   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout,
137                                                               cell,
138                                                               attribute,
139                                                               column);
140 }
141
142 void
143 gtk_cell_layout_set_cell_data_func (GtkCellLayout         *cell_layout,
144                                     GtkCellRenderer       *cell,
145                                     GtkCellLayoutDataFunc  func,
146                                     gpointer               func_data,
147                                     GDestroyNotify         destroy)
148 {
149   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
150   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
151
152   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout,
153                                                                    cell,
154                                                                    func,
155                                                                    func_data,
156                                                                    destroy);
157 }
158
159 void
160 gtk_cell_layout_clear_attributes (GtkCellLayout   *cell_layout,
161                                   GtkCellRenderer *cell)
162 {
163   g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
164   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
165
166   (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout,
167                                                                  cell);
168 }