]> spindle.queued.net Git - midori/commitdiff
New property "key" for Midori.Extension object
authorAndré Stösel <andre@stoesel.de>
Sat, 31 Mar 2012 15:19:01 +0000 (17:19 +0200)
committerChristian Dywan <christian@twotoasts.de>
Thu, 5 Apr 2012 20:43:58 +0000 (22:43 +0200)
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
midori/midori-extension.c
midori/midori.vapi

index 6d995f6581b2cb7bcd8a46b454bc4cf732dda433..3a4c9171ad4b63a4dac2baed03b5fa9cfa9a3598 100644 (file)
@@ -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);
index 7927e72f067aed0604f35e3773273ad646eccc44..28156342cc0879f589bd1b6713cc81e41cbd66f6 100644 (file)
@@ -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;
index c9d9f6466b7b7dfd07825b78e2a01a7ff08cd2f8..61c5990d55f60ac41c0d7e646a292b3e6c835e87 100644 (file)
@@ -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 ();