Disable spell check option if there are no enchant modules

This commit is contained in:
Christian Dywan 2011-08-04 23:29:56 +02:00
parent 49d7ae1fad
commit e6ecd20be4
4 changed files with 37 additions and 17 deletions

View file

@ -1197,27 +1197,11 @@ midori_load_extensions (gpointer data)
g_object_set (app, "extensions", extensions, NULL); g_object_set (app, "extensions", extensions, NULL);
if (g_module_supported ()) if (g_module_supported ())
{ {
/* FIXME: Read extensions from system data dirs */
gchar* extension_path; gchar* extension_path;
GDir* extension_dir; GDir* extension_dir;
if (!(extension_path = g_strdup (g_getenv ("MIDORI_EXTENSION_PATH")))) if (!(extension_path = g_strdup (g_getenv ("MIDORI_EXTENSION_PATH"))))
{ extension_path = sokoke_find_lib_path (PACKAGE_NAME);
#ifdef G_OS_WIN32
{
gchar *path = g_win32_get_package_installation_directory_of_module (NULL);
extension_path = g_build_filename (path, "lib", PACKAGE_NAME, NULL);
g_free (path);
if (g_access (extension_path, F_OK) != 0)
{
g_free (extension_path);
extension_path = g_build_filename (LIBDIR, PACKAGE_NAME, NULL);
}
}
#else
extension_path = g_build_filename (LIBDIR, PACKAGE_NAME, NULL);
#endif
}
extension_dir = g_dir_open (extension_path, 0, NULL); extension_dir = g_dir_open (extension_path, 0, NULL);
if (extension_dir != NULL) if (extension_dir != NULL)
{ {

View file

@ -357,6 +357,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
INDENTED_ADD (button); INDENTED_ADD (button);
button = katze_property_proxy (settings, "enable-spell-checking", NULL); button = katze_property_proxy (settings, "enable-spell-checking", NULL);
SPANNED_ADD (button); SPANNED_ADD (button);
/* Disable spell check option if there are no enchant modules */
{
gchar* enchant_path = sokoke_find_lib_path ("enchant");
if (enchant_path == NULL)
gtk_widget_set_sensitive (button, FALSE);
else
g_free (enchant_path);
}
button = katze_property_proxy (settings, "enable-scripts", NULL); button = katze_property_proxy (settings, "enable-scripts", NULL);
INDENTED_ADD (button); INDENTED_ADD (button);
button = katze_property_proxy (settings, "enable-plugins", NULL); button = katze_property_proxy (settings, "enable-plugins", NULL);

View file

@ -1705,6 +1705,31 @@ sokoke_find_config_filename (const gchar* folder,
return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL); return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL);
} }
/**
* sokoke_find_lib_path:
* @folder: the lib subfolder
*
* Looks for the specified folder in the lib directories.
*
* Return value: a newly allocated full path, or %NULL
**/
gchar* sokoke_find_lib_path (const gchar* folder)
{
#ifdef G_OS_WIN32
gchar* path = g_win32_get_package_installation_directory_of_module (NULL);
gchar* lib_path = g_build_filename (path, "lib", folder ? folder : "", NULL);
g_free (path);
if (g_access (lib_path, F_OK) == 0)
return lib_path;
#else
gchar* lib_path = g_build_filename (LIBDIR, folder ? folder : "", NULL);
if (g_access (lib_path, F_OK) == 0)
return lib_path;
#endif
return NULL;
}
/** /**
* sokoke_find_data_filename: * sokoke_find_data_filename:
* @filename: a filename or relative path * @filename: a filename or relative path

View file

@ -225,6 +225,9 @@ gchar*
sokoke_find_config_filename (const gchar* folder, sokoke_find_config_filename (const gchar* folder,
const gchar* filename); const gchar* filename);
gchar*
sokoke_find_lib_path (const gchar* folder);
gchar* gchar*
sokoke_find_data_filename (const gchar* filename); sokoke_find_data_filename (const gchar* filename);