finch/libgnt/gntentry.c

Wed, 07 Nov 2007 13:49:26 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Wed, 07 Nov 2007 13:49:26 +0000
changeset 21428
869ddf4d7ea1
parent 20351
83f3c26afa02
child 21240
b78eaddaae02
permissions
-rw-r--r--

disapproval of revision '40c706f04342bffe4e576e1e11a54fc8ef3d354b'

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

mercurial