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