finch/libgnt/gntentry.c

Sat, 18 Aug 2007 05:54:49 +0000

author
William Ehlhardt <williamehlhardt@gmail.com>
date
Sat, 18 Aug 2007 05:54:49 +0000
branch
soc.2007.certmgr
changeset 19489
772b691e901b
parent 19235
a6b00192295b
child 19859
71d37b57eff2
permissions
-rw-r--r--

- Add purple_certificate_display_x509

18114
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
1 /**
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
2 * GNT - The GLib Ncurses Toolkit
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
3 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
4 * GNT is the legal property of its developers, whose names are too numerous
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
6 * source distribution.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
7 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
8 * This library is free software; you can redistribute it and/or modify
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
9 * it under the terms of the GNU General Public License as published by
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
11 * (at your option) any later version.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
12 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
13 * This program is distributed in the hope that it will be useful,
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
16 * GNU General Public License for more details.
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
17 *
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
18 * You should have received a copy of the GNU General Public License
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
19 * along with this program; if not, write to the Free Software
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
21 */
adb3cfadc125 Doxygen skeleton and license info for gnt files.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16954
diff changeset
22
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13944
diff changeset
23 #include <ctype.h>
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24 #include <string.h>
13950
bd8d39b3a9e2 [gaim-migrate @ 16369]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13944
diff changeset
25
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
26 #include "gntbox.h"
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "gntentry.h"
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
28 #include "gntmarshal.h"
14898
107b971b39f2 [gaim-migrate @ 17605]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14890
diff changeset
29 #include "gntstyle.h"
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
30 #include "gnttree.h"
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
31 #include "gntutils.h"
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
33 enum
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
34 {
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
35 SIG_TEXT_CHANGED,
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
36 SIG_COMPLETION,
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
37 SIGS,
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 };
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
39 static guint signals[SIGS] = { 0 };
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41 static GntWidgetClass *parent_class = NULL;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42
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
43 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
44 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
45
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
46 static void
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
47 destroy_suggest(GntEntry *entry)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
48 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
49 if (entry->ddown)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
50 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
51 gnt_widget_destroy(entry->ddown->parent);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
52 entry->ddown = NULL;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
53 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
54 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
55
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
56 static char *
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
57 get_beginning_of_word(GntEntry *entry)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
58 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
59 char *s = entry->cursor;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
60 while (s > entry->start)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
61 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
62 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
63 if (isspace(*t))
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
64 break;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
65 s = t;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
66 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
67 return s;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
68 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
69
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
70 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
71 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
72 {
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
73 gboolean changed = FALSE;
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
74 int offstart = 0, offend = 0;
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
75
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
76 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
77 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
78 const char *iter = text;
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
79 offstart = g_utf8_pointer_to_offset(entry->start, s);
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
80 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
81 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
82 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
83 *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
84 }
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
85 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
86 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
87 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
88 }
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
89 offend = g_utf8_pointer_to_offset(entry->start, entry->cursor);
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
90 } else {
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
91 offstart = 0;
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
92 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
93 changed = TRUE;
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
94 offend = g_utf8_strlen(text, -1);
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
95 }
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
96
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
97 if (changed)
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
98 g_signal_emit(G_OBJECT(entry), signals[SIG_COMPLETION], 0,
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
99 entry->start + offstart, entry->start + offend);
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
100 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
101 }
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
102
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
103 static gboolean
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
104 show_suggest_dropdown(GntEntry *entry)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
105 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
106 char *suggest = NULL;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
107 int len;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
108 int offset = 0, x, y;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
109 int count = 0;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
110 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
111 const char *text = NULL;
16954
b6488f782355 Fix tab-completion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16945
diff changeset
112 const char *sgst = NULL;
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
113
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
114 if (entry->word)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
115 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
116 char *s = get_beginning_of_word(entry);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
117 suggest = g_strndup(s, entry->cursor - s);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
118 if (entry->scroll < s)
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
119 offset = gnt_util_onscreen_width(entry->scroll, s);
14153
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 else
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
122 suggest = g_strdup(entry->start);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
123 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
124
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
125 if (entry->ddown == NULL)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
126 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
127 GntWidget *box = gnt_vbox_new(FALSE);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
128 entry->ddown = gnt_tree_new();
14167
ca6027c33d2c [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14156
diff changeset
129 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
130 gnt_box_add_widget(GNT_BOX(box), entry->ddown);
14539
7d5528c864a1 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14494
diff changeset
131 /* 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
132
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
133 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT);
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 gnt_widget_get_position(GNT_WIDGET(entry), &x, &y);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
136 x += offset;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
137 y++;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
138 if (y + 10 >= getmaxy(stdscr))
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
139 y -= 11;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
140 gnt_widget_set_position(box, x, y);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
141 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
142 else
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
143 gnt_tree_remove_all(GNT_TREE(entry->ddown));
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
144
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
145 for (count = 0, iter = entry->suggests; iter; iter = iter->next)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
146 {
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
147 text = iter->data;
14156
aacb0581eaf6 [gaim-migrate @ 16723]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14153
diff changeset
148 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
149 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
150 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
151 gnt_tree_create_row(GNT_TREE(entry->ddown), text),
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
152 NULL, NULL);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
153 count++;
16954
b6488f782355 Fix tab-completion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16945
diff changeset
154 sgst = text;
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
155 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
156 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
157 g_free(suggest);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
158
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
159 if (count == 0) {
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
160 destroy_suggest(entry);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
161 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
162 } 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
163 destroy_suggest(entry);
16954
b6488f782355 Fix tab-completion.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16945
diff changeset
164 return complete_suggest(entry, sgst);
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
165 } 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
166 gnt_widget_draw(entry->ddown->parent);
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
167 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
168
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
169 return TRUE;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
170 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
171
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
172 static void
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
173 gnt_entry_draw(GntWidget *widget)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
174 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
175 GntEntry *entry = GNT_ENTRY(widget);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
176 int stop;
14103
bcac61d40461 [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14093
diff changeset
177 gboolean focus;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
178
14103
bcac61d40461 [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14093
diff changeset
179 if ((focus = gnt_widget_has_focus(widget)))
13958
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13950
diff changeset
180 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_TEXT_NORMAL));
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13950
diff changeset
181 else
bd1c3bb3f33d [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13950
diff changeset
182 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
183
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
184 if (entry->masked)
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
185 {
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
186 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
187 g_utf8_pointer_to_offset(entry->scroll, entry->end));
14041
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
188 }
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
189 else
14369
e9a9ac6bd8de [gaim-migrate @ 16997]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14318
diff changeset
190 mvwprintw(widget->window, 0, 0, "%s", entry->scroll);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
191
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
192 stop = gnt_util_onscreen_width(entry->scroll, entry->end);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
193 if (stop < widget->priv.width)
18401
416ff3a69f61 Draw the password entries correctly.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18114
diff changeset
194 mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
195
14103
bcac61d40461 [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14093
diff changeset
196 if (focus)
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
197 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
198 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
199
14494
3575eac3a518 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
200 GNTDEBUG;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
201 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
202
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
203 static void
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204 gnt_entry_size_request(GntWidget *widget)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
205 {
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
206 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED))
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
207 {
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
208 widget->priv.height = 1;
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
209 widget->priv.width = 20;
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
210 }
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
211 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
212
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
213 static void
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
214 gnt_entry_map(GntWidget *widget)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
215 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
216 if (widget->priv.width == 0 || widget->priv.height == 0)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
217 gnt_widget_size_request(widget);
14494
3575eac3a518 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
218 GNTDEBUG;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
219 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
220
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
221 static void
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
222 entry_redraw(GntWidget *widget)
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
223 {
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
224 gnt_entry_draw(widget);
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
225 gnt_widget_queue_update(widget);
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
226 }
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
227
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
228 static void
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
229 entry_text_changed(GntEntry *entry)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
230 {
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
231 g_signal_emit(entry, signals[SIG_TEXT_CHANGED], 0);
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
232 }
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
233
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
234 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
235 move_back(GntBindable *bind, GList *null)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
236 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
237 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
238 if (entry->cursor <= entry->start)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
239 return FALSE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
240 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
241 if (entry->cursor < entry->scroll)
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
242 entry->scroll = entry->cursor;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
243 entry_redraw(GNT_WIDGET(entry));
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
244 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
245 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
246
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
247 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
248 move_forward(GntBindable *bind, GList *list)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
249 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
250 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
251 if (entry->cursor >= entry->end)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
252 return FALSE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
253 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
254 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
255 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
256 entry_redraw(GNT_WIDGET(entry));
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
257 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
258 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
259
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
260 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
261 backspace(GntBindable *bind, GList *null)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
262 {
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
263 int len;
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
264 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
265
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
266 if (entry->cursor <= entry->start)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
267 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
268
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
269 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
270 entry->cursor -= len;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
271 memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor);
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
272 entry->end -= len;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
273
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
274 if (entry->scroll > entry->start)
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
275 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
276
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
277 entry_redraw(GNT_WIDGET(entry));
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
278 if (entry->ddown)
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
279 show_suggest_dropdown(entry);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
280 entry_text_changed(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
281 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
282 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
283
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
284 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
285 delkey(GntBindable *bind, GList *null)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
286 {
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
287 int len;
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
288 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
289
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
290 if (entry->cursor >= entry->end)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
291 return FALSE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
292
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
293 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
294 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
295 entry->end -= len;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
296 entry_redraw(GNT_WIDGET(entry));
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
297
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
298 if (entry->ddown)
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
299 show_suggest_dropdown(entry);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
300 entry_text_changed(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
301 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
302 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
303
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
304 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
305 move_start(GntBindable *bind, GList *null)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
306 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
307 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
308 entry->scroll = entry->cursor = entry->start;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
309 entry_redraw(GNT_WIDGET(entry));
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
310 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
311 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
312
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
313 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
314 move_end(GntBindable *bind, GList *null)
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
315 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
316 GntEntry *entry = GNT_ENTRY(bind);
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
317 entry->cursor = entry->end;
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
318 /* This should be better than this */
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
319 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
320 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
321 entry_redraw(GNT_WIDGET(entry));
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
322 return TRUE;
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
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
325 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
326 history_prev(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
327 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
328 GntEntry *entry = GNT_ENTRY(bind);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
329 if (entry->histlength && entry->history->prev)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
330 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
331 entry->history = entry->history->prev;
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
332 gnt_entry_set_text_internal(entry, entry->history->data);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
333 destroy_suggest(entry);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
334 entry_text_changed(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
335
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
336 return TRUE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
337 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
338 return FALSE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
339 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
340
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
341 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
342 history_next(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
343 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
344 GntEntry *entry = GNT_ENTRY(bind);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
345 if (entry->histlength && entry->history->next)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
346 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
347 if (entry->history->prev == NULL)
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
348 {
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
349 /* Save the current contents */
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
350 char *text = g_strdup(gnt_entry_get_text(entry));
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
351 g_free(entry->history->data);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
352 entry->history->data = text;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
353 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
354
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
355 entry->history = entry->history->next;
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
356 gnt_entry_set_text_internal(entry, entry->history->data);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
357 destroy_suggest(entry);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
358 entry_text_changed(entry);
14855
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 return TRUE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
361 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
362 return FALSE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
363 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
364
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
365 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
366 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
367 {
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
368 GntEntry *entry = GNT_ENTRY(bind);
15838
45289a1439b2 Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents: 15837
diff changeset
369 gchar *i, *text, *a, *all;
45289a1439b2 Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents: 15837
diff changeset
370 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
371 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
372 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
373 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
374 *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
375 }
15838
45289a1439b2 Get rid of some minor C99isms
Mark Doliner <markdoliner@pidgin.im>
parents: 15837
diff changeset
376 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
377 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
378 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
379 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
380 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
381 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
382 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
383 }
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
384
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
385 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
386 suggest_show(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
387 {
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
388 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
389 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
390 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
391 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
392 }
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
393 return show_suggest_dropdown(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
394 }
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 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
397 suggest_next(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
398 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
399 GntEntry *entry = GNT_ENTRY(bind);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
400 if (entry->ddown) {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
401 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
402 return TRUE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
403 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
404 return FALSE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
405 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
406
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
407 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
408 suggest_prev(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
409 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
410 GntEntry *entry = GNT_ENTRY(bind);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
411 if (entry->ddown) {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
412 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
413 return TRUE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
414 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
415 return FALSE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
416 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
417
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
418 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
419 del_to_home(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
420 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
421 GntEntry *entry = GNT_ENTRY(bind);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
422 if (entry->cursor <= entry->start)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
423 return TRUE;
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
424 memmove(entry->start, entry->cursor, entry->end - entry->cursor);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
425 entry->end -= (entry->cursor - entry->start);
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
426 entry->cursor = entry->scroll = entry->start;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
427 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
428 entry_redraw(GNT_WIDGET(bind));
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
429 entry_text_changed(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
430 return TRUE;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
431 }
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
432
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
433 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
434 del_to_end(GntBindable *bind, GList *null)
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
435 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
436 GntEntry *entry = GNT_ENTRY(bind);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
437 if (entry->end <= entry->cursor)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
438 return TRUE;
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
439 entry->end = entry->cursor;
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
440 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
441 entry_redraw(GNT_WIDGET(bind));
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
442 entry_text_changed(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
443 return TRUE;
14275
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
444 }
ef418684623d [gaim-migrate @ 16894]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14167
diff changeset
445
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
446 #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
447 (g_unichar_isdigit(a) && g_unichar_isdigit(b)) || \
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
448 (g_unichar_isspace(a) && g_unichar_isspace(b)) || \
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
449 (g_unichar_iswide(a) && g_unichar_iswide(b)))
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
450
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
451 static const char *
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
452 begin_word(const char *text, const char *begin)
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
453 {
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
454 gunichar ch = 0;
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
455 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
456 text = g_utf8_find_prev_char(begin, text);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
457 ch = g_utf8_get_char(text);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
458 while ((text = g_utf8_find_prev_char(begin, text)) >= begin) {
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
459 gunichar cur = g_utf8_get_char(text);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
460 if (!SAME(ch, cur))
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
461 break;
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
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
464 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
465 }
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
466
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
467 static const char *
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
468 next_begin_word(const char *text, const char *end)
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
469 {
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
470 gunichar ch = 0;
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
471 ch = g_utf8_get_char(text);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
472 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
473 gunichar cur = g_utf8_get_char(text);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
474 if (!SAME(ch, cur))
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
475 break;
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
476 }
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
477
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
478 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
479 text = g_utf8_find_next_char(text, end);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
480 return (text ? text : end);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
481 }
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
482
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
483 #undef SAME
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
484 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
485 move_back_word(GntBindable *bind, GList *null)
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
486 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
487 GntEntry *entry = GNT_ENTRY(bind);
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
488 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
489
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
490 if (iter < entry->start)
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
491 return TRUE;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
492 iter = begin_word(iter, entry->start);
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
493 entry->cursor = (char*)iter;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
494 if (entry->cursor < entry->scroll)
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
495 entry->scroll = entry->cursor;
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
496 entry_redraw(GNT_WIDGET(bind));
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
497 return TRUE;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
498 }
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
499
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
500 static gboolean
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
501 del_prev_word(GntBindable *bind, GList *null)
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
502 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
503 GntWidget *widget = GNT_WIDGET(bind);
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
504 GntEntry *entry = GNT_ENTRY(bind);
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
505 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
506 int count;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
507
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
508 if (iter < entry->start)
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
509 return TRUE;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
510 iter = (char*)begin_word(iter, entry->start);
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
511 count = entry->cursor - iter;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
512 memmove(iter, entry->cursor, entry->end - entry->cursor);
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
513 entry->end -= count;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
514 entry->cursor = iter;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
515 if (entry->cursor <= entry->scroll) {
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
516 entry->scroll = entry->cursor - widget->priv.width + 2;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
517 if (entry->scroll < entry->start)
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
518 entry->scroll = entry->start;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
519 }
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
520 memset(entry->end, '\0', entry->buffer - (entry->end - entry->start));
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
521 entry_redraw(widget);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
522 entry_text_changed(entry);
14890
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
523
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
524 return TRUE;
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
525 }
78c01aad3cfa [gaim-migrate @ 17595]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14889
diff changeset
526
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
527 static gboolean
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
528 move_forward_word(GntBindable *bind, GList *list)
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
529 {
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
530 GntEntry *entry = GNT_ENTRY(bind);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
531 GntWidget *widget = GNT_WIDGET(bind);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
532 entry->cursor = (char *)next_begin_word(entry->cursor, entry->end);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
533 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
534 entry->scroll = g_utf8_find_next_char(entry->scroll, NULL);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
535 }
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
536 entry_redraw(widget);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
537 return TRUE;
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
538 }
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
539
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
540 static gboolean
15187
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
541 delete_forward_word(GntBindable *bind, GList *list)
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
542 {
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
543 GntEntry *entry = GNT_ENTRY(bind);
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
544 GntWidget *widget = GNT_WIDGET(bind);
15187
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
545 char *iter = (char *)next_begin_word(entry->cursor, entry->end);
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
546 int len = entry->end - iter + 1;
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
547 if (len <= 0)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
548 return TRUE;
15187
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
549 memmove(entry->cursor, iter, len);
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
550 len = iter - entry->cursor;
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
551 entry->end -= len;
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
552 memset(entry->end, '\0', len);
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
553 entry_redraw(widget);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
554 entry_text_changed(entry);
15186
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
555 return TRUE;
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
556 }
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
557
62aead088a8b [gaim-migrate @ 17910]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15038
diff changeset
558 static gboolean
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
559 gnt_entry_key_pressed(GntWidget *widget, const char *text)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
560 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
561 GntEntry *entry = GNT_ENTRY(widget);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
562
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
563 if (text[0] == 27)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
564 {
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
565 if (text[1] == 0)
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
566 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
567 destroy_suggest(entry);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
568 return TRUE;
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
569 }
14005
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13992
diff changeset
570
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
571 return FALSE;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
572 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
573 else
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
574 {
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
575 if ((text[0] == '\r' || text[0] == ' ') && entry->ddown)
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
576 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
577 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
578 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
579 complete_suggest(entry, text);
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
580 g_free(text);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
581 entry_text_changed(entry);
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
582 return TRUE;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
583 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
584
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
585 if (!iscntrl(text[0]))
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
586 {
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
587 const char *str, *next;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
588
14413
bd998fe17d82 [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14373
diff changeset
589 for (str = text; *str; str = next)
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
590 {
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
591 int len;
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
592 next = g_utf8_find_next_char(str, NULL);
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
593 len = next - str;
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
594
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
595 /* Valid input? */
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
596 /* XXX: Is it necessary to use _unichar_ variants here? */
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
597 if (ispunct(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_PUNCT))
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
598 continue;
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
599 if (isspace(*str) && (entry->flag & GNT_ENTRY_FLAG_NO_SPACE))
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
600 continue;
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
601 if (isalpha(*str) && !(entry->flag & GNT_ENTRY_FLAG_ALPHA))
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
602 continue;
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
603 if (isdigit(*str) && !(entry->flag & GNT_ENTRY_FLAG_INT))
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
604 continue;
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 /* Reached the max? */
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
607 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
608 continue;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
609
14807
45797fd1d1dc [gaim-migrate @ 17502]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14791
diff changeset
610 if (entry->end + len - entry->start >= entry->buffer)
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
611 {
14807
45797fd1d1dc [gaim-migrate @ 17502]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14791
diff changeset
612 /* 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
613 char *tmp = g_strdup(entry->start);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
614 gnt_entry_set_text_internal(entry, tmp);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
615 g_free(tmp);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
616 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
617
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
618 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
619 entry->end += len;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
620
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
621 while (str < next)
14278
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
622 {
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
623 if (*str == '\r' || *str == '\n')
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
624 *entry->cursor = ' ';
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
625 else
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
626 *entry->cursor = *str;
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
627 entry->cursor++;
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
628 str++;
9e2a97a4542e [gaim-migrate @ 16897]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14275
diff changeset
629 }
14090
a8552e906a76 [gaim-migrate @ 16630]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14041
diff changeset
630
14373
609c902d20f5 [gaim-migrate @ 17001]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14371
diff changeset
631 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
632 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
633
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
634 if (entry->ddown)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
635 show_suggest_dropdown(entry);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
636 }
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
637 entry_redraw(widget);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
638 entry_text_changed(entry);
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
639 return TRUE;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
640 }
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 return FALSE;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
644 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
645
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
646 static void
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
647 gnt_entry_destroy(GntWidget *widget)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
648 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
649 GntEntry *entry = GNT_ENTRY(widget);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
650 g_free(entry->start);
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
651
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
652 if (entry->history)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
653 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
654 entry->history = g_list_first(entry->history);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
655 g_list_foreach(entry->history, (GFunc)g_free, NULL);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
656 g_list_free(entry->history);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
657 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
658
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
659 if (entry->suggests)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
660 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
661 g_list_foreach(entry->suggests, (GFunc)g_free, NULL);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
662 g_list_free(entry->suggests);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
663 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
664
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
665 if (entry->ddown)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
666 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
667 gnt_widget_destroy(entry->ddown->parent);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
668 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
669 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
670
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
671 static void
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
672 gnt_entry_lost_focus(GntWidget *widget)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
673 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
674 GntEntry *entry = GNT_ENTRY(widget);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
675 destroy_suggest(entry);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
676 entry_redraw(widget);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
677 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
678
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
679 static void
13922
7195a6fe2416 [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13917
diff changeset
680 gnt_entry_class_init(GntEntryClass *klass)
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
681 {
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
682 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
14963
1c783f0acfa9 [gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
683 char s[2] = {erasechar(), 0};
1c783f0acfa9 [gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
684
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
685 parent_class = GNT_WIDGET_CLASS(klass);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
686 parent_class->destroy = gnt_entry_destroy;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
687 parent_class->draw = gnt_entry_draw;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
688 parent_class->map = gnt_entry_map;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
689 parent_class->size_request = gnt_entry_size_request;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
690 parent_class->key_pressed = gnt_entry_key_pressed;
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
691 parent_class->lost_focus = gnt_entry_lost_focus;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
692
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
693 signals[SIG_TEXT_CHANGED] =
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
694 g_signal_new("text_changed",
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
695 G_TYPE_FROM_CLASS(klass),
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
696 G_SIGNAL_RUN_LAST,
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
697 G_STRUCT_OFFSET(GntEntryClass, text_changed),
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
698 NULL, NULL,
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
699 g_cclosure_marshal_VOID__VOID,
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
700 G_TYPE_NONE, 0);
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
701
18422
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
702 signals[SIG_COMPLETION] =
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
703 g_signal_new("completion",
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
704 G_TYPE_FROM_CLASS(klass),
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
705 G_SIGNAL_RUN_LAST,
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
706 0, NULL, NULL,
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
707 gnt_closure_marshal_VOID__POINTER_POINTER,
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
708 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
c41881f99687 A 'completion' signal to emit whenever user accepts a completion suggest.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18401
diff changeset
709
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
710 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
711 GNT_KEY_CTRL_A, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
712 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
713 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
714 GNT_KEY_CTRL_E, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
715 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
716 gnt_bindable_class_register_action(bindable, "delete-prev", backspace,
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
717 GNT_KEY_BACKSPACE, NULL);
14963
1c783f0acfa9 [gaim-migrate @ 17673]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14962
diff changeset
718 gnt_bindable_register_binding(bindable, "delete-prev", s, NULL);
15366
df6795069c0b [gaim-migrate @ 18095]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15292
diff changeset
719 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
720 gnt_bindable_class_register_action(bindable, "delete-next", delkey,
14938
ee27e45919ef [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14934
diff changeset
721 GNT_KEY_DEL, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
722 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
723 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
724 GNT_KEY_CTRL_U, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
725 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
726 GNT_KEY_CTRL_K, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
727 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
728 GNT_KEY_CTRL_W, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
729 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
730 "\033" "b", NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
731 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
732 GNT_KEY_LEFT, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
733 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
734 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
735 GNT_KEY_RIGHT, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
736 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
737 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
738 "\033" "f", NULL);
15187
841272d50d22 [gaim-migrate @ 17911]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15186
diff changeset
739 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
740 "\033" "d", NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
741 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
742 "\t", NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
743 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
744 GNT_KEY_DOWN, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
745 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
746 GNT_KEY_UP, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
747 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
748 GNT_KEY_CTRL_DOWN, NULL);
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
749 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
750 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
751 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
752 GNT_KEY_CTRL_V, NULL);
14855
84c869823944 [gaim-migrate @ 17558]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14807
diff changeset
753
14962
abfaa2e03ac7 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14938
diff changeset
754 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
755 GNTDEBUG;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
756 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
757
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
758 static void
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
759 gnt_entry_init(GTypeInstance *instance, gpointer class)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
760 {
14005
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13992
diff changeset
761 GntWidget *widget = GNT_WIDGET(instance);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
762 GntEntry *entry = GNT_ENTRY(instance);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
763
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
764 entry->flag = GNT_ENTRY_FLAG_ALL;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
765 entry->max = 0;
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
766
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
767 entry->histlength = 0;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
768 entry->history = NULL;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
769
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
770 entry->word = TRUE;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
771 entry->always = FALSE;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
772 entry->suggests = NULL;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
773
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
774 GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry),
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
775 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
776 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
777
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13992
diff changeset
778 widget->priv.minw = 3;
198d1658b390 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13992
diff changeset
779 widget->priv.minh = 1;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
780
14494
3575eac3a518 [gaim-migrate @ 17146]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14413
diff changeset
781 GNTDEBUG;
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
782 }
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 /******************************************************************************
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
785 * GntEntry API
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 GType
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
788 gnt_entry_get_gtype(void)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
789 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
790 static GType type = 0;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
791
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
792 if(type == 0)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
793 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
794 static const GTypeInfo info = {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
795 sizeof(GntEntryClass),
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
796 NULL, /* base_init */
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
797 NULL, /* base_finalize */
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
798 (GClassInitFunc)gnt_entry_class_init,
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
799 NULL, /* class_finalize */
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
800 NULL, /* class_data */
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
801 sizeof(GntEntry),
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
802 0, /* n_preallocs */
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
803 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
804 NULL /* value_table */
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
805 };
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
806
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
807 type = g_type_register_static(GNT_TYPE_WIDGET,
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
808 "GntEntry",
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
809 &info, 0);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
810 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
811
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
812 return type;
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
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
815 GntWidget *gnt_entry_new(const char *text)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
816 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
817 GntWidget *widget = g_object_new(GNT_TYPE_ENTRY, NULL);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
818 GntEntry *entry = GNT_ENTRY(widget);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
819
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
820 gnt_entry_set_text_internal(entry, text);
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
821
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
822 return widget;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
823 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
824
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
825 static void
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
826 gnt_entry_set_text_internal(GntEntry *entry, const char *text)
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
827 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
828 int len;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
829 int scroll, cursor;
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 g_free(entry->start);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
832
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
833 if (text && text[0])
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
834 {
14093
98bd96324489 [gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14090
diff changeset
835 len = strlen(text);
13917
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 else
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
838 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
839 len = 0;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
840 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
841
14093
98bd96324489 [gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14090
diff changeset
842 entry->buffer = len + 128;
98bd96324489 [gaim-migrate @ 16633]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14090
diff changeset
843
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
844 scroll = entry->scroll - entry->start;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
845 cursor = entry->end - entry->cursor;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
846
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
847 entry->start = g_new0(char, entry->buffer);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
848 if (text)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
849 snprintf(entry->start, len + 1, "%s", text);
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
850 entry->end = entry->start + len;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
851
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
852 entry->scroll = entry->start + scroll;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
853 entry->cursor = entry->end - cursor;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
854
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
855 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
856 entry_redraw(GNT_WIDGET(entry));
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
857 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
858
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
859 void gnt_entry_set_text(GntEntry *entry, const char *text)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
860 {
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
861 gboolean changed = TRUE;
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
862 if (text == NULL && entry->start == NULL)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
863 changed = FALSE;
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
864 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
865 changed = FALSE;
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
866 gnt_entry_set_text_internal(entry, text);
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
867 if (changed)
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
868 entry_text_changed(entry);
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
869 }
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
870
13917
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
871 void gnt_entry_set_max(GntEntry *entry, int max)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
872 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
873 entry->max = max;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
874 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
875
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
876 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag)
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
877 {
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
878 entry->flag = flag;
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
879 /* 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
880 }
7c435cf1ee60 [gaim-migrate @ 16314]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
881
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
882 const char *gnt_entry_get_text(GntEntry *entry)
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
883 {
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
884 return entry->start;
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
885 }
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
886
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
887 void gnt_entry_clear(GntEntry *entry)
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
888 {
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
889 gnt_entry_set_text_internal(entry, NULL);
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
890 entry->scroll = entry->cursor = entry->end = entry->start;
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
891 entry_redraw(GNT_WIDGET(entry));
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
892 destroy_suggest(entry);
15292
e5ea308a70b8 [gaim-migrate @ 18020]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15188
diff changeset
893 entry_text_changed(entry);
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
894 }
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
895
14041
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
896 void gnt_entry_set_masked(GntEntry *entry, gboolean set)
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
897 {
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
898 entry->masked = set;
6afba85cfc30 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14005
diff changeset
899 }
13944
2269d17043b1 [gaim-migrate @ 16362]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13940
diff changeset
900
14153
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
901 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
902 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
903 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
904
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
905 if (g_list_length(entry->history) >= entry->histlength)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
906 return;
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->history = g_list_first(entry->history);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
909 g_free(entry->history->data);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
910 entry->history->data = g_strdup(text);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
911 entry->history = g_list_prepend(entry->history, NULL);
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
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
914 void gnt_entry_set_history_length(GntEntry *entry, int num)
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 if (num == 0)
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->histlength = num;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
919 if (entry->history)
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 entry->history = g_list_first(entry->history);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
922 g_list_foreach(entry->history, (GFunc)g_free, NULL);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
923 g_list_free(entry->history);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
924 entry->history = NULL;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
925 }
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
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
929 if (entry->histlength == 0)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
930 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
931 entry->histlength = num;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
932 entry->history = g_list_append(NULL, NULL);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
933 return;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
934 }
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 if (num > 0 && num < entry->histlength)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
937 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
938 GList *first, *iter;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
939 int index = 0;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
940 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
941 while ((iter = g_list_nth(first, num)) != NULL)
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 g_free(iter->data);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
944 first = g_list_delete_link(first, iter);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
945 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
946 entry->histlength = num;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
947 if (index >= num)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
948 entry->history = g_list_last(first);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
949 return;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
950 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
951
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
952 entry->histlength = num;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
953 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
954
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
955 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
956 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
957 entry->word = word;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
958 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
959
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
960 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
961 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
962 entry->always = always;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
963 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
964
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
965 void gnt_entry_add_suggest(GntEntry *entry, const char *text)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
966 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
967 GList *find;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
968
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
969 if (!text || !*text)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
970 return;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
971
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
972 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
973 if (find)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
974 return;
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
975 entry->suggests = g_list_append(entry->suggests, g_strdup(text));
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
976 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
977
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
978 void gnt_entry_remove_suggest(GntEntry *entry, const char *text)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
979 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
980 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
981 if (find)
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
982 {
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
983 g_free(find->data);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
984 entry->suggests = g_list_delete_link(entry->suggests, find);
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
985 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
986 }
9da98052a4e1 [gaim-migrate @ 16715]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14103
diff changeset
987

mercurial