1/* gtkentrybuffer.h
2 * Copyright (C) 2009 Stefan Walter <[email protected]>
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#ifndef __GTK_ENTRY_BUFFER_H__
21#define __GTK_ENTRY_BUFFER_H__
22
23#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24#error "Only <gtk/gtk.h> can be included directly."
25#endif
26
27#include <glib-object.h>
28
29G_BEGIN_DECLS
30
31/* Maximum size of text buffer, in bytes */
32#define GTK_ENTRY_BUFFER_MAX_SIZE G_MAXUSHORT
33
34#define GTK_TYPE_ENTRY_BUFFER (gtk_entry_buffer_get_type ())
35#define GTK_ENTRY_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY_BUFFER, GtkEntryBuffer))
36#define GTK_ENTRY_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY_BUFFER, GtkEntryBufferClass))
37#define GTK_IS_ENTRY_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY_BUFFER))
38#define GTK_IS_ENTRY_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY_BUFFER))
39#define GTK_ENTRY_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_BUFFER, GtkEntryBufferClass))
40
41typedef struct _GtkEntryBuffer GtkEntryBuffer;
42typedef struct _GtkEntryBufferClass GtkEntryBufferClass;
43typedef struct _GtkEntryBufferPrivate GtkEntryBufferPrivate;
44
45struct _GtkEntryBuffer
46{
47 GObject parent_instance;
48
49 /*< private >*/
50 GtkEntryBufferPrivate *priv;
51};
52
53struct _GtkEntryBufferClass
54{
55 GObjectClass parent_class;
56
57 /* Signals */
58
59 void (*inserted_text) (GtkEntryBuffer *buffer,
60 guint position,
61 const gchar *chars,
62 guint n_chars);
63
64 void (*deleted_text) (GtkEntryBuffer *buffer,
65 guint position,
66 guint n_chars);
67
68 /* Virtual Methods */
69
70 const gchar* (*get_text) (GtkEntryBuffer *buffer,
71 gsize *n_bytes);
72
73 guint (*get_length) (GtkEntryBuffer *buffer);
74
75 guint (*insert_text) (GtkEntryBuffer *buffer,
76 guint position,
77 const gchar *chars,
78 guint n_chars);
79
80 guint (*delete_text) (GtkEntryBuffer *buffer,
81 guint position,
82 guint n_chars);
83
84 /* Padding for future expansion */
85 void (*_gtk_reserved0) (void);
86 void (*_gtk_reserved1) (void);
87 void (*_gtk_reserved2) (void);
88 void (*_gtk_reserved3) (void);
89 void (*_gtk_reserved4) (void);
90 void (*_gtk_reserved5) (void);
91};
92
93GType gtk_entry_buffer_get_type (void) G_GNUC_CONST;
94
95GtkEntryBuffer* gtk_entry_buffer_new (const gchar *initial_chars,
96 gint n_initial_chars);
97
98gsize gtk_entry_buffer_get_bytes (GtkEntryBuffer *buffer);
99
100guint gtk_entry_buffer_get_length (GtkEntryBuffer *buffer);
101
102const gchar* gtk_entry_buffer_get_text (GtkEntryBuffer *buffer);
103
104void gtk_entry_buffer_set_text (GtkEntryBuffer *buffer,
105 const gchar *chars,
106 gint n_chars);
107
108void gtk_entry_buffer_set_max_length (GtkEntryBuffer *buffer,
109 gint max_length);
110
111gint gtk_entry_buffer_get_max_length (GtkEntryBuffer *buffer);
112
113guint gtk_entry_buffer_insert_text (GtkEntryBuffer *buffer,
114 guint position,
115 const gchar *chars,
116 gint n_chars);
117
118guint gtk_entry_buffer_delete_text (GtkEntryBuffer *buffer,
119 guint position,
120 gint n_chars);
121
122void gtk_entry_buffer_emit_inserted_text (GtkEntryBuffer *buffer,
123 guint position,
124 const gchar *chars,
125 guint n_chars);
126
127void gtk_entry_buffer_emit_deleted_text (GtkEntryBuffer *buffer,
128 guint position,
129 guint n_chars);
130
131G_END_DECLS
132
133#endif /* __GTK_ENTRY_BUFFER_H__ */
134