midori_view_unmark_text_matches (MIDORI_VIEW (view));
gtk_widget_hide (browser->find);
browser->find_typing = FALSE;
- gtk_window_set_focus (GTK_WINDOW (browser),
- midori_view_get_web_view (MIDORI_VIEW (view)) ?
- midori_view_get_web_view (MIDORI_VIEW (view)) : view);
+ gtk_window_set_focus (GTK_WINDOW (browser), view);
}
static void
MidoriBrowser* browser)
{
GtkWidget* view = midori_browser_get_current_tab (browser);
- GtkWidget* child = midori_view_get_web_view (MIDORI_VIEW (view));
- gtk_widget_grab_focus (child ? child : view);
+ gtk_widget_grab_focus (view);
}
static const gchar* credits_authors[] =
gint n)
{
GtkWidget* view;
- GtkWidget* web_view;
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
- if (view && midori_view_is_blank (MIDORI_VIEW (view)))
+ if (midori_view_is_blank (MIDORI_VIEW (view)))
gtk_action_activate (_action_by_name (browser, "Location"));
- else if ((web_view = midori_view_get_web_view (MIDORI_VIEW (view))))
- gtk_widget_grab_focus (web_view);
else
gtk_widget_grab_focus (view);
}
GtkWidget* view)
{
gint n;
- GtkWidget* web_view;
g_return_if_fail (MIDORI_IS_BROWSER (browser));
g_return_if_fail (GTK_IS_WIDGET (view));
n = gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
- if (view && midori_view_is_blank (MIDORI_VIEW (view)))
+ if (midori_view_is_blank (MIDORI_VIEW (view)))
gtk_action_activate (_action_by_name (browser, "Location"));
- else if ((web_view = midori_view_get_web_view (MIDORI_VIEW (view))))
- gtk_widget_grab_focus (web_view);
else
gtk_widget_grab_focus (view);
}
GValue* value,
GParamSpec* pspec);
+static gboolean
+midori_view_focus_in_event (GtkWidget* widget,
+ GdkEventFocus* event);
+
static void
midori_view_settings_notify_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
midori_view_class_init (MidoriViewClass* class)
{
GObjectClass* gobject_class;
+ GtkWidgetClass* gtkwidget_class;
GParamFlags flags;
signals[ACTIVATE_ACTION] = g_signal_new (
gobject_class->set_property = midori_view_set_property;
gobject_class->get_property = midori_view_get_property;
+ gtkwidget_class = GTK_WIDGET_CLASS (class);
+ gtkwidget_class->focus_in_event = midori_view_focus_in_event;
+
flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
g_object_class_install_property (gobject_class,
}
}
+static gboolean
+midori_view_focus_in_event (GtkWidget* widget,
+ GdkEventFocus* event)
+{
+ MidoriView* view = MIDORI_VIEW (widget);
+
+ /* Always propagate focus to the child web view,
+ * create it if it's not there yet. */
+ if (!view->web_view)
+ midori_view_construct_web_view (view);
+ gtk_widget_grab_focus (view->web_view);
+ return TRUE;
+}
+
/**
* midori_view_new:
* @net: a #KatzeNet