Mercurial > pidgin.yaz
annotate console/libgnt/gntentry.c @ 14503:1a79eb31c2f7
[gaim-migrate @ 17222]
Move ChangeLog.API next to ChangeLog and ChangeLog.win32
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 10 Sep 2006 20:04:20 +0000 |
parents | ca36763497d9 |
children | 60845d332ea6 |
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" |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
7 #include "gntutils.h" |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 enum |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 SIGS = 1, |
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 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 static GntWidgetClass *parent_class = NULL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 static guint signals[SIGS] = { 0 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 static void |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
18 destroy_suggest(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
19 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
20 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
21 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
22 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
23 entry->ddown = NULL; |
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 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
27 static char * |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
28 get_beginning_of_word(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
29 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
30 char *s = entry->cursor; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
31 while (s > entry->start) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
32 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
33 char *t = g_utf8_find_prev_char(entry->start, s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
34 if ((*t < 'A' || *t > 'Z') && (*t < 'a' || *t > 'z')) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
35 break; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
36 s = t; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
37 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
38 return s; |
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 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
41 static gboolean |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
42 show_suggest_dropdown(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
43 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
44 char *suggest = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
45 int len; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
46 int offset = 0, x, y; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
47 int count = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
48 GList *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
49 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
50 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
51 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
52 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
53 suggest = g_strndup(s, entry->cursor - s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
54 if (entry->scroll < s) |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
55 offset = gnt_util_onscreen_width(entry->scroll, s); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
56 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
57 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
58 suggest = g_strdup(entry->start); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
59 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
|
60 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
61 if (entry->ddown == NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
62 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
63 GntWidget *box = gnt_vbox_new(FALSE); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
64 entry->ddown = gnt_tree_new(); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14094
diff
changeset
|
65 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
|
66 gnt_box_add_widget(GNT_BOX(box), entry->ddown); |
14477
ca36763497d9
[gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
67 /* XXX: Connect to the "activate" signal for the dropdown tree */ |
14091
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_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
70 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
71 gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
72 x += offset; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
73 y++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
74 if (y + 10 >= getmaxy(stdscr)) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
75 y -= 11; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
76 gnt_widget_set_position(box, x, y); |
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 gnt_widget_draw(box); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
79 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
80 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
81 gnt_tree_remove_all(GNT_TREE(entry->ddown)); |
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 for (count = 0, iter = entry->suggests; iter; iter = iter->next) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
84 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
85 const char *text = iter->data; |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
86 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
|
87 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
88 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
|
89 gnt_tree_create_row(GNT_TREE(entry->ddown), text), |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
90 NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
91 count++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
92 } |
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 g_free(suggest); |
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 if (count == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
97 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
98 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
99 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
100 } |
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 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
103 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
104 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
105 static void |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 gnt_entry_draw(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 int stop; |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
110 gboolean focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
112 if ((focus = gnt_widget_has_focus(widget))) |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
113 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
114 else |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
115 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
|
116 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
117 if (entry->masked) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
118 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
119 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
|
120 g_utf8_pointer_to_offset(entry->scroll, entry->end)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
121 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
122 else |
14307
7c91ba42b9ba
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14256
diff
changeset
|
123 mvwprintw(widget->window, 0, 0, "%s", entry->scroll); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
125 stop = gnt_util_onscreen_width(entry->scroll, entry->end); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 if (stop < widget->priv.width) |
14307
7c91ba42b9ba
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14256
diff
changeset
|
127 whline(widget->window, ENTRY_CHAR, widget->priv.width - stop); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
129 if (focus) |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
130 mvwchgat(widget->window, 0, gnt_util_onscreen_width(entry->scroll, entry->cursor), |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
131 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
|
132 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
133 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 gnt_entry_size_request(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 { |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
139 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
140 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
141 widget->priv.height = 1; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
142 widget->priv.width = 20; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
143 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 gnt_entry_map(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 if (widget->priv.width == 0 || widget->priv.height == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 gnt_widget_size_request(widget); |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
151 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
154 static void |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
155 entry_redraw(GntWidget *widget) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
156 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
157 gnt_entry_draw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
158 gnt_widget_queue_update(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
159 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
160 |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
161 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
162 move_back(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
163 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
164 if (entry->cursor <= entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
165 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
166 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
|
167 if (entry->cursor < entry->scroll) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
168 entry->scroll = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
169 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
170 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
171 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
172 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
173 move_forward(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
174 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
175 if (entry->cursor >= entry->end) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
176 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
177 entry->cursor = g_utf8_find_next_char(entry->cursor, NULL); |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
178 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
179 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
180 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
181 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
182 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
183 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
184 backspace(GntEntry *entry) |
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 int len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
187 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
188 if (entry->cursor <= entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
189 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
190 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
191 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
|
192 entry->cursor -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
193 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
194 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
195 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
196 if (entry->scroll > entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
197 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
|
198 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
199 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
200 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
201 show_suggest_dropdown(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
202 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
203 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
204 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
205 delkey(GntEntry *entry) |
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 int len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
208 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
209 if (entry->cursor >= entry->end) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
210 return; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
211 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
212 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
|
213 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
|
214 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
215 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
216 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
217 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
218 show_suggest_dropdown(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
219 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
220 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
221 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
222 move_start(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
223 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
224 entry->scroll = entry->cursor = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
225 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
226 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
227 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
228 static void |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
229 move_end(GntEntry *entry) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
230 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
231 entry->cursor = entry->end; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
232 /* This should be better than this */ |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
233 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
234 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
235 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
236 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
237 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 static gboolean |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 gnt_entry_key_pressed(GntWidget *widget, const char *text) |
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 GntEntry *entry = GNT_ENTRY(widget); |
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 (text[0] == 27) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 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
|
246 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
247 delkey(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
248 return TRUE; |
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 else if (strcmp(text + 1, GNT_KEY_LEFT) == 0) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
252 move_back(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
253 return TRUE; |
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 else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
257 move_forward(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
258 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
259 } |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
260 else if (strcmp(text + 1, GNT_KEY_HOME) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
261 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
262 move_start(entry); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
263 return TRUE; |
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 else if (strcmp(text + 1, GNT_KEY_END) == 0) |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
266 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
267 move_end(entry); |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
268 return TRUE; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
269 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
270 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
|
271 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
272 if (entry->history->prev) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
273 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
274 entry->history = entry->history->prev; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
275 gnt_entry_set_text(entry, entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
276 destroy_suggest(entry); |
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 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
279 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
280 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
281 else if (strcmp(text + 1, GNT_KEY_UP) == 0 || |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
282 strcmp(text + 1, GNT_KEY_DOWN) == 0) |
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 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
285 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
286 gnt_widget_key_pressed(entry->ddown, text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
287 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
288 } |
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 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
|
291 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
292 if (entry->history->next) |
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 if (entry->history->prev == NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
295 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
296 /* Save the current contents */ |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
297 char *text = g_strdup(gnt_entry_get_text(entry)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
298 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
299 entry->history->data = text; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
300 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
301 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
302 entry->history = entry->history->next; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
303 gnt_entry_set_text(entry, entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
304 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
305 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
306 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
307 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
308 } |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
309 else if (text[1] == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
310 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
311 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
312 } |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
313 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
314 return FALSE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 { |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
318 if (text[0] == '\t') |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
319 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
320 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
321 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
322 else if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
323 return show_suggest_dropdown(entry); |
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 return FALSE; |
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 else if (text[0] == '\r' && entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
328 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
329 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
|
330 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
331 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
332 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
333 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
334 char *iter = text; |
14309
578a2c9af05e
[gaim-migrate @ 16999]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14307
diff
changeset
|
335 while (*iter && toupper(*s) == toupper(*iter)) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
336 { |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
337 *s++ = *iter++; |
14091
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 gnt_entry_key_pressed(widget, iter); |
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 else |
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 gnt_entry_set_text(entry, text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
344 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
345 g_free(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
346 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
347 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
348 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
349 if (!iscntrl(text[0])) |
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 const char *str, *next; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
352 |
14351
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14311
diff
changeset
|
353 for (str = text; *str; str = next) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
354 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
355 int len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
356 next = g_utf8_find_next_char(str, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
357 len = next - str; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
358 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
359 /* Valid input? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
360 /* XXX: Is it necessary to use _unichar_ variants here? */ |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
361 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
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 (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
364 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
365 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
366 continue; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
367 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
368 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
369 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
370 /* Reached the max? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
371 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
|
372 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
373 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
374 if (entry->end - entry->start >= entry->buffer) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
375 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
376 char *tmp = g_strdup_printf(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
377 gnt_entry_set_text(entry, tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
378 g_free(tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
379 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
380 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
381 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
|
382 entry->end += len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
383 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
384 while (str < next) |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
385 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
386 if (*str == '\r' || *str == '\n') |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
387 *entry->cursor = ' '; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
388 else |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
389 *entry->cursor = *str; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
390 entry->cursor++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
391 str++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
392 } |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
393 |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
394 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width) |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
395 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
|
396 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
397 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
398 show_suggest_dropdown(entry); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
399 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
400 entry_redraw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
401 return TRUE; |
13855
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 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
404 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
405 if (strcmp(text, GNT_KEY_BACKSPACE) == 0 && entry->cursor > entry->start) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
406 { |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
407 backspace(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
408 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_A) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
411 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
412 move_start(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
413 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_B) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
416 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
417 move_back(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
418 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_D) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
421 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
422 delkey(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
423 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_E) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
426 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
427 move_end(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
428 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_F) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
431 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
432 move_forward(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
433 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_H) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
436 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
437 backspace(entry); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
438 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_K) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
441 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
442 entry->end = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
443 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
|
444 entry_redraw(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
445 return TRUE; |
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 else if (strcmp(text, GNT_KEY_CTRL_U) == 0) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
448 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
449 memmove(entry->start, entry->cursor, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
450 entry->end -= (entry->cursor - entry->start); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
451 entry->cursor = entry->scroll = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
452 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
453 entry_redraw(widget); |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
454 return TRUE; |
13855
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 } |
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 return FALSE; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
460 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
461 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
462 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
463 gnt_entry_destroy(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
464 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
465 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
466 g_free(entry->start); |
14091
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 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
469 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
470 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
471 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
472 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
473 } |
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 if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
476 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
477 g_list_foreach(entry->suggests, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
478 g_list_free(entry->suggests); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
479 } |
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 if (entry->ddown) |
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 gnt_widget_destroy(entry->ddown->parent); |
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 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
486 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
487 static void |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
488 gnt_entry_lost_focus(GntWidget *widget) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
489 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
490 GntEntry *entry = GNT_ENTRY(widget); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
491 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
492 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
493 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
494 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
495 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
496 gnt_entry_class_init(GntEntryClass *klass) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
497 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
498 parent_class = GNT_WIDGET_CLASS(klass); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
499 parent_class->destroy = gnt_entry_destroy; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
500 parent_class->draw = gnt_entry_draw; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
501 parent_class->map = gnt_entry_map; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
502 parent_class->size_request = gnt_entry_size_request; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
503 parent_class->key_pressed = gnt_entry_key_pressed; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
504 parent_class->lost_focus = gnt_entry_lost_focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
505 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
506 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
507 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
508 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
509 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
510 gnt_entry_init(GTypeInstance *instance, gpointer class) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
511 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
512 GntWidget *widget = GNT_WIDGET(instance); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
513 GntEntry *entry = GNT_ENTRY(instance); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
514 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
515 entry->flag = GNT_ENTRY_FLAG_ALL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
516 entry->max = 0; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
517 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
518 entry->histlength = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
519 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
520 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
521 entry->word = TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
522 entry->always = FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
523 entry->suggests = NULL; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
524 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
525 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
526 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
|
527 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
|
528 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
529 widget->priv.minw = 3; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
530 widget->priv.minh = 1; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
531 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
532 GNTDEBUG; |
13855
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 |
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 * GntEntry API |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
537 *****************************************************************************/ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
538 GType |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 gnt_entry_get_gtype(void) |
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 static GType 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 if(type == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
544 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
545 static const GTypeInfo info = { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
546 sizeof(GntEntryClass), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
547 NULL, /* base_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
548 NULL, /* base_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
549 (GClassInitFunc)gnt_entry_class_init, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
550 NULL, /* class_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
551 NULL, /* class_data */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
552 sizeof(GntEntry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
553 0, /* n_preallocs */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
554 gnt_entry_init, /* instance_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
555 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
556 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
557 type = g_type_register_static(GNT_TYPE_WIDGET, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
558 "GntEntry", |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
559 &info, 0); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
560 } |
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 return type; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
563 } |
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 *gnt_entry_new(const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
566 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
567 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
568 GntEntry *entry = GNT_ENTRY(widget); |
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 gnt_entry_set_text(entry, text); |
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 return widget; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
573 } |
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 void gnt_entry_set_text(GntEntry *entry, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
577 int len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
578 int scroll, cursor; |
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 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
581 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
582 if (text && text[0]) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
583 { |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
584 len = strlen(text); |
13855
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 else |
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 len = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
589 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
590 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
591 entry->buffer = len + 128; |
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
592 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
593 scroll = entry->scroll - entry->start; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
594 cursor = entry->end - entry->cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
595 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
596 entry->start = g_new0(char, entry->buffer); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
597 if (text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
598 snprintf(entry->start, len + 1, "%s", text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
599 entry->end = entry->start + len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 entry->scroll = entry->start + scroll; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
602 entry->cursor = entry->end - cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
603 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
604 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
|
605 entry_redraw(GNT_WIDGET(entry)); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
606 } |
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 void gnt_entry_set_max(GntEntry *entry, int 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 entry->max = max; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
611 } |
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 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
614 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
615 entry->flag = flag; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
616 /* 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
|
617 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
619 const char *gnt_entry_get_text(GntEntry *entry) |
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 return entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
622 } |
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 void gnt_entry_clear(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
625 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
626 gnt_entry_set_text(entry, NULL); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
627 entry->scroll = entry->cursor = entry->end = entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
628 entry_redraw(GNT_WIDGET(entry)); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
629 destroy_suggest(entry); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
630 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
631 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
632 void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
633 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
634 entry->masked = set; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
635 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
636 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
637 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
|
638 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
639 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
|
640 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
641 if (g_list_length(entry->history) >= entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
642 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
643 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
644 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
645 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
646 entry->history->data = g_strdup(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
647 entry->history = g_list_prepend(entry->history, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
648 } |
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 void gnt_entry_set_history_length(GntEntry *entry, int num) |
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 if (num == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
653 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
654 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
655 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
656 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
657 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
658 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
659 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
660 entry->history = NULL; |
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 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
663 } |
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 if (entry->histlength == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
666 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
667 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
668 entry->history = g_list_append(NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
669 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
670 } |
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 if (num > 0 && num < entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
673 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
674 GList *first, *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
675 int index = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
676 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
|
677 while ((iter = g_list_nth(first, num)) != NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
678 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
679 g_free(iter->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
680 first = g_list_delete_link(first, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
681 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
682 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
683 if (index >= num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
684 entry->history = g_list_last(first); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
685 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
686 } |
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 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
689 } |
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 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean 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 entry->word = word; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
694 } |
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 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean 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 entry->always = always; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
699 } |
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 void gnt_entry_add_suggest(GntEntry *entry, const char *text) |
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 GList *find; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
704 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
705 if (!text || !*text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
706 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
707 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
708 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
|
709 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
710 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
711 entry->suggests = g_list_append(entry->suggests, g_strdup(text)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
712 } |
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 void gnt_entry_remove_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
715 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
716 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
|
717 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
718 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
719 g_free(find->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
720 entry->suggests = g_list_delete_link(entry->suggests, find); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
721 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
722 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
723 |