From: Christian Dywan Date: Thu, 4 Aug 2011 21:29:56 +0000 (+0200) Subject: Disable spell check option if there are no enchant modules X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6ecd20be4085f16e5f750a43c894ca0034d131b;p=midori Disable spell check option if there are no enchant modules --- diff --git a/midori/main.c b/midori/main.c index b7dd32e0..14805c9d 100644 --- a/midori/main.c +++ b/midori/main.c @@ -1197,27 +1197,11 @@ midori_load_extensions (gpointer data) g_object_set (app, "extensions", extensions, NULL); if (g_module_supported ()) { - /* FIXME: Read extensions from system data dirs */ gchar* extension_path; GDir* extension_dir; if (!(extension_path = g_strdup (g_getenv ("MIDORI_EXTENSION_PATH")))) - { - #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_path = sokoke_find_lib_path (PACKAGE_NAME); extension_dir = g_dir_open (extension_path, 0, NULL); if (extension_dir != NULL) { diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index 5cba2c9c..de4f30d8 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -357,6 +357,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences, INDENTED_ADD (button); button = katze_property_proxy (settings, "enable-spell-checking", NULL); 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); INDENTED_ADD (button); button = katze_property_proxy (settings, "enable-plugins", NULL); diff --git a/midori/sokoke.c b/midori/sokoke.c index e1fb17a6..9969a869 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -1705,6 +1705,31 @@ sokoke_find_config_filename (const gchar* folder, 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: * @filename: a filename or relative path diff --git a/midori/sokoke.h b/midori/sokoke.h index 6768556a..2632b14b 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -225,6 +225,9 @@ gchar* sokoke_find_config_filename (const gchar* folder, const gchar* filename); +gchar* +sokoke_find_lib_path (const gchar* folder); + gchar* sokoke_find_data_filename (const gchar* filename);