comparison finch/libgnt/gntentry.c @ 30909:25e200cb3532

propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d) to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 31 Aug 2010 18:28:10 +0000
parents 351d07aefb09
children a8cc50c2279f
comparison
equal deleted inserted replaced
30908:c44ec533a48c 30909:25e200cb3532
478 static gboolean 478 static gboolean
479 history_search(GntBindable *bind, GList *null) 479 history_search(GntBindable *bind, GList *null)
480 { 480 {
481 GntEntry *entry = GNT_ENTRY(bind); 481 GntEntry *entry = GNT_ENTRY(bind);
482 GList *iter; 482 GList *iter;
483 const char *current , *pos; 483 const char *current;
484 int len;
485 484
486 if (entry->history->prev && entry->search->needle) 485 if (entry->history->prev && entry->search->needle)
487 current = entry->search->needle; 486 current = entry->search->needle;
488 else 487 else
489 current = gnt_entry_get_text(entry); 488 current = gnt_entry_get_text(entry);
490 489
491 if (!entry->histlength || !entry->history->next || !*current) 490 if (!entry->histlength || !entry->history->next || !*current)
492 return FALSE; 491 return FALSE;
493 492
494 len = g_utf8_strlen(current, -1);
495
496 for (iter = entry->history->next; iter; iter = iter->next) { 493 for (iter = entry->history->next; iter; iter = iter->next) {
497 const char *str = iter->data; 494 const char *str = iter->data;
498 /* A more utf8-friendly version of strstr would have been better, but 495 /* A more utf8-friendly version of strstr would have been better, but
499 * for now, this will have to do. */ 496 * for now, this will have to do. */
500 if ((pos = strstr(str, current))) 497 if (strstr(str, current) != NULL)
501 break; 498 break;
502 } 499 }
503 500
504 if (!iter) 501 if (!iter)
505 return TRUE; 502 return TRUE;
571 suggest_prev(GntBindable *bind, GList *null) 568 suggest_prev(GntBindable *bind, GList *null)
572 { 569 {
573 GntEntry *entry = GNT_ENTRY(bind); 570 GntEntry *entry = GNT_ENTRY(bind);
574 if (entry->ddown) { 571 if (entry->ddown) {
575 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-up", NULL); 572 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "move-up", NULL);
573 return TRUE;
574 }
575 return FALSE;
576 }
577
578 static gboolean
579 suggest_next_page(GntBindable *bind, GList *null)
580 {
581 GntEntry *entry = GNT_ENTRY(bind);
582 if (entry->ddown) {
583 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-down", NULL);
584 return TRUE;
585 }
586 return FALSE;
587 }
588
589 static gboolean
590 suggest_prev_page(GntBindable *bind, GList *null)
591 {
592 GntEntry *entry = GNT_ENTRY(bind);
593 if (entry->ddown) {
594 gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-up", NULL);
576 return TRUE; 595 return TRUE;
577 } 596 }
578 return FALSE; 597 return FALSE;
579 } 598 }
580 599
984 "\t", NULL); 1003 "\t", NULL);
985 gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next, 1004 gnt_bindable_class_register_action(bindable, "suggest-next", suggest_next,
986 GNT_KEY_DOWN, NULL); 1005 GNT_KEY_DOWN, NULL);
987 gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev, 1006 gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev,
988 GNT_KEY_UP, NULL); 1007 GNT_KEY_UP, NULL);
1008 gnt_bindable_class_register_action(bindable, "suggest-next-page", suggest_next_page,
1009 GNT_KEY_PGDOWN, NULL);
1010 gnt_bindable_class_register_action(bindable, "suggest-prev-page", suggest_prev_page,
1011 GNT_KEY_PGUP, NULL);
989 gnt_bindable_class_register_action(bindable, "history-next", history_next, 1012 gnt_bindable_class_register_action(bindable, "history-next", history_next,
990 GNT_KEY_CTRL_DOWN, NULL); 1013 GNT_KEY_CTRL_DOWN, NULL);
991 gnt_bindable_class_register_action(bindable, "history-prev", history_prev, 1014 gnt_bindable_class_register_action(bindable, "history-prev", history_prev,
992 GNT_KEY_CTRL_UP, NULL); 1015 GNT_KEY_CTRL_UP, NULL);
993 gnt_bindable_register_binding(bindable, "history-prev", GNT_KEY_CTRL_P, NULL); 1016 gnt_bindable_register_binding(bindable, "history-prev", GNT_KEY_CTRL_P, NULL);