Mercurial > pidgin.yaz
annotate console/libgnt/gntentry.c @ 14876:70623f0d5cdc
[gaim-migrate @ 17645]
Use terminfo/termcap information (from ncurses) as much as possible. There
still need to be some manual 'refinement' based on $TERM. I'll see if I
can get rid of those. Also, I am probably going to allow users to provide
information that terminfo can't provide, like the keycode for ctrl+up etc.
Let me know if any of the keybinding doesn't work.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 01 Nov 2006 03:38:23 +0000 |
parents | a73b2b332ec2 |
children | 065e7ac30338 |
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" |
14836
bfcdd361357e
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14828
diff
changeset
|
6 #include "gntstyle.h" |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
7 #include "gnttree.h" |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
8 #include "gntutils.h" |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 enum |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 SIGS = 1, |
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 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 static GntWidgetClass *parent_class = NULL; |
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); |
14578
60845d332ea6
[gaim-migrate @ 17302]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14477
diff
changeset
|
34 if (isspace(*t)) |
14091
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), |
14625
3e193cf68660
[gaim-migrate @ 17357]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14578
diff
changeset
|
131 1, A_REVERSE, 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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
161 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
162 move_back(GntWidget *widget, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
163 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
164 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
165 if (entry->cursor <= entry->start) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
166 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
167 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
|
168 if (entry->cursor < entry->scroll) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
169 entry->scroll = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
170 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
171 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
172 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
173 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
174 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
175 move_forward(GntWidget *widget, GList *list) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
176 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
177 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
178 if (entry->cursor >= entry->end) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
179 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
180 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
|
181 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
|
182 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
183 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
184 return TRUE; |
14213
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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
187 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
188 backspace(GntWidget *widget, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
189 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
190 int len; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
191 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
192 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
193 if (entry->cursor <= entry->start) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
194 return TRUE; |
14213
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 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
|
197 entry->cursor -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
198 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
199 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
200 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
201 if (entry->scroll > entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
202 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
|
203 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
204 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
205 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
206 show_suggest_dropdown(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
207 return TRUE; |
14213
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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
210 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
211 delkey(GntWidget *widget, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
212 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
213 int len; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
214 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
215 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
216 if (entry->cursor >= entry->end) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
217 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
218 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
219 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
|
220 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
|
221 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
222 entry_redraw(GNT_WIDGET(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 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
225 show_suggest_dropdown(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
226 return TRUE; |
14213
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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
229 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
230 move_start(GntWidget *widget, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
231 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
232 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
233 entry->scroll = entry->cursor = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
234 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
235 return TRUE; |
14213
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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
238 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
239 move_end(GntWidget *widget, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
240 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
241 GntEntry *entry = GNT_ENTRY(widget); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
242 entry->cursor = entry->end; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
243 /* This should be better than this */ |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
244 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
|
245 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
246 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
247 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
248 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
249 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
250 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
251 history_prev(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
252 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
253 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
254 if (entry->histlength && entry->history->prev) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
255 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
256 entry->history = entry->history->prev; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
257 gnt_entry_set_text(entry, entry->history->data); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
258 destroy_suggest(entry); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
259 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
260 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
261 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
262 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
263 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
264 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
265 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
266 history_next(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
267 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
268 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
269 if (entry->histlength && entry->history->next) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
270 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
271 if (entry->history->prev == NULL) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
272 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
273 /* Save the current contents */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
274 char *text = g_strdup(gnt_entry_get_text(entry)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
275 g_free(entry->history->data); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
276 entry->history->data = text; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
277 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
278 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
279 entry->history = entry->history->next; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
280 gnt_entry_set_text(entry, entry->history->data); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
281 destroy_suggest(entry); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
282 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
283 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
284 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
285 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
286 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
287 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
288 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
289 suggest_show(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
290 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
291 return show_suggest_dropdown(GNT_ENTRY(widget)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
292 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
293 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
294 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
295 suggest_next(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
296 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
297 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
298 if (entry->ddown) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
299 gnt_widget_perform_action_named(entry->ddown, "move-down", NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
300 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
301 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
302 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
303 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
304 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
305 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
306 suggest_prev(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
307 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
308 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
309 if (entry->ddown) { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
310 gnt_widget_perform_action_named(entry->ddown, "move-up", NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
311 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
312 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
313 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
314 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
315 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
316 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
317 del_to_home(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
318 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
319 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
320 memmove(entry->start, entry->cursor, entry->end - entry->cursor); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
321 entry->end -= (entry->cursor - entry->start); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
322 entry->cursor = entry->scroll = entry->start; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
323 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
324 entry_redraw(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
325 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
326 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
327 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
328 static gboolean |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
329 del_to_end(GntWidget *widget, GList *null) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
330 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
331 GntEntry *entry = GNT_ENTRY(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
332 entry->end = entry->cursor; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
333 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
334 entry_redraw(widget); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
335 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
336 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
337 |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
338 static const char * |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
339 begin_word(const char *text, const char *begin) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
340 { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
341 char ch; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
342 ch = *text; |
14836
bfcdd361357e
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14828
diff
changeset
|
343 #define SAME(a,b) ((isalpha(a) && isalpha(b)) || (isdigit(a) && isdigit(b)) || (isspace(a) && isspace(b))) |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
344 while (--text >= begin) { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
345 if (!SAME(ch, *text)) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
346 break; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
347 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
348 #undef SAME |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
349 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
350 return ++text; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
351 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
352 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
353 static gboolean |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
354 move_back_word(GntWidget *widget, GList *null) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
355 { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
356 GntEntry *entry = GNT_ENTRY(widget); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
357 const char *iter = entry->cursor - 1; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
358 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
359 if (iter < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
360 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
361 iter = begin_word(iter, entry->start); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
362 entry->cursor = (char*)iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
363 if (entry->cursor < entry->scroll) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
364 entry->scroll = entry->cursor; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
365 entry_redraw(widget); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
366 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
367 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
368 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
369 static gboolean |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
370 del_prev_word(GntWidget *widget, GList *null) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
371 { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
372 GntEntry *entry = GNT_ENTRY(widget); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
373 char *iter = entry->cursor - 1; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
374 int count; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
375 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
376 if (iter < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
377 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
378 iter = (char*)begin_word(iter, entry->start); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
379 count = entry->cursor - iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
380 memmove(iter, entry->cursor, entry->end - entry->cursor); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
381 entry->end -= count; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
382 entry->cursor = iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
383 if (entry->cursor <= entry->scroll) { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
384 entry->scroll = entry->cursor - widget->priv.width + 2; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
385 if (entry->scroll < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
386 entry->scroll = entry->start; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
387 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
388 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
389 entry_redraw(widget); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
390 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
391 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
392 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
393 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
394 static gboolean |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
395 gnt_entry_key_pressed(GntWidget *widget, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
396 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
397 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
398 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
399 if (text[0] == 27) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
400 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
401 if (text[1] == 0) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
402 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
403 destroy_suggest(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
404 return TRUE; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
405 } |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
406 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
407 return FALSE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
408 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
409 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
410 { |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
411 if (text[0] == '\t') |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
412 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
413 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
414 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
415 else if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
416 return show_suggest_dropdown(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
417 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
418 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
419 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
420 else if (text[0] == '\r' && entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
421 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
422 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
|
423 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
424 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
425 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
426 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
427 char *iter = text; |
14309
578a2c9af05e
[gaim-migrate @ 16999]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14307
diff
changeset
|
428 while (*iter && toupper(*s) == toupper(*iter)) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
429 { |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
430 *s++ = *iter++; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
431 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
432 gnt_entry_key_pressed(widget, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
433 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
434 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
435 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
436 gnt_entry_set_text(entry, text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
437 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
438 g_free(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
439 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
440 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
441 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
442 if (!iscntrl(text[0])) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
443 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
444 const char *str, *next; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
445 |
14351
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14311
diff
changeset
|
446 for (str = text; *str; str = next) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
447 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
448 int len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
449 next = g_utf8_find_next_char(str, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
450 len = next - str; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
451 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
452 /* Valid input? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
453 /* XXX: Is it necessary to use _unichar_ variants here? */ |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
454 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
455 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
456 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
457 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
458 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
459 continue; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
460 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
461 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
462 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
463 /* Reached the max? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
464 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
|
465 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
466 |
14745
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
467 if (entry->end + len - entry->start >= entry->buffer) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
468 { |
14745
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
469 /* This will cause the buffer to grow */ |
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
470 char *tmp = g_strdup_printf("%s%*s", entry->start, len, ""); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
471 gnt_entry_set_text(entry, tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
472 g_free(tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
473 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
474 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
475 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
|
476 entry->end += len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
477 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
478 while (str < next) |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
479 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
480 if (*str == '\r' || *str == '\n') |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
481 *entry->cursor = ' '; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
482 else |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
483 *entry->cursor = *str; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
484 entry->cursor++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
485 str++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
486 } |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
487 |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
488 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
|
489 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
|
490 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
491 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
492 show_suggest_dropdown(entry); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
493 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
494 entry_redraw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
495 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
496 } |
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 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
499 return FALSE; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
500 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
501 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
502 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
503 gnt_entry_destroy(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
504 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
505 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
506 g_free(entry->start); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
507 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
508 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
509 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
510 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
511 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
512 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
513 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
514 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
515 if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
516 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
517 g_list_foreach(entry->suggests, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
518 g_list_free(entry->suggests); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
519 } |
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 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
522 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
523 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
524 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
525 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
526 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
527 static void |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
528 gnt_entry_lost_focus(GntWidget *widget) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
529 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
530 GntEntry *entry = GNT_ENTRY(widget); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
531 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
532 entry_redraw(widget); |
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 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
536 gnt_entry_class_init(GntEntryClass *klass) |
13855
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 parent_class = GNT_WIDGET_CLASS(klass); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 parent_class->destroy = gnt_entry_destroy; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
540 parent_class->draw = gnt_entry_draw; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
541 parent_class->map = gnt_entry_map; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
542 parent_class->size_request = gnt_entry_size_request; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
543 parent_class->key_pressed = gnt_entry_key_pressed; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
544 parent_class->lost_focus = gnt_entry_lost_focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
545 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
546 parent_class->actions = g_hash_table_duplicate(parent_class->actions, g_str_hash, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
547 g_str_equal, g_free, (GDestroyNotify)gnt_widget_action_free); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
548 parent_class->bindings = g_hash_table_duplicate(parent_class->bindings, g_str_hash, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
549 g_str_equal, g_free, (GDestroyNotify)gnt_widget_action_param_free); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
550 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
551 gnt_widget_class_register_action(parent_class, "cursor-home", move_start, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
552 GNT_KEY_CTRL_A, NULL); |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
553 gnt_widget_register_binding(parent_class, "cursor-home", GNT_KEY_HOME, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
554 gnt_widget_class_register_action(parent_class, "cursor-end", move_end, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
555 GNT_KEY_CTRL_E, NULL); |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
556 gnt_widget_register_binding(parent_class, "cursor-end", GNT_KEY_END, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
557 gnt_widget_class_register_action(parent_class, "delete-prev", backspace, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
558 GNT_KEY_BACKSPACE, NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
559 gnt_widget_class_register_action(parent_class, "delete-next", delkey, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
560 GNT_KEY_DEL, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
561 gnt_widget_register_binding(parent_class, "delete-next", GNT_KEY_CTRL_D, NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
562 gnt_widget_class_register_action(parent_class, "delete-start", del_to_home, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
563 GNT_KEY_CTRL_U, NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
564 gnt_widget_class_register_action(parent_class, "delete-end", del_to_end, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
565 GNT_KEY_CTRL_K, NULL); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
566 gnt_widget_class_register_action(parent_class, "delete-prev-word", del_prev_word, |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
567 NULL, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
568 #if 0 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
569 gnt_widget_class_register_action(parent_class, "delete-next-word", del_next_word, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
570 NULL, 1, NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
571 #endif |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
572 gnt_widget_class_register_action(parent_class, "cursor-prev-word", move_back_word, |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
573 NULL, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
574 gnt_widget_class_register_action(parent_class, "cursor-prev", move_back, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
575 GNT_KEY_LEFT, NULL); |
14872
a73b2b332ec2
[gaim-migrate @ 17641]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14871
diff
changeset
|
576 gnt_widget_register_binding(parent_class, "cursor-prev", GNT_KEY_CTRL_B, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
577 gnt_widget_class_register_action(parent_class, "cursor-next", move_forward, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
578 GNT_KEY_RIGHT, NULL); |
14872
a73b2b332ec2
[gaim-migrate @ 17641]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14871
diff
changeset
|
579 gnt_widget_register_binding(parent_class, "cursor-next", GNT_KEY_CTRL_F, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
580 gnt_widget_class_register_action(parent_class, "suggest-show", suggest_show, |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
581 "\t", NULL); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
582 gnt_widget_class_register_action(parent_class, "suggest-next", suggest_next, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
583 GNT_KEY_DOWN, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
584 gnt_widget_class_register_action(parent_class, "suggest-prev", suggest_prev, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
585 GNT_KEY_UP, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
586 gnt_widget_class_register_action(parent_class, "history-prev", history_prev, |
14827
02b70dc43044
[gaim-migrate @ 17594]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14793
diff
changeset
|
587 "\033" GNT_KEY_CTRL_DOWN, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
588 gnt_widget_class_register_action(parent_class, "history-next", history_next, |
14827
02b70dc43044
[gaim-migrate @ 17594]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14793
diff
changeset
|
589 "\033" GNT_KEY_CTRL_UP, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
590 |
14836
bfcdd361357e
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14828
diff
changeset
|
591 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), parent_class); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
592 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
593 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
594 } |
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 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
597 gnt_entry_init(GTypeInstance *instance, gpointer class) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
598 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
599 GntWidget *widget = GNT_WIDGET(instance); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
600 GntEntry *entry = GNT_ENTRY(instance); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
601 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
602 entry->flag = GNT_ENTRY_FLAG_ALL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
603 entry->max = 0; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
604 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
605 entry->histlength = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
606 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
607 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
608 entry->word = TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
609 entry->always = FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
610 entry->suggests = NULL; |
13855
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 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
613 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
|
614 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
|
615 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
616 widget->priv.minw = 3; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
617 widget->priv.minh = 1; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
619 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
620 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
621 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
622 /****************************************************************************** |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
623 * GntEntry API |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
624 *****************************************************************************/ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
625 GType |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
626 gnt_entry_get_gtype(void) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
627 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
628 static GType type = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
629 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
630 if(type == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
631 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
632 static const GTypeInfo info = { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
633 sizeof(GntEntryClass), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
634 NULL, /* base_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
635 NULL, /* base_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
636 (GClassInitFunc)gnt_entry_class_init, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
637 NULL, /* class_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
638 NULL, /* class_data */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
639 sizeof(GntEntry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
640 0, /* n_preallocs */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
641 gnt_entry_init, /* instance_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
642 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
643 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
644 type = g_type_register_static(GNT_TYPE_WIDGET, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
645 "GntEntry", |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
646 &info, 0); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
647 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
648 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
649 return type; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
650 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
651 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
652 GntWidget *gnt_entry_new(const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
653 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
654 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
655 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
656 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
657 gnt_entry_set_text(entry, text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
658 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
659 return widget; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
660 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
661 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
662 void gnt_entry_set_text(GntEntry *entry, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
663 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
664 int len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
665 int scroll, cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
666 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
667 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
668 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
669 if (text && text[0]) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
670 { |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
671 len = strlen(text); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
672 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
673 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
674 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
675 len = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
676 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
677 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
678 entry->buffer = len + 128; |
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
679 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
680 scroll = entry->scroll - entry->start; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
681 cursor = entry->end - entry->cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
682 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
683 entry->start = g_new0(char, entry->buffer); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
684 if (text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
685 snprintf(entry->start, len + 1, "%s", text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
686 entry->end = entry->start + len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
687 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
688 entry->scroll = entry->start + scroll; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
689 entry->cursor = entry->end - cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
690 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
691 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
|
692 entry_redraw(GNT_WIDGET(entry)); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
693 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
694 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
695 void gnt_entry_set_max(GntEntry *entry, int max) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
696 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
697 entry->max = max; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
698 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
699 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
700 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
701 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
702 entry->flag = flag; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
703 /* 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
|
704 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
705 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
706 const char *gnt_entry_get_text(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
707 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
708 return entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
709 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
710 |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
711 void gnt_entry_clear(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
712 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
713 gnt_entry_set_text(entry, NULL); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
714 entry->scroll = entry->cursor = entry->end = entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
715 entry_redraw(GNT_WIDGET(entry)); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
716 destroy_suggest(entry); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
717 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
718 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
719 void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
720 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
721 entry->masked = set; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
722 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
723 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
724 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
|
725 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
726 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
|
727 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
728 if (g_list_length(entry->history) >= entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
729 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
730 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
731 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
732 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
733 entry->history->data = g_strdup(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
734 entry->history = g_list_prepend(entry->history, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
735 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
736 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
737 void gnt_entry_set_history_length(GntEntry *entry, int num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
738 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
739 if (num == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
740 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
741 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
742 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
743 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
744 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
745 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
746 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
747 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
748 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
749 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
750 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
751 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
752 if (entry->histlength == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
753 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
754 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
755 entry->history = g_list_append(NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
756 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
757 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
758 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
759 if (num > 0 && num < entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
760 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
761 GList *first, *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
762 int index = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
763 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
|
764 while ((iter = g_list_nth(first, num)) != NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
765 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
766 g_free(iter->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
767 first = g_list_delete_link(first, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
768 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
769 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
770 if (index >= num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
771 entry->history = g_list_last(first); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
772 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
773 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
774 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
775 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
776 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
777 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
778 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
779 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
780 entry->word = word; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
781 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
782 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
783 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
784 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
785 entry->always = always; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
786 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
787 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
788 void gnt_entry_add_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
789 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
790 GList *find; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
791 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
792 if (!text || !*text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
793 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
794 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
795 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
|
796 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
797 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
798 entry->suggests = g_list_append(entry->suggests, g_strdup(text)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
799 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
800 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
801 void gnt_entry_remove_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
802 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
803 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
|
804 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
805 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
806 g_free(find->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
807 entry->suggests = g_list_delete_link(entry->suggests, find); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
808 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
809 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
810 |