From 39e47ac3b7b355f403f1a735d8e5af67d3c8b2d5 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 10 Sep 2009 02:02:49 +0200 Subject: [PATCH] Disable extensions that are unavailable on the system 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 | 8 ++++++-- extensions/toolbar-editor.c | 8 +++++--- midori/main.c | 4 ++-- panels/midori-extensions.c | 24 +++++++++++++++++------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/extensions/adblock.c b/extensions/adblock.c index d49ea392..3624be9a 100644 --- a/extensions/adblock.c +++ b/extensions/adblock.c @@ -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 ", 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 diff --git a/extensions/toolbar-editor.c b/extensions/toolbar-editor.c index dd038a94..2a39057a 100644 --- a/extensions/toolbar-editor.c +++ b/extensions/toolbar-editor.c @@ -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 ", NULL); + #if !HAVE_HILDON g_signal_connect(extension, "activate", G_CALLBACK(tb_editor_activate_cb), NULL); + #endif return extension; } - - -#endif diff --git a/midori/main.c b/midori/main.c index d445ae13..19aed56d 100644 --- a/midori/main.c +++ b/midori/main.c @@ -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 { diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c index 1dec4d1b..5bbaa9ab 100644 --- a/panels/midori-extensions.c +++ b/panels/midori-extensions.c @@ -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 ("%s %s\n%s", name, version, desc); + text = g_markup_printf_escaped ("%s %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; + MidoriExtension* extension; 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; + MidoriExtension* extension; 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); -- 2.39.5