Mercurial > pidgin.yaz
diff console/libgnt/gntentry.c @ 15751:0eb7846f9e7e
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).
If you use the s.so WM, pressing alt-shift-c ("toggle-clipboard") will toggle display of the clipboard contents in a possibly easy-to-copy-with-the-x-mouse window.
This includes a plugin which interacts with the X selection, which is not built by default.
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Fri, 02 Mar 2007 01:48:11 +0000 |
parents | 492f4e7416a3 |
children | b5c4de70577d |
line wrap: on
line diff
--- a/console/libgnt/gntentry.c Thu Mar 01 21:52:57 2007 +0000 +++ b/console/libgnt/gntentry.c Fri Mar 02 01:48:11 2007 +0000 @@ -299,6 +299,26 @@ } static gboolean +clipboard_paste(GntBindable *bind, GList *n) +{ + GntEntry *entry = GNT_ENTRY(bind); + gchar *i; + gchar *text = i = gnt_get_clipboard_string(); + while (*i != '\0') { + i = g_utf8_next_char(i); + if (*i == '\r' || *i == '\n') + *i = ' '; + } + char *a = g_strndup(entry->start, entry->cursor - entry->start); + char *all = g_strconcat(a, text, entry->cursor, NULL); + gnt_entry_set_text_internal(entry, all); + g_free(a); + g_free(text); + g_free(all); + return TRUE; +} + +static gboolean suggest_show(GntBindable *bind, GList *null) { return show_suggest_dropdown(GNT_ENTRY(bind)); @@ -673,6 +693,8 @@ GNT_KEY_CTRL_DOWN, NULL); gnt_bindable_class_register_action(bindable, "history-next", history_next, GNT_KEY_CTRL_UP, NULL); + gnt_bindable_class_register_action(bindable, "clipboard-past", clipboard_paste, + GNT_KEY_CTRL_V, NULL); gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); GNTDEBUG;