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