comparison finch/libgnt/gntentry.h @ 15818:0e3a8505ebbe

renamed gaim-text to finch
author Sean Egan <seanegan@gmail.com>
date Sun, 18 Mar 2007 19:38:15 +0000
parents
children f00f2e283ffb
comparison
equal deleted inserted replaced
15817:317e7613e581 15818:0e3a8505ebbe
1 #ifndef GNT_ENTRY_H
2 #define GNT_ENTRY_H
3
4 #include "gntwidget.h"
5 #include "gnt.h"
6 #include "gntcolors.h"
7 #include "gntkeys.h"
8
9 #define GNT_TYPE_ENTRY (gnt_entry_get_gtype())
10 #define GNT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_ENTRY, GntEntry))
11 #define GNT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_ENTRY, GntEntryClass))
12 #define GNT_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_ENTRY))
13 #define GNT_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_ENTRY))
14 #define GNT_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_ENTRY, GntEntryClass))
15
16 #define GNT_ENTRY_FLAGS(obj) (GNT_ENTRY(obj)->priv.flags)
17 #define GNT_ENTRY_SET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) |= flags)
18 #define GNT_ENTRY_UNSET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) &= ~(flags))
19
20 #define ENTRY_CHAR '_' /* The character to use to fill in the blank places */
21
22 typedef struct _GnEntry GntEntry;
23 typedef struct _GnEntryPriv GntEntryPriv;
24 typedef struct _GnEntryClass GntEntryClass;
25
26 typedef enum
27 {
28 GNT_ENTRY_FLAG_ALPHA = 1 << 0, /* Only alpha */
29 GNT_ENTRY_FLAG_INT = 1 << 1, /* Only integer */
30 GNT_ENTRY_FLAG_NO_SPACE = 1 << 2, /* No blank space is allowed */
31 GNT_ENTRY_FLAG_NO_PUNCT = 1 << 3, /* No punctuations */
32 GNT_ENTRY_FLAG_MASK = 1 << 4, /* Mask the inputs */
33 } GntEntryFlag;
34
35 #define GNT_ENTRY_FLAG_ALL (GNT_ENTRY_FLAG_ALPHA | GNT_ENTRY_FLAG_INT)
36
37 struct _GnEntry
38 {
39 GntWidget parent;
40
41 GntEntryFlag flag;
42
43 char *start;
44 char *end;
45 char *scroll; /* Current scrolling position */
46 char *cursor; /* Cursor location */
47 /* 0 <= cursor - scroll < widget-width */
48
49 size_t buffer; /* Size of the buffer */
50
51 int max; /* 0 means infinite */
52 gboolean masked;
53
54 GList *history; /* History of the strings. User can use this by pressing ctrl+up/down */
55 int histlength; /* How long can the history be? */
56
57 GList *suggests; /* List of suggestions */
58 gboolean word; /* Are the suggestions for only a word, or for the whole thing? */
59 gboolean always; /* Should the list of suggestions show at all times, or only on tab-press? */
60 GntWidget *ddown; /* The dropdown with the suggested list */
61 };
62
63 struct _GnEntryClass
64 {
65 GntWidgetClass parent;
66
67 void (*text_changed)(GntEntry *entry);
68 void (*gnt_reserved1)(void);
69 void (*gnt_reserved2)(void);
70 void (*gnt_reserved3)(void);
71 void (*gnt_reserved4)(void);
72 };
73
74 G_BEGIN_DECLS
75
76 GType gnt_entry_get_gtype(void);
77
78 GntWidget *gnt_entry_new(const char *text);
79
80 void gnt_entry_set_max(GntEntry *entry, int max);
81
82 void gnt_entry_set_text(GntEntry *entry, const char *text);
83
84 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag);
85
86 const char *gnt_entry_get_text(GntEntry *entry);
87
88 void gnt_entry_clear(GntEntry *entry);
89
90 void gnt_entry_set_masked(GntEntry *entry, gboolean set);
91
92 void gnt_entry_add_to_history(GntEntry *entry, const char *text);
93
94 void gnt_entry_set_history_length(GntEntry *entry, int num);
95
96 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word);
97
98 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always);
99
100 void gnt_entry_add_suggest(GntEntry *entry, const char *text);
101
102 void gnt_entry_remove_suggest(GntEntry *entry, const char *text);
103
104 G_END_DECLS
105
106 #endif /* GNT_ENTRY_H */