From b7e88574c50e3e5671b3f14173ce7525afa62a68 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 12 Sep 2010 21:03:14 +0200 Subject: [PATCH] Remove the viewable scheme registration mechanism --- midori/midori-viewable.c | 133 --------------------------------------- midori/midori-viewable.h | 12 ---- 2 files changed, 145 deletions(-) diff --git a/midori/midori-viewable.c b/midori/midori-viewable.c index 566f847e..f17c305a 100644 --- a/midori/midori-viewable.c +++ b/midori/midori-viewable.c @@ -97,8 +97,6 @@ midori_viewable_base_init (MidoriViewableIface* iface) 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; @@ -109,137 +107,6 @@ midori_viewable_base_init (MidoriViewableIface* iface) 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))); } /** diff --git a/midori/midori-viewable.h b/midori/midori-viewable.h index fca3e603..7e36c7b0 100644 --- a/midori/midori-viewable.h +++ b/midori/midori-viewable.h @@ -12,8 +12,6 @@ #ifndef __MIDORI_VIEWABLE_H__ #define __MIDORI_VIEWABLE_H__ -#include - #include G_BEGIN_DECLS @@ -44,21 +42,11 @@ struct _MidoriViewableIface GtkWidget* (*get_toolbar) (MidoriViewable* viewable); - - /* Private data */ - gpointer p; }; GType midori_viewable_get_type (void) G_GNUC_CONST; -GtkWidget* -midori_viewable_new_from_uri (const gchar* uri); - -void -midori_viewable_register_protocol (GType type, - const gchar* protocol); - const gchar* midori_viewable_get_stock_id (MidoriViewable* viewable); -- 2.39.5