* Note that subclass specific features will only
* be preserved if the class implements it.
*
+ * Since 0.4.3 meta data is copied.
+ *
* Return value: a new #KatzeItem
*
* Since: 0.1.3
katze_item_copy (KatzeItem* item)
{
KatzeItem* copy;
+ GHashTableIter iter;
+ const gchar* key;
+ const gchar* value;
KatzeItemClass* class;
g_return_val_if_fail (KATZE_IS_ITEM (item), NULL);
"added", item->added,
"parent", item->parent,
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);
return class->copy ? class->copy (copy) : copy;
}
source_uri = g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
- source = midori_view_new (NULL);
- midori_view_set_settings (MIDORI_VIEW (source), browser->settings);
+ source = midori_view_new_with_title (NULL, browser->settings, FALSE);
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_load_uri (WEBKIT_WEB_VIEW (source_view), source_uri);
- gtk_widget_show (source);
midori_browser_add_tab (browser, source);
}
else
KatzeItem* item)
{
const gchar* uri;
- const gchar* title;
GtkWidget* view;
gint page;
- KatzeItem* proxy_item;
- GList* keys;
g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
g_return_val_if_fail (KATZE_IS_ITEM (item), -1);
uri = katze_item_get_uri (item);
- if (!uri)
- uri = "about:blank";
- title = katze_item_get_name (item);
- view = midori_view_new_with_title (title, browser->settings,
+ view = midori_view_new_with_item (item, browser->settings,
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);
/* Blank pages should not be delayed */
else
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;
}
/**
* 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
MidoriWebSettings* settings,
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)
_midori_view_set_settings (view, settings);
if (append)
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);
return (GtkWidget*)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 = "";
-
if (g_getenv ("MIDORI_UNARMED") == NULL)
{
- if (!strcmp (uri, ""))
+ if (!uri || !strcmp (uri, "") || !strcmp (uri, "about:blank"))
{
#ifdef G_ENABLE_DEBUG
GTimer* timer = NULL;
* as a title. Most of the time this will be the title
* or the current URI.
*
- * An empty page is represented as "about:blank".
- *
* You can assume that the string is not %NULL.
*
* Return value: a title string
{
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);
midori_view_set_uri (view, uri);
MidoriWebSettings* settings,
gboolean append);
+GtkWidget*
+midori_view_new_with_item (KatzeItem* item,
+ MidoriWebSettings* settings,
+ gboolean append);
+
void
midori_view_set_settings (MidoriView* view,
MidoriWebSettings* settings);