[Telepathy] swapping return/ctrl-return keybindings

Brian J. Murrell brian at interlinx.bc.ca
Thu Mar 19 13:22:47 PDT 2009


On Thu, 19 Mar 2009 19:23:53 +0100, Xavier Claessens wrote:
>  
> Sorry but I have no idea how to make that with a gtkrc file. Maybe you
> should ask pidgin developers how they did.

Better yet.  Ask the source.  :-)

I really know zip about GTK programming but this is what I have 
discovered.  Their equivalent of empathy's "chat->input_text_view" looks 
like it's a "gtkconv->entry":

	frame = pidgin_create_imhtml(TRUE, &gtkconv->entry, &gtkconv->toolbar, NULL);

The give it a name:

	gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry");

and then plumb a signal for it (message_send == send_cb()):

	g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send",
	                       G_CALLBACK(send_cb), gtkconv);

Like empathy, they also do plumb a callback for keypresses:

	g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event",
	                 G_CALLBACK(entry_key_press_cb), gtkconv);

But unlike empathy, the only keypresses they do anything with are:

	if (event->state & GDK_CONTROL_MASK) {
		switch (event->keyval) {
			case GDK_Up:
...
			case GDK_Down:
...
	else if (event->state & GDK_MOD1_MASK) 	{

	}

	/* If neither CTRL nor ALT were held down... */
	else {
		switch (event->keyval) {
		case GDK_Tab:
		case GDK_KP_Tab:
		case GDK_ISO_Left_Tab:
...
		case GDK_Page_Up:
...
		case GDK_Page_Down:
		}
	}

Notice there is no processing for (this taken from empathy):

	if (IS_ENTER (event->keyval) &&
	    !(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK))) {

...
		chat_input_text_view_send (chat);
...
	}

Instead they do the GDK_KP_Enter keypress processing with keybindings in 
their IMHtml class's init:

static void gtk_imhtml_class_init (GtkIMHtmlClass *klass)
{
...

	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);


Notice the call to the "message_send" signal which they plumbed 
previously?

So, I guess the solution is to get rid of the processing of the Enter key
in chat_input_key_press_event_cb() and plumb it with a keybinding on the
chat->input_text_view object.  I *think* then, a .gtkrc setting could over-
ride the programmed binding.

Does that help anyone (with GTK programming know-how) come up with a quick
fix or do I need to dig some more and see how this is actually done?

b.




More information about the telepathy mailing list