Replace midori_view_new_with_uri with _new_with_title
The old function is actually being removed because it breaks monitoring of page loading. It was only used internally so far. Moreover a warning is now emitted when loading an URI before adding a view to a browser.
This commit is contained in:
parent
6b38ed85cf
commit
6780ed8be3
3 changed files with 43 additions and 31 deletions
|
@ -4401,10 +4401,11 @@ _action_tab_duplicate_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
GtkWidget* view = midori_browser_get_current_tab (browser);
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
||||||
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
|
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
|
||||||
GtkWidget* new_view = midori_view_new_with_uri (
|
GtkWidget* new_view = midori_view_new_with_title (
|
||||||
midori_view_get_display_uri (MIDORI_VIEW (view)),
|
NULL, browser->settings, FALSE);
|
||||||
NULL, browser->settings);
|
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
||||||
g_signal_emit_by_name (view, "new-view", new_view, where);
|
g_signal_emit_by_name (view, "new-view", new_view, where);
|
||||||
|
midori_view_set_uri (MIDORI_VIEW (new_view), uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -4749,8 +4750,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
|
||||||
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
|
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
|
||||||
{
|
{
|
||||||
gint n;
|
gint n;
|
||||||
GtkWidget* view = midori_view_new_with_uri ("", NULL, browser->settings);
|
GtkWidget* view = midori_view_new_with_title (NULL, browser->settings, TRUE);
|
||||||
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
|
|
||||||
n = midori_browser_add_tab (browser, view);
|
n = midori_browser_add_tab (browser, view);
|
||||||
midori_browser_set_current_page (browser, n);
|
midori_browser_set_current_page (browser, n);
|
||||||
|
|
||||||
|
@ -6717,22 +6717,21 @@ midori_browser_add_item (MidoriBrowser* browser,
|
||||||
if (!uri)
|
if (!uri)
|
||||||
uri = "about:blank";
|
uri = "about:blank";
|
||||||
title = katze_item_get_name (item);
|
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 */
|
/* Blank pages should not be delayed */
|
||||||
if (katze_item_get_meta_integer (item, "delay") > 0
|
if (katze_item_get_meta_integer (item, "delay") > 0
|
||||||
&& strcmp (uri, "about:blank") != 0)
|
&& strcmp (uri, "about:blank") != 0)
|
||||||
{
|
{
|
||||||
gchar* new_uri = g_strdup_printf ("pause:%s", uri);
|
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);
|
g_free (new_uri);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
view = midori_view_new_with_uri (uri, title, browser->settings);
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
page = midori_browser_add_tab (browser, view);
|
|
||||||
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
||||||
if ((keys = katze_item_get_meta_keys (item)))
|
if ((keys = katze_item_get_meta_keys (item)))
|
||||||
{
|
{
|
||||||
|
@ -6760,12 +6759,15 @@ midori_browser_add_uri (MidoriBrowser* browser,
|
||||||
const gchar* uri)
|
const gchar* uri)
|
||||||
{
|
{
|
||||||
GtkWidget* view;
|
GtkWidget* view;
|
||||||
|
gint n;
|
||||||
|
|
||||||
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
|
||||||
g_return_val_if_fail (uri != NULL, -1);
|
g_return_val_if_fail (uri != NULL, -1);
|
||||||
|
|
||||||
view = midori_view_new_with_uri (uri, NULL, browser->settings);
|
view = midori_view_new_with_title (NULL, browser->settings, FALSE);
|
||||||
return midori_browser_add_tab (browser, view);
|
n = midori_browser_add_tab (browser, view);
|
||||||
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2813,8 +2813,8 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view,
|
||||||
new_view = view;
|
new_view = view;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_view = (MidoriView*)midori_view_new_with_uri (NULL, NULL,
|
new_view = (MidoriView*)midori_view_new_with_title (NULL,
|
||||||
view->settings);
|
view->settings, FALSE);
|
||||||
midori_view_construct_web_view (new_view);
|
midori_view_construct_web_view (new_view);
|
||||||
g_signal_connect (new_view->web_view, "web-view-ready",
|
g_signal_connect (new_view->web_view, "web-view-ready",
|
||||||
G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
|
G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
|
||||||
|
@ -3274,7 +3274,7 @@ midori_view_focus_in_event (GtkWidget* widget,
|
||||||
*
|
*
|
||||||
* Return value: a new #MidoriView
|
* 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*
|
GtkWidget*
|
||||||
midori_view_new (KatzeNet* net)
|
midori_view_new (KatzeNet* net)
|
||||||
|
@ -3311,22 +3311,23 @@ _midori_view_update_settings (MidoriView* view)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_view_new_with_uri:
|
* midori_view_new_with_title:
|
||||||
* @uri: an URI string, or %NULL
|
* @uri: an URI string, or %NULL
|
||||||
* @title: a title, or %NULL
|
* @title: a title, or %NULL
|
||||||
* @settings: a #MidoriWebSettings, or %NULL
|
* @settings: a #MidoriWebSettings, or %NULL
|
||||||
|
* @append: if %TRUE, the view should be appended
|
||||||
*
|
*
|
||||||
* Creates a new view with the specified parameters that
|
* Creates a new view with the specified parameters that
|
||||||
* is visible by default.
|
* is visible by default.
|
||||||
*
|
*
|
||||||
* Return value: a new #MidoriView
|
* Return value: a new #MidoriView
|
||||||
*
|
*
|
||||||
* Since: 0.2.8
|
* Since: 0.3.0
|
||||||
**/
|
**/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
midori_view_new_with_uri (const gchar* uri,
|
midori_view_new_with_title (const gchar* title,
|
||||||
const gchar* title,
|
MidoriWebSettings* settings,
|
||||||
MidoriWebSettings* settings)
|
gboolean append)
|
||||||
{
|
{
|
||||||
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
|
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
|
||||||
view->title = g_strdup (title);
|
view->title = g_strdup (title);
|
||||||
|
@ -3339,8 +3340,8 @@ midori_view_new_with_uri (const gchar* uri,
|
||||||
g_signal_connect (settings, "notify",
|
g_signal_connect (settings, "notify",
|
||||||
G_CALLBACK (midori_view_settings_notify_cb), view);
|
G_CALLBACK (midori_view_settings_notify_cb), view);
|
||||||
}
|
}
|
||||||
if (uri != NULL)
|
if (append)
|
||||||
midori_view_set_uri (view, uri);
|
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
|
||||||
gtk_widget_show ((GtkWidget*)view);
|
gtk_widget_show ((GtkWidget*)view);
|
||||||
return (GtkWidget*)view;
|
return (GtkWidget*)view;
|
||||||
}
|
}
|
||||||
|
@ -3692,6 +3693,10 @@ midori_view_construct_web_view (MidoriView* view)
|
||||||
* @view: a #MidoriView
|
* @view: a #MidoriView
|
||||||
*
|
*
|
||||||
* Opens the specified URI in the view.
|
* 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
|
void
|
||||||
midori_view_set_uri (MidoriView* view,
|
midori_view_set_uri (MidoriView* view,
|
||||||
|
@ -3701,6 +3706,10 @@ midori_view_set_uri (MidoriView* view,
|
||||||
|
|
||||||
g_return_if_fail (MIDORI_IS_VIEW (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(). */
|
/* Treat "about:blank" and "" equally, see midori_view_is_blank(). */
|
||||||
if (!uri || !strcmp (uri, "about:blank")) uri = "";
|
if (!uri || !strcmp (uri, "about:blank")) uri = "";
|
||||||
|
|
||||||
|
@ -4254,10 +4263,11 @@ midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
|
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
|
||||||
GtkWidget* new_view = midori_view_new_with_uri (
|
GtkWidget* new_view = midori_view_new_with_title (
|
||||||
midori_view_get_display_uri (view),
|
NULL, view->settings, FALSE);
|
||||||
NULL, view->settings);
|
const gchar* uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
||||||
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
|
g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
|
||||||
|
midori_view_set_uri (MIDORI_VIEW (new_view), uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5315,7 +5325,7 @@ midori_view_speed_dial_inject_thumb (MidoriView* view,
|
||||||
|
|
||||||
if (!view->thumb_view)
|
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);
|
gtk_container_add (GTK_CONTAINER (notebook), view->thumb_view);
|
||||||
/* We use an empty label. It's not invisible but at least hard to spot. */
|
/* We use an empty label. It's not invisible but at least hard to spot. */
|
||||||
label = gtk_event_box_new ();
|
label = gtk_event_box_new ();
|
||||||
|
|
|
@ -81,9 +81,9 @@ GtkWidget*
|
||||||
midori_view_new (KatzeNet* net);
|
midori_view_new (KatzeNet* net);
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
midori_view_new_with_uri (const gchar* uri,
|
midori_view_new_with_title (const gchar* title,
|
||||||
const gchar* title,
|
MidoriWebSettings* settings,
|
||||||
MidoriWebSettings* settings);
|
gboolean append);
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_view_set_settings (MidoriView* view,
|
midori_view_set_settings (MidoriView* view,
|
||||||
|
|
Loading…
Reference in a new issue