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