]> spindle.queued.net Git - midori/commitdiff
Disable spell check option if there are no enchant modules
authorChristian Dywan <christian@twotoasts.de>
Thu, 4 Aug 2011 21:29:56 +0000 (23:29 +0200)
committerChristian Dywan <christian@twotoasts.de>
Thu, 4 Aug 2011 21:29:56 +0000 (23:29 +0200)
midori/main.c
midori/midori-preferences.c
midori/sokoke.c
midori/sokoke.h

index b7dd32e0a589a092353195c68b9d1c9077ee9c5a..14805c9d508d8dedd62c0e9a021088d5cfa4a90f 100644 (file)
@@ -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)
         {
index 5cba2c9c782cce4752318bd9ea587d614b20b5a2..de4f30d8205e9cf06b9a0809e72743ccaa151966 100644 (file)
@@ -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);
index e1fb17a6bc68a9329d3f521f9a22269e7468e8c5..9969a869f503a9c0b14697bd02306a4592c81797 100644 (file)
@@ -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
index 6768556a09e55bcd440751dc681da7dceb62cd67..2632b14b87346f1539cd27556cf14131cb4781de 100644 (file)
@@ -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);