]> Pileus Git - ~andy/gtk/blob - gtk/gtkcelleditable.c
09f47533b010987a6fbb1f357e221d889b44a67b
[~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  * SECTION:gtkcelleditable
22  * @Short_description: Interface for widgets which can are used for editing
23  *  cells
24  * @Title: GtkCellEditable
25  * @See_also: #GtkEntry, #GtkCellRenderer
26  *
27  * The #GtkCellEditable interface must be implemented for widgets to be usable
28  * when editing the contents of a #GtkTreeView cell.
29  */
30
31 #include "config.h"
32 #include "gtkcelleditable.h"
33 #include "gtkmarshalers.h"
34 #include "gtkprivate.h"
35 #include "gtkintl.h"
36
37
38 typedef GtkCellEditableIface GtkCellEditableInterface;
39 G_DEFINE_INTERFACE(GtkCellEditable, gtk_cell_editable, GTK_TYPE_WIDGET)
40
41 static void
42 gtk_cell_editable_default_init (GtkCellEditableInterface *iface)
43 {
44   /**
45    * GtkCellEditable:editing-canceled:
46    *
47    * Indicates whether editing on the cell has been canceled.
48    *
49    * Since: 2.20
50    */
51   g_object_interface_install_property (iface,
52                                        g_param_spec_boolean ("editing-canceled",
53                                        P_("Editing Canceled"),
54                                        P_("Indicates that editing has been canceled"),
55                                        FALSE,
56                                        GTK_PARAM_READWRITE));
57
58   /**
59    * GtkCellEditable::editing-done:
60    * @cell_editable: the object on which the signal was emitted
61    *
62    * This signal is a sign for the cell renderer to update its
63    * value from the @cell_editable.
64    *
65    * Implementations of #GtkCellEditable are responsible for
66    * emitting this signal when they are done editing, e.g.
67    * #GtkEntry is emitting it when the user presses Enter.
68    *
69    * gtk_cell_editable_editing_done() is a convenience method
70    * for emitting #GtkCellEditable::editing-done.
71    */
72   g_signal_new (I_("editing-done"),
73                 GTK_TYPE_CELL_EDITABLE,
74                 G_SIGNAL_RUN_LAST,
75                 G_STRUCT_OFFSET (GtkCellEditableIface, editing_done),
76                 NULL, NULL,
77                 _gtk_marshal_VOID__VOID,
78                 G_TYPE_NONE, 0);
79
80   /**
81    * GtkCellEditable::remove-widget:
82    * @cell_editable: the object on which the signal was emitted
83    *
84    * This signal is meant to indicate that the cell is finished
85    * editing, and the widget may now be destroyed.
86    *
87    * Implementations of #GtkCellEditable are responsible for
88    * emitting this signal when they are done editing. It must
89    * be emitted after the #GtkCellEditable::editing-done signal,
90    * to give the cell renderer a chance to update the cell's value
91    * before the widget is removed.
92    *
93    * gtk_cell_editable_remove_widget() is a convenience method
94    * for emitting #GtkCellEditable::remove-widget.
95    */
96   g_signal_new (I_("remove-widget"),
97                 GTK_TYPE_CELL_EDITABLE,
98                 G_SIGNAL_RUN_LAST,
99                 G_STRUCT_OFFSET (GtkCellEditableIface, remove_widget),
100                 NULL, NULL,
101                 _gtk_marshal_VOID__VOID,
102                 G_TYPE_NONE, 0);
103 }
104
105 /**
106  * gtk_cell_editable_start_editing:
107  * @cell_editable: A #GtkCellEditable
108  * @event: (allow-none): A #GdkEvent, or %NULL
109  * 
110  * Begins editing on a @cell_editable. @event is the #GdkEvent that began 
111  * the editing process. It may be %NULL, in the instance that editing was 
112  * initiated through programatic means.
113  **/
114 void
115 gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
116                                  GdkEvent        *event)
117 {
118   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
119
120   (* GTK_CELL_EDITABLE_GET_IFACE (cell_editable)->start_editing) (cell_editable, event);
121 }
122
123 /**
124  * gtk_cell_editable_editing_done:
125  * @cell_editable: A #GtkTreeEditable
126  * 
127  * Emits the #GtkCellEditable::editing-done signal. 
128  **/
129 void
130 gtk_cell_editable_editing_done (GtkCellEditable *cell_editable)
131 {
132   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
133
134   g_signal_emit_by_name (cell_editable, "editing-done");
135 }
136
137 /**
138  * gtk_cell_editable_remove_widget:
139  * @cell_editable: A #GtkTreeEditable
140  * 
141  * Emits the #GtkCellEditable::remove-widget signal.  
142  **/
143 void
144 gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable)
145 {
146   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
147
148   g_signal_emit_by_name (cell_editable, "remove-widget");
149 }