]> spindle.queued.net Git - midori/commitdiff
Disable extensions that are unavailable on the system
authorChristian Dywan <christian@twotoasts.de>
Thu, 10 Sep 2009 00:02:49 +0000 (02:02 +0200)
committerChristian Dywan <christian@twotoasts.de>
Thu, 10 Sep 2009 00:07:27 +0000 (02:07 +0200)
Extensions can be unavailable on a particular platform or a system
lacking a build-time requirement. Let's handle this more cleanly
and reflect it in the Extensions panel.

extensions/adblock.c
extensions/toolbar-editor.c
midori/main.c
panels/midori-extensions.c

index d49ea392a28b28b7403e61c526d8de8e46112b5e..3624be9a50ef54828ad5e2fde12da6e1b3d4a98d 100644 (file)
@@ -561,21 +561,25 @@ extension_test (void)
 }
 #endif
 
+#endif
+
 MidoriExtension*
 extension_init (void)
 {
     MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
         "name", _("Advertisement blocker"),
         "description", _("Block advertisements according to a filter list"),
+        #if WEBKIT_CHECK_VERSION (1, 1, 14)
         "version", "0.1",
+        #endif
         "authors", "Christian Dywan <christian@twotoasts.de>",
         NULL);
+    #if WEBKIT_CHECK_VERSION (1, 1, 14)
     midori_extension_install_string_list (extension, "filters", NULL, G_MAXSIZE);
 
     g_signal_connect (extension, "activate",
         G_CALLBACK (adblock_activate_cb), NULL);
+    #endif
 
     return extension;
 }
-
-#endif
index dd038a94c58d2167253def6d80a31550716c427d..2a39057adec3938a3fe37c6adfc6413f8c02ddd6 100644 (file)
@@ -604,20 +604,22 @@ static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app)
        g_object_unref(browsers);
 }
 
+#endif
 
 MidoriExtension *extension_init(void)
 {
        MidoriExtension* extension = g_object_new(MIDORI_TYPE_EXTENSION,
                "name", _("Toolbar Editor"),
                "description", _("Easily edit the toolbar layout"),
+               #if !HAVE_HILDON
                "version", "0.1",
+               #endif
                "authors", "Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>",
                NULL);
 
+       #if !HAVE_HILDON
        g_signal_connect(extension, "activate", G_CALLBACK(tb_editor_activate_cb), NULL);
+       #endif
 
        return extension;
 }
-
-
-#endif
index d445ae13c28dbbf72a3b859d31a710a3dfb1871a..19aed56dbd0db25e374db0880037d8e834a75681 100644 (file)
@@ -1300,11 +1300,11 @@ midori_load_extensions (gpointer data)
                                                (gpointer) &extension_init))
                 {
                     extension = extension_init ();
-                    /* FIXME: Validate the extension */
                     /* Signal that we want the extension to load and save */
                     g_object_set_data_full (G_OBJECT (extension), "filename",
                                             g_strdup (filename), g_free);
-                    midori_extension_get_config_dir (extension);
+                    if (midori_extension_is_prepared (extension))
+                        midori_extension_get_config_dir (extension);
                 }
                 else
                 {
index 1dec4d1bec829a94ffc33133bf530adbdf8d9001..5bbaa9ab3226273133df10994790884e3167ad08 100644 (file)
@@ -221,7 +221,10 @@ midori_extensions_treeview_render_tick_cb (GtkTreeViewColumn* column,
 
     gtk_tree_model_get (model, iter, 0, &extension, -1);
 
-    g_object_set (renderer, "active", midori_extension_is_active (extension), NULL);
+    g_object_set (renderer,
+        "activatable", midori_extension_is_prepared (extension),
+        "active", midori_extension_is_active (extension),
+        NULL);
 
     g_object_unref (extension);
 }
@@ -244,12 +247,16 @@ midori_extensions_treeview_render_text_cb (GtkTreeViewColumn* column,
     name = katze_object_get_string (extension, "name");
     version = katze_object_get_string (extension, "version");
     desc = katze_object_get_string (extension, "description");
-    text = g_markup_printf_escaped ("<b>%s</b> %s\n%s", name, version, desc);
+    text = g_markup_printf_escaped ("<b>%s</b> %s\n%s",
+        name, version && *version ? version : "", desc);
     g_free (name);
     g_free (version);
     g_free (desc);
 
-    g_object_set (renderer, "markup", text, NULL);
+    g_object_set (renderer,
+        "markup", text,
+        "sensitive", midori_extension_is_prepared (extension),
+        NULL);
 
     g_free (text);
     g_object_unref (extension);
@@ -272,7 +279,7 @@ midori_extensions_treeview_row_activated_cb (GtkTreeView*       treeview,
         gtk_tree_model_get (model, &iter, 0, &extension, -1);
         if (midori_extension_is_active (extension))
             midori_extension_deactivate (extension);
-        else
+        else if (midori_extension_is_prepared (extension))
             g_signal_emit_by_name (extension, "activate", extensions->app);
 
         g_object_unref (extension);
@@ -410,7 +417,7 @@ midori_extensions_button_release_event_cb (GtkWidget*         widget,
 
     if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
     {
-        MidoriExtension *extension;
+        MidoriExtensionextension;
 
         gtk_tree_model_get (model, &iter, 0, &extension, -1);
 
@@ -432,12 +439,12 @@ midori_extensions_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer,
     model = gtk_tree_view_get_model (GTK_TREE_VIEW (extensions->treeview));
     if (gtk_tree_model_get_iter_from_string (model, &iter, path))
     {
-        MidoriExtension *extension;
+        MidoriExtensionextension;
 
         gtk_tree_model_get (model, &iter, 0, &extension, -1);
         if (midori_extension_is_active (extension))
             midori_extension_deactivate (extension);
-        else
+        else if (midori_extension_is_prepared (extension))
             g_signal_emit_by_name (extension, "activate", extensions->app);
 
         g_object_unref (extension);
@@ -460,6 +467,9 @@ midori_extensions_tree_sort_func (GtkTreeModel* model,
     name1 = katze_object_get_string (e1, "name");
     name2 = katze_object_get_string (e2, "name");
 
+    g_object_unref (e1);
+    g_object_unref (e2);
+
     result = g_strcmp0 (name1, name2);
 
     g_free (name1);