]> Pileus Git - ~andy/gtk/blob - gtk/gtkcellrenderer.c
Add hidden aliases for exported symbols which are used internally in order
[~andy/gtk] / gtk / gtkcellrenderer.c
1 /* gtkcellrenderer.c
2  * Copyright (C) 2000  Red Hat, Inc. Jonathan Blandford
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 <config.h>
21 #include "gtkalias.h"
22 #include "gtkcellrenderer.h"
23 #include "gtkintl.h"
24 #include "gtkmarshalers.h"
25 #include "gtktreeprivate.h"
26
27 static void gtk_cell_renderer_init       (GtkCellRenderer      *cell);
28 static void gtk_cell_renderer_class_init (GtkCellRendererClass *class);
29 static void gtk_cell_renderer_get_property  (GObject              *object,
30                                              guint                 param_id,
31                                              GValue               *value,
32                                              GParamSpec           *pspec);
33 static void gtk_cell_renderer_set_property  (GObject              *object,
34                                              guint                 param_id,
35                                              const GValue         *value,
36                                              GParamSpec           *pspec);
37 static void set_cell_bg_color               (GtkCellRenderer      *cell,
38                                              GdkColor             *color);
39
40
41 #define GTK_CELL_RENDERER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererPrivate))
42
43 typedef struct _GtkCellRendererPrivate GtkCellRendererPrivate;
44 struct _GtkCellRendererPrivate
45 {
46   GdkColor cell_background;
47 };
48
49
50 enum {
51   PROP_ZERO,
52   PROP_MODE,
53   PROP_VISIBLE,
54   PROP_SENSITIVE,
55   PROP_XALIGN,
56   PROP_YALIGN,
57   PROP_XPAD,
58   PROP_YPAD,
59   PROP_WIDTH,
60   PROP_HEIGHT,
61   PROP_IS_EXPANDER,
62   PROP_IS_EXPANDED,
63   PROP_CELL_BACKGROUND,
64   PROP_CELL_BACKGROUND_GDK,
65   PROP_CELL_BACKGROUND_SET
66 };
67
68 /* Signal IDs */
69 enum {
70   EDITING_CANCELED,
71   EDITING_STARTED,
72   LAST_SIGNAL
73 };
74
75 static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
76
77
78 GType
79 gtk_cell_renderer_get_type (void)
80 {
81   static GType cell_type = 0;
82
83   if (!cell_type)
84     {
85       static const GTypeInfo cell_info =
86       {
87         sizeof (GtkCellRendererClass),
88         NULL,           /* base_init */
89         NULL,           /* base_finalize */
90         (GClassInitFunc) gtk_cell_renderer_class_init,
91         NULL,           /* class_finalize */
92         NULL,           /* class_data */
93         sizeof (GtkCellRenderer),
94         0,              /* n_preallocs */
95         (GInstanceInitFunc) gtk_cell_renderer_init,
96         NULL,           /* value_table */
97       };
98
99       cell_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkCellRenderer", 
100                                           &cell_info, G_TYPE_FLAG_ABSTRACT);
101     }
102
103   return cell_type;
104 }
105
106 static void
107 gtk_cell_renderer_init (GtkCellRenderer *cell)
108 {
109   cell->mode = GTK_CELL_RENDERER_MODE_INERT;
110   cell->visible = TRUE;
111   cell->width = -1;
112   cell->height = -1;
113   cell->xalign = 0.5;
114   cell->yalign = 0.5;
115   cell->xpad = 0;
116   cell->ypad = 0;
117   cell->sensitive = TRUE;
118   cell->is_expander = FALSE;
119   cell->is_expanded = FALSE;
120 }
121
122 static void
123 gtk_cell_renderer_class_init (GtkCellRendererClass *class)
124 {
125   GObjectClass *object_class = G_OBJECT_CLASS (class);
126
127   object_class->get_property = gtk_cell_renderer_get_property;
128   object_class->set_property = gtk_cell_renderer_set_property;
129
130   class->render = NULL;
131   class->get_size = NULL;
132
133   /**
134    * GtkCellRenderer::editing-canceled:
135    * @renderer: the object which received the signal
136    *
137    * This signal gets emitted when the user cancels the process of editing a
138    * cell.  For example, an editable cell renderer could be written to cancel
139    * editing when the user presses Escape. 
140    *
141    * See also: gtk_cell_renderer_editing_canceled()
142    *
143    * Since: 2.4
144    */
145   cell_renderer_signals[EDITING_CANCELED] =
146     g_signal_new ("editing-canceled",
147                   G_OBJECT_CLASS_TYPE (object_class),
148                   G_SIGNAL_RUN_FIRST,
149                   G_STRUCT_OFFSET (GtkCellRendererClass, editing_canceled),
150                   NULL, NULL,
151                   _gtk_marshal_VOID__VOID,
152                   G_TYPE_NONE, 0);
153
154   /**
155    * GtkCellRenderer::editing-started:
156    * @renderer: the object which received the signal
157    * @editable: the #GtkCellEditable
158    * @path: the path identifying the edited cell
159    *
160    * This signal gets emitted when a cell starts to be edited.
161    * The indended use of this signal is to do special setup
162    * on @editable, e.g. adding a #GtkEntryCompletion or setting
163    * up additional columns in a #GtkComboBox.
164    *
165    * Note that GTK+ doesn't guarantee that cell renderers will
166    * continue to use the same kind of widget for editing in future
167    * releases, therefore you should check the type of @editable
168    * before doing any specific setup, as in the following example:
169    *
170    * <informalexample><programlisting>
171    * static void
172    * text_editing_started (GtkCellRenderer *cell,
173    *                       GtkCellEditable *editable,
174    *                       const gchar     *path,
175    *                       gpointer         data)
176    * {
177    *   if (GTK_IS_ENTRY (editable)) 
178    *     {
179    *       GtkEntry *entry = GTK_ENTRY (editable);
180    *       <!-- -->
181    *       /<!-- -->* ... create a GtkEntryCompletion *<!-- -->/
182    *       <!-- -->
183    *       gtk_entry_set_completion (entry, completion);
184    *     }
185    * }
186    * </programlisting></informalexample>
187    *
188    * Since: 2.6
189    */
190   cell_renderer_signals[EDITING_STARTED] =
191     g_signal_new ("editing-started",
192                   G_OBJECT_CLASS_TYPE (object_class),
193                   G_SIGNAL_RUN_FIRST,
194                   G_STRUCT_OFFSET (GtkCellRendererClass, editing_started),
195                   NULL, NULL,
196                   _gtk_marshal_VOID__OBJECT_STRING,
197                   G_TYPE_NONE, 2,
198                   GTK_TYPE_CELL_EDITABLE,
199                   G_TYPE_STRING);
200
201   g_object_class_install_property (object_class,
202                                    PROP_MODE,
203                                    g_param_spec_enum ("mode",
204                                                       P_("mode"),
205                                                       P_("Editable mode of the CellRenderer"),
206                                                       GTK_TYPE_CELL_RENDERER_MODE,
207                                                       GTK_CELL_RENDERER_MODE_INERT,
208                                                       G_PARAM_READABLE |
209                                                       G_PARAM_WRITABLE));
210
211   g_object_class_install_property (object_class,
212                                    PROP_VISIBLE,
213                                    g_param_spec_boolean ("visible",
214                                                          P_("visible"),
215                                                          P_("Display the cell"),
216                                                          TRUE,
217                                                          G_PARAM_READWRITE));
218   g_object_class_install_property (object_class,
219                                    PROP_SENSITIVE,
220                                    g_param_spec_boolean ("sensitive",
221                                                          P_("Sensitive"),
222                                                          P_("Display the cell sensitive"),
223                                                          TRUE,
224                                                          G_PARAM_READWRITE));
225
226   g_object_class_install_property (object_class,
227                                    PROP_XALIGN,
228                                    g_param_spec_float ("xalign",
229                                                        P_("xalign"),
230                                                        P_("The x-align"),
231                                                        0.0,
232                                                        1.0,
233                                                        0.5,
234                                                        G_PARAM_READABLE |
235                                                        G_PARAM_WRITABLE));
236
237   g_object_class_install_property (object_class,
238                                    PROP_YALIGN,
239                                    g_param_spec_float ("yalign",
240                                                        P_("yalign"),
241                                                        P_("The y-align"),
242                                                        0.0,
243                                                        1.0,
244                                                        0.5,
245                                                        G_PARAM_READABLE |
246                                                        G_PARAM_WRITABLE));
247
248   g_object_class_install_property (object_class,
249                                    PROP_XPAD,
250                                    g_param_spec_uint ("xpad",
251                                                       P_("xpad"),
252                                                       P_("The xpad"),
253                                                       0,
254                                                       G_MAXUINT,
255                                                       0,
256                                                       G_PARAM_READABLE |
257                                                       G_PARAM_WRITABLE));
258
259   g_object_class_install_property (object_class,
260                                    PROP_YPAD,
261                                    g_param_spec_uint ("ypad",
262                                                       P_("ypad"),
263                                                       P_("The ypad"),
264                                                       0,
265                                                       G_MAXUINT,
266                                                       0,
267                                                       G_PARAM_READABLE |
268                                                       G_PARAM_WRITABLE));
269
270   g_object_class_install_property (object_class,
271                                    PROP_WIDTH,
272                                    g_param_spec_int ("width",
273                                                      P_("width"),
274                                                      P_("The fixed width"),
275                                                      -1,
276                                                      G_MAXINT,
277                                                      -1,
278                                                      G_PARAM_READABLE |
279                                                      G_PARAM_WRITABLE));
280
281   g_object_class_install_property (object_class,
282                                    PROP_HEIGHT,
283                                    g_param_spec_int ("height",
284                                                      P_("height"),
285                                                      P_("The fixed height"),
286                                                      -1,
287                                                      G_MAXINT,
288                                                      -1,
289                                                      G_PARAM_READABLE |
290                                                      G_PARAM_WRITABLE));
291
292   g_object_class_install_property (object_class,
293                                    PROP_IS_EXPANDER,
294                                    g_param_spec_boolean ("is_expander",
295                                                          P_("Is Expander"),
296                                                          P_("Row has children"),
297                                                          FALSE,
298                                                          G_PARAM_READABLE |
299                                                          G_PARAM_WRITABLE));
300
301
302   g_object_class_install_property (object_class,
303                                    PROP_IS_EXPANDED,
304                                    g_param_spec_boolean ("is_expanded",
305                                                          P_("Is Expanded"),
306                                                          P_("Row is an expander row, and is expanded"),
307                                                          FALSE,
308                                                          G_PARAM_READABLE |
309                                                          G_PARAM_WRITABLE));
310
311   g_object_class_install_property (object_class,
312                                    PROP_CELL_BACKGROUND,
313                                    g_param_spec_string ("cell_background",
314                                                         P_("Cell background color name"),
315                                                         P_("Cell background color as a string"),
316                                                         NULL,
317                                                         G_PARAM_WRITABLE));
318
319   g_object_class_install_property (object_class,
320                                    PROP_CELL_BACKGROUND_GDK,
321                                    g_param_spec_boxed ("cell_background_gdk",
322                                                        P_("Cell background color"),
323                                                        P_("Cell background color as a GdkColor"),
324                                                        GDK_TYPE_COLOR,
325                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
326
327
328 #define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
329
330   ADD_SET_PROP ("cell_background_set", PROP_CELL_BACKGROUND_SET,
331                 P_("Cell background set"),
332                 P_("Whether this tag affects the cell background color"));
333
334   g_type_class_add_private (object_class, sizeof (GtkCellRendererPrivate));
335 }
336
337 static void
338 gtk_cell_renderer_get_property (GObject     *object,
339                                 guint        param_id,
340                                 GValue      *value,
341                                 GParamSpec  *pspec)
342 {
343   GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
344   GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (object);
345
346   switch (param_id)
347     {
348     case PROP_MODE:
349       g_value_set_enum (value, cell->mode);
350       break;
351     case PROP_VISIBLE:
352       g_value_set_boolean (value, cell->visible);
353       break;
354     case PROP_SENSITIVE:
355       g_value_set_boolean (value, cell->sensitive);
356       break;
357     case PROP_XALIGN:
358       g_value_set_float (value, cell->xalign);
359       break;
360     case PROP_YALIGN:
361       g_value_set_float (value, cell->yalign);
362       break;
363     case PROP_XPAD:
364       g_value_set_uint (value, cell->xpad);
365       break;
366     case PROP_YPAD:
367       g_value_set_uint (value, cell->ypad);
368       break;
369     case PROP_WIDTH:
370       g_value_set_int (value, cell->width);
371       break;
372     case PROP_HEIGHT:
373       g_value_set_int (value, cell->height);
374       break;
375     case PROP_IS_EXPANDER:
376       g_value_set_boolean (value, cell->is_expander);
377       break;
378     case PROP_IS_EXPANDED:
379       g_value_set_boolean (value, cell->is_expanded);
380       break;
381     case PROP_CELL_BACKGROUND_GDK:
382       {
383         GdkColor color;
384
385         color.red = priv->cell_background.red;
386         color.green = priv->cell_background.green;
387         color.blue = priv->cell_background.blue;
388
389         g_value_set_boxed (value, &color);
390       }
391       break;
392     case PROP_CELL_BACKGROUND_SET:
393       g_value_set_boolean (value, cell->cell_background_set);
394       break;
395     case PROP_CELL_BACKGROUND:
396     default:
397       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
398       break;
399     }
400
401 }
402
403 static void
404 gtk_cell_renderer_set_property (GObject      *object,
405                                 guint         param_id,
406                                 const GValue *value,
407                                 GParamSpec   *pspec)
408 {
409   GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
410
411   switch (param_id)
412     {
413     case PROP_MODE:
414       cell->mode = g_value_get_enum (value);
415       break;
416     case PROP_VISIBLE:
417       cell->visible = g_value_get_boolean (value);
418       break;
419     case PROP_SENSITIVE:
420       cell->sensitive = g_value_get_boolean (value);
421       break;
422     case PROP_XALIGN:
423       cell->xalign = g_value_get_float (value);
424       break;
425     case PROP_YALIGN:
426       cell->yalign = g_value_get_float (value);
427       break;
428     case PROP_XPAD:
429       cell->xpad = g_value_get_uint (value);
430       break;
431     case PROP_YPAD:
432       cell->ypad = g_value_get_uint (value);
433       break;
434     case PROP_WIDTH:
435       cell->width = g_value_get_int (value);
436       break;
437     case PROP_HEIGHT:
438       cell->height = g_value_get_int (value);
439       break;
440     case PROP_IS_EXPANDER:
441       cell->is_expander = g_value_get_boolean (value);
442       break;
443     case PROP_IS_EXPANDED:
444       cell->is_expanded = g_value_get_boolean (value);
445       break;
446     case PROP_CELL_BACKGROUND:
447       {
448         GdkColor color;
449
450         if (!g_value_get_string (value))
451           set_cell_bg_color (cell, NULL);
452         else if (gdk_color_parse (g_value_get_string (value), &color))
453           set_cell_bg_color (cell, &color);
454         else
455           g_warning ("Don't know color `%s'", g_value_get_string (value));
456
457         g_object_notify (object, "cell_background_gdk");
458       }
459       break;
460     case PROP_CELL_BACKGROUND_GDK:
461       set_cell_bg_color (cell, g_value_get_boxed (value));
462       break;
463     case PROP_CELL_BACKGROUND_SET:
464       cell->cell_background_set = g_value_get_boolean (value);
465       break;
466     default:
467       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
468       break;
469     }
470 }
471
472 static void
473 set_cell_bg_color (GtkCellRenderer *cell,
474                    GdkColor        *color)
475 {
476   GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
477
478   if (color)
479     {
480       if (!cell->cell_background_set)
481         {
482           cell->cell_background_set = TRUE;
483           g_object_notify (G_OBJECT (cell), "cell_background_set");
484         }
485
486       priv->cell_background.red = color->red;
487       priv->cell_background.green = color->green;
488       priv->cell_background.blue = color->blue;
489     }
490   else
491     {
492       if (cell->cell_background_set)
493         {
494           cell->cell_background_set = FALSE;
495           g_object_notify (G_OBJECT (cell), "cell_background_set");
496         }
497     }
498 }
499
500 /**
501  * gtk_cell_renderer_get_size:
502  * @cell: a #GtkCellRenderer
503  * @widget: the widget the renderer is rendering to
504  * @cell_area: The area a cell will be allocated, or %NULL
505  * @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
506  * @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
507  * @width: location to return width needed to render a cell, or %NULL
508  * @height: location to return height needed to render a cell, or %NULL
509  *
510  * Obtains the width and height needed to render the cell. Used by view widgets
511  * to determine the appropriate size for the cell_area passed to
512  * gtk_cell_renderer_render().  If @cell_area is not %NULL, fills in the x and y
513  * offsets (if set) of the cell relative to this location.  Please note that the
514  * values set in @width and @height, as well as those in @x_offset and @y_offset
515  * are inclusive of the xpad and ypad properties.
516  **/
517 void
518 gtk_cell_renderer_get_size (GtkCellRenderer *cell,
519                             GtkWidget       *widget,
520                             GdkRectangle    *cell_area,
521                             gint            *x_offset,
522                             gint            *y_offset,
523                             gint            *width,
524                             gint            *height)
525 {
526   gint *real_width = width;
527   gint *real_height = height;
528
529   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
530   g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
531
532   if (width && cell->width != -1)
533     {
534       real_width = NULL;
535       *width = cell->width;
536     }
537   if (height && cell->height != -1)
538     {
539       real_height = NULL;
540       *height = cell->height;
541     }
542
543   GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell,
544                                                 widget,
545                                                 cell_area,
546                                                 x_offset,
547                                                 y_offset,
548                                                 real_width,
549                                                 real_height);
550 }
551
552 /**
553  * gtk_cell_renderer_render:
554  * @cell: a #GtkCellRenderer
555  * @window: a #GdkDrawable to draw to
556  * @widget: the widget owning @window
557  * @background_area: entire cell area (including tree expanders and maybe padding on the sides)
558  * @cell_area: area normally rendered by a cell renderer
559  * @expose_area: area that actually needs updating
560  * @flags: flags that affect rendering
561  *
562  * Invokes the virtual render function of the #GtkCellRenderer. The three
563  * passed-in rectangles are areas of @window. Most renderers will draw within
564  * @cell_area; the xalign, yalign, xpad, and ypad fields of the #GtkCellRenderer
565  * should be honored with respect to @cell_area. @background_area includes the
566  * blank space around the cell, and also the area containing the tree expander;
567  * so the @background_area rectangles for all cells tile to cover the entire
568  * @window.  @expose_area is a clip rectangle.
569  *
570  **/
571 void
572 gtk_cell_renderer_render (GtkCellRenderer     *cell,
573                           GdkWindow           *window,
574                           GtkWidget           *widget,
575                           GdkRectangle        *background_area,
576                           GdkRectangle        *cell_area,
577                           GdkRectangle        *expose_area,
578                           GtkCellRendererState flags)
579 {
580   gboolean selected = FALSE;
581   GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
582
583   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
584   g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
585
586   selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
587
588   if (cell->cell_background_set && !selected)
589     {
590       GdkColor color;
591       GdkGC *gc;
592
593       color.red = priv->cell_background.red;
594       color.green = priv->cell_background.green;
595       color.blue = priv->cell_background.blue;
596
597       gc = gdk_gc_new (window);
598       gdk_gc_set_rgb_fg_color (gc, &color);
599       gdk_draw_rectangle (window, gc, TRUE,
600                           background_area->x, background_area->y,
601                           background_area->width, background_area->height);
602       g_object_unref (gc);
603     }
604
605   GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
606                                               window,
607                                               widget,
608                                               background_area,
609                                               cell_area,
610                                               expose_area,
611                                               flags);
612 }
613
614 /**
615  * gtk_cell_renderer_activate:
616  * @cell: a #GtkCellRenderer
617  * @event: a #GdkEvent
618  * @widget: widget that received the event
619  * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
620  * @background_area: background area as passed to @gtk_cell_renderer_render
621  * @cell_area: cell area as passed to @gtk_cell_renderer_render
622  * @flags: render flags
623  *
624  * Passes an activate event to the cell renderer for possible processing.  Some
625  * cell renderers may use events; for example, #GtkCellRendererToggle toggles
626  * when it gets a mouse click.
627  *
628  * Return value: %TRUE if the event was consumed/handled
629  **/
630 gboolean
631 gtk_cell_renderer_activate (GtkCellRenderer      *cell,
632                             GdkEvent             *event,
633                             GtkWidget            *widget,
634                             const gchar          *path,
635                             GdkRectangle         *background_area,
636                             GdkRectangle         *cell_area,
637                             GtkCellRendererState  flags)
638 {
639   g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), FALSE);
640
641   if (cell->mode != GTK_CELL_RENDERER_MODE_ACTIVATABLE)
642     return FALSE;
643
644   if (GTK_CELL_RENDERER_GET_CLASS (cell)->activate == NULL)
645     return FALSE;
646
647   return GTK_CELL_RENDERER_GET_CLASS (cell)->activate (cell,
648                                                        event,
649                                                        widget,
650                                                        path,
651                                                        background_area,
652                                                        cell_area,
653                                                        flags);
654 }
655
656 /**
657  * gtk_cell_renderer_start_editing:
658  * @cell: a #GtkCellRenderer
659  * @event: a #GdkEvent
660  * @widget: widget that received the event
661  * @path: widget-dependent string representation of the event location; e.g. for #GtkTreeView, a string representation of #GtkTreePath
662  * @background_area: background area as passed to @gtk_cell_renderer_render
663  * @cell_area: cell area as passed to @gtk_cell_renderer_render
664  * @flags: render flags
665  * 
666  * Passes an activate event to the cell renderer for possible processing.
667  * 
668  * Return value: A new #GtkCellEditable, or %NULL
669  **/
670 GtkCellEditable *
671 gtk_cell_renderer_start_editing (GtkCellRenderer      *cell,
672                                  GdkEvent             *event,
673                                  GtkWidget            *widget,
674                                  const gchar          *path,
675                                  GdkRectangle         *background_area,
676                                  GdkRectangle         *cell_area,
677                                  GtkCellRendererState  flags)
678
679 {
680   GtkCellEditable *editable;
681
682   g_return_val_if_fail (GTK_IS_CELL_RENDERER (cell), NULL);
683
684   if (cell->mode != GTK_CELL_RENDERER_MODE_EDITABLE)
685     return NULL;
686
687   if (GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing == NULL)
688     return NULL;
689
690   
691   editable = GTK_CELL_RENDERER_GET_CLASS (cell)->start_editing (cell,
692                                                                 event,
693                                                                 widget,
694                                                                 path,
695                                                                 background_area,
696                                                                 cell_area,
697                                                                 flags);
698
699   g_signal_emit (cell, 
700                  cell_renderer_signals[EDITING_STARTED], 0,
701                  editable, path);
702
703   return editable;
704 }
705
706 /**
707  * gtk_cell_renderer_set_fixed_size:
708  * @cell: A #GtkCellRenderer
709  * @width: the width of the cell renderer, or -1
710  * @height: the height of the cell renderer, or -1
711  * 
712  * Sets the renderer size to be explicit, independent of the properties set.
713  **/
714 void
715 gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
716                                   gint             width,
717                                   gint             height)
718 {
719   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
720   g_return_if_fail (width >= -1 && height >= -1);
721
722   if ((width != cell->width) || (height != cell->height))
723     {
724       g_object_freeze_notify (G_OBJECT (cell));
725
726       if (width != cell->width)
727         {
728           cell->width = width;
729           g_object_notify (G_OBJECT (cell), "width");
730         }
731
732       if (height != cell->height)
733         {
734           cell->height = height;
735           g_object_notify (G_OBJECT (cell), "height");
736         }
737
738       g_object_thaw_notify (G_OBJECT (cell));
739     }
740 }
741
742 /**
743  * gtk_cell_renderer_get_fixed_size:
744  * @cell: A #GtkCellRenderer
745  * @width: location to fill in with the fixed width of the widget, or %NULL
746  * @height: location to fill in with the fixed height of the widget, or %NULL
747  * 
748  * Fills in @width and @height with the appropriate size of @cell.
749  **/
750 void
751 gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
752                                   gint            *width,
753                                   gint            *height)
754 {
755   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
756
757   if (width)
758     (* width) = cell->width;
759   if (height)
760     (* height) = cell->height;
761 }
762
763 /**
764  * gtk_cell_renderer_editing_canceled:
765  * @cell: A #GtkCellRenderer
766  * 
767  * Causes the cell renderer to emit the "editing-canceled" signal.  This
768  * function is for use only by implementations of cell renderers that need to
769  * notify the client program that an editing process was canceled and the
770  * changes were not committed.
771  *
772  * Since: 2.4
773  **/
774 void
775 gtk_cell_renderer_editing_canceled (GtkCellRenderer *cell)
776 {
777   g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
778
779   g_signal_emit (cell, cell_renderer_signals[EDITING_CANCELED], 0);
780 }