From d0ef9c65750d14989872303092de8a6ad58ce1d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20St=C3=B6sel?= Date: Sat, 31 Mar 2012 17:19:01 +0200 Subject: [PATCH] New property "key" for Midori.Extension object This property is needed if the module contains more than one extension. Add properties "website" and "key" to the vapi. If the extension has a key, it should be used as part of the config filename. --- midori/main.c | 34 +++++++++++++++++++++++++++++++--- midori/midori-extension.c | 28 +++++++++++++++++++++++++++- midori/midori.vapi | 4 ++++ 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/midori/main.c b/midori/main.c index 6d995f65..3a4c9171 100644 --- a/midori/main.c +++ b/midori/main.c @@ -264,8 +264,24 @@ settings_save_to_file (MidoriWebSettings* settings, { KATZE_ARRAY_FOREACH_ITEM (extension, extensions) if (midori_extension_is_active (extension)) - g_key_file_set_boolean (key_file, "extensions", - g_object_get_data (G_OBJECT (extension), "filename"), TRUE); + { + const gchar* filename = g_object_get_data ( + G_OBJECT (extension), "filename"); + + gchar* key; + gchar* term; + + key = katze_object_get_string (extension, "key"); + if (key && *key) + term = g_strdup_printf ("%s/%s", filename, key); + else + term = g_strdup (filename); + + g_key_file_set_boolean (key_file, "extensions", term, TRUE); + + g_free (key); + g_free (term); + } g_object_unref (extensions); } else if ((_extensions = g_object_get_data (G_OBJECT (app), "extensions"))) @@ -1246,10 +1262,22 @@ midori_load_extension (MidoriApp* app, if (active_extensions) { guint i = 0; + gchar* key; gchar* name; + gchar* term; + + key = katze_object_get_string (extension, "key"); + if (key && *key) + term = g_strdup_printf ("%s/%s", filename, key); + else + term = g_strdup (filename); + while ((name = active_extensions[i++])) - if (!g_strcmp0 (filename, name)) + if (!g_strcmp0 (term, name)) g_signal_emit_by_name (extension, "activate", app); + + g_free (key); + g_free (term); } g_signal_connect_after (extension, "activate", G_CALLBACK (extension_activate_cb), app); diff --git a/midori/midori-extension.c b/midori/midori-extension.c index 7927e72f..28156342 100644 --- a/midori/midori-extension.c +++ b/midori/midori-extension.c @@ -25,6 +25,7 @@ struct _MidoriExtensionPrivate gchar* version; gchar* authors; gchar* website; + gchar* key; MidoriApp* app; gint active; @@ -127,7 +128,8 @@ enum PROP_DESCRIPTION, PROP_VERSION, PROP_AUTHORS, - PROP_WEBSITE + PROP_WEBSITE, + PROP_KEY }; enum { @@ -260,6 +262,23 @@ midori_extension_class_init (MidoriExtensionClass* class) NULL, flags)); + /** + * MidoriExtension:key: + * + * The extension key. + * Needed if there is more than one extension object in a single module. + * + * Since: 0.4.5 + */ + g_object_class_install_property (gobject_class, + PROP_KEY, + g_param_spec_string ( + "key", + "Key", + "The extension key", + NULL, + flags)); + g_type_class_add_private (class, sizeof (MidoriExtensionPrivate)); } @@ -400,6 +419,7 @@ midori_extension_finalize (GObject* object) katze_assign (extension->priv->version, NULL); katze_assign (extension->priv->authors, NULL); katze_assign (extension->priv->website, NULL); + katze_assign (extension->priv->key, NULL); katze_assign (extension->priv->config_dir, NULL); g_list_free (extension->priv->lsettings); @@ -446,6 +466,9 @@ midori_extension_set_property (GObject* object, case PROP_WEBSITE: katze_assign (extension->priv->website, g_value_dup_string (value)); break; + case PROP_KEY: + katze_assign (extension->priv->key, g_value_dup_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -477,6 +500,9 @@ midori_extension_get_property (GObject* object, case PROP_WEBSITE: g_value_set_string (value, extension->priv->website); break; + case PROP_KEY: + g_value_set_string (value, extension->priv->key); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/midori/midori.vapi b/midori/midori.vapi index c9d9f646..61c5990d 100644 --- a/midori/midori.vapi +++ b/midori/midori.vapi @@ -115,6 +115,10 @@ namespace Midori { public string version { get; set; } [NoAccessorMethod] public string authors { get; set; } + [NoAccessorMethod] + public string website { get; set; } + [NoAccessorMethod] + public string key { get; set; } public signal void activate (Midori.App app); public signal void deactivate (); -- 2.39.5