Mercurial > pidgin
annotate console/libgnt/gntentry.c @ 14264:d171bdecf17b
[gaim-migrate @ 16946]
Use the gtk conversation unseen_count instead of keeping my own count.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 21 Aug 2006 06:06:54 +0000 |
parents | e7de1f6d9f35 |
children | 7c91ba42b9ba |
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 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
4 #include "gntbox.h" |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include "gntentry.h" |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
6 #include "gnttree.h" |
13855
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 enum |
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 SIGS = 1, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 static GntWidgetClass *parent_class = NULL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 static guint signals[SIGS] = { 0 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 static void |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
17 destroy_suggest(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
18 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
19 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
20 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
21 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
22 entry->ddown = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
23 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
24 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
25 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
26 static char * |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
27 get_beginning_of_word(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
28 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
29 char *s = entry->cursor; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
30 while (s > entry->start) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
31 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
32 char *t = g_utf8_find_prev_char(entry->start, s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
33 if ((*t < 'A' || *t > 'Z') && (*t < 'a' || *t > 'z')) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
34 break; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
35 s = t; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
36 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
37 return s; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
38 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
39 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
40 static gboolean |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
41 show_suggest_dropdown(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
42 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
43 char *suggest = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
44 int len; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
45 int offset = 0, x, y; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
46 int count = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
47 GList *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
48 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
49 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
50 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
51 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
52 suggest = g_strndup(s, entry->cursor - s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
53 if (entry->scroll < s) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
54 offset = g_utf8_pointer_to_offset(entry->scroll, s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
55 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
56 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
57 suggest = g_strdup(entry->start); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
58 len = strlen(suggest); /* Don't need to use the utf8-function here */ |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
59 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
60 if (entry->ddown == NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
61 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
62 GntWidget *box = gnt_vbox_new(FALSE); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
63 entry->ddown = gnt_tree_new(); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14094
diff
changeset
|
64 gnt_tree_set_compare_func(GNT_TREE(entry->ddown), (GCompareFunc)g_utf8_collate); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
65 gnt_box_add_widget(GNT_BOX(box), entry->ddown); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
66 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
67 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
68 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
69 gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
70 x += offset; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
71 y++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
72 if (y + 10 >= getmaxy(stdscr)) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
73 y -= 11; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
74 gnt_widget_set_position(box, x, y); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
75 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
76 gnt_widget_draw(box); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
77 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
78 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
79 gnt_tree_remove_all(GNT_TREE(entry->ddown)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
80 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
81 for (count = 0, iter = entry->suggests; iter; iter = iter->next) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
82 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
83 const char *text = iter->data; |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
84 if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
85 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
86 gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
87 gnt_tree_create_row(GNT_TREE(entry->ddown), text), |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
88 NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
89 count++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
90 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
91 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
92 g_free(suggest); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
93 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
94 if (count == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
95 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
96 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
97 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
98 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
99 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
100 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
101 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
102 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
103 static void |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 gnt_entry_draw(GntWidget *widget) |
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 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 int stop; |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
108 gboolean focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
110 if ((focus = gnt_widget_has_focus(widget))) |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
111 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
112 else |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
113 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
|
114 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
115 if (entry->masked) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
116 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
117 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
|
118 g_utf8_pointer_to_offset(entry->scroll, entry->end)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
119 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
120 else |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
121 mvwprintw(widget->window, 0, 0, entry->scroll); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
123 stop = g_utf8_pointer_to_offset(entry->scroll, entry->end); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 if (stop < widget->priv.width) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
127 if (focus) |
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
128 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
|
129 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
|
130 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 DEBUG; |
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 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 gnt_entry_size_request(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 { |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
137 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
138 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
139 widget->priv.height = 1; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
140 widget->priv.width = 20; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
141 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 gnt_entry_map(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 if (widget->priv.width == 0 || widget->priv.height == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 gnt_widget_size_request(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
152 static void |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
153 entry_redraw(GntWidget *widget) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
154 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
155 gnt_entry_draw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
156 gnt_widget_queue_update(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
157 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
158 |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
159 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
160 move_back(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
161 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
162 if (entry->cursor <= entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
163 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
164 entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
165 if (entry->cursor < entry->scroll) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
166 entry->scroll = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
167 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
168 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
169 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
170 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
171 move_forward(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
172 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
173 if (entry->cursor >= entry->end) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
174 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
175 entry->cursor = g_utf8_find_next_char(entry->cursor, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
176 if (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
177 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
178 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
179 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
180 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
181 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
182 backspace(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
183 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
184 int len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
185 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
186 if (entry->cursor <= entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
187 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
188 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
189 len = entry->cursor - g_utf8_find_prev_char(entry->start, entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
190 entry->cursor -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
191 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
192 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
193 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
194 if (entry->scroll > entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
195 entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
196 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
197 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
198 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
199 show_suggest_dropdown(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
200 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
201 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
202 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
203 delkey(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
204 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
205 int len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
206 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
207 if (entry->cursor >= entry->end) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
208 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
209 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
210 len = g_utf8_find_next_char(entry->cursor, NULL) - entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
211 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
212 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
213 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
214 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
215 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
216 show_suggest_dropdown(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
217 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
218 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
219 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
220 move_start(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
221 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
222 entry->scroll = entry->cursor = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
223 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
224 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
225 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
226 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
227 move_end(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
228 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
229 entry->cursor = entry->end; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
230 /* This should be better than this */ |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
231 while (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
232 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
233 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
234 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
235 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 static gboolean |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 gnt_entry_key_pressed(GntWidget *widget, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 GntEntry *entry = GNT_ENTRY(widget); |
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 if (text[0] == 27) |
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 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
|
244 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
245 delkey(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
246 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 } |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
248 else if (strcmp(text + 1, GNT_KEY_LEFT) == 0) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
250 move_back(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
251 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 } |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
253 else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
255 move_forward(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
256 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
257 } |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
258 else if (strcmp(text + 1, GNT_KEY_HOME) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
259 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
260 move_start(entry); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
261 return TRUE; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
262 } |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
263 else if (strcmp(text + 1, GNT_KEY_END) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
264 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
265 move_end(entry); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
266 return TRUE; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
267 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
268 else if (strcmp(text + 1, GNT_KEY_CTRL_DOWN) == 0 && entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
269 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
270 if (entry->history->prev) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
271 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
272 entry->history = entry->history->prev; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
273 gnt_entry_set_text(entry, entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
274 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
275 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
276 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
277 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
278 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
279 else if (strcmp(text + 1, GNT_KEY_UP) == 0 || |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
280 strcmp(text + 1, GNT_KEY_DOWN) == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
281 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
282 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
283 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
284 gnt_widget_key_pressed(entry->ddown, text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
285 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
286 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
287 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
288 else if (strcmp(text + 1, GNT_KEY_CTRL_UP) == 0 && entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
289 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
290 if (entry->history->next) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
291 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
292 if (entry->history->prev == NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
293 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
294 /* Save the current contents */ |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
295 char *text = g_strdup(gnt_entry_get_text(entry)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
296 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
297 entry->history->data = text; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
298 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
299 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
300 entry->history = entry->history->next; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
301 gnt_entry_set_text(entry, entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
302 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
303 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
304 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
305 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
307 else if (text[1] == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
308 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
309 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
310 } |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
311 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
312 return FALSE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 { |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
316 if (text[0] == '\t') |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
317 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
318 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
319 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
320 else if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
321 return show_suggest_dropdown(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
322 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
323 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
324 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
325 else if (text[0] == '\r' && entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
326 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
327 char *text = g_strdup(gnt_tree_get_selection_data(GNT_TREE(entry->ddown))); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
328 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
329 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
330 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
331 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
332 char *iter = text; |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
333 while (toupper(*s) == toupper(*iter)) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
334 { |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
335 *s++ = *iter++; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
336 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
337 gnt_entry_key_pressed(widget, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
338 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
339 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
340 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
341 gnt_entry_set_text(entry, text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
342 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
343 g_free(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
344 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
345 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
346 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
347 if (!iscntrl(text[0])) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
348 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
349 const char *str, *next; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
350 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
351 for (str = text; *str;) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
352 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
353 int len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
354 next = g_utf8_find_next_char(str, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
355 len = next - str; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
356 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
357 /* Valid input? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
358 /* XXX: Is it necessary to use _unichar_ variants here? */ |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
359 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
360 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
361 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
362 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
363 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
364 continue; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
365 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
366 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
367 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
368 /* Reached the max? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
369 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
|
370 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
371 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
372 if (entry->end - entry->start >= entry->buffer) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
373 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
374 char *tmp = g_strdup_printf(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
375 gnt_entry_set_text(entry, tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
376 g_free(tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
377 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
378 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
379 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
|
380 entry->end += len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
381 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
382 while (str < next) |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
383 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
384 if (*str == '\r' || *str == '\n') |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
385 *entry->cursor = ' '; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
386 else |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
387 *entry->cursor = *str; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
388 entry->cursor++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
389 str++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
390 } |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
391 |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
392 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
|
393 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
394 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
395 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
396 show_suggest_dropdown(entry); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
397 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
398 entry_redraw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
399 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
400 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
401 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
402 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
403 if (strcmp(text, GNT_KEY_BACKSPACE) == 0 && entry->cursor > entry->start) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
404 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
405 backspace(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
406 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
407 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
408 else if (strcmp(text, GNT_KEY_CTRL_A) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
409 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
410 move_start(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
411 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
412 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
413 else if (strcmp(text, GNT_KEY_CTRL_B) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
414 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
415 move_back(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
416 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
417 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
418 else if (strcmp(text, GNT_KEY_CTRL_D) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
419 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
420 delkey(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
421 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
422 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
423 else if (strcmp(text, GNT_KEY_CTRL_E) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
424 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
425 move_end(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
426 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
427 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
428 else if (strcmp(text, GNT_KEY_CTRL_F) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
429 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
430 move_forward(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
431 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
432 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
433 else if (strcmp(text, GNT_KEY_CTRL_H) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
434 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
435 backspace(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
436 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
437 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
438 else if (strcmp(text, GNT_KEY_CTRL_K) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
439 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
440 entry->end = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
441 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
442 entry_redraw(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
443 return TRUE; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
444 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
445 else if (strcmp(text, GNT_KEY_CTRL_U) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
446 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
447 memmove(entry->start, entry->cursor, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
448 entry->end -= (entry->cursor - entry->start); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
449 entry->cursor = entry->scroll = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
450 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
451 entry_redraw(widget); |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
452 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
453 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
454 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
455 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
456 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
457 return FALSE; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
458 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
459 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
460 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
461 gnt_entry_destroy(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
462 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
463 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
464 g_free(entry->start); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
465 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
466 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
467 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
468 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
469 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
470 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
471 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
472 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
473 if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
474 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
475 g_list_foreach(entry->suggests, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
476 g_list_free(entry->suggests); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
477 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
478 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
479 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
480 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
481 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
482 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
483 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
484 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
485 static void |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
486 gnt_entry_lost_focus(GntWidget *widget) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
487 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
488 GntEntry *entry = GNT_ENTRY(widget); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
489 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
490 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
491 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
492 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
493 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
494 gnt_entry_class_init(GntEntryClass *klass) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
495 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
496 parent_class = GNT_WIDGET_CLASS(klass); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
497 parent_class->destroy = gnt_entry_destroy; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
498 parent_class->draw = gnt_entry_draw; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
499 parent_class->map = gnt_entry_map; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
500 parent_class->size_request = gnt_entry_size_request; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
501 parent_class->key_pressed = gnt_entry_key_pressed; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
502 parent_class->lost_focus = gnt_entry_lost_focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
503 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
504 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
505 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
506 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
507 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
508 gnt_entry_init(GTypeInstance *instance, gpointer class) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
509 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
510 GntWidget *widget = GNT_WIDGET(instance); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
511 GntEntry *entry = GNT_ENTRY(instance); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
512 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
513 entry->flag = GNT_ENTRY_FLAG_ALL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
514 entry->max = 0; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
515 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
516 entry->histlength = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
517 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
518 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
519 entry->word = TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
520 entry->always = FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
521 entry->suggests = NULL; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
522 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
523 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
524 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
|
525 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
|
526 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
527 widget->priv.minw = 3; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
528 widget->priv.minh = 1; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
529 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
530 DEBUG; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
531 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
532 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
533 /****************************************************************************** |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
534 * GntEntry API |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
535 *****************************************************************************/ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
536 GType |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
537 gnt_entry_get_gtype(void) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
538 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 static GType type = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
540 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
541 if(type == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
542 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
543 static const GTypeInfo info = { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
544 sizeof(GntEntryClass), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
545 NULL, /* base_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
546 NULL, /* base_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
547 (GClassInitFunc)gnt_entry_class_init, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
548 NULL, /* class_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
549 NULL, /* class_data */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
550 sizeof(GntEntry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
551 0, /* n_preallocs */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
552 gnt_entry_init, /* instance_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
553 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
554 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
555 type = g_type_register_static(GNT_TYPE_WIDGET, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
556 "GntEntry", |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
557 &info, 0); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
558 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
559 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
560 return type; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
561 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
562 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
563 GntWidget *gnt_entry_new(const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
564 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
565 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
566 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
567 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
568 gnt_entry_set_text(entry, text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
569 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
570 return widget; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
571 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
572 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
573 void gnt_entry_set_text(GntEntry *entry, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
574 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
575 int len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 int scroll, cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
577 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
578 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
579 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
580 if (text && text[0]) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
581 { |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
582 len = strlen(text); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
583 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
584 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
585 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
586 len = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
587 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
588 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
589 entry->buffer = len + 128; |
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
590 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
591 scroll = entry->scroll - entry->start; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
592 cursor = entry->end - entry->cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
593 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
594 entry->start = g_new0(char, entry->buffer); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
595 if (text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
596 snprintf(entry->start, len + 1, "%s", text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
597 entry->end = entry->start + len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
598 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
599 entry->scroll = entry->start + scroll; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 entry->cursor = entry->end - cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
602 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
|
603 entry_redraw(GNT_WIDGET(entry)); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
604 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
605 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
606 void gnt_entry_set_max(GntEntry *entry, int max) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
607 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
608 entry->max = max; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
609 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
610 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
611 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
612 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
613 entry->flag = flag; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
614 /* 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
|
615 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
616 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
617 const char *gnt_entry_get_text(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
618 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
619 return entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
620 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
621 |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
622 void gnt_entry_clear(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
623 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
624 gnt_entry_set_text(entry, NULL); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
625 entry->scroll = entry->cursor = entry->end = entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
626 entry_redraw(GNT_WIDGET(entry)); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
627 destroy_suggest(entry); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
628 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
629 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
630 void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
631 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
632 entry->masked = set; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
633 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
634 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
635 void gnt_entry_add_to_history(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
636 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
637 g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */ |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
638 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
639 if (g_list_length(entry->history) >= entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
640 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
641 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
642 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
643 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
644 entry->history->data = g_strdup(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
645 entry->history = g_list_prepend(entry->history, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
646 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
647 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
648 void gnt_entry_set_history_length(GntEntry *entry, int num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
649 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
650 if (num == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
651 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
652 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
653 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
654 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
655 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
656 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
657 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
658 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
659 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
660 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
661 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
662 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
663 if (entry->histlength == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
664 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
665 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
666 entry->history = g_list_append(NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
667 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
668 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
669 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
670 if (num > 0 && num < entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
671 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
672 GList *first, *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
673 int index = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
674 for (first = entry->history, index = 0; first->prev; first = first->prev, index++); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
675 while ((iter = g_list_nth(first, num)) != NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
676 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
677 g_free(iter->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
678 first = g_list_delete_link(first, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
679 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
680 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
681 if (index >= num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
682 entry->history = g_list_last(first); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
683 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
684 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
685 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
686 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
687 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
688 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
689 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
690 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
691 entry->word = word; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
692 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
693 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
694 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
695 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
696 entry->always = always; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
697 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
698 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
699 void gnt_entry_add_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
700 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
701 GList *find; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
702 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
703 if (!text || !*text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
704 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
705 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
706 find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
707 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
708 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
709 entry->suggests = g_list_append(entry->suggests, g_strdup(text)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
710 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
711 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
712 void gnt_entry_remove_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
713 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
714 GList *find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
715 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
716 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
717 g_free(find->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
718 entry->suggests = g_list_delete_link(entry->suggests, find); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
719 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
720 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
721 |