]> Pileus Git - ~andy/gtk/blob - gtk/gtkcelleditable.c
7400ec77582c8795c637ecf083fc799e5c7f4edf
[~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 "gtkalias.h"
25
26 static void gtk_cell_editable_base_init (gpointer g_class);
27
28 GType
29 gtk_cell_editable_get_type (void)
30 {
31   static GType cell_editable_type = 0;
32
33   if (! cell_editable_type)
34     {
35       static const GTypeInfo cell_editable_info =
36       {
37         sizeof (GtkCellEditableIface), /* class_size */
38         gtk_cell_editable_base_init,   /* base_init */
39         NULL,           /* base_finalize */
40         NULL,
41         NULL,           /* class_finalize */
42         NULL,           /* class_data */
43         0,
44         0,
45         NULL
46       };
47
48       cell_editable_type =
49         g_type_register_static (G_TYPE_INTERFACE, g_intern_static_string ("GtkCellEditable"),
50                                 &cell_editable_info, 0);
51
52       g_type_interface_add_prerequisite (cell_editable_type, GTK_TYPE_WIDGET);
53     }
54
55   return cell_editable_type;
56 }
57
58 static void
59 gtk_cell_editable_base_init (gpointer g_class)
60 {
61   static gboolean initialized = FALSE;
62
63   if (! initialized)
64     {
65       g_signal_new ("editing_done",
66                     GTK_TYPE_CELL_EDITABLE,
67                     G_SIGNAL_RUN_LAST,
68                     G_STRUCT_OFFSET (GtkCellEditableIface, editing_done),
69                     NULL, NULL,
70                     _gtk_marshal_VOID__VOID,
71                     G_TYPE_NONE, 0);
72       g_signal_new ("remove_widget",
73                     GTK_TYPE_CELL_EDITABLE,
74                     G_SIGNAL_RUN_LAST,
75                     G_STRUCT_OFFSET (GtkCellEditableIface, remove_widget),
76                     NULL, NULL,
77                     _gtk_marshal_VOID__VOID,
78                     G_TYPE_NONE, 0);
79       initialized = TRUE;
80     }
81 }
82
83 /**
84  * gtk_cell_editable_start_editing:
85  * @cell_editable: A #GtkCellEditable
86  * @event: A #GdkEvent, or %NULL
87  * 
88  * Begins editing on a @cell_editable.  @event is the #GdkEvent that began the
89  * editing process.  It may be %NULL, in the instance that editing was initiated
90  * through programatic means.
91  **/
92 void
93 gtk_cell_editable_start_editing (GtkCellEditable *cell_editable,
94                                  GdkEvent        *event)
95 {
96   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
97
98   (* GTK_CELL_EDITABLE_GET_IFACE (cell_editable)->start_editing) (cell_editable, event);
99 }
100
101 /**
102  * gtk_cell_editable_editing_done:
103  * @cell_editable: A #GtkTreeEditable
104  * 
105  * Emits the "editing_done" signal.  This signal is a sign for the cell renderer
106  * to update its value from the cell.
107  **/
108 void
109 gtk_cell_editable_editing_done (GtkCellEditable *cell_editable)
110 {
111   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
112
113   g_signal_emit_by_name (cell_editable, "editing_done");
114 }
115
116 /**
117  * gtk_cell_editable_remove_widget:
118  * @cell_editable: A #GtkTreeEditable
119  * 
120  * Emits the "remove_widget" signal.  This signal is meant to indicate that the
121  * cell is finished editing, and the widget may now be destroyed.
122  **/
123 void
124 gtk_cell_editable_remove_widget (GtkCellEditable *cell_editable)
125 {
126   g_return_if_fail (GTK_IS_CELL_EDITABLE (cell_editable));
127
128   g_signal_emit_by_name (cell_editable, "remove_widget");
129 }
130
131 #define __GTK_CELL_EDITABLE_C__
132 #include "gtkaliasdef.c"