Mercurial > pidgin.yaz
changeset 30030:ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
This should be useful when people paste non-plaintext text as plaintext
text often enough that right-click -> 'Paste as Plain Text' isn't good
enough.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 22 Mar 2010 20:15:55 +0000 |
parents | bab8917b8b5c |
children | 9f59abd49def |
files | ChangeLog ChangeLog.API doc/gtkimhtml-signals.dox doc/gtkrc-2.0 pidgin/gtkimhtml.c |
diffstat | 5 files changed, 62 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Mar 21 20:40:17 2010 +0000 +++ b/ChangeLog Mon Mar 22 20:15:55 2010 +0000 @@ -25,6 +25,9 @@ * Added a menu set mood globally for all mood-supporting accounts (currently XMPP and ICQ). * Use standard (but small) GTK+ buttons instead of custom "X" symbol. + * Default binding of Ctrl+Shift+v to 'Paste as Plain Text' in + conversation windows. This can be changed in .gtkrc-2.0. For example, + Ctrl+v can be bound to 'Paste as Plain Text' by default. Bonjour: * Added support for IPv6. (Thanks to T_X for testing)
--- a/ChangeLog.API Sun Mar 21 20:40:17 2010 +0000 +++ b/ChangeLog.API Mon Mar 22 20:15:55 2010 +0000 @@ -31,6 +31,7 @@ * pidgin_dialogs_developers (should not be used by anything but Pidgin) * pidgin_dialogs_translators (should not be used by anything but Pidgin) * gtk_imhtmltoolbar_switch_active_conversation + * 'paste' signal for GtkIMHtml (more in gtkimhtml-signals.dox) version 2.6.6 (02/18/2010): libpurple:
--- a/doc/gtkimhtml-signals.dox Sun Mar 21 20:40:17 2010 +0000 +++ b/doc/gtkimhtml-signals.dox Mon Mar 22 20:15:55 2010 +0000 @@ -6,6 +6,7 @@ @signal format_function_clear @signal format_function_toggle @signal format_function_update + @paste @endsignals @see gtkimhtml.h @@ -57,6 +58,17 @@ @signaldesc Emitted when the cursor has moved and formatting has changed @param imhtml The GtkIMHtml emitting the signal. @param data User defined data. + + @signaldef paste + @signalproto +void (*paste) (GtkIMHtml *imhtml, char *format) + @endsignalproto + @signaldef Emitted when paste from the clipboard is requested. + @param imhtml The GtkIMHtml emitting the signal. + @param format If 'text', then the formatting of the clipboard content + will be removed before pasting. If empty or 'html', then + the formatting will not be removed. Any other value for + this parameter is ignored and nothing is pasted. @endsignaldef */ // vim: syntax=c.doxygen tw=75 et
--- a/doc/gtkrc-2.0 Sun Mar 21 20:40:17 2010 +0000 +++ b/doc/gtkrc-2.0 Mon Mar 22 20:15:55 2010 +0000 @@ -81,6 +81,12 @@ bind "<alt>F2" { "format_toggle" (2) } # Ctrl-alt-shift-f3 toggles underline bind "<ctrl><alt><shift>F3" { "format_toggle" (4) } + +# Ctrl-v to paste as plain text + bind "<ctrl>v" { "paste" ("text") } + +# Ctrl-Shift-v for normal 'Paste' + bind "<ctrl><shift>v" { "paste" ("html") } } widget "*pidgin_conv_entry" binding "my-bindings"
--- a/pidgin/gtkimhtml.c Sun Mar 21 20:40:17 2010 +0000 +++ b/pidgin/gtkimhtml.c Mon Mar 22 20:15:55 2010 +0000 @@ -152,6 +152,7 @@ MESSAGE_SEND, UNDO, REDO, + PASTE, LAST_SIGNAL }; static guint signals [LAST_SIGNAL] = { 0 }; @@ -1343,6 +1344,15 @@ return FALSE; } +static void +imhtml_paste_cb(GtkIMHtml *imhtml, const char *str) +{ + if (!str || !*str || !strcmp(str, "html")) + g_signal_emit_by_name(imhtml, "paste_clipboard"); + else if (!strcmp(str, "text")) + paste_unformatted_cb(NULL, imhtml); +} + static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) { /* since this function is the handler for the formatting keystrokes, @@ -1513,24 +1523,31 @@ NULL, 0, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - signals [UNDO] = g_signal_new ("undo", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkIMHtmlClass, undo), - NULL, - NULL, - gtksourceview_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - signals [REDO] = g_signal_new ("redo", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkIMHtmlClass, redo), - NULL, - NULL, - gtksourceview_marshal_VOID__VOID, - G_TYPE_NONE, - 0); + signals[PASTE] = g_signal_new("paste", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, + 0, g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + signals [UNDO] = g_signal_new ("undo", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (GtkIMHtmlClass, undo), + NULL, + NULL, + gtksourceview_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals [REDO] = g_signal_new ("redo", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (GtkIMHtmlClass, redo), + NULL, + NULL, + gtksourceview_marshal_VOID__VOID, + G_TYPE_NONE, + 0); @@ -1615,10 +1632,10 @@ gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); - gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); - gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); - gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); - + gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); + gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); + gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); + gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text"); } static void gtk_imhtml_init (GtkIMHtml *imhtml) @@ -1689,6 +1706,7 @@ g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL); g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); + g_signal_connect(G_OBJECT(imhtml), "paste", G_CALLBACK(imhtml_paste_cb), NULL); #ifndef _WIN32 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",