Fri, 04 May 2007 15:53:24 +0000
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
|
13950
bd8d39b3a9e2
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13944
diff
changeset
|
1 | #include <ctype.h> |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
2 | #include <string.h> |
|
13950
bd8d39b3a9e2
[gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13944
diff
changeset
|
3 | |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
4 | #include "gntbox.h" |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
5 | #include "gntentry.h" |
|
14898
107b971b39f2
[gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14890
diff
changeset
|
6 | #include "gntstyle.h" |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
7 | #include "gnttree.h" |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
8 | #include "gntutils.h" |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
9 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
10 | enum |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
11 | { |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
12 | SIG_TEXT_CHANGED, |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
13 | SIGS, |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
14 | }; |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
15 | static guint signals[SIGS] = { 0 }; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
16 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
17 | static GntWidgetClass *parent_class = NULL; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
18 | |
|
16020
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
19 | static gboolean gnt_entry_key_pressed(GntWidget *widget, const char *text); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
20 | static void gnt_entry_set_text_internal(GntEntry *entry, const char *text); |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
21 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
22 | static void |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
23 | destroy_suggest(GntEntry *entry) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
24 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
25 | if (entry->ddown) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
26 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
27 | gnt_widget_destroy(entry->ddown->parent); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
28 | entry->ddown = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
29 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
30 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
31 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
32 | static char * |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
33 | get_beginning_of_word(GntEntry *entry) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
34 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
35 | char *s = entry->cursor; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
36 | while (s > entry->start) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
37 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
38 | char *t = g_utf8_find_prev_char(entry->start, s); |
|
14640
9f0f2bbbc4e2
[gaim-migrate @ 17302]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14539
diff
changeset
|
39 | if (isspace(*t)) |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
40 | break; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
41 | s = t; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
42 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
43 | return s; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
44 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
45 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
46 | static gboolean |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
47 | complete_suggest(GntEntry *entry, const char *text) |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
48 | { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
49 | gboolean changed = FALSE; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
50 | if (entry->word) { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
51 | char *s = get_beginning_of_word(entry); |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
52 | const char *iter = text; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
53 | while (*iter && toupper(*s) == toupper(*iter)) { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
54 | if (*s != *iter) |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
55 | changed = TRUE; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
56 | *s++ = *iter++; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
57 | } |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
58 | if (*iter) { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
59 | gnt_entry_key_pressed(GNT_WIDGET(entry), iter); |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
60 | changed = TRUE; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
61 | } |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
62 | } else { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
63 | gnt_entry_set_text_internal(entry, text); |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
64 | changed = TRUE; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
65 | } |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
66 | return changed; |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
67 | } |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
68 | |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
69 | static gboolean |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
70 | show_suggest_dropdown(GntEntry *entry) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
71 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
72 | char *suggest = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
73 | int len; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
74 | int offset = 0, x, y; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
75 | int count = 0; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
76 | GList *iter; |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
77 | const char *text = NULL; |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
78 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
79 | if (entry->word) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
80 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
81 | char *s = get_beginning_of_word(entry); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
82 | suggest = g_strndup(s, entry->cursor - s); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
83 | if (entry->scroll < s) |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
84 | offset = gnt_util_onscreen_width(entry->scroll, s); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
85 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
86 | else |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
87 | suggest = g_strdup(entry->start); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
88 | len = strlen(suggest); /* Don't need to use the utf8-function here */ |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
89 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
90 | if (entry->ddown == NULL) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
91 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
92 | GntWidget *box = gnt_vbox_new(FALSE); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
93 | entry->ddown = gnt_tree_new(); |
|
14167
ca6027c33d2c
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14156
diff
changeset
|
94 | gnt_tree_set_compare_func(GNT_TREE(entry->ddown), (GCompareFunc)g_utf8_collate); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
95 | gnt_box_add_widget(GNT_BOX(box), entry->ddown); |
|
14539
7d5528c864a1
[gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14494
diff
changeset
|
96 | /* XXX: Connect to the "activate" signal for the dropdown tree */ |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
97 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
98 | GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
99 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
100 | gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
101 | x += offset; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
102 | y++; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
103 | if (y + 10 >= getmaxy(stdscr)) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
104 | y -= 11; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
105 | gnt_widget_set_position(box, x, y); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
106 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
107 | else |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
108 | gnt_tree_remove_all(GNT_TREE(entry->ddown)); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
109 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
110 | for (count = 0, iter = entry->suggests; iter; iter = iter->next) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
111 | { |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
112 | text = iter->data; |
|
14156
aacb0581eaf6
[gaim-migrate @ 16723]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14153
diff
changeset
|
113 | if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len) |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
114 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
115 | gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
116 | gnt_tree_create_row(GNT_TREE(entry->ddown), text), |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
117 | NULL, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
118 | count++; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
119 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
120 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
121 | g_free(suggest); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
122 | |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
123 | if (count == 0) { |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
124 | destroy_suggest(entry); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
125 | return FALSE; |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
126 | } else if (count == 1) { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
127 | destroy_suggest(entry); |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
128 | return complete_suggest(entry, text); |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
129 | } else { |
|
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
130 | gnt_widget_draw(entry->ddown->parent); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
131 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
132 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
133 | return TRUE; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
134 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
135 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
136 | static void |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
137 | gnt_entry_draw(GntWidget *widget) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
138 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
139 | GntEntry *entry = GNT_ENTRY(widget); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
140 | int stop; |
|
14103
bcac61d40461
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14093
diff
changeset
|
141 | gboolean focus; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
142 | |
|
14103
bcac61d40461
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14093
diff
changeset
|
143 | if ((focus = gnt_widget_has_focus(widget))) |
|
13958
bd1c3bb3f33d
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13950
diff
changeset
|
144 | wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL)); |
|
bd1c3bb3f33d
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13950
diff
changeset
|
145 | else |
|
bd1c3bb3f33d
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13950
diff
changeset
|
146 | wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
147 | |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
148 | if (entry->masked) |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
149 | { |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
150 | mvwhline(widget->window, 0, 0, gnt_ascii_only() ? '*' : ACS_BULLET, |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
151 | g_utf8_pointer_to_offset(entry->scroll, entry->end)); |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
152 | } |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
153 | else |
|
14369
e9a9ac6bd8de
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14318
diff
changeset
|
154 | mvwprintw(widget->window, 0, 0, "%s", entry->scroll); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
155 | |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
156 | stop = gnt_util_onscreen_width(entry->scroll, entry->end); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
157 | if (stop < widget->priv.width) |
|
14369
e9a9ac6bd8de
[gaim-migrate @ 16997]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14318
diff
changeset
|
158 | whline(widget->window, ENTRY_CHAR, widget->priv.width - stop); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
159 | |
|
14103
bcac61d40461
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14093
diff
changeset
|
160 | if (focus) |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
161 | mvwchgat(widget->window, 0, gnt_util_onscreen_width(entry->scroll, entry->cursor), |
|
14687
46437fa5eebe
[gaim-migrate @ 17357]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14640
diff
changeset
|
162 | 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL); |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
163 | |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14413
diff
changeset
|
164 | GNTDEBUG; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
165 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
166 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
167 | static void |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
168 | gnt_entry_size_request(GntWidget *widget) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
169 | { |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
170 | if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
171 | { |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
172 | widget->priv.height = 1; |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
173 | widget->priv.width = 20; |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
174 | } |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
175 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
176 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
177 | static void |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
178 | gnt_entry_map(GntWidget *widget) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
179 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
180 | if (widget->priv.width == 0 || widget->priv.height == 0) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
181 | gnt_widget_size_request(widget); |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14413
diff
changeset
|
182 | GNTDEBUG; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
183 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
184 | |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
185 | static void |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
186 | entry_redraw(GntWidget *widget) |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
187 | { |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
188 | gnt_entry_draw(widget); |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
189 | gnt_widget_queue_update(widget); |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
190 | } |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
191 | |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
192 | static void |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
193 | entry_text_changed(GntEntry *entry) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
194 | { |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
195 | g_signal_emit(entry, signals[SIG_TEXT_CHANGED], 0); |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
196 | } |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
197 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
198 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
199 | move_back(GntBindable *bind, GList *null) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
200 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
201 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
202 | if (entry->cursor <= entry->start) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
203 | return FALSE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
204 | entry->cursor = g_utf8_find_prev_char(entry->start, entry->cursor); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
205 | if (entry->cursor < entry->scroll) |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
206 | entry->scroll = entry->cursor; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
207 | entry_redraw(GNT_WIDGET(entry)); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
208 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
209 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
210 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
211 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
212 | move_forward(GntBindable *bind, GList *list) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
213 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
214 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
215 | if (entry->cursor >= entry->end) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
216 | return FALSE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
217 | entry->cursor = g_utf8_find_next_char(entry->cursor, NULL); |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
218 | while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
219 | entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
220 | entry_redraw(GNT_WIDGET(entry)); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
221 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
222 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
223 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
224 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
225 | backspace(GntBindable *bind, GList *null) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
226 | { |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
227 | int len; |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
228 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
229 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
230 | if (entry->cursor <= entry->start) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
231 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
232 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
233 | len = entry->cursor - g_utf8_find_prev_char(entry->start, entry->cursor); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
234 | entry->cursor -= len; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
235 | memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
236 | entry->end -= len; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
237 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
238 | if (entry->scroll > entry->start) |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
239 | entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
240 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
241 | entry_redraw(GNT_WIDGET(entry)); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
242 | if (entry->ddown) |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
243 | show_suggest_dropdown(entry); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
244 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
245 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
246 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
247 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
248 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
249 | delkey(GntBindable *bind, GList *null) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
250 | { |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
251 | int len; |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
252 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
253 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
254 | if (entry->cursor >= entry->end) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
255 | return FALSE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
256 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
257 | len = g_utf8_find_next_char(entry->cursor, NULL) - entry->cursor; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
258 | memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
259 | entry->end -= len; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
260 | entry_redraw(GNT_WIDGET(entry)); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
261 | |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
262 | if (entry->ddown) |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
263 | show_suggest_dropdown(entry); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
264 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
265 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
266 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
267 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
268 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
269 | move_start(GntBindable *bind, GList *null) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
270 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
271 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
272 | entry->scroll = entry->cursor = entry->start; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
273 | entry_redraw(GNT_WIDGET(entry)); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
274 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
275 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
276 | |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
277 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
278 | move_end(GntBindable *bind, GList *null) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
279 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
280 | GntEntry *entry = GNT_ENTRY(bind); |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
281 | entry->cursor = entry->end; |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
282 | /* This should be better than this */ |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
283 | while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= GNT_WIDGET(entry)->priv.width) |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
284 | entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
285 | entry_redraw(GNT_WIDGET(entry)); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
286 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
287 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
288 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
289 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
290 | history_prev(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
291 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
292 | GntEntry *entry = GNT_ENTRY(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
293 | if (entry->histlength && entry->history->prev) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
294 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
295 | entry->history = entry->history->prev; |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
296 | gnt_entry_set_text_internal(entry, entry->history->data); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
297 | destroy_suggest(entry); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
298 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
299 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
300 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
301 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
302 | return FALSE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
303 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
304 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
305 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
306 | history_next(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
307 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
308 | GntEntry *entry = GNT_ENTRY(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
309 | if (entry->histlength && entry->history->next) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
310 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
311 | if (entry->history->prev == NULL) |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
312 | { |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
313 | /* Save the current contents */ |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
314 | char *text = g_strdup(gnt_entry_get_text(entry)); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
315 | g_free(entry->history->data); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
316 | entry->history->data = text; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
317 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
318 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
319 | entry->history = entry->history->next; |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
320 | gnt_entry_set_text_internal(entry, entry->history->data); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
321 | destroy_suggest(entry); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
322 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
323 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
324 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
325 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
326 | return FALSE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
327 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
328 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
329 | static gboolean |
|
15814
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
330 | clipboard_paste(GntBindable *bind, GList *n) |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
331 | { |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
332 | GntEntry *entry = GNT_ENTRY(bind); |
|
15838
45289a1439b2
Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents:
15837
diff
changeset
|
333 | gchar *i, *text, *a, *all; |
|
45289a1439b2
Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents:
15837
diff
changeset
|
334 | text = i = gnt_get_clipboard_string(); |
|
15814
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
335 | while (*i != '\0') { |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
336 | i = g_utf8_next_char(i); |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
337 | if (*i == '\r' || *i == '\n') |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
338 | *i = ' '; |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
339 | } |
|
15838
45289a1439b2
Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents:
15837
diff
changeset
|
340 | a = g_strndup(entry->start, entry->cursor - entry->start); |
|
45289a1439b2
Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents:
15837
diff
changeset
|
341 | all = g_strconcat(a, text, entry->cursor, NULL); |
|
15814
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
342 | gnt_entry_set_text_internal(entry, all); |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
343 | g_free(a); |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
344 | g_free(text); |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
345 | g_free(all); |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
346 | return TRUE; |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
347 | } |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
348 | |
|
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
349 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
350 | suggest_show(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
351 | { |
|
16020
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
352 | GntEntry *entry = GNT_ENTRY(bind); |
|
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
353 | if (entry->ddown) { |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
354 | gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-down"); |
|
16020
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
355 | return TRUE; |
|
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
356 | } |
|
dd8e83225ad5
Update the tab completion a little bit. The binding for suggest-show will perform suggest-next if the suggest-dropdown is already showing. If there's just one suggestion, then complete with that suggestion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15886
diff
changeset
|
357 | return show_suggest_dropdown(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
358 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
359 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
360 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
361 | suggest_next(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
362 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
363 | GntEntry *entry = GNT_ENTRY(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
364 | if (entry->ddown) { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
365 | gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-down", NULL); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
366 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
367 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
368 | return FALSE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
369 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
370 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
371 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
372 | suggest_prev(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
373 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
374 | GntEntry *entry = GNT_ENTRY(bind); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
375 | if (entry->ddown) { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
376 | gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-up", NULL); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
377 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
378 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
379 | return FALSE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
380 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
381 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
382 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
383 | del_to_home(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
384 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
385 | GntEntry *entry = GNT_ENTRY(bind); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
386 | if (entry->cursor <= entry->start) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
387 | return TRUE; |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
388 | memmove(entry->start, entry->cursor, entry->end - entry->cursor); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
389 | entry->end -= (entry->cursor - entry->start); |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
390 | entry->cursor = entry->scroll = entry->start; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
391 | memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
392 | entry_redraw(GNT_WIDGET(bind)); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
393 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
394 | return TRUE; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
395 | } |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
396 | |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
397 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
398 | del_to_end(GntBindable *bind, GList *null) |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
399 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
400 | GntEntry *entry = GNT_ENTRY(bind); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
401 | if (entry->end <= entry->cursor) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
402 | return TRUE; |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
403 | entry->end = entry->cursor; |
|
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
404 | memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
405 | entry_redraw(GNT_WIDGET(bind)); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
406 | entry_text_changed(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
407 | return TRUE; |
|
14275
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
408 | } |
|
ef418684623d
[gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14167
diff
changeset
|
409 | |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
410 | #define SAME(a,b) ((g_unichar_isalpha(a) && g_unichar_isalpha(b)) || \ |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
411 | (g_unichar_isdigit(a) && g_unichar_isdigit(b)) || \ |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
412 | (g_unichar_isspace(a) && g_unichar_isspace(b)) || \ |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
413 | (g_unichar_iswide(a) && g_unichar_iswide(b))) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
414 | |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
415 | static const char * |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
416 | begin_word(const char *text, const char *begin) |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
417 | { |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
418 | gunichar ch = 0; |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
419 | while (text > begin && (!*text || g_unichar_isspace(g_utf8_get_char(text)))) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
420 | text = g_utf8_find_prev_char(begin, text); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
421 | ch = g_utf8_get_char(text); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
422 | while ((text = g_utf8_find_prev_char(begin, text)) >= begin) { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
423 | gunichar cur = g_utf8_get_char(text); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
424 | if (!SAME(ch, cur)) |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
425 | break; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
426 | } |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
427 | |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
428 | return (text ? g_utf8_find_next_char(text, NULL) : begin); |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
429 | } |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
430 | |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
431 | static const char * |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
432 | next_begin_word(const char *text, const char *end) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
433 | { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
434 | gunichar ch = 0; |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
435 | ch = g_utf8_get_char(text); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
436 | while ((text = g_utf8_find_next_char(text, end)) != NULL && text <= end) { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
437 | gunichar cur = g_utf8_get_char(text); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
438 | if (!SAME(ch, cur)) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
439 | break; |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
440 | } |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
441 | |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
442 | while (text && text < end && g_unichar_isspace(g_utf8_get_char(text))) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
443 | text = g_utf8_find_next_char(text, end); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
444 | return (text ? text : end); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
445 | } |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
446 | |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
447 | #undef SAME |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
448 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
449 | move_back_word(GntBindable *bind, GList *null) |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
450 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
451 | GntEntry *entry = GNT_ENTRY(bind); |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
452 | const char *iter = g_utf8_find_prev_char(entry->start, entry->cursor); |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
453 | |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
454 | if (iter < entry->start) |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
455 | return TRUE; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
456 | iter = begin_word(iter, entry->start); |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
457 | entry->cursor = (char*)iter; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
458 | if (entry->cursor < entry->scroll) |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
459 | entry->scroll = entry->cursor; |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
460 | entry_redraw(GNT_WIDGET(bind)); |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
461 | return TRUE; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
462 | } |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
463 | |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
464 | static gboolean |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
465 | del_prev_word(GntBindable *bind, GList *null) |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
466 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
467 | GntWidget *widget = GNT_WIDGET(bind); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
468 | GntEntry *entry = GNT_ENTRY(bind); |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
469 | char *iter = g_utf8_find_prev_char(entry->start, entry->cursor); |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
470 | int count; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
471 | |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
472 | if (iter < entry->start) |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
473 | return TRUE; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
474 | iter = (char*)begin_word(iter, entry->start); |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
475 | count = entry->cursor - iter; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
476 | memmove(iter, entry->cursor, entry->end - entry->cursor); |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
477 | entry->end -= count; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
478 | entry->cursor = iter; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
479 | if (entry->cursor <= entry->scroll) { |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
480 | entry->scroll = entry->cursor - widget->priv.width + 2; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
481 | if (entry->scroll < entry->start) |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
482 | entry->scroll = entry->start; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
483 | } |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
484 | memset(entry->end, '\0', entry->buffer - (entry->end - entry->start)); |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
485 | entry_redraw(widget); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
486 | entry_text_changed(entry); |
|
14890
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
487 | |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
488 | return TRUE; |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
489 | } |
|
78c01aad3cfa
[gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14889
diff
changeset
|
490 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
491 | static gboolean |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
492 | move_forward_word(GntBindable *bind, GList *list) |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
493 | { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
494 | GntEntry *entry = GNT_ENTRY(bind); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
495 | GntWidget *widget = GNT_WIDGET(bind); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
496 | entry->cursor = (char *)next_begin_word(entry->cursor, entry->end); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
497 | while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width) { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
498 | entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
499 | } |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
500 | entry_redraw(widget); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
501 | return TRUE; |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
502 | } |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
503 | |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
504 | static gboolean |
|
15187
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
505 | delete_forward_word(GntBindable *bind, GList *list) |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
506 | { |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
507 | GntEntry *entry = GNT_ENTRY(bind); |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
508 | GntWidget *widget = GNT_WIDGET(bind); |
|
15187
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
509 | char *iter = (char *)next_begin_word(entry->cursor, entry->end); |
|
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
510 | int len = entry->end - iter + 1; |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
511 | if (len <= 0) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
512 | return TRUE; |
|
15187
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
513 | memmove(entry->cursor, iter, len); |
|
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
514 | len = iter - entry->cursor; |
|
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
515 | entry->end -= len; |
|
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
516 | memset(entry->end, '\0', len); |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
517 | entry_redraw(widget); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
518 | entry_text_changed(entry); |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
519 | return TRUE; |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
520 | } |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
521 | |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
522 | static gboolean |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
523 | gnt_entry_key_pressed(GntWidget *widget, const char *text) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
524 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
525 | GntEntry *entry = GNT_ENTRY(widget); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
526 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
527 | if (text[0] == 27) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
528 | { |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
529 | if (text[1] == 0) |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
530 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
531 | destroy_suggest(entry); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
532 | return TRUE; |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
533 | } |
|
14005
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
534 | |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
535 | return FALSE; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
536 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
537 | else |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
538 | { |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
539 | if ((text[0] == '\r' || text[0] == ' ') && entry->ddown) |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
540 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
541 | char *text = g_strdup(gnt_tree_get_selection_data(GNT_TREE(entry->ddown))); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
542 | destroy_suggest(entry); |
|
16945
ac3a37a76525
Fix some ickyness in the tab-completion. Now, if there's only one suggest word, then the first tab will just complete the suggestion. If there's only one suggest word, and it's already completed, then tab will take focus to the next widget. If there is a dropdown, then you can select a suggest word by pressing tabs to move to it, then either space or enter to accept it.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16020
diff
changeset
|
543 | complete_suggest(entry, text); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
544 | g_free(text); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
545 | entry_text_changed(entry); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
546 | return TRUE; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
547 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
548 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
549 | if (!iscntrl(text[0])) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
550 | { |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
551 | const char *str, *next; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
552 | |
|
14413
bd998fe17d82
[gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14373
diff
changeset
|
553 | for (str = text; *str; str = next) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
554 | { |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
555 | int len; |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
556 | next = g_utf8_find_next_char(str, NULL); |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
557 | len = next - str; |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
558 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
559 | /* Valid input? */ |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
560 | /* XXX: Is it necessary to use _unichar_ variants here? */ |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
561 | if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT)) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
562 | continue; |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
563 | if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE)) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
564 | continue; |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
565 | if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA)) |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
566 | continue; |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
567 | if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT)) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
568 | continue; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
569 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
570 | /* Reached the max? */ |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
571 | if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
572 | continue; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
573 | |
|
14807
45797fd1d1dc
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14791
diff
changeset
|
574 | if (entry->end + len - entry->start >= entry->buffer) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
575 | { |
|
14807
45797fd1d1dc
[gaim-migrate @ 17502]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14791
diff
changeset
|
576 | /* This will cause the buffer to grow */ |
|
15852
99c67d0a7eed
fix extraneous char being added when gntentry's buffer grows
Richard Nelson <wabz@pidgin.im>
parents:
15838
diff
changeset
|
577 | char *tmp = g_strdup(entry->start); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
578 | gnt_entry_set_text_internal(entry, tmp); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
579 | g_free(tmp); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
580 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
581 | |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
582 | memmove(entry->cursor + len, entry->cursor, entry->end - entry->cursor + 1); |
|
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
583 | entry->end += len; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
584 | |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
585 | while (str < next) |
|
14278
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
586 | { |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
587 | if (*str == '\r' || *str == '\n') |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
588 | *entry->cursor = ' '; |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
589 | else |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
590 | *entry->cursor = *str; |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
591 | entry->cursor++; |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
592 | str++; |
|
9e2a97a4542e
[gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14275
diff
changeset
|
593 | } |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
594 | |
|
14373
609c902d20f5
[gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14371
diff
changeset
|
595 | while (gnt_util_onscreen_width(entry->scroll, entry->cursor) >= widget->priv.width) |
|
14090
a8552e906a76
[gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14041
diff
changeset
|
596 | entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
597 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
598 | if (entry->ddown) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
599 | show_suggest_dropdown(entry); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
600 | } |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
601 | entry_redraw(widget); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
602 | entry_text_changed(entry); |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
603 | return TRUE; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
604 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
605 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
606 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
607 | return FALSE; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
608 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
609 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
610 | static void |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
611 | gnt_entry_destroy(GntWidget *widget) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
612 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
613 | GntEntry *entry = GNT_ENTRY(widget); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
614 | g_free(entry->start); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
615 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
616 | if (entry->history) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
617 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
618 | entry->history = g_list_first(entry->history); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
619 | g_list_foreach(entry->history, (GFunc)g_free, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
620 | g_list_free(entry->history); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
621 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
622 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
623 | if (entry->suggests) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
624 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
625 | g_list_foreach(entry->suggests, (GFunc)g_free, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
626 | g_list_free(entry->suggests); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
627 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
628 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
629 | if (entry->ddown) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
630 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
631 | gnt_widget_destroy(entry->ddown->parent); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
632 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
633 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
634 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
635 | static void |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
636 | gnt_entry_lost_focus(GntWidget *widget) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
637 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
638 | GntEntry *entry = GNT_ENTRY(widget); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
639 | destroy_suggest(entry); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
640 | entry_redraw(widget); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
641 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
642 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
643 | static void |
|
13922
7195a6fe2416
[gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13917
diff
changeset
|
644 | gnt_entry_class_init(GntEntryClass *klass) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
645 | { |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
646 | GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); |
|
14963
1c783f0acfa9
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
647 | char s[2] = {erasechar(), 0}; |
|
1c783f0acfa9
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
648 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
649 | parent_class = GNT_WIDGET_CLASS(klass); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
650 | parent_class->destroy = gnt_entry_destroy; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
651 | parent_class->draw = gnt_entry_draw; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
652 | parent_class->map = gnt_entry_map; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
653 | parent_class->size_request = gnt_entry_size_request; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
654 | parent_class->key_pressed = gnt_entry_key_pressed; |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
655 | parent_class->lost_focus = gnt_entry_lost_focus; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
656 | |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
657 | signals[SIG_TEXT_CHANGED] = |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
658 | g_signal_new("text_changed", |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
659 | G_TYPE_FROM_CLASS(klass), |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
660 | G_SIGNAL_RUN_LAST, |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
661 | G_STRUCT_OFFSET(GntEntryClass, text_changed), |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
662 | NULL, NULL, |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
663 | g_cclosure_marshal_VOID__VOID, |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
664 | G_TYPE_NONE, 0); |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
665 | |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
666 | gnt_bindable_class_register_action(bindable, "cursor-home", move_start, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
667 | GNT_KEY_CTRL_A, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
668 | gnt_bindable_register_binding(bindable, "cursor-home", GNT_KEY_HOME, NULL); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
669 | gnt_bindable_class_register_action(bindable, "cursor-end", move_end, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
670 | GNT_KEY_CTRL_E, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
671 | gnt_bindable_register_binding(bindable, "cursor-end", GNT_KEY_END, NULL); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
672 | gnt_bindable_class_register_action(bindable, "delete-prev", backspace, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
673 | GNT_KEY_BACKSPACE, NULL); |
|
14963
1c783f0acfa9
[gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14962
diff
changeset
|
674 | gnt_bindable_register_binding(bindable, "delete-prev", s, NULL); |
|
15366
df6795069c0b
[gaim-migrate @ 18095]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15292
diff
changeset
|
675 | gnt_bindable_register_binding(bindable, "delete-prev", GNT_KEY_CTRL_H, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
676 | gnt_bindable_class_register_action(bindable, "delete-next", delkey, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14934
diff
changeset
|
677 | GNT_KEY_DEL, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
678 | gnt_bindable_register_binding(bindable, "delete-next", GNT_KEY_CTRL_D, NULL); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
679 | gnt_bindable_class_register_action(bindable, "delete-start", del_to_home, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
680 | GNT_KEY_CTRL_U, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
681 | gnt_bindable_class_register_action(bindable, "delete-end", del_to_end, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
682 | GNT_KEY_CTRL_K, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
683 | gnt_bindable_class_register_action(bindable, "delete-prev-word", del_prev_word, |
|
15035
aa885309086e
[gaim-migrate @ 17752]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14963
diff
changeset
|
684 | GNT_KEY_CTRL_W, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
685 | gnt_bindable_class_register_action(bindable, "cursor-prev-word", move_back_word, |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
686 | "\033" "b", NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
687 | gnt_bindable_class_register_action(bindable, "cursor-prev", move_back, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14934
diff
changeset
|
688 | GNT_KEY_LEFT, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
689 | gnt_bindable_register_binding(bindable, "cursor-prev", GNT_KEY_CTRL_B, NULL); |
|
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
690 | gnt_bindable_class_register_action(bindable, "cursor-next", move_forward, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14934
diff
changeset
|
691 | GNT_KEY_RIGHT, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
692 | gnt_bindable_register_binding(bindable, "cursor-next", GNT_KEY_CTRL_F, NULL); |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
693 | gnt_bindable_class_register_action(bindable, "cursor-next-word", move_forward_word, |
|
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
694 | "\033" "f", NULL); |
|
15187
841272d50d22
[gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15186
diff
changeset
|
695 | gnt_bindable_class_register_action(bindable, "delete-next-word", delete_forward_word, |
|
15186
62aead088a8b
[gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15038
diff
changeset
|
696 | "\033" "d", NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
697 | gnt_bindable_class_register_action(bindable, "suggest-show", suggest_show, |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
698 | "\t", NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
699 | gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14934
diff
changeset
|
700 | GNT_KEY_DOWN, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
701 | gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev, |
|
14938
ee27e45919ef
[gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14934
diff
changeset
|
702 | GNT_KEY_UP, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
703 | gnt_bindable_class_register_action(bindable, "history-prev", history_prev, |
|
15038
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15035
diff
changeset
|
704 | GNT_KEY_CTRL_DOWN, NULL); |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
705 | gnt_bindable_class_register_action(bindable, "history-next", history_next, |
|
15038
e57ca0ff0489
[gaim-migrate @ 17755]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15035
diff
changeset
|
706 | GNT_KEY_CTRL_UP, NULL); |
|
15837
7718f3b6f643
Display selected double-width cell chars properly and select the correct number of bytes when these characters are on a selection line.
Richard Nelson <wabz@pidgin.im>
parents:
15814
diff
changeset
|
707 | gnt_bindable_class_register_action(bindable, "clipboard-paste", clipboard_paste, |
|
15814
2db42c6a13fa
Add a gntclipboard. You can select text in a textview with the mouse, and paste it in an entry with ctrl-v (or rebind GntEntry's clipboard-paste).
Richard Nelson <wabz@pidgin.im>
parents:
15366
diff
changeset
|
708 | GNT_KEY_CTRL_V, NULL); |
|
14855
84c869823944
[gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14807
diff
changeset
|
709 | |
|
14962
abfaa2e03ac7
[gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14938
diff
changeset
|
710 | gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14413
diff
changeset
|
711 | GNTDEBUG; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
712 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
713 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
714 | static void |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
715 | gnt_entry_init(GTypeInstance *instance, gpointer class) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
716 | { |
|
14005
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
717 | GntWidget *widget = GNT_WIDGET(instance); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
718 | GntEntry *entry = GNT_ENTRY(instance); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
719 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
720 | entry->flag = GNT_ENTRY_FLAG_ALL; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
721 | entry->max = 0; |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
722 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
723 | entry->histlength = 0; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
724 | entry->history = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
725 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
726 | entry->word = TRUE; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
727 | entry->always = FALSE; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
728 | entry->suggests = NULL; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
729 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
730 | GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
731 | GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS); |
|
13992
a6bbcc09c4eb
[gaim-migrate @ 16457]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13958
diff
changeset
|
732 | GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_GROW_X); |
|
14005
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
733 | |
|
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
734 | widget->priv.minw = 3; |
|
198d1658b390
[gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13992
diff
changeset
|
735 | widget->priv.minh = 1; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
736 | |
|
14494
3575eac3a518
[gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14413
diff
changeset
|
737 | GNTDEBUG; |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
738 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
739 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
740 | /****************************************************************************** |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
741 | * GntEntry API |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
742 | *****************************************************************************/ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
743 | GType |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
744 | gnt_entry_get_gtype(void) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
745 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
746 | static GType type = 0; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
747 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
748 | if(type == 0) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
749 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
750 | static const GTypeInfo info = { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
751 | sizeof(GntEntryClass), |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
752 | NULL, /* base_init */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
753 | NULL, /* base_finalize */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
754 | (GClassInitFunc)gnt_entry_class_init, |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
755 | NULL, /* class_finalize */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
756 | NULL, /* class_data */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
757 | sizeof(GntEntry), |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
758 | 0, /* n_preallocs */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
759 | gnt_entry_init, /* instance_init */ |
|
15874
46df7421a1b5
Enable DEBUG_CFLAGS in libgnt and fix up a number of compile warnings and
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15852
diff
changeset
|
760 | NULL /* value_table */ |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
761 | }; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
762 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
763 | type = g_type_register_static(GNT_TYPE_WIDGET, |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
764 | "GntEntry", |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
765 | &info, 0); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
766 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
767 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
768 | return type; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
769 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
770 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
771 | GntWidget *gnt_entry_new(const char *text) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
772 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
773 | GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
774 | GntEntry *entry = GNT_ENTRY(widget); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
775 | |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
776 | gnt_entry_set_text_internal(entry, text); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
777 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
778 | return widget; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
779 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
780 | |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
781 | static void |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
782 | gnt_entry_set_text_internal(GntEntry *entry, const char *text) |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
783 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
784 | int len; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
785 | int scroll, cursor; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
786 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
787 | g_free(entry->start); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
788 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
789 | if (text && text[0]) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
790 | { |
|
14093
98bd96324489
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14090
diff
changeset
|
791 | len = strlen(text); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
792 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
793 | else |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
794 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
795 | len = 0; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
796 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
797 | |
|
14093
98bd96324489
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14090
diff
changeset
|
798 | entry->buffer = len + 128; |
|
98bd96324489
[gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14090
diff
changeset
|
799 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
800 | scroll = entry->scroll - entry->start; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
801 | cursor = entry->end - entry->cursor; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
802 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
803 | entry->start = g_new0(char, entry->buffer); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
804 | if (text) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
805 | snprintf(entry->start, len + 1, "%s", text); |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
806 | entry->end = entry->start + len; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
807 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
808 | entry->scroll = entry->start + scroll; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
809 | entry->cursor = entry->end - cursor; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
810 | |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
811 | if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED)) |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
812 | entry_redraw(GNT_WIDGET(entry)); |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
813 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
814 | |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
815 | void gnt_entry_set_text(GntEntry *entry, const char *text) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
816 | { |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
817 | gboolean changed = TRUE; |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
818 | if (text == NULL && entry->start == NULL) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
819 | changed = FALSE; |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
820 | if (text && entry->start && g_utf8_collate(text, entry->start) == 0) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
821 | changed = FALSE; |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
822 | gnt_entry_set_text_internal(entry, text); |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
823 | if (changed) |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
824 | entry_text_changed(entry); |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
825 | } |
|
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
826 | |
|
13917
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
827 | void gnt_entry_set_max(GntEntry *entry, int max) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
828 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
829 | entry->max = max; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
830 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
831 | |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
832 | void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag) |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
833 | { |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
834 | entry->flag = flag; |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
835 | /* XXX: Check the existing string to make sure the flags are respected? */ |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
836 | } |
|
7c435cf1ee60
[gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
837 | |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
838 | const char *gnt_entry_get_text(GntEntry *entry) |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
839 | { |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
840 | return entry->start; |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
841 | } |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
842 | |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
843 | void gnt_entry_clear(GntEntry *entry) |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
844 | { |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
845 | gnt_entry_set_text_internal(entry, NULL); |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
846 | entry->scroll = entry->cursor = entry->end = entry->start; |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
847 | entry_redraw(GNT_WIDGET(entry)); |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
848 | destroy_suggest(entry); |
|
15292
e5ea308a70b8
[gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15188
diff
changeset
|
849 | entry_text_changed(entry); |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
850 | } |
|
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
851 | |
|
14041
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
852 | void gnt_entry_set_masked(GntEntry *entry, gboolean set) |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
853 | { |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
854 | entry->masked = set; |
|
6afba85cfc30
[gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14005
diff
changeset
|
855 | } |
|
13944
2269d17043b1
[gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13940
diff
changeset
|
856 | |
|
14153
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
857 | void gnt_entry_add_to_history(GntEntry *entry, const char *text) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
858 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
859 | g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */ |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
860 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
861 | if (g_list_length(entry->history) >= entry->histlength) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
862 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
863 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
864 | entry->history = g_list_first(entry->history); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
865 | g_free(entry->history->data); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
866 | entry->history->data = g_strdup(text); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
867 | entry->history = g_list_prepend(entry->history, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
868 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
869 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
870 | void gnt_entry_set_history_length(GntEntry *entry, int num) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
871 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
872 | if (num == 0) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
873 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
874 | entry->histlength = num; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
875 | if (entry->history) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
876 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
877 | entry->history = g_list_first(entry->history); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
878 | g_list_foreach(entry->history, (GFunc)g_free, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
879 | g_list_free(entry->history); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
880 | entry->history = NULL; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
881 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
882 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
883 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
884 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
885 | if (entry->histlength == 0) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
886 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
887 | entry->histlength = num; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
888 | entry->history = g_list_append(NULL, NULL); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
889 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
890 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
891 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
892 | if (num > 0 && num < entry->histlength) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
893 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
894 | GList *first, *iter; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
895 | int index = 0; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
896 | for (first = entry->history, index = 0; first->prev; first = first->prev, index++); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
897 | while ((iter = g_list_nth(first, num)) != NULL) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
898 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
899 | g_free(iter->data); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
900 | first = g_list_delete_link(first, iter); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
901 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
902 | entry->histlength = num; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
903 | if (index >= num) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
904 | entry->history = g_list_last(first); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
905 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
906 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
907 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
908 | entry->histlength = num; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
909 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
910 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
911 | void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
912 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
913 | entry->word = word; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
914 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
915 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
916 | void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
917 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
918 | entry->always = always; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
919 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
920 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
921 | void gnt_entry_add_suggest(GntEntry *entry, const char *text) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
922 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
923 | GList *find; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
924 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
925 | if (!text || !*text) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
926 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
927 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
928 | find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
929 | if (find) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
930 | return; |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
931 | entry->suggests = g_list_append(entry->suggests, g_strdup(text)); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
932 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
933 | |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
934 | void gnt_entry_remove_suggest(GntEntry *entry, const char *text) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
935 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
936 | GList *find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
937 | if (find) |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
938 | { |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
939 | g_free(find->data); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
940 | entry->suggests = g_list_delete_link(entry->suggests, find); |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
941 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
942 | } |
|
9da98052a4e1
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14103
diff
changeset
|
943 |