aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-09-27 03:42:39 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-09-27 03:42:39 +0800
commit010204b7bf75592bd178c735206331f4f6c23af5 (patch)
treea9c60623dbeecfdf8c8bf0c4967c72b8ac490552 /widgets
parent31f1562d1435fd8b99f9b7f5b19bc93b3210bab4 (diff)
downloadgsoc2013-evolution-010204b7bf75592bd178c735206331f4f6c23af5.tar.gz
gsoc2013-evolution-010204b7bf75592bd178c735206331f4f6c23af5.tar.zst
gsoc2013-evolution-010204b7bf75592bd178c735206331f4f6c23af5.zip
Allow ctrl-p and ctrl-n to be used to move up and down in the completion
2001-09-26 Jon Trowbridge <trow@ximian.com> * gal/e-text/e-completion-view.c (e_completion_view_key_press_handler): Allow ctrl-p and ctrl-n to be used to move up and down in the completion list. (Bug #10500) * gal/e-text/e-completion-match.c (e_completion_match_set_text): Properly validate the utf8. svn path=/trunk/; revision=13159
Diffstat (limited to 'widgets')
-rw-r--r--widgets/text/e-completion-match.c4
-rw-r--r--widgets/text/e-completion-view.c31
2 files changed, 30 insertions, 5 deletions
diff --git a/widgets/text/e-completion-match.c b/widgets/text/e-completion-match.c
index 19a0980516..45c54ccce3 100644
--- a/widgets/text/e-completion-match.c
+++ b/widgets/text/e-completion-match.c
@@ -96,13 +96,13 @@ e_completion_match_set_text (ECompletionMatch *match,
if (match_text == NULL) {
match_text = "Unknown_Match";
- } else if (! g_utf8_validate (match_text, 0, NULL)) {
+ } else if (! g_utf8_validate (match_text, -1, NULL)) {
match_text = "Invalid_UTF8";
}
if (menu_text == NULL) {
menu_text = match_text;
- } else if (! g_utf8_validate (menu_text, 0, NULL)) {
+ } else if (! g_utf8_validate (menu_text, -1, NULL)) {
menu_text = "Invalid_UTF8";
}
diff --git a/widgets/text/e-completion-view.c b/widgets/text/e-completion-view.c
index 400494623e..06f6428fd4 100644
--- a/widgets/text/e-completion-view.c
+++ b/widgets/text/e-completion-view.c
@@ -452,16 +452,28 @@ e_completion_view_key_press_handler (GtkWidget *w, GdkEventKey *key_event, gpoin
{
ECompletionView *cv = E_COMPLETION_VIEW (user_data);
gint dir = 0;
- gboolean key_handled = TRUE;
+ gboolean key_handled = TRUE, complete_key = FALSE, uncomplete_key = FALSE;
+
+ /* FIXME: This is totally lame.
+ The ECompletionView should be able to specify multiple completion/uncompletion keys, or just
+ have sensible defaults. */
+
+ if ((cv->complete_key && key_event->keyval == cv->complete_key)
+ || ((key_event->keyval == GDK_n || key_event->keyval == GDK_N) && (key_event->state & GDK_CONTROL_MASK)))
+ complete_key = TRUE;
+
+ if ((cv->uncomplete_key && key_event->keyval == cv->uncomplete_key)
+ || ((key_event->keyval == GDK_p || key_event->keyval == GDK_P) && (key_event->state & GDK_CONTROL_MASK)))
+ uncomplete_key = TRUE;
/* Start up a completion.*/
- if (cv->complete_key && key_event->keyval == cv->complete_key && !cv->editable) {
+ if (complete_key && !cv->editable) {
gtk_signal_emit (GTK_OBJECT (cv), e_completion_view_signals[E_COMPLETION_VIEW_BROWSE], NULL);
goto stop_emission;
}
/* Stop our completion. */
- if (cv->uncomplete_key && key_event->keyval == cv->uncomplete_key && cv->editable && cv->selection < 0) {
+ if (uncomplete_key && cv->editable && cv->selection < 0) {
e_completion_view_set_cursor_row (cv, -1);
gtk_signal_emit (GTK_OBJECT (cv), e_completion_view_signals[E_COMPLETION_VIEW_UNBROWSE]);
goto stop_emission;
@@ -471,11 +483,24 @@ e_completion_view_key_press_handler (GtkWidget *w, GdkEventKey *key_event, gpoin
return FALSE;
switch (key_event->keyval) {
+
+ case GDK_n:
+ case GDK_N:
+ /* We (heart) emacs: treat ctrl-n as down */
+ if (! (key_event->state & GDK_CONTROL_MASK))
+ return FALSE;
+
case GDK_Down:
case GDK_KP_Down:
dir = 1;
break;
+ case GDK_p:
+ case GDK_P:
+ /* Treat ctrl-p as up */
+ if (! (key_event->state & GDK_CONTROL_MASK))
+ return FALSE;
+
case GDK_Up:
case GDK_KP_Up:
dir = -1;