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.
This commit is contained in:
Christian Dywan 2009-09-10 02:02:49 +02:00
parent e59b291709
commit 39e47ac3b7
4 changed files with 30 additions and 14 deletions

View 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

View 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

View file

@ -1300,10 +1300,10 @@ 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);
if (midori_extension_is_prepared (extension))
midori_extension_get_config_dir (extension);
}
else

View 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);
@ -437,7 +444,7 @@ midori_extensions_cell_renderer_toggled_cb (GtkCellRendererToggle* renderer,
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);