[Xfce4-commits] <midori:master> Disable spell check option if there are no enchant modules

Christian Dywan noreply at xfce.org
Thu Aug 4 23:32:01 CEST 2011


Updating branch refs/heads/master
         to e6ecd20be4085f16e5f750a43c894ca0034d131b (commit)
       from 49d7ae1fad3acc3359b3575bf693ed3d7de46ca2 (commit)

commit e6ecd20be4085f16e5f750a43c894ca0034d131b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Aug 4 23:29:56 2011 +0200

    Disable spell check option if there are no enchant modules

 midori/main.c               |   18 +-----------------
 midori/midori-preferences.c |    8 ++++++++
 midori/sokoke.c             |   25 +++++++++++++++++++++++++
 midori/sokoke.h             |    3 +++
 4 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index b7dd32e..14805c9 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 5cba2c9..de4f30d 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 e1fb17a..9969a86 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1706,6 +1706,31 @@ sokoke_find_config_filename (const gchar* folder,
 }
 
 /**
+ * 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 6768556..2632b14 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -226,6 +226,9 @@ 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);
 
 gchar**


More information about the Xfce4-commits mailing list