Mercurial > pidgin.yaz
annotate console/libgnt/gntentry.c @ 14072:cf48a70da762
[gaim-migrate @ 16693]
Fix CID 111 (which never would actually happen, but this is cleaner and clearer)
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 11 Aug 2006 00:55:18 +0000 |
parents | 27182f83b79b |
children | ae4cbed1b309 |
rev | line source |
---|---|
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
1 #include <ctype.h> |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include <string.h> |
13888
9d66969a2e32
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13882
diff
changeset
|
3 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gntentry.h" |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 enum |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 SIGS = 1, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 static GntWidgetClass *parent_class = NULL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 static guint signals[SIGS] = { 0 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 gnt_entry_draw(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 int stop; |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
19 gboolean focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
21 if ((focus = gnt_widget_has_focus(widget))) |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
22 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
23 else |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
24 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
25 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
26 if (entry->masked) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
27 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
28 mvwhline(widget->window, 0, 0, gnt_ascii_only() ? '*' : ACS_BULLET, |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
29 g_utf8_pointer_to_offset(entry->scroll, entry->end)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
30 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
31 else |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
32 mvwprintw(widget->window, 0, 0, entry->scroll); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
34 stop = g_utf8_pointer_to_offset(entry->scroll, entry->end); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 if (stop < widget->priv.width) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
38 if (focus) |
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
39 mvwchgat(widget->window, 0, g_utf8_pointer_to_offset(entry->scroll, entry->cursor), |
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
40 1, A_REVERSE, COLOR_PAIR(GNT_COLOR_TEXT_NORMAL), NULL); |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
41 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 gnt_entry_size_request(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 { |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
48 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
49 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
50 widget->priv.height = 1; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
51 widget->priv.width = 20; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
52 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 gnt_entry_map(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 if (widget->priv.width == 0 || widget->priv.height == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 gnt_widget_size_request(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
63 static void |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
64 entry_redraw(GntWidget *widget) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
65 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
66 gnt_entry_draw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
67 gnt_widget_queue_update(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
68 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
69 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 static gboolean |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 gnt_entry_key_pressed(GntWidget *widget, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 if (text[0] == 27) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 if (strcmp(text + 1, GNT_KEY_DEL) == 0 && entry->cursor < entry->end) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
79 int len = g_utf8_find_next_char(entry->cursor, NULL) - entry->cursor; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
80 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
81 entry->end -= len; |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
82 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 else if (strcmp(text + 1, GNT_KEY_LEFT) == 0 && entry->cursor > entry->start) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
86 entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 if (entry->cursor < entry->scroll) |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
88 entry->scroll = entry->cursor; |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
89 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0 && entry->cursor < entry->end) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
93 entry->cursor = g_utf8_find_next_char(entry->cursor, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
94 if (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
95 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
96 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 /* XXX: handle other keys, like home/end, and ctrl+ goodness */ |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
99 else |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
100 return FALSE; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
101 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
102 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 if (!iscntrl(text[0])) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
108 const char *str, *next; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
110 for (str = text; *str;) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
112 int len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
113 next = g_utf8_find_next_char(str, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
114 len = next - str; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
115 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 /* Valid input? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
117 /* XXX: Is it necessary to use _unichar_ variants here? */ |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
118 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
120 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
122 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
123 continue; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
124 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 /* Reached the max? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
128 if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
131 if (entry->end - entry->start >= entry->buffer) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 char *tmp = g_strdup_printf(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 gnt_entry_set_text(entry, tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 g_free(tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
138 memmove(entry->cursor + len, entry->cursor, entry->end - entry->cursor + 1); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
139 entry->end += len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
141 while (str < next) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
142 *(entry->cursor++) = *str++; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
143 |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
144 while (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
145 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
147 entry_redraw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
148 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 /* Backspace is here */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 if (strcmp(text, GNT_KEY_BACKSPACE) == 0 && entry->cursor > entry->start) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
155 int len = entry->cursor - g_utf8_find_prev_char(entry->start, entry->cursor); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
156 entry->cursor -= len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
157 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
158 entry->end -= len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 if (entry->scroll > entry->start) |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
161 entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
163 entry_redraw(widget); |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
164 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 return FALSE; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 gnt_entry_destroy(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
176 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
177 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
180 gnt_entry_class_init(GntEntryClass *klass) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 parent_class = GNT_WIDGET_CLASS(klass); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 parent_class->destroy = gnt_entry_destroy; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 parent_class->draw = gnt_entry_draw; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 parent_class->map = gnt_entry_map; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 parent_class->size_request = gnt_entry_size_request; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 parent_class->key_pressed = gnt_entry_key_pressed; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 gnt_entry_init(GTypeInstance *instance, gpointer class) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
195 GntWidget *widget = GNT_WIDGET(instance); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 GntEntry *entry = GNT_ENTRY(instance); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 entry->flag = GNT_ENTRY_FLAG_ALL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 entry->max = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS); |
13930
3dbcbc5e57e1
[gaim-migrate @ 16457]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
203 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_GROW_X); |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
204 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
205 widget->priv.minw = 3; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
206 widget->priv.minh = 1; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 /****************************************************************************** |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 * GntEntry API |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 *****************************************************************************/ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 GType |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 gnt_entry_get_gtype(void) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 static GType type = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 if(type == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 static const GTypeInfo info = { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 sizeof(GntEntryClass), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 NULL, /* base_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 NULL, /* base_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 (GClassInitFunc)gnt_entry_class_init, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
226 NULL, /* class_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
227 NULL, /* class_data */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
228 sizeof(GntEntry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
229 0, /* n_preallocs */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
230 gnt_entry_init, /* instance_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
231 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
232 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
233 type = g_type_register_static(GNT_TYPE_WIDGET, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 "GntEntry", |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
235 &info, 0); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 return type; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 GntWidget *gnt_entry_new(const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 gnt_entry_set_text(entry, text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 return widget; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 void gnt_entry_set_text(GntEntry *entry, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 int len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 int scroll, cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 if (text && text[0]) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 { |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
260 len = strlen(text); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 len = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
267 entry->buffer = len + 128; |
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
268 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 scroll = entry->scroll - entry->start; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 cursor = entry->end - entry->cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 entry->start = g_new0(char, entry->buffer); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 if (text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 snprintf(entry->start, len + 1, "%s", text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 entry->end = entry->start + len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 entry->scroll = entry->start + scroll; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 entry->cursor = entry->end - cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
280 if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED)) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
281 entry_redraw(GNT_WIDGET(entry)); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
282 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
283 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 void gnt_entry_set_max(GntEntry *entry, int max) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
285 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 entry->max = max; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
288 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
289 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
290 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
291 entry->flag = flag; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
292 /* XXX: Check the existing string to make sure the flags are respected? */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
293 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
294 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
295 const char *gnt_entry_get_text(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
296 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
297 return entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
298 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
299 |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
300 void gnt_entry_clear(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
301 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
302 gnt_entry_set_text(entry, NULL); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
303 entry->scroll = entry->cursor = entry->end = entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
304 entry_redraw(GNT_WIDGET(entry)); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
305 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
306 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
307 void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
308 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
309 entry->masked = set; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
310 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
311 |