From c3636f9263596bf17e74fc5a2473bd978a41bac8 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Wed, 16 Jan 2008 13:07:43 -0800 Subject: [PATCH] [Window] Focus the VteTerminal when pulled down This has the PULL_DOWN code automatically focus the VteTerminal so that the user can begin typing. This was originally handled by a callback, but this seems not to be necessary. It seems easier to handle it in the PULL_DOWN code. --- tilda-window.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tilda-window.c b/tilda-window.c index b735532..fb2f0e8 100644 --- a/tilda-window.c +++ b/tilda-window.c @@ -2,6 +2,31 @@ #include "tilda-window.h" #include "tilda-window-dbus-glue.h" +/** + * Find the TildaTerminal corresponding to the currently selected + * tab in self->notebook. This could go away if TildaTerminal were + * a proper subclass of GtkWidget. + */ +static TildaTerminal * +tilda_window_find_current_terminal (TildaWindow *self) +{ + gint i; + TildaTerminal *ret; + gint current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(self->notebook)); + GtkWidget *box = gtk_notebook_get_nth_page (GTK_NOTEBOOK(self->notebook), current_page); + + for (i=0; iterms->len; ++i) + { + ret = g_ptr_array_index (self->terms, i); + + if (ret->hbox == box) + return ret; + } + + g_printerr ("FIXME: unable to find current terminal!\n"); + return NULL; +} + static gint tilda_window_find_next_free_terminal_number (TildaWindow *tw) { @@ -135,6 +160,7 @@ static void tilda_window_keybinding_cb (const gchar *keystr, gpointer data) { TildaWindow *self = TILDA_WINDOW(data); + TildaTerminal *tt; g_print ("tilda_window_keybinding_cb() called! -- window %d\n", self->number); // FIXME: this doesn't handle animation! @@ -145,6 +171,10 @@ tilda_window_keybinding_cb (const gchar *keystr, gpointer data) /* Pull Down */ tomboy_window_present_hardcore (GTK_WINDOW(self->window)); self->state = WINDOW_DOWN; + + // Focusing the term here works perfectly, near as I can tell + tt = tilda_window_find_current_terminal (self); + gtk_widget_grab_focus (GTK_WIDGET(tt->vte_term)); break; case WINDOW_DOWN: -- 2.25.1