Grab focus on the browser when explicitly opening an uri

This commit is contained in:
Marco Pesenti Gritti 2006-10-20 19:54:28 +02:00
parent 19715991ec
commit 5a26d51d20
4 changed files with 22 additions and 0 deletions

View File

@ -121,6 +121,7 @@ class Toolbar(gtk.Toolbar):
def _entry_activate_cb(self, entry): def _entry_activate_cb(self, entry):
self._embed.load_url(entry.get_text()) self._embed.load_url(entry.get_text())
self._embed.grab_focus()
def _go_back_cb(self, button): def _go_back_cb(self, button):
self._embed.go_back() self._embed.go_back()

View File

@ -59,6 +59,12 @@
(return-type "none") (return-type "none")
) )
(define-method grab_focus
(of-object "SugarBrowser")
(c-name "sugar_browser_grab_focus")
(return-type "none")
)
(define-method create_window (define-method create_window
(of-object "SugarBrowser") (of-object "SugarBrowser")
(c-name "sugar_browser_create_window") (c-name "sugar_browser_create_window")

View File

@ -305,3 +305,17 @@ sugar_browser_scroll_pixels(SugarBrowser *browser,
DOMWindow->ScrollBy (dx, dy); DOMWindow->ScrollBy (dx, dy);
} }
void
sugar_browser_grab_focus(SugarBrowser *browser)
{
GtkWidget *child;
child = gtk_bin_get_child(GTK_BIN(browser));
if (child != NULL) {
gtk_widget_grab_focus (child);
} else {
g_warning ("Need to realize the embed before grabbing focus!\n");
}
}

View File

@ -59,6 +59,7 @@ SugarBrowser *sugar_browser_create_window (SugarBrowser *browser);
void sugar_browser_scroll_pixels (SugarBrowser *browser, void sugar_browser_scroll_pixels (SugarBrowser *browser,
int dx, int dx,
int dy); int dy);
void sugar_browser_grab_focus (SugarBrowser *browser);
G_END_DECLS G_END_DECLS