diff options
Diffstat (limited to 'embed/ephy-embed-factory.c')
-rw-r--r-- | embed/ephy-embed-factory.c | 71 |
1 files changed, 21 insertions, 50 deletions
diff --git a/embed/ephy-embed-factory.c b/embed/ephy-embed-factory.c index 5a81004f0..ef382c9eb 100644 --- a/embed/ephy-embed-factory.c +++ b/embed/ephy-embed-factory.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 Marco Pesenti Gritti + * Copyright (C) 2000-2004 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,68 +26,39 @@ #include "mozilla-embed.h" #include "mozilla-embed-persist.h" #include "mozilla-embed-single.h" +#include "ephy-embed.h" +#include "ephy-embed-persist.h" +#include "ephy-embed-single.h" -#include <string.h> - -typedef enum -{ - EPHY_EMBED_OBJECT, - EPHY_EMBED_PERSIST_OBJECT, - EPHY_EMBED_SINGLE_OBJECT -} EmbedObjectType; - -static EmbedObjectType -type_from_id (const char *object_id) +/** + * ephy_embed_factory_new_object: + * @type: a #GType specifying which object to create + * + * Create an instance of an object implementing the @type interface. + * + * Return value: the object instance + **/ +GObject * +ephy_embed_factory_new_object (GType type) { - EmbedObjectType result = 0; + GObject *object = NULL; - if (strcmp (object_id, "EphyEmbed") == 0) + if (type == EPHY_TYPE_EMBED) { - result = EPHY_EMBED_OBJECT; + object = g_object_new (MOZILLA_TYPE_EMBED, NULL); } - else if (strcmp (object_id, "EphyEmbedPersist") == 0) + else if (type == EPHY_TYPE_EMBED_PERSIST) { - result = EPHY_EMBED_PERSIST_OBJECT; + object = g_object_new (MOZILLA_TYPE_EMBED_PERSIST, NULL); } - else if (strcmp (object_id, "EphyEmbedSingle") == 0) + else if (type == EPHY_TYPE_EMBED_SINGLE) { - result = EPHY_EMBED_SINGLE_OBJECT; + object = g_object_new (MOZILLA_TYPE_EMBED_SINGLE, NULL); } else { g_assert_not_reached (); } - return result; -} - -/** - * ephy_embed_factory_new_object: - * @object_id: identifier of the object to create - * - * Create an instance of the object identified by @object_id. - * - * Return value: the object instance - **/ -GObject * -ephy_embed_factory_new_object (const char *object_id) -{ - GObject *object; - - switch (type_from_id (object_id)) - { - case EPHY_EMBED_OBJECT: - object = g_object_new (MOZILLA_TYPE_EMBED, NULL); - break; - case EPHY_EMBED_PERSIST_OBJECT: - object = g_object_new (MOZILLA_TYPE_EMBED_PERSIST, NULL); - break; - case EPHY_EMBED_SINGLE_OBJECT: - object = g_object_new (MOZILLA_TYPE_EMBED_SINGLE, NULL); - break; - default: - object = NULL; - } - return object; } |