{
GtkWidget* view = midori_browser_get_current_tab (browser);
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = midori_view_new_with_uri (
- midori_view_get_display_uri (MIDORI_VIEW (view)),
- NULL, browser->settings);
+ GtkWidget* new_view = midori_view_new_with_title (
+ NULL, browser->settings, FALSE);
+ const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
g_signal_emit_by_name (view, "new-view", new_view, where);
+ midori_view_set_uri (MIDORI_VIEW (new_view), uri);
}
static void
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
{
gint n;
- GtkWidget* view = midori_view_new_with_uri ("", NULL, browser->settings);
- g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
+ GtkWidget* view = midori_view_new_with_title (NULL, browser->settings, TRUE);
n = midori_browser_add_tab (browser, view);
midori_browser_set_current_page (browser, n);
if (!uri)
uri = "about:blank";
title = katze_item_get_name (item);
+ view = midori_view_new_with_title (title, browser->settings,
+ g_object_get_data (G_OBJECT (item), "midori-view-append") ? TRUE : FALSE);
+ page = midori_browser_add_tab (browser, view);
+
/* Blank pages should not be delayed */
if (katze_item_get_meta_integer (item, "delay") > 0
&& strcmp (uri, "about:blank") != 0)
{
gchar* new_uri = g_strdup_printf ("pause:%s", uri);
- view = midori_view_new_with_uri (new_uri, title, browser->settings);
+ midori_view_set_uri (MIDORI_VIEW (view), new_uri);
g_free (new_uri);
}
else
- view = midori_view_new_with_uri (uri, title, browser->settings);
-
- /* FIXME: We should have public API for that */
- if (g_object_get_data (G_OBJECT (item), "midori-view-append"))
- g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
+ midori_view_set_uri (MIDORI_VIEW (view), uri);
- page = midori_browser_add_tab (browser, view);
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
if ((keys = katze_item_get_meta_keys (item)))
{
const gchar* uri)
{
GtkWidget* view;
+ gint n;
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
g_return_val_if_fail (uri != NULL, -1);
- view = midori_view_new_with_uri (uri, NULL, browser->settings);
- return midori_browser_add_tab (browser, view);
+ view = midori_view_new_with_title (NULL, browser->settings, FALSE);
+ n = midori_browser_add_tab (browser, view);
+ midori_view_set_uri (MIDORI_VIEW (view), uri);
+ return n;
}
/**
new_view = view;
else
{
- new_view = (MidoriView*)midori_view_new_with_uri (NULL, NULL,
- view->settings);
+ new_view = (MidoriView*)midori_view_new_with_title (NULL,
+ view->settings, FALSE);
midori_view_construct_web_view (new_view);
g_signal_connect (new_view->web_view, "web-view-ready",
G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
*
* Return value: a new #MidoriView
*
- * Deprecated: 0.2.8: Use midori_view_new_with_uri() instead.
+ * Deprecated: 0.2.8: Use midori_view_new_with_title() instead.
**/
GtkWidget*
midori_view_new (KatzeNet* net)
}
/**
- * midori_view_new_with_uri:
+ * midori_view_new_with_title:
* @uri: an URI string, or %NULL
* @title: a title, or %NULL
* @settings: a #MidoriWebSettings, or %NULL
+ * @append: if %TRUE, the view should be appended
*
* Creates a new view with the specified parameters that
* is visible by default.
*
* Return value: a new #MidoriView
*
- * Since: 0.2.8
+ * Since: 0.3.0
**/
GtkWidget*
-midori_view_new_with_uri (const gchar* uri,
- const gchar* title,
- MidoriWebSettings* settings)
+midori_view_new_with_title (const gchar* title,
+ MidoriWebSettings* settings,
+ gboolean append)
{
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
view->title = g_strdup (title);
g_signal_connect (settings, "notify",
G_CALLBACK (midori_view_settings_notify_cb), view);
}
- if (uri != NULL)
- midori_view_set_uri (view, uri);
+ if (append)
+ g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
gtk_widget_show ((GtkWidget*)view);
return (GtkWidget*)view;
}
* @view: a #MidoriView
*
* Opens the specified URI in the view.
+ *
+ * Since 0.3.0 a warning is shown if the view is not yet
+ * contained in a browser. This is because extensions
+ * can't monitor page loading if that happens.
**/
void
midori_view_set_uri (MidoriView* view,
g_return_if_fail (MIDORI_IS_VIEW (view));
+ if (!gtk_widget_get_parent (GTK_WIDGET (view)))
+ g_warning ("Calling %s() before adding the view to a browser. This "
+ "breaks extensions that monitor page loading.", G_STRFUNC);
+
/* Treat "about:blank" and "" equally, see midori_view_is_blank(). */
if (!uri || !strcmp (uri, "about:blank")) uri = "";
MidoriView* view)
{
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = midori_view_new_with_uri (
- midori_view_get_display_uri (view),
- NULL, view->settings);
+ GtkWidget* new_view = midori_view_new_with_title (
+ NULL, view->settings, FALSE);
+ const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
+ midori_view_set_uri (MIDORI_VIEW (new_view), uri);
}
static void
if (!view->thumb_view)
{
- view->thumb_view = midori_view_new_with_uri (NULL, NULL, NULL);
+ view->thumb_view = midori_view_new_with_title (NULL, NULL, FALSE);
gtk_container_add (GTK_CONTAINER (notebook), view->thumb_view);
/* We use an empty label. It's not invisible but at least hard to spot. */
label = gtk_event_box_new ();