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.
This commit is contained in:
parent
a32cc0908e
commit
d0ef9c6575
3 changed files with 62 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ();
|
||||
|
|
Loading…
Reference in a new issue