]> spindle.queued.net Git - midori/commitdiff
Listen for (de)activation of extensions and save the config
authorChristian Dywan <christian@twotoasts.de>
Sun, 7 Jun 2009 00:15:32 +0000 (02:15 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 7 Jun 2009 00:15:32 +0000 (02:15 +0200)
midori/main.c

index 1c3b26a05ac8b7c8bd12d076fcb153bcd88eb2fd..7f4726147cbad134aaf427089d12d279365b39de 100644 (file)
@@ -744,6 +744,15 @@ settings_notify_cb (MidoriWebSettings* settings,
     g_free (config_file);
 }
 
+static void
+extension_activate_cb (MidoriExtension* extension,
+                       MidoriApp*       app)
+{
+    MidoriWebSettings* settings = katze_object_get_object (app, "settings");
+    settings_notify_cb (settings, NULL, app);
+    g_object_unref (settings);
+}
+
 static void
 accel_map_changed_cb (GtkAccelMap*    accel_map,
                       gchar*          accel_path,
@@ -1185,6 +1194,8 @@ midori_load_extensions (gpointer data)
         if (extension_dir != NULL)
         {
             const gchar* filename;
+            gchar* config_file = build_config_filename ("config");
+            gboolean is_writable = is_writable (config_file);
 
             while ((filename = g_dir_read_name (extension_dir)))
             {
@@ -1228,9 +1239,17 @@ midori_load_extensions (gpointer data)
                         if (!g_strcmp0 (filename, name))
                             g_signal_emit_by_name (extension, "activate", app);
                 }
+                if (is_writable)
+                {
+                    g_signal_connect_after (extension, "activate",
+                        G_CALLBACK (extension_activate_cb), app);
+                    g_signal_connect_after (extension, "deactivate",
+                        G_CALLBACK (extension_activate_cb), app);
+                }
                 g_object_unref (extension);
             }
             g_dir_close (extension_dir);
+            g_free (config_file);
         }
         g_free (extension_path);
     }