G_TYPE_NONE, 1,
GTK_TYPE_MENU);
- iface->p = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
iface->get_stock_id = midori_viewable_default_get_stock_id;
iface->get_label = midori_viewable_default_get_label;
iface->get_toolbar = midori_viewable_default_get_toolbar;
static void
midori_viewable_base_finalize (MidoriViewableIface* iface)
{
- g_hash_table_destroy (iface->p);
-}
-
-/**
- * midori_viewable_new_from_uri:
- * @uri: an URI
- *
- * Attempts to create a new #MidoriViewable from the specified URI.
- *
- * The protocol of @uri must previously have been registered by
- * the #MidoriViewable via midori_viewable_register_protocol().
- *
- * Return value: a new #MidoriViewable, or %NULL
- *
- * Deprecated: 0.2.6
- **/
-GtkWidget*
-midori_viewable_new_from_uri (const gchar* uri)
-{
- MidoriViewableIface* iface;
- gchar** parts;
- gchar* type_name;
- GType type;
-
- if (!(iface = g_type_default_interface_peek (MIDORI_TYPE_VIEWABLE)))
- {
- g_warning ("No viewable interface available");
- return NULL;
- }
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (!g_hash_table_size (iface->p))
- return NULL;
-
- if ((parts = g_strsplit (uri, "://", 2)))
- {
- if (!(type_name = g_hash_table_lookup (iface->p, parts[0])))
- {
- /* FIXME: Support midori://dummy/foo */
-
- type_name = g_hash_table_lookup (iface->p, uri);
- }
- g_strfreev (parts);
- if (type_name)
- {
- type = g_type_from_name (type_name);
- g_free (type_name);
- if (type)
- return g_object_new (type, "uri", uri, NULL);
- }
- }
- else if ((parts = g_strsplit_set (uri, ":", 2)))
- {
- type_name = g_hash_table_lookup (iface->p, parts[0]);
- g_strfreev (parts);
- if (type_name)
- {
- type = g_type_from_name (type_name);
- g_free (type_name);
- if (type)
- return g_object_new (type, "uri", uri, NULL);
- }
- }
- return NULL;
-}
-
-static gboolean
-viewable_type_implements (GType type,
- GType interface)
-{
- GType *interfaces;
- guint i;
-
- if (!(interfaces = g_type_interfaces (type, NULL)))
- return FALSE;
- for (i = 0; interfaces[i]; i++)
- {
- if (interfaces[i] == interface)
- {
- g_free (interfaces);
- return TRUE;
- }
- }
- g_free (interfaces);
- return FALSE;
-}
-
-/**
- * midori_viewable_register_protocol:
- * @type: a type that implements #MidoriViewable
- * @protocol: a protocol
- *
- * Registers the specified protocol as supported by @type.
- *
- * The following kinds of protocols are supported:
- *
- * "dummy": support URIs like "dummy://foo/bar"
- * "about:dummy": support URIs like "about:dummy"
- * FIXME: The following is not yet fully supported
- * "midori://dummy": support URIs like "midori://dummy/foo"
- *
- * Return value: a new #MidoriViewable, or %NULL
- *
- * Deprecated: 0.2.6
- **/
-void
-midori_viewable_register_protocol (GType type,
- const gchar* protocol)
-{
- MidoriViewableIface* iface;
- GObjectClass* class;
-
- if (!(iface = g_type_default_interface_peek (MIDORI_TYPE_VIEWABLE)))
- {
- g_warning ("No viewable interface available");
- return;
- }
-
- g_return_if_fail (viewable_type_implements (type, MIDORI_TYPE_VIEWABLE));
-
- if (!(class = g_type_class_peek (type)))
- {
- g_warning ("No class for %s available", g_type_name (type));
- return;
- }
- g_return_if_fail (g_object_class_find_property (class, "uri"));
- /* FIXME: Verify the syntax of protocol */
-
- g_hash_table_insert (iface->p, g_strdup (protocol),
- g_strdup (g_type_name (type)));
}
/**