{
GtkWidget* view = midori_browser_get_current_tab (browser);
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", browser->settings, NULL);
- midori_view_set_uri (MIDORI_VIEW (new_view),
- midori_view_get_display_uri (MIDORI_VIEW (view)));
- gtk_widget_show (new_view);
+ GtkWidget* new_view = midori_view_new_with_uri (
+ midori_view_get_display_uri (MIDORI_VIEW (view)),
+ NULL, browser->settings);
g_signal_emit_by_name (view, "new-view", new_view, where);
}
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
{
gint n;
- GtkWidget* view;
-
- view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", browser->settings,
- NULL);
- midori_view_set_uri (MIDORI_VIEW (view), "");
- gtk_widget_show (view);
+ GtkWidget* view = midori_view_new_with_uri ("", NULL, browser->settings);
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
n = midori_browser_add_tab (browser, view);
midori_browser_set_current_page (browser, n);
uri = katze_item_get_uri (item);
title = katze_item_get_name (item);
- view = g_object_new (MIDORI_TYPE_VIEW,
- "title", title,
- "settings", browser->settings,
- NULL);
/* Blank pages should not be delayed */
if (katze_item_get_meta_integer (item, "delay") > 0
&& uri != NULL && strcmp (uri, "about:blank") != 0)
{
- gchar* new_uri;
- new_uri = g_strdup_printf ("pause:%s", uri);
- midori_view_set_uri (MIDORI_VIEW (view), new_uri);
+ gchar* new_uri = g_strdup_printf ("pause:%s", uri);
+ view = midori_view_new_with_uri (new_uri, title, browser->settings);
g_free (new_uri);
}
else
- midori_view_set_uri (MIDORI_VIEW (view), uri);
-
- gtk_widget_show (view);
+ 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_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
g_return_val_if_fail (uri != NULL, -1);
- view = g_object_new (MIDORI_TYPE_VIEW, "settings", browser->settings,
- NULL);
- midori_view_set_uri (MIDORI_VIEW (view), uri);
- gtk_widget_show (view);
-
+ view = midori_view_new_with_uri (uri, NULL, browser->settings);
return midori_browser_add_tab (browser, view);
}
new_view = view;
else
{
- new_view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", view->settings,
- NULL);
+ new_view = (MidoriView*)midori_view_new_with_uri (NULL, NULL,
+ view->settings);
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);
/**
* midori_view_new:
- * @net: a #KatzeNet, or %NULL
+ * @net: %NULL
*
* Creates a new view.
*
* Return value: a new #MidoriView
+ *
+ * Deprecated: 0.2.8: Use midori_view_new_with_uri() instead.
**/
GtkWidget*
midori_view_new (KatzeNet* net)
g_object_set (view->scrolled_window, "kinetic-scrolling", kinetic_scrolling, NULL);
}
+/**
+ * midori_view_new_with_uri:
+ * @uri: an URI string, or %NULL
+ * @title: a title, or %NULL
+ * @settings: a #MidoriWebSettings, or %NULL
+ *
+ * Creates a new view with the specified parameters that
+ * is visible by default.
+ *
+ * Return value: a new #MidoriView
+ *
+ * Since: 0.2.8
+ **/
+GtkWidget*
+midori_view_new_with_uri (const gchar* uri,
+ const gchar* title,
+ MidoriWebSettings* settings)
+{
+ MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
+ view->title = g_strdup (title);
+ if (title != NULL)
+ midori_view_update_title (view);
+ if (settings)
+ {
+ view->settings = g_object_ref (settings);
+ _midori_view_update_settings (view);
+ g_signal_connect (settings, "notify",
+ G_CALLBACK (midori_view_settings_notify_cb), view);
+ }
+ if (uri != NULL)
+ midori_view_set_uri (view, uri);
+ gtk_widget_show ((GtkWidget*)view);
+ return (GtkWidget*)view;
+}
+
static void
midori_view_settings_notify_cb (MidoriWebSettings* settings,
GParamSpec* pspec,
MidoriView* view)
{
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", view->settings, NULL);
- midori_view_set_uri (MIDORI_VIEW (new_view),
- midori_view_get_display_uri (view));
- gtk_widget_show (new_view);
+ GtkWidget* new_view = midori_view_new_with_uri (
+ midori_view_get_display_uri (view),
+ NULL, view->settings);
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
}