]> Pileus Git - ~andy/gtk/blob - gtk/gtkcelleditable.c
a0a818b6107c14036e86c14567649a5c1349c8d7
[~andy/gtk] / gtk / gtkcelleditable.c
1 /* gtkcelleditable.c
2  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
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
21 #include "config.h"
22 #include "gtkcelleditable.h"
23 #include "gtkmarshalers.h"
24 #include "gtkprivate.h"
25 #include "gtkintl.h"
26 #include "gtkalias.h"
27
28 static void gtk_cell_editable_base_init (GtkCellEditableIface *iface);
29
30 GType
31 gtk_cell_editable_get_type (void)
32 {
33   static GType cell_editable_type = 0;
34
35   if (! cell_editable_type)
36     {
37       const GTypeInfo cell_editable_info =
38       {
39         sizeof (GtkCellEditableIface),                 /* class_size */
40         (GBaseInitFunc) gtk_cell_editable_base_init,   /* base_init */
41         NULL,                                          /* base_finalize */
42         NULL,
43         NULL,                                          /* class_finalize */
44         NULL,                                          /* class_data */
45         0,
46         0,
47         NULL
48       };
49
50       cell_editable_type =
51         g_type_register_static (G_TYPE_INTERFACE, I_("GtkCellEditable"),
52                                 &cell_editable_info, 0);
53
54       g_type_interface_add_prerequisite (cell_editable_type, GTK_TYPE_WIDGET);
55     }
56
57   return cell_editable_type;
58 }
59
60 static void
61 gtk_cell_editable_base_init (GtkCellEditableIface *iface)
62 {
63   static gboolean initialized = FALSE;
64
65   if (! initialized)
66     {
67       /**
68        * GtkCellEditable:editing-canceled:
69        *
70        * Indicates whether editing on the cell has been canceled.
71        *
72        * Since: 2.20
73        **/
74       g_object_interface_install_property (iface,
75                                            g_param_spec_boolean ("editing-canceled",
76                                                                  P_("Editing Canceled"),
77                                                                  P_("Indicates that editing has been canceled"),
78                                                                  FALSE,
79                                                                  GTK_PARAM_READWRITE));
80
81       /**
82        * GtkCellEditable::editing-done:
83        * @cell_editable: the object on which the signal was emitted
84        *
85        * This signal is a sign for the cell renderer to update its 
86        * value from the @cell_editable. 
87        *
88        * Implementations of #GtkCellEditable are responsible for 
89        * emitting this signal when they are done editing, e.g. 
90        * #GtkEntry is emitting it when the user presses Enter.
91        *
92        * gtk_cell_editable_editing_done() is a convenience method
93        * for emitting ::editing-done. 
94        */
95       g_signal_new (I_("editing-done"),
96                     GTK_TYPE_CELL_EDITABLE,
97                     G_SIGNAL_RUN_LAST,
98                     G_STRUCT_OFFSET (GtkCellEditableIface, editing_done),
99                     NULL, NULL,
100                     _gtk_marshal_VOID__VOID,
101                     G_TYPE_NONE, 0);
102
103       /**
104        * GtkCellEditable::remove-widget:
105        * @cell_editable: the object on which the signal was emitted
106        *
107        * This signal is meant to indicate that the cell is finished 
108        * editing, and the widget may now be destroyed. 
109        *
110        * Implementations of #GtkCellEditable are responsible for 
111        * emitting this signal when they are done editing. It must
112        * be emitted after the #GtkCellEditable::editing-done signal, 
113        * to give the cell renderer a chance to update the cell's value 
114        * before the widget is removed. 
115        *
116        * gtk_cell_editable_remove_widget() is a convenience method
117        * for emitting ::remove-widget. 
118        */
119       g_signal_new (I_("remove-widget"),
120                     GTK_TYPE_CELL_EDITABLE,
121                     G_SIGNAL_RUN_LAST,
122                     G_STRUCT_OFFSET (GtkCellEditableIface, remove_widget),
123                     NULL, NULL,
124                     _gtk_marshal_VOID__VOID,
125                     G_TYPE_NONE, 0);
126       initialized = TRUE;
127     }
128 }
129
130 /**
131  * gtk_cell_editable_start_editing:
132  * @cell_editable: A #GtkCellEditable
133  * @event: (allow-none): A #GdkEvent, or %NULL
134  * 
135  * Begins editing on a @cell_editable. @event is the #GdkEvent that began 
136  * the editing process. It may be %NULL, in the instance that editing was 
137  * initiated through programatic means.
138  **/
139 void
140 gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
141                                  GdkEvent        *event)
142 {
143   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
144
145   (* GTK_CELL_EDITABLE_GET_IFACE (cell_editable)->start_editing) (cell_editable, event);
146 }
147
148 /**
149  * gtk_cell_editable_editing_done:
150  * @cell_editable: A #GtkTreeEditable
151  * 
152  * Emits the #GtkCellEditable::editing-done signal. 
153  **/
154 void
155 gtk_cell_editable_editing_done (GtkCellEditable *cell_editable)
156 {
157   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
158
159   g_signal_emit_by_name (cell_editable, "editing-done");
160 }
161
162 /**
163  * gtk_cell_editable_remove_widget:
164  * @cell_editable: A #GtkTreeEditable
165  * 
166  * Emits the #GtkCellEditable::remove-widget signal.  
167  **/
168 void
169 gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable)
170 {
171   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
172
173   g_signal_emit_by_name (cell_editable, "remove-widget");
174 }
175
176 #define __GTK_CELL_EDITABLE_C__
177 #include "gtkaliasdef.c"