--- a/gntentry.c Fri Apr 02 02:16:25 2010 +0000
+++ b/gntentry.c Fri Apr 02 21:01:42 2010 +0000
@@ -55,6 +55,11 @@
static guint signals[SIGS] = { 0 };
static GntWidgetClass *parent_class = NULL;
@@ -471,6 +476,55 @@
+history_search(GntBindable *bind, GList *null) + GntEntry *entry = GNT_ENTRY(bind); + const char *current , *pos; + if (entry->history->prev && entry->search->needle) + current = entry->search->needle; + current = gnt_entry_get_text(entry); + if (!entry->histlength || !entry->history->next || !*current) + len = g_utf8_strlen(current, -1); + for (iter = entry->history->next; iter; iter = iter->next) { + const char *str = iter->data; + /* A more utf8-friendly version of strstr would have been better, but + * for now, this will have to do. */ + if ((pos = strstr(str, current))) + if (entry->history->prev == NULL) { + /* We are doing it for the first time. Save the current contents */ + char *text = g_strdup(gnt_entry_get_text(entry)); + g_free(entry->search->needle); + entry->search->needle = g_strdup(current); + g_free(entry->history->data); + entry->history->data = text; + gnt_entry_set_text_internal(entry, entry->history->data); + destroy_suggest(entry); + entry_text_changed(entry); + update_kill_ring(entry, ENTRY_JAIL, NULL, 0); clipboard_paste(GntBindable *bind, GList *n)
GntEntry *entry = GNT_ENTRY(bind);
@@ -833,6 +887,9 @@
gnt_widget_destroy(entry->ddown->parent);
+ g_free(entry->search->needle); jail_killring(entry->killring);
@@ -935,6 +992,8 @@
gnt_bindable_register_binding(bindable, "history-prev", GNT_KEY_CTRL_P, NULL);
gnt_bindable_register_binding(bindable, "history-next", GNT_KEY_CTRL_N, NULL);
+ gnt_bindable_class_register_action(bindable, "history-search", history_search, gnt_bindable_class_register_action(bindable, "clipboard-paste", clipboard_paste,
@@ -966,6 +1025,7 @@
entry->killring = new_killring();
+ entry->search = g_new0(GntEntrySearch, 1); GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry),
GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS);
--- a/gntentry.h Fri Apr 02 02:16:25 2010 +0000
+++ b/gntentry.h Fri Apr 02 21:01:42 2010 +0000
@@ -49,6 +49,7 @@
typedef struct _GntEntryPriv GntEntryPriv;
typedef struct _GntEntryClass GntEntryClass;
typedef struct _GntEntryKillRing GntEntryKillRing;
+typedef struct _GntEntrySearch GntEntrySearch; @@ -86,6 +87,7 @@
gboolean always; /* Should the list of suggestions show at all times, or only on tab-press? */
GntWidget *ddown; /* The dropdown with the suggested list */
GntEntryKillRing *killring; /**< @since 2.3.0 */
+ GntEntrySearch *search; /**< @since 2.7.0 */