{
if (error->code == G_FILE_ERROR_NOENT)
{
- gchar* config_file = sokoke_find_config_filename ("config");
+ gchar* config_file = sokoke_find_config_filename (NULL, "config");
g_key_file_load_from_file (key_file, config_file,
G_KEY_FILE_KEEP_COMMENTS, NULL);
}
search_engines = search_engines_new_from_file (config_file, NULL);
#else
katze_assign (config_file,
- sokoke_find_config_filename ("search"));
+ sokoke_find_config_filename (NULL, "search"));
search_engines = search_engines_new_from_file (config_file, NULL);
#endif
}
if (error->code == G_FILE_ERROR_NOENT)
{
katze_assign (config_file,
- sokoke_find_config_filename ("bookmarks.xbel"));
+ sokoke_find_config_filename (NULL, "bookmarks.xbel"));
midori_array_from_file (bookmarks, config_file, "xbel", NULL);
}
else
if (!g_key_file_load_from_file (extension->priv->key_file, config_file,
G_KEY_FILE_KEEP_COMMENTS, &error))
{
- if (error->code != G_FILE_ERROR_NOENT)
+ if (error->code == G_FILE_ERROR_NOENT)
+ {
+ gchar* filename = g_object_get_data (G_OBJECT (extension), "filename");
+ gchar* folder = g_strconcat ("extensions/", filename, NULL);
+ katze_assign (config_file,
+ sokoke_find_config_filename (folder, "config"));
+ g_key_file_load_from_file (extension->priv->key_file, config_file,
+ G_KEY_FILE_KEEP_COMMENTS, NULL);
+ }
+ else
printf (_("The configuration of the extension '%s' couldn't be loaded: %s\n"),
extension->priv->name, error->message);
g_error_free (error);
}
+ g_free (config_file);
}
while (lsettings)
/**
* sokoke_find_config_filename:
+ * @folder: a subfolder
* @filename: a filename or relative path
*
* Looks for the specified filename in the system config
* Return value: a full path
**/
gchar*
-sokoke_find_config_filename (const gchar* filename)
+sokoke_find_config_filename (const gchar* folder,
+ const gchar* filename)
{
const gchar* const* config_dirs = g_get_system_config_dirs ();
guint i = 0;
const gchar* config_dir;
+ if (!folder)
+ folder = "";
+
while ((config_dir = config_dirs[i++]))
{
- gchar* path = g_build_filename (config_dir, PACKAGE_NAME, filename, NULL);
+ gchar* path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
}
- return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, filename, NULL);
+ return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL);
}
/**
gboolean ignore_errors);
gchar*
-sokoke_find_config_filename (const gchar* filename);
+sokoke_find_config_filename (const gchar* folder,
+ const gchar* filename);
gchar*
sokoke_find_data_filename (const gchar* filename);