Introduce and use midori_view_new_with_item
This commit is contained in:
parent
98f2e3b572
commit
6143654279
4 changed files with 48 additions and 35 deletions
|
@ -707,6 +707,8 @@ katze_item_set_parent (KatzeItem* item,
|
||||||
* Note that subclass specific features will only
|
* Note that subclass specific features will only
|
||||||
* be preserved if the class implements it.
|
* be preserved if the class implements it.
|
||||||
*
|
*
|
||||||
|
* Since 0.4.3 meta data is copied.
|
||||||
|
*
|
||||||
* Return value: a new #KatzeItem
|
* Return value: a new #KatzeItem
|
||||||
*
|
*
|
||||||
* Since: 0.1.3
|
* Since: 0.1.3
|
||||||
|
@ -715,6 +717,9 @@ KatzeItem*
|
||||||
katze_item_copy (KatzeItem* item)
|
katze_item_copy (KatzeItem* item)
|
||||||
{
|
{
|
||||||
KatzeItem* copy;
|
KatzeItem* copy;
|
||||||
|
GHashTableIter iter;
|
||||||
|
const gchar* key;
|
||||||
|
const gchar* value;
|
||||||
KatzeItemClass* class;
|
KatzeItemClass* class;
|
||||||
|
|
||||||
g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
|
g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
|
||||||
|
@ -727,6 +732,15 @@ katze_item_copy (KatzeItem* item)
|
||||||
"added", item->added,
|
"added", item->added,
|
||||||
"parent", item->parent,
|
"parent", item->parent,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
g_hash_table_iter_init (&iter, item->metadata);
|
||||||
|
while (g_hash_table_iter_next (&iter, (void*)&key, (void*)&value))
|
||||||
|
{
|
||||||
|
if (g_str_has_prefix (key, "midori:"))
|
||||||
|
key = &key[7];
|
||||||
|
g_hash_table_insert (copy->metadata, g_strdup (key), g_strdup (value));
|
||||||
|
}
|
||||||
|
|
||||||
class = KATZE_ITEM_GET_CLASS (item);
|
class = KATZE_ITEM_GET_CLASS (item);
|
||||||
return class->copy ? class->copy (copy) : copy;
|
return class->copy ? class->copy (copy) : copy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3418,12 +3418,10 @@ _action_source_view_activate (GtkAction* action,
|
||||||
source_uri = g_filename_to_uri (filename, NULL, NULL);
|
source_uri = g_filename_to_uri (filename, NULL, NULL);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
source = midori_view_new (NULL);
|
source = midori_view_new_with_title (NULL, browser->settings, FALSE);
|
||||||
midori_view_set_settings (MIDORI_VIEW (source), browser->settings);
|
|
||||||
source_view = midori_view_get_web_view (MIDORI_VIEW (source));
|
source_view = midori_view_get_web_view (MIDORI_VIEW (source));
|
||||||
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (source_view), TRUE);
|
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (source_view), TRUE);
|
||||||
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (source_view), source_uri);
|
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (source_view), source_uri);
|
||||||
gtk_widget_show (source);
|
|
||||||
midori_browser_add_tab (browser, source);
|
midori_browser_add_tab (browser, source);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -7053,27 +7051,15 @@ midori_browser_add_item (MidoriBrowser* browser,
|
||||||
KatzeItem* item)
|
KatzeItem* item)
|
||||||
{
|
{
|
||||||
const gchar* uri;
|
const gchar* uri;
|
||||||
const gchar* title;
|
|
||||||
GtkWidget* view;
|
GtkWidget* view;
|
||||||
gint page;
|
gint page;
|
||||||
KatzeItem* proxy_item;
|
|
||||||
GList* keys;
|
|
||||||
|
|
||||||
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 (KATZE_IS_ITEM (item), -1);
|
g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
|
||||||
|
|
||||||
uri = katze_item_get_uri (item);
|
uri = katze_item_get_uri (item);
|
||||||
if (!uri)
|
view = midori_view_new_with_item (item, browser->settings,
|
||||||
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);
|
g_object_get_data (G_OBJECT (item), "midori-view-append") ? TRUE : FALSE);
|
||||||
|
|
||||||
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
||||||
|
|
||||||
if (katze_item_get_meta_boolean (item, "dont-write-history"))
|
|
||||||
katze_item_set_meta_integer (proxy_item, "dont-write-history", 1);
|
|
||||||
|
|
||||||
page = midori_browser_add_tab (browser, view);
|
page = midori_browser_add_tab (browser, view);
|
||||||
|
|
||||||
/* Blank pages should not be delayed */
|
/* Blank pages should not be delayed */
|
||||||
|
@ -7088,16 +7074,6 @@ midori_browser_add_item (MidoriBrowser* browser,
|
||||||
else
|
else
|
||||||
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
||||||
|
|
||||||
proxy_item = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
|
||||||
if ((keys = katze_item_get_meta_keys (item)))
|
|
||||||
{
|
|
||||||
guint i = 0;
|
|
||||||
const gchar* key;
|
|
||||||
while ((key = g_list_nth_data (keys, i++)))
|
|
||||||
katze_item_set_meta_string (proxy_item, key,
|
|
||||||
katze_item_get_meta_string (item, key));
|
|
||||||
g_list_free (keys);
|
|
||||||
}
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3251,7 +3251,6 @@ _midori_view_set_settings (MidoriView* view,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_view_new_with_title:
|
* midori_view_new_with_title:
|
||||||
* @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
|
* @append: if %TRUE, the view should be appended
|
||||||
|
@ -3268,11 +3267,35 @@ midori_view_new_with_title (const gchar* title,
|
||||||
MidoriWebSettings* settings,
|
MidoriWebSettings* settings,
|
||||||
gboolean append)
|
gboolean append)
|
||||||
{
|
{
|
||||||
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, "title", title, NULL);
|
KatzeItem* item = katze_item_new ();
|
||||||
|
item->name = g_strdup (title);
|
||||||
|
return midori_view_new_with_item (item, settings, append);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_view_new_with_item:
|
||||||
|
* @item: a #KatzeItem, or %NULL
|
||||||
|
* @settings: a #MidoriWebSettings, or %NULL
|
||||||
|
* @append: if %TRUE, the view should be appended
|
||||||
|
*
|
||||||
|
* Creates a new view from an item that is visible by default.
|
||||||
|
*
|
||||||
|
* Return value: a new #MidoriView
|
||||||
|
*
|
||||||
|
* Since: 0.4.3
|
||||||
|
**/
|
||||||
|
GtkWidget*
|
||||||
|
midori_view_new_with_item (KatzeItem* item,
|
||||||
|
MidoriWebSettings* settings,
|
||||||
|
gboolean append)
|
||||||
|
{
|
||||||
|
MidoriView* view = g_object_new (MIDORI_TYPE_VIEW, NULL);
|
||||||
if (settings)
|
if (settings)
|
||||||
_midori_view_set_settings (view, settings);
|
_midori_view_set_settings (view, settings);
|
||||||
if (append)
|
if (append)
|
||||||
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
|
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
|
||||||
|
if (item)
|
||||||
|
katze_object_assign (view->item, katze_item_copy (item));
|
||||||
gtk_widget_show ((GtkWidget*)view);
|
gtk_widget_show ((GtkWidget*)view);
|
||||||
return (GtkWidget*)view;
|
return (GtkWidget*)view;
|
||||||
}
|
}
|
||||||
|
@ -3808,12 +3831,9 @@ midori_view_set_uri (MidoriView* view,
|
||||||
g_warning ("Calling %s() before adding the view to a browser. This "
|
g_warning ("Calling %s() before adding the view to a browser. This "
|
||||||
"breaks extensions that monitor page loading.", G_STRFUNC);
|
"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 = "";
|
|
||||||
|
|
||||||
if (g_getenv ("MIDORI_UNARMED") == NULL)
|
if (g_getenv ("MIDORI_UNARMED") == NULL)
|
||||||
{
|
{
|
||||||
if (!strcmp (uri, ""))
|
if (!uri || !strcmp (uri, "") || !strcmp (uri, "about:blank"))
|
||||||
{
|
{
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
GTimer* timer = NULL;
|
GTimer* timer = NULL;
|
||||||
|
@ -4074,8 +4094,6 @@ midori_view_get_display_uri (MidoriView* view)
|
||||||
* as a title. Most of the time this will be the title
|
* as a title. Most of the time this will be the title
|
||||||
* or the current URI.
|
* or the current URI.
|
||||||
*
|
*
|
||||||
* An empty page is represented as "about:blank".
|
|
||||||
*
|
|
||||||
* You can assume that the string is not %NULL.
|
* You can assume that the string is not %NULL.
|
||||||
*
|
*
|
||||||
* Return value: a title string
|
* Return value: a title string
|
||||||
|
@ -4841,7 +4859,7 @@ midori_view_reload (MidoriView* view,
|
||||||
{
|
{
|
||||||
g_return_if_fail (MIDORI_IS_VIEW (view));
|
g_return_if_fail (MIDORI_IS_VIEW (view));
|
||||||
|
|
||||||
if (!(view->uri && *view->uri && strncmp (view->uri, "about:", 6)))
|
if (midori_uri_is_blank (view->uri))
|
||||||
{
|
{
|
||||||
gchar* uri = g_strdup (view->uri);
|
gchar* uri = g_strdup (view->uri);
|
||||||
midori_view_set_uri (view, uri);
|
midori_view_set_uri (view, uri);
|
||||||
|
|
|
@ -78,6 +78,11 @@ midori_view_new_with_title (const gchar* title,
|
||||||
MidoriWebSettings* settings,
|
MidoriWebSettings* settings,
|
||||||
gboolean append);
|
gboolean append);
|
||||||
|
|
||||||
|
GtkWidget*
|
||||||
|
midori_view_new_with_item (KatzeItem* item,
|
||||||
|
MidoriWebSettings* settings,
|
||||||
|
gboolean append);
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_view_set_settings (MidoriView* view,
|
midori_view_set_settings (MidoriView* view,
|
||||||
MidoriWebSettings* settings);
|
MidoriWebSettings* settings);
|
||||||
|
|
Loading…
Reference in a new issue