Mercurial > pidgin
annotate console/libgnt/gntentry.c @ 15597:77b56a42ec25
merge of '8f483f61f048cc605240bf7c848d0ffb7aebf70e'
and '9e71b1fda18f2e878dd6a5f8493d75b69e821c23'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 09 Feb 2007 16:55:06 +0000 |
parents | 492f4e7416a3 |
children | 0eb7846f9e7e |
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 { |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
12 SIG_TEXT_CHANGED, |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
13 SIGS, |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 }; |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
15 static guint signals[SIGS] = { 0 }; |
13855
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 GntWidgetClass *parent_class = NULL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
19 static void gnt_entry_set_text_internal(GntEntry *entry, const char *text); |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
20 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 static void |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
22 destroy_suggest(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
23 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
24 if (entry->ddown) |
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 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
27 entry->ddown = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
28 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
29 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
30 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
31 static char * |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
32 get_beginning_of_word(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
33 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
34 char *s = entry->cursor; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
35 while (s > entry->start) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
36 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
37 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
|
38 if (isspace(*t)) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
39 break; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
40 s = t; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
41 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
42 return s; |
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 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
45 static gboolean |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
46 show_suggest_dropdown(GntEntry *entry) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
47 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
48 char *suggest = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
49 int len; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
50 int offset = 0, x, y; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
51 int count = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
52 GList *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
53 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
54 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
55 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
56 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
57 suggest = g_strndup(s, entry->cursor - s); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
58 if (entry->scroll < s) |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
59 offset = gnt_util_onscreen_width(entry->scroll, s); |
14091
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 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
62 suggest = g_strdup(entry->start); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
63 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
|
64 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
65 if (entry->ddown == NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
66 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
67 GntWidget *box = gnt_vbox_new(FALSE); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
68 entry->ddown = gnt_tree_new(); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14094
diff
changeset
|
69 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
|
70 gnt_box_add_widget(GNT_BOX(box), entry->ddown); |
14477
ca36763497d9
[gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14432
diff
changeset
|
71 /* 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
|
72 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
73 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
74 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
75 gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
76 x += offset; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
77 y++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
78 if (y + 10 >= getmaxy(stdscr)) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
79 y -= 11; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
80 gnt_widget_set_position(box, x, y); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
81 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
82 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
83 gnt_tree_remove_all(GNT_TREE(entry->ddown)); |
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 for (count = 0, iter = entry->suggests; iter; iter = iter->next) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
86 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
87 const char *text = iter->data; |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
88 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
|
89 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
90 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
|
91 gnt_tree_create_row(GNT_TREE(entry->ddown), text), |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
92 NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
93 count++; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
94 } |
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 g_free(suggest); |
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 if (count == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
99 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
100 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
101 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
102 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
103 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
104 gnt_widget_draw(entry->ddown->parent); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
105 return TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
106 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
107 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
108 static void |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 gnt_entry_draw(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 int stop; |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
113 gboolean focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
115 if ((focus = gnt_widget_has_focus(widget))) |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
116 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
117 else |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13888
diff
changeset
|
118 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
|
119 |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
120 if (entry->masked) |
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 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
|
123 g_utf8_pointer_to_offset(entry->scroll, entry->end)); |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
124 } |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
125 else |
14307
7c91ba42b9ba
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14256
diff
changeset
|
126 mvwprintw(widget->window, 0, 0, "%s", entry->scroll); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
128 stop = gnt_util_onscreen_width(entry->scroll, entry->end); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 if (stop < widget->priv.width) |
14307
7c91ba42b9ba
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14256
diff
changeset
|
130 whline(widget->window, ENTRY_CHAR, widget->priv.width - stop); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14031
diff
changeset
|
132 if (focus) |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
133 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
|
134 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL); |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
135 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
136 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 gnt_entry_size_request(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 { |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
142 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
143 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
144 widget->priv.height = 1; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
145 widget->priv.width = 20; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
146 } |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 } |
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 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 gnt_entry_map(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 if (widget->priv.width == 0 || widget->priv.height == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 gnt_widget_size_request(widget); |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
154 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
157 static void |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
158 entry_redraw(GntWidget *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 gnt_entry_draw(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
161 gnt_widget_queue_update(widget); |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
162 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
163 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
164 static void |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
165 entry_text_changed(GntEntry *entry) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
166 { |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
167 g_signal_emit(entry, signals[SIG_TEXT_CHANGED], 0); |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
168 } |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
169 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
170 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
171 move_back(GntBindable *bind, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
172 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
173 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
174 if (entry->cursor <= entry->start) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
175 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
176 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
|
177 if (entry->cursor < entry->scroll) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
178 entry->scroll = entry->cursor; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
179 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
180 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
181 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
182 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
183 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
184 move_forward(GntBindable *bind, GList *list) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
185 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
186 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
187 if (entry->cursor >= entry->end) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
188 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
189 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
|
190 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
|
191 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
192 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
193 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
194 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
195 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
196 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
197 backspace(GntBindable *bind, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
198 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
199 int len; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
200 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
201 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
202 if (entry->cursor <= entry->start) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
203 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
204 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
205 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
|
206 entry->cursor -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
207 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
208 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
209 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
210 if (entry->scroll > entry->start) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
211 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
|
212 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
213 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
214 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
215 show_suggest_dropdown(entry); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
216 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
217 return TRUE; |
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 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
220 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
221 delkey(GntBindable *bind, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
222 { |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
223 int len; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
224 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
225 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
226 if (entry->cursor >= entry->end) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
227 return FALSE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
228 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
229 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
|
230 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
|
231 entry->end -= len; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
232 entry_redraw(GNT_WIDGET(entry)); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
233 |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
234 if (entry->ddown) |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
235 show_suggest_dropdown(entry); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
236 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
237 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
238 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
239 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
240 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
241 move_start(GntBindable *bind, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
242 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
243 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
244 entry->scroll = entry->cursor = entry->start; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
245 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
246 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
247 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
248 |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
249 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
250 move_end(GntBindable *bind, GList *null) |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
251 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
252 GntEntry *entry = GNT_ENTRY(bind); |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
253 entry->cursor = entry->end; |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
254 /* This should be better than this */ |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
255 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
|
256 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
257 entry_redraw(GNT_WIDGET(entry)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
258 return TRUE; |
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 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
261 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
262 history_prev(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
263 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
264 GntEntry *entry = GNT_ENTRY(bind); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
265 if (entry->histlength && entry->history->prev) |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
266 { |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
267 entry->history = entry->history->prev; |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
268 gnt_entry_set_text_internal(entry, entry->history->data); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
269 destroy_suggest(entry); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
270 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
271 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
272 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
273 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
274 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
275 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
276 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
277 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
278 history_next(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
279 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
280 GntEntry *entry = GNT_ENTRY(bind); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
281 if (entry->histlength && entry->history->next) |
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 if (entry->history->prev == NULL) |
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 /* Save the current contents */ |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
286 char *text = g_strdup(gnt_entry_get_text(entry)); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
287 g_free(entry->history->data); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
288 entry->history->data = text; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
289 } |
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 entry->history = entry->history->next; |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
292 gnt_entry_set_text_internal(entry, entry->history->data); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
293 destroy_suggest(entry); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
294 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
295 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
296 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
297 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
298 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
299 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
300 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
301 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
302 suggest_show(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
303 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
304 return show_suggest_dropdown(GNT_ENTRY(bind)); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
305 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
306 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
307 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
308 suggest_next(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
309 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
310 GntEntry *entry = GNT_ENTRY(bind); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
311 if (entry->ddown) { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
312 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-down", NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
313 return TRUE; |
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 return FALSE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
316 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
317 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
318 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
319 suggest_prev(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
320 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
321 GntEntry *entry = GNT_ENTRY(bind); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
322 if (entry->ddown) { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
323 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-up", NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
324 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
325 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
326 return FALSE; |
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 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
329 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
330 del_to_home(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
331 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
332 GntEntry *entry = GNT_ENTRY(bind); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
333 if (entry->cursor <= entry->start) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
334 return TRUE; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
335 memmove(entry->start, entry->cursor, entry->end - entry->cursor); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
336 entry->end -= (entry->cursor - entry->start); |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
337 entry->cursor = entry->scroll = entry->start; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
338 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
339 entry_redraw(GNT_WIDGET(bind)); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
340 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
341 return TRUE; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
342 } |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
343 |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
344 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
345 del_to_end(GntBindable *bind, GList *null) |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
346 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
347 GntEntry *entry = GNT_ENTRY(bind); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
348 if (entry->end <= entry->cursor) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
349 return TRUE; |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
350 entry->end = entry->cursor; |
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
351 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
352 entry_redraw(GNT_WIDGET(bind)); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
353 entry_text_changed(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
354 return TRUE; |
14213
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
355 } |
28269422838f
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
356 |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
357 #define SAME(a,b) ((g_unichar_isalpha(a) && g_unichar_isalpha(b)) || \ |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
358 (g_unichar_isdigit(a) && g_unichar_isdigit(b)) || \ |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
359 (g_unichar_isspace(a) && g_unichar_isspace(b)) || \ |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
360 (g_unichar_iswide(a) && g_unichar_iswide(b))) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
361 |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
362 static const char * |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
363 begin_word(const char *text, const char *begin) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
364 { |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
365 gunichar ch = 0; |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
366 while (text > begin && (!*text || g_unichar_isspace(g_utf8_get_char(text)))) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
367 text = g_utf8_find_prev_char(begin, text); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
368 ch = g_utf8_get_char(text); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
369 while ((text = g_utf8_find_prev_char(begin, text)) >= begin) { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
370 gunichar cur = g_utf8_get_char(text); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
371 if (!SAME(ch, cur)) |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
372 break; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
373 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
374 |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
375 return (text ? g_utf8_find_next_char(text, NULL) : begin); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
376 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
377 |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
378 static const char * |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
379 next_begin_word(const char *text, const char *end) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
380 { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
381 gunichar ch = 0; |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
382 ch = g_utf8_get_char(text); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
383 while ((text = g_utf8_find_next_char(text, end)) != NULL && text <= end) { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
384 gunichar cur = g_utf8_get_char(text); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
385 if (!SAME(ch, cur)) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
386 break; |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
387 } |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
388 |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
389 while (text && text < end && g_unichar_isspace(g_utf8_get_char(text))) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
390 text = g_utf8_find_next_char(text, end); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
391 return (text ? text : end); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
392 } |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
393 |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
394 #undef SAME |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
395 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
396 move_back_word(GntBindable *bind, GList *null) |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
397 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
398 GntEntry *entry = GNT_ENTRY(bind); |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
399 const char *iter = g_utf8_find_prev_char(entry->start, entry->cursor); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
400 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
401 if (iter < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
402 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
403 iter = begin_word(iter, entry->start); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
404 entry->cursor = (char*)iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
405 if (entry->cursor < entry->scroll) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
406 entry->scroll = entry->cursor; |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
407 entry_redraw(GNT_WIDGET(bind)); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
408 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
409 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
410 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
411 static gboolean |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
412 del_prev_word(GntBindable *bind, GList *null) |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
413 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
414 GntWidget *widget = GNT_WIDGET(bind); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
415 GntEntry *entry = GNT_ENTRY(bind); |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
416 char *iter = g_utf8_find_prev_char(entry->start, entry->cursor); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
417 int count; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
418 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
419 if (iter < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
420 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
421 iter = (char*)begin_word(iter, entry->start); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
422 count = entry->cursor - iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
423 memmove(iter, entry->cursor, entry->end - entry->cursor); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
424 entry->end -= count; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
425 entry->cursor = iter; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
426 if (entry->cursor <= entry->scroll) { |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
427 entry->scroll = entry->cursor - widget->priv.width + 2; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
428 if (entry->scroll < entry->start) |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
429 entry->scroll = entry->start; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
430 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
431 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
432 entry_redraw(widget); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
433 entry_text_changed(entry); |
14828
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
434 |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
435 return TRUE; |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
436 } |
91a89d5ef714
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14827
diff
changeset
|
437 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
438 static gboolean |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
439 move_forward_word(GntBindable *bind, GList *list) |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
440 { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
441 GntEntry *entry = GNT_ENTRY(bind); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
442 GntWidget *widget = GNT_WIDGET(bind); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
443 entry->cursor = (char *)next_begin_word(entry->cursor, entry->end); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
444 while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width) { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
445 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
446 } |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
447 entry_redraw(widget); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
448 return TRUE; |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
449 } |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
450 |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
451 static gboolean |
15125
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
452 delete_forward_word(GntBindable *bind, GList *list) |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
453 { |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
454 GntEntry *entry = GNT_ENTRY(bind); |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
455 GntWidget *widget = GNT_WIDGET(bind); |
15125
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
456 char *iter = (char *)next_begin_word(entry->cursor, entry->end); |
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
457 int len = entry->end - iter + 1; |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
458 if (len <= 0) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
459 return TRUE; |
15125
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
460 memmove(entry->cursor, iter, len); |
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
461 len = iter - entry->cursor; |
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
462 entry->end -= len; |
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
463 memset(entry->end, '\0', len); |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
464 entry_redraw(widget); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
465 entry_text_changed(entry); |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
466 return TRUE; |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
467 } |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
468 |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
469 static gboolean |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
470 gnt_entry_key_pressed(GntWidget *widget, const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
471 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
472 GntEntry *entry = GNT_ENTRY(widget); |
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 if (text[0] == 27) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
475 { |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
476 if (text[1] == 0) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
477 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
478 destroy_suggest(entry); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
479 return TRUE; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
480 } |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
481 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
482 return FALSE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
483 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
484 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
485 { |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
486 if (text[0] == '\t') |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
487 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
488 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
489 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
490 else if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
491 return show_suggest_dropdown(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
492 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
493 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
494 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
495 else if (text[0] == '\r' && entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
496 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
497 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
|
498 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
499 if (entry->word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
500 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
501 char *s = get_beginning_of_word(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
502 char *iter = text; |
14309
578a2c9af05e
[gaim-migrate @ 16999]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14307
diff
changeset
|
503 while (*iter && toupper(*s) == toupper(*iter)) |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
504 { |
14094
d0f3eba2717c
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
505 *s++ = *iter++; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
506 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
507 gnt_entry_key_pressed(widget, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
508 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
509 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
510 { |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
511 gnt_entry_set_text_internal(entry, text); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
512 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
513 g_free(text); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
514 entry_text_changed(entry); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
515 return TRUE; |
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 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
518 if (!iscntrl(text[0])) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
519 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
520 const char *str, *next; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
521 |
14351
1bd09d355f9e
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14311
diff
changeset
|
522 for (str = text; *str; str = next) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
523 { |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
524 int len; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
525 next = g_utf8_find_next_char(str, NULL); |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
526 len = next - str; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
527 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
528 /* Valid input? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
529 /* XXX: Is it necessary to use _unichar_ variants here? */ |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
530 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
531 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
532 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
533 continue; |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
534 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
535 continue; |
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
536 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
537 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
538 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
539 /* Reached the max? */ |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
540 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
|
541 continue; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
542 |
14745
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
543 if (entry->end + len - entry->start >= entry->buffer) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
544 { |
14745
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
545 /* This will cause the buffer to grow */ |
61416f315d1c
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14729
diff
changeset
|
546 char *tmp = g_strdup_printf("%s%*s", entry->start, len, ""); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
547 gnt_entry_set_text_internal(entry, tmp); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
548 g_free(tmp); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
549 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
550 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
551 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
|
552 entry->end += len; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
553 |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
554 while (str < next) |
14216
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
555 { |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
556 if (*str == '\r' || *str == '\n') |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
557 *entry->cursor = ' '; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
558 else |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
559 *entry->cursor = *str; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
560 entry->cursor++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
561 str++; |
e9dd2f76e61b
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14213
diff
changeset
|
562 } |
14028
4c939ea15004
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13979
diff
changeset
|
563 |
14311
fda9dc44807d
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14309
diff
changeset
|
564 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
|
565 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
|
566 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
567 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
568 show_suggest_dropdown(entry); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
569 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
570 entry_redraw(widget); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
571 entry_text_changed(entry); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
572 return TRUE; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
573 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
574 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
575 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
576 return FALSE; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
577 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
578 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
579 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
580 gnt_entry_destroy(GntWidget *widget) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
581 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
582 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
583 g_free(entry->start); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
584 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
585 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
586 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
587 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
588 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
589 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
590 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
591 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
592 if (entry->suggests) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
593 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
594 g_list_foreach(entry->suggests, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
595 g_list_free(entry->suggests); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
596 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
597 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
598 if (entry->ddown) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
599 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
600 gnt_widget_destroy(entry->ddown->parent); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
601 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
602 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
603 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
604 static void |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
605 gnt_entry_lost_focus(GntWidget *widget) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
606 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
607 GntEntry *entry = GNT_ENTRY(widget); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
608 destroy_suggest(entry); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
609 entry_redraw(widget); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
610 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
611 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
612 static void |
13860
c1e3f7c75c3f
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13855
diff
changeset
|
613 gnt_entry_class_init(GntEntryClass *klass) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
614 { |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
615 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); |
14901
d9d28bd79715
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
616 char s[2] = {erasechar(), 0}; |
d9d28bd79715
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
617 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
618 parent_class = GNT_WIDGET_CLASS(klass); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
619 parent_class->destroy = gnt_entry_destroy; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
620 parent_class->draw = gnt_entry_draw; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
621 parent_class->map = gnt_entry_map; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
622 parent_class->size_request = gnt_entry_size_request; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
623 parent_class->key_pressed = gnt_entry_key_pressed; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
624 parent_class->lost_focus = gnt_entry_lost_focus; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
625 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
626 signals[SIG_TEXT_CHANGED] = |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
627 g_signal_new("text_changed", |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
628 G_TYPE_FROM_CLASS(klass), |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
629 G_SIGNAL_RUN_LAST, |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
630 G_STRUCT_OFFSET(GntEntryClass, text_changed), |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
631 NULL, NULL, |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
632 g_cclosure_marshal_VOID__VOID, |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
633 G_TYPE_NONE, 0); |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
634 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
635 gnt_bindable_class_register_action(bindable, "cursor-home", move_start, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
636 GNT_KEY_CTRL_A, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
637 gnt_bindable_register_binding(bindable, "cursor-home", GNT_KEY_HOME, NULL); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
638 gnt_bindable_class_register_action(bindable, "cursor-end", move_end, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
639 GNT_KEY_CTRL_E, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
640 gnt_bindable_register_binding(bindable, "cursor-end", GNT_KEY_END, NULL); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
641 gnt_bindable_class_register_action(bindable, "delete-prev", backspace, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
642 GNT_KEY_BACKSPACE, NULL); |
14901
d9d28bd79715
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14900
diff
changeset
|
643 gnt_bindable_register_binding(bindable, "delete-prev", s, NULL); |
15304
492f4e7416a3
[gaim-migrate @ 18095]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15230
diff
changeset
|
644 gnt_bindable_register_binding(bindable, "delete-prev", GNT_KEY_CTRL_H, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
645 gnt_bindable_class_register_action(bindable, "delete-next", delkey, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
646 GNT_KEY_DEL, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
647 gnt_bindable_register_binding(bindable, "delete-next", GNT_KEY_CTRL_D, NULL); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
648 gnt_bindable_class_register_action(bindable, "delete-start", del_to_home, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
649 GNT_KEY_CTRL_U, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
650 gnt_bindable_class_register_action(bindable, "delete-end", del_to_end, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
651 GNT_KEY_CTRL_K, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
652 gnt_bindable_class_register_action(bindable, "delete-prev-word", del_prev_word, |
14973
f16e056f816d
[gaim-migrate @ 17752]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14901
diff
changeset
|
653 GNT_KEY_CTRL_W, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
654 gnt_bindable_class_register_action(bindable, "cursor-prev-word", move_back_word, |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
655 "\033" "b", NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
656 gnt_bindable_class_register_action(bindable, "cursor-prev", move_back, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
657 GNT_KEY_LEFT, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
658 gnt_bindable_register_binding(bindable, "cursor-prev", GNT_KEY_CTRL_B, NULL); |
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
659 gnt_bindable_class_register_action(bindable, "cursor-next", move_forward, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
660 GNT_KEY_RIGHT, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
661 gnt_bindable_register_binding(bindable, "cursor-next", GNT_KEY_CTRL_F, NULL); |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
662 gnt_bindable_class_register_action(bindable, "cursor-next-word", move_forward_word, |
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
663 "\033" "f", NULL); |
15125
1bd757119ca7
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15124
diff
changeset
|
664 gnt_bindable_class_register_action(bindable, "delete-next-word", delete_forward_word, |
15124
ed14c190a868
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14976
diff
changeset
|
665 "\033" "d", NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
666 gnt_bindable_class_register_action(bindable, "suggest-show", suggest_show, |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
667 "\t", NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
668 gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
669 GNT_KEY_DOWN, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
670 gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev, |
14876
70623f0d5cdc
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14872
diff
changeset
|
671 GNT_KEY_UP, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
672 gnt_bindable_class_register_action(bindable, "history-prev", history_prev, |
14976
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14973
diff
changeset
|
673 GNT_KEY_CTRL_DOWN, NULL); |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
674 gnt_bindable_class_register_action(bindable, "history-next", history_next, |
14976
1c0772f7260b
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14973
diff
changeset
|
675 GNT_KEY_CTRL_UP, NULL); |
14793
8a0cfee11af8
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14745
diff
changeset
|
676 |
14900
065e7ac30338
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14876
diff
changeset
|
677 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
678 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
679 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
680 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
681 static void |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
682 gnt_entry_init(GTypeInstance *instance, gpointer class) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
683 { |
13943
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
684 GntWidget *widget = GNT_WIDGET(instance); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
685 GntEntry *entry = GNT_ENTRY(instance); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
686 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
687 entry->flag = GNT_ENTRY_FLAG_ALL; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
688 entry->max = 0; |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
689 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
690 entry->histlength = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
691 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
692 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
693 entry->word = TRUE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
694 entry->always = FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
695 entry->suggests = NULL; |
13855
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 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
698 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
|
699 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
|
700 |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
701 widget->priv.minw = 3; |
25be562aaca8
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13930
diff
changeset
|
702 widget->priv.minh = 1; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
703 |
14432
3ac156db9cb6
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14351
diff
changeset
|
704 GNTDEBUG; |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
705 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
706 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
707 /****************************************************************************** |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
708 * GntEntry API |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
709 *****************************************************************************/ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
710 GType |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
711 gnt_entry_get_gtype(void) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
712 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
713 static GType type = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
714 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
715 if(type == 0) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
716 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
717 static const GTypeInfo info = { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
718 sizeof(GntEntryClass), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
719 NULL, /* base_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
720 NULL, /* base_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
721 (GClassInitFunc)gnt_entry_class_init, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
722 NULL, /* class_finalize */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
723 NULL, /* class_data */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
724 sizeof(GntEntry), |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
725 0, /* n_preallocs */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
726 gnt_entry_init, /* instance_init */ |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
727 }; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
728 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
729 type = g_type_register_static(GNT_TYPE_WIDGET, |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
730 "GntEntry", |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
731 &info, 0); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
732 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
733 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
734 return type; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
735 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
736 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
737 GntWidget *gnt_entry_new(const char *text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
738 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
739 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
740 GntEntry *entry = GNT_ENTRY(widget); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
741 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
742 gnt_entry_set_text_internal(entry, text); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
743 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
744 return widget; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
745 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
746 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
747 static void |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
748 gnt_entry_set_text_internal(GntEntry *entry, const char *text) |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
749 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
750 int len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
751 int scroll, cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
752 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
753 g_free(entry->start); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
754 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
755 if (text && text[0]) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
756 { |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
757 len = strlen(text); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
758 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
759 else |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
760 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
761 len = 0; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
762 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
763 |
14031
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
764 entry->buffer = len + 128; |
942170284c55
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14028
diff
changeset
|
765 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
766 scroll = entry->scroll - entry->start; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
767 cursor = entry->end - entry->cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
768 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
769 entry->start = g_new0(char, entry->buffer); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
770 if (text) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
771 snprintf(entry->start, len + 1, "%s", text); |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
772 entry->end = entry->start + len; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
773 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
774 entry->scroll = entry->start + scroll; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
775 entry->cursor = entry->end - cursor; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
776 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
777 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
|
778 entry_redraw(GNT_WIDGET(entry)); |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
779 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
780 |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
781 void gnt_entry_set_text(GntEntry *entry, const char *text) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
782 { |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
783 gboolean changed = TRUE; |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
784 if (text == NULL && entry->start == NULL) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
785 changed = FALSE; |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
786 if (text && entry->start && g_utf8_collate(text, entry->start) == 0) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
787 changed = FALSE; |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
788 gnt_entry_set_text_internal(entry, text); |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
789 if (changed) |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
790 entry_text_changed(entry); |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
791 } |
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
792 |
13855
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
793 void gnt_entry_set_max(GntEntry *entry, int max) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
794 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
795 entry->max = max; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
796 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
797 |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
798 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
799 { |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
800 entry->flag = flag; |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
801 /* 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
|
802 } |
5b288502a382
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
803 |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
804 const char *gnt_entry_get_text(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
805 { |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
806 return entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
807 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
808 |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
809 void gnt_entry_clear(GntEntry *entry) |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
810 { |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
811 gnt_entry_set_text_internal(entry, NULL); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
812 entry->scroll = entry->cursor = entry->end = entry->start; |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
813 entry_redraw(GNT_WIDGET(entry)); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
814 destroy_suggest(entry); |
15230
4f0575a9264d
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15126
diff
changeset
|
815 entry_text_changed(entry); |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
816 } |
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
817 |
13979
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
818 void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
819 { |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
820 entry->masked = set; |
a71678d2da16
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13943
diff
changeset
|
821 } |
13882
5c750626eaa5
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13878
diff
changeset
|
822 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
823 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
|
824 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
825 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
|
826 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
827 if (g_list_length(entry->history) >= entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
828 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
829 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
830 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
831 g_free(entry->history->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
832 entry->history->data = g_strdup(text); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
833 entry->history = g_list_prepend(entry->history, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
834 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
835 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
836 void gnt_entry_set_history_length(GntEntry *entry, int num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
837 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
838 if (num == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
839 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
840 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
841 if (entry->history) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
842 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
843 entry->history = g_list_first(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
844 g_list_foreach(entry->history, (GFunc)g_free, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
845 g_list_free(entry->history); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
846 entry->history = NULL; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
847 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
848 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
849 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
850 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
851 if (entry->histlength == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
852 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
853 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
854 entry->history = g_list_append(NULL, NULL); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
855 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
856 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
857 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
858 if (num > 0 && num < entry->histlength) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
859 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
860 GList *first, *iter; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
861 int index = 0; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
862 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
|
863 while ((iter = g_list_nth(first, num)) != NULL) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
864 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
865 g_free(iter->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
866 first = g_list_delete_link(first, iter); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
867 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
868 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
869 if (index >= num) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
870 entry->history = g_list_last(first); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
871 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
872 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
873 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
874 entry->histlength = num; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
875 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
876 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
877 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
878 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
879 entry->word = word; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
880 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
881 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
882 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
883 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
884 entry->always = always; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
885 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
886 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
887 void gnt_entry_add_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
888 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
889 GList *find; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
890 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
891 if (!text || !*text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
892 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
893 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
894 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
|
895 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
896 return; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
897 entry->suggests = g_list_append(entry->suggests, g_strdup(text)); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
898 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
899 |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
900 void gnt_entry_remove_suggest(GntEntry *entry, const char *text) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
901 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
902 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
|
903 if (find) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
904 { |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
905 g_free(find->data); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
906 entry->suggests = g_list_delete_link(entry->suggests, find); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
907 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
908 } |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
909 |