Move config/ data/ res_filename/ lib_path to Midori.Paths

This commit is contained in:
Christian Dywan 2012-08-29 20:19:05 +02:00
parent 3fbd36f3f5
commit 0668aba7cc
12 changed files with 156 additions and 262 deletions

View file

@ -15,6 +15,11 @@ namespace GLib {
#endif #endif
} }
extern const string LIBDIR;
extern const string MDATADIR;
extern const string PACKAGE_NAME;
extern const string SYSCONFDIR;
namespace Midori { namespace Midori {
public enum RuntimeMode { public enum RuntimeMode {
UNDEFINED, UNDEFINED,
@ -25,7 +30,10 @@ namespace Midori {
} }
namespace Paths { namespace Paths {
static string? exec_path = null;
static string[] command_line = null;
static RuntimeMode mode = RuntimeMode.UNDEFINED; static RuntimeMode mode = RuntimeMode.UNDEFINED;
static string? config_dir = null; static string? config_dir = null;
static string? cache_dir = null; static string? cache_dir = null;
static string? user_data_dir = null; static string? user_data_dir = null;
@ -34,16 +42,11 @@ namespace Midori {
public static string get_readonly_config_dir (RuntimeMode new_mode) { public static string get_readonly_config_dir (RuntimeMode new_mode) {
assert (mode == RuntimeMode.UNDEFINED); assert (mode == RuntimeMode.UNDEFINED);
if (new_mode == RuntimeMode.PORTABLE) { if (new_mode == RuntimeMode.PORTABLE) {
#if HAVE_WIN32
string profile = win32_get_package_installation_directory_of_module ();
#else
string profile = "profile://";
#endif
return Path.build_path (Path.DIR_SEPARATOR_S, return Path.build_path (Path.DIR_SEPARATOR_S,
profile, "profile", "config"); exec_path, "profile", "config");
} }
return Path.build_path (Path.DIR_SEPARATOR_S, return Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_user_config_dir (), "midori"); Environment.get_user_config_dir (), PACKAGE_NAME);
} }
public static void init (RuntimeMode new_mode, string? config_base) { public static void init (RuntimeMode new_mode, string? config_base) {
@ -51,19 +54,14 @@ namespace Midori {
assert (new_mode != RuntimeMode.UNDEFINED); assert (new_mode != RuntimeMode.UNDEFINED);
mode = new_mode; mode = new_mode;
if (mode == RuntimeMode.PORTABLE) { if (mode == RuntimeMode.PORTABLE) {
#if HAVE_WIN32
string profile = win32_get_package_installation_directory_of_module ();
#else
string profile = "profile://";
#endif
config_dir = Path.build_path (Path.DIR_SEPARATOR_S, config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
profile, "profile", "config"); exec_path, "profile", "config");
cache_dir = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
profile, "profile", "cache"); exec_path, "profile", "cache");
user_data_dir = Path.build_path (Path.DIR_SEPARATOR_S, user_data_dir = Path.build_path (Path.DIR_SEPARATOR_S,
profile, "profile", "misc"); exec_path, "profile", "misc");
tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S, tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
profile, "profile", "tmp"); exec_path, "profile", "tmp");
} }
else if (mode == RuntimeMode.PRIVATE || mode == RuntimeMode.APP) { else if (mode == RuntimeMode.PRIVATE || mode == RuntimeMode.APP) {
config_dir = "private-or-app://"; config_dir = "private-or-app://";
@ -77,9 +75,9 @@ namespace Midori {
config_dir = config_base; config_dir = config_base;
else else
config_dir = Path.build_path (Path.DIR_SEPARATOR_S, config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_user_config_dir (), "midori"); Environment.get_user_config_dir (), PACKAGE_NAME);
cache_dir = Path.build_path (Path.DIR_SEPARATOR_S, cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_user_cache_dir (), "midori"); Environment.get_user_cache_dir (), PACKAGE_NAME);
user_data_dir = Environment.get_user_data_dir (); user_data_dir = Environment.get_user_data_dir ();
tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S, tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ()); Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
@ -94,24 +92,133 @@ namespace Midori {
return mode == RuntimeMode.APP || mode == RuntimeMode.PRIVATE; return mode == RuntimeMode.APP || mode == RuntimeMode.PRIVATE;
} }
public static string get_config_dir () { public static unowned string get_config_dir () {
assert (config_dir != null); assert (config_dir != null);
return config_dir; return config_dir;
} }
public static string get_cache_dir () { public static unowned string get_cache_dir () {
assert (cache_dir != null); assert (cache_dir != null);
return cache_dir; return cache_dir;
} }
public static string get_user_data_dir () { public static unowned string get_user_data_dir () {
assert (user_data_dir != null); assert (user_data_dir != null);
return user_data_dir; return user_data_dir;
} }
public static string get_tmp_dir () { public static unowned string get_tmp_dir () {
assert (tmp_dir != null); assert (tmp_dir != null);
return tmp_dir; return tmp_dir;
} }
public static void init_exec_path (string[] new_command_line) {
assert (command_line == null);
command_line = new_command_line;
#if HAVE_WIN32
exec_path = win32_get_package_installation_directory_of_module ();
#else
string? executable;
try {
if (!Path.is_absolute (command_line[0])) {
string program = Environment.find_program_in_path (command_line[0]);
if (FileUtils.test (program, FileTest.IS_SYMLINK))
executable = FileUtils.read_link (program);
else
executable = program;
}
else
executable = FileUtils.read_link (command_line[0]);
}
catch (Error error) {
executable = command_line[0];
}
exec_path = File.new_for_path (executable).get_parent ().get_parent ().get_path ();
#endif
if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
stdout.printf ("command_line: %s\nexec_path: %s\nres: %s\nlib: %s\n",
"".joinv (" ", command_line), exec_path,
get_res_filename (""), get_lib_path (PACKAGE_NAME));
}
}
public static unowned string[] get_command_line () {
assert (command_line != null);
return command_line;
}
public static string get_lib_path (string package) {
assert (command_line != null);
string path = Path.build_filename (exec_path, "lib", package);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
if (package == PACKAGE_NAME) {
/* Fallback to build folder */
path = Path.build_filename ((File.new_for_path (exec_path).get_path ()), "extensions");
if (Posix.access (path, Posix.F_OK) == 0)
return path;
}
return Path.build_filename (LIBDIR, PACKAGE_NAME);
}
public static string get_res_filename (string filename) {
assert (command_line != null);
string path = Path.build_filename (exec_path, "share", PACKAGE_NAME, "res", filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
/* Fallback to build folder */
path = Path.build_filename ((File.new_for_path (exec_path)
.get_parent ().get_parent ().get_path ()), "data", filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
return Path.build_filename (MDATADIR, PACKAGE_NAME, "res", filename);
}
public static string get_data_filename (string filename, bool res) {
assert (command_line != null);
string res1 = res ? PACKAGE_NAME : "";
string res2 = res ? "res" : "";
#if HAVE_WIN32
string path = Path.build_filename (exec_path, "share", res1, res2, filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
#else
string path = Path.build_filename (get_user_data_dir (), res1, res2, filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
foreach (string data_dir in Environment.get_system_data_dirs ()) {
path = Path.build_filename (data_dir, res1, res2, filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
}
#endif
return Path.build_filename (MDATADIR, res1, res2, filename);
}
public static string get_config_filename (string? folder, string filename) {
assert (config_dir != null);
foreach (string config_dir in Environment.get_system_config_dirs ()) {
string path = Path.build_filename (config_dir, PACKAGE_NAME, folder ?? "", filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
}
#if HAVE_WIN32
string path = Path.build_filename (exec_path, "etc", "xdg", PACKAGE_NAME, folder ?? "", filename);
if (Posix.access (path, Posix.F_OK) == 0)
return path;
#endif
return Path.build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder ?? "", filename);
}
} }
} }

View file

@ -83,7 +83,7 @@ settings_and_accels_new (const gchar* config,
if (error->code == G_FILE_ERROR_NOENT) if (error->code == G_FILE_ERROR_NOENT)
{ {
GError* inner_error = NULL; GError* inner_error = NULL;
katze_assign (config_file, sokoke_find_config_filename (NULL, "config")); katze_assign (config_file, midori_paths_get_config_filename (NULL, "config"));
g_key_file_load_from_file (key_file, config_file, g_key_file_load_from_file (key_file, config_file,
G_KEY_FILE_KEEP_COMMENTS, &inner_error); G_KEY_FILE_KEEP_COMMENTS, &inner_error);
if (inner_error != NULL) if (inner_error != NULL)
@ -158,7 +158,7 @@ settings_and_accels_new (const gchar* config,
/* Load accelerators */ /* Load accelerators */
katze_assign (config_file, g_build_filename (config, "accels", NULL)); katze_assign (config_file, g_build_filename (config, "accels", NULL));
if (g_access (config_file, F_OK) != 0) if (g_access (config_file, F_OK) != 0)
katze_assign (config_file, sokoke_find_config_filename (NULL, "accels")); katze_assign (config_file, midori_paths_get_config_filename (NULL, "accels"));
gtk_accel_map_load (config_file); gtk_accel_map_load (config_file);
g_free (config_file); g_free (config_file);
@ -364,7 +364,7 @@ search_engines_new_from_folder (const gchar* config,
search_engines = search_engines_new_from_file (config_file, NULL); search_engines = search_engines_new_from_file (config_file, NULL);
#else #else
katze_assign (config_file, katze_assign (config_file,
sokoke_find_config_filename (NULL, "search")); midori_paths_get_config_filename (NULL, "search"));
search_engines = search_engines_new_from_file (config_file, NULL); search_engines = search_engines_new_from_file (config_file, NULL);
#endif #endif
} }
@ -639,7 +639,7 @@ midori_browser_show_preferences_cb (MidoriBrowser* browser,
return; return;
array = katze_object_get_object (app, "extensions"); array = katze_object_get_object (app, "extensions");
if ((extension_path = midori_app_get_lib_path (PACKAGE_NAME))) if ((extension_path = midori_paths_get_lib_path (PACKAGE_NAME)))
{ {
GDir* extension_dir = NULL; GDir* extension_dir = NULL;
if ((extension_dir = g_dir_open (extension_path, 0, NULL))) if ((extension_dir = g_dir_open (extension_path, 0, NULL)))
@ -993,7 +993,7 @@ midori_load_soup_session (gpointer settings)
/* We cannot use "ssl-use-system-ca-file" on Windows /* We cannot use "ssl-use-system-ca-file" on Windows
* some GTLS backend pieces are missing currently. * some GTLS backend pieces are missing currently.
* Instead we specify the bundle we ship ourselves */ * Instead we specify the bundle we ship ourselves */
gchar* certificate_file = midori_app_find_res_filename ("ca-bundle.crt"); gchar* certificate_file = midori_paths_get_res_filename ("ca-bundle.crt");
g_object_set (session, g_object_set (session,
"ssl-ca-file", certificate_file, "ssl-ca-file", certificate_file,
"ssl-strict", FALSE, "ssl-strict", FALSE,
@ -1330,7 +1330,7 @@ midori_load_extensions (gpointer data)
if (g_module_supported ()) if (g_module_supported ())
{ {
gchar* extension_path; gchar* extension_path;
if (keys && (extension_path = midori_app_get_lib_path (PACKAGE_NAME))) if (keys && (extension_path = midori_paths_get_lib_path (PACKAGE_NAME)))
{ {
gint i = 0; gint i = 0;
const gchar* filename; const gchar* filename;

View file

@ -233,7 +233,7 @@ _midori_app_add_browser (MidoriApp* app,
if (app->browser == NULL) if (app->browser == NULL)
{ {
gchar* filename; gchar* filename;
if ((filename = midori_app_find_res_filename ("gtk3.css"))) if ((filename = midori_paths_get_res_filename ("gtk3.css")))
{ {
GtkCssProvider* css_provider = gtk_css_provider_new (); GtkCssProvider* css_provider = gtk_css_provider_new ();
GError* error = NULL; GError* error = NULL;
@ -1342,91 +1342,6 @@ midori_app_send_notification (MidoriApp* app,
#endif #endif
} }
static gchar** command_line = NULL;
static gchar* exec_path = NULL;
/**
* midori_app_get_command_line:
*
* Retrieves the argument vector passed at program startup.
*
* Return value: the argument vector
*
* Since: 0.4.7
**/
gchar**
midori_app_get_command_line (void)
{
return command_line;
}
/**
* midori_app_find_res_filename:
* @filename: a filename or relative path
*
* Looks for the specified filename in Midori's resources.
*
* Return value: a newly allocated full path
*
* Since: 0.4.7
**/
gchar*
midori_app_find_res_filename (const gchar* filename)
{
gchar* path;
path = g_build_filename (exec_path, "share", PACKAGE_NAME, "res", filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
/* Fallback to build folder */
path = g_build_filename (g_file_get_path (g_file_get_parent (
g_file_get_parent (g_file_new_for_path (exec_path)))),
"data", filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
return g_build_filename (MDATADIR, PACKAGE_NAME, "res", filename, NULL);
}
/**
* midori_app_get_lib_path:
* @package: a filename or relative path
*
* Looks for the specified filename in Midori's library path.
*
* Return value: a newly allocated full path
*
* Since: 0.4.7
**/
gchar*
midori_app_get_lib_path (const gchar* package)
{
gchar* path;
path = g_build_filename (exec_path, "lib", package, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
if (!strcmp (package, PACKAGE_NAME))
{
/* Fallback to build folder */
path = g_build_filename (g_file_get_path (
g_file_new_for_path (exec_path)),
"extensions", NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
return g_build_filename (LIBDIR, PACKAGE_NAME, NULL);
}
/** /**
* midori_app_setup: * midori_app_setup:
* *
@ -1445,9 +1360,6 @@ midori_app_setup (gint *argc,
GtkIconSet* icon_set; GtkIconSet* icon_set;
GtkIconFactory* factory; GtkIconFactory* factory;
gsize i; gsize i;
#ifndef G_OS_WIN32
gchar* executable;
#endif
gboolean success; gboolean success;
static GtkStockItem items[] = static GtkStockItem items[] =
@ -1477,6 +1389,11 @@ midori_app_setup (gint *argc,
if (!g_thread_supported ()) g_thread_init (NULL); if (!g_thread_supported ()) g_thread_init (NULL);
#endif #endif
/* Midori.Paths uses GFile */
g_type_init ();
/* Preserve argument vector */
midori_paths_init_exec_path (*argument_vector, *argc);
#if ENABLE_NLS #if ENABLE_NLS
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
if (g_getenv ("MIDORI_NLSPATH")) if (g_getenv ("MIDORI_NLSPATH"))
@ -1484,7 +1401,7 @@ midori_app_setup (gint *argc,
else else
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
{ {
gchar* path = sokoke_find_data_filename ("locale", FALSE); gchar* path = midori_paths_get_data_filename ("locale", FALSE);
bindtextdomain (GETTEXT_PACKAGE, path); bindtextdomain (GETTEXT_PACKAGE, path);
g_free (path); g_free (path);
} }
@ -1495,8 +1412,6 @@ midori_app_setup (gint *argc,
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
#endif #endif
/* Preserve argument vector */
command_line = g_strdupv (*argument_vector);
success = gtk_init_with_args (argc, argument_vector, _("[Addresses]"), success = gtk_init_with_args (argc, argument_vector, _("[Addresses]"),
entries, GETTEXT_PACKAGE, error); entries, GETTEXT_PACKAGE, error);
@ -1515,28 +1430,6 @@ midori_app_setup (gint *argc,
gtk_icon_factory_add_default (factory); gtk_icon_factory_add_default (factory);
g_object_unref (factory); g_object_unref (factory);
#ifdef G_OS_WIN32
exec_path = g_win32_get_package_installation_directory_of_module (NULL);
#else
if (!g_path_is_absolute (command_line[0]))
{
gchar* program = g_find_program_in_path (command_line[0]);
if (g_file_test (program, G_FILE_TEST_IS_SYMLINK))
executable = g_file_read_link (program, NULL);
else
executable = g_strdup (program);
g_free (program);
}
else
executable = g_file_read_link (command_line[0], NULL);
exec_path = g_file_get_path (g_file_get_parent (g_file_get_parent (g_file_new_for_path (
executable ? executable : command_line[0]))));
g_free (executable);
#endif
/* Print messages to stdout on Win32 console, cf. AbiWord /* Print messages to stdout on Win32 console, cf. AbiWord
* http://svn.abisource.com/abiword/trunk/src/wp/main/win/Win32Main.cpp */ * http://svn.abisource.com/abiword/trunk/src/wp/main/win/Win32Main.cpp */
#ifdef _WIN32 #ifdef _WIN32

View file

@ -88,15 +88,6 @@ midori_app_setup (gint *argc,
const GOptionEntry *entries, const GOptionEntry *entries,
GError* *error); GError* *error);
gchar**
midori_app_get_command_line (void);
gchar*
midori_app_find_res_filename (const gchar* filename);
gchar*
midori_app_get_lib_path (const gchar* package);
gboolean gboolean
midori_debug (const gchar* token); midori_debug (const gchar* token);

View file

@ -3812,11 +3812,11 @@ _action_readable_activate (GtkAction* action,
if (!view) if (!view)
return; return;
filename = midori_app_find_res_filename ("faq.css"); filename = midori_paths_get_res_filename ("faq.css");
stylesheet = NULL; stylesheet = NULL;
if (!g_file_get_contents (filename, &stylesheet, NULL, NULL)) if (!g_file_get_contents (filename, &stylesheet, NULL, NULL))
{ {
katze_assign (filename, sokoke_find_data_filename ("doc/midori/faq.css", FALSE)); katze_assign (filename, midori_paths_get_data_filename ("doc/midori/faq.css", FALSE));
g_file_get_contents (filename, &stylesheet, NULL, NULL); g_file_get_contents (filename, &stylesheet, NULL, NULL);
} }
if (!(stylesheet && *stylesheet)) if (!(stylesheet && *stylesheet))
@ -5106,7 +5106,7 @@ static gchar*
midori_browser_get_docs (gboolean error) midori_browser_get_docs (gboolean error)
{ {
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
gchar* path = sokoke_find_data_filename ("doc/midori/faq.html", FALSE); gchar* path = midori_paths_get_data_filename ("doc/midori/faq.html", FALSE);
if (g_access (path, F_OK) == 0) if (g_access (path, F_OK) == 0)
return g_filename_to_uri (path, NULL, NULL); return g_filename_to_uri (path, NULL, NULL);
else else

View file

@ -321,7 +321,7 @@ midori_extension_activate_cb (MidoriExtension* extension,
folder = g_strconcat ("extensions/", filename, NULL); folder = g_strconcat ("extensions/", filename, NULL);
g_free (filename); g_free (filename);
katze_assign (config_file, katze_assign (config_file,
sokoke_find_config_filename (folder, "config")); midori_paths_get_config_filename (folder, "config"));
g_free (folder); g_free (folder);
g_key_file_load_from_file (extension->priv->key_file, config_file, g_key_file_load_from_file (extension->priv->key_file, config_file,
G_KEY_FILE_KEEP_COMMENTS, NULL); G_KEY_FILE_KEEP_COMMENTS, NULL);

View file

@ -367,7 +367,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
SPANNED_ADD (button); SPANNED_ADD (button);
/* Disable spell check option if there are no enchant modules */ /* Disable spell check option if there are no enchant modules */
{ {
gchar* enchant_path = midori_app_get_lib_path ("enchant"); gchar* enchant_path = midori_paths_get_lib_path ("enchant");
if (enchant_path == NULL) if (enchant_path == NULL)
{ {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);

View file

@ -1185,7 +1185,7 @@ midori_view_web_view_resource_request_cb (WebKitWebView* web_view,
if (g_str_has_prefix (uri, "res://")) if (g_str_has_prefix (uri, "res://"))
{ {
gchar* filepath = midori_app_find_res_filename (&uri[6]); gchar* filepath = midori_paths_get_res_filename (&uri[6]);
gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL); gchar* file_uri = g_filename_to_uri (filepath, NULL, NULL);
g_free (filepath); g_free (filepath);
webkit_network_request_set_uri (request, file_uri); webkit_network_request_set_uri (request, file_uri);
@ -1503,7 +1503,7 @@ midori_view_display_error (MidoriView* view,
const gchar* try_again, const gchar* try_again,
WebKitWebFrame* web_frame) WebKitWebFrame* web_frame)
{ {
gchar* path = midori_app_find_res_filename ("error.html"); gchar* path = midori_paths_get_res_filename ("error.html");
gchar* template; gchar* template;
if (g_file_get_contents (path, &template, NULL, NULL)) if (g_file_get_contents (path, &template, NULL, NULL))
@ -4243,7 +4243,7 @@ prepare_speed_dial_html (MidoriView* view,
gchar** groups; gchar** groups;
g_object_get (browser, "speed-dial", &key_file, NULL); g_object_get (browser, "speed-dial", &key_file, NULL);
file_path = midori_app_find_res_filename ("speeddial-head.html"); file_path = midori_paths_get_res_filename ("speeddial-head.html");
if (key_file != NULL if (key_file != NULL
&& g_access (file_path, F_OK) == 0 && g_access (file_path, F_OK) == 0
@ -4523,8 +4523,8 @@ midori_view_set_uri (MidoriView* view,
} }
else if (!strcmp (uri, "about:paths")) else if (!strcmp (uri, "about:paths"))
{ {
gchar* res_dir = midori_app_find_res_filename (""); gchar* res_dir = midori_paths_get_res_filename ("");
gchar* lib_dir = midori_app_get_lib_path (PACKAGE_NAME); gchar* lib_dir = midori_paths_get_lib_path (PACKAGE_NAME);
data = g_strdup_printf ("<body><h1>%s</h1>" data = g_strdup_printf ("<body><h1>%s</h1>"
"<p>config: %s</p>" "<p>config: %s</p>"
"<p>res: %s</p>" "<p>res: %s</p>"
@ -4540,7 +4540,7 @@ midori_view_set_uri (MidoriView* view,
} }
else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version")) else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version"))
{ {
gchar* arguments = g_strjoinv (" ", midori_app_get_command_line ()); gchar* arguments = g_strjoinv (" ", midori_paths_get_command_line (NULL));
gchar* command_line = sokoke_replace_variables ( gchar* command_line = sokoke_replace_variables (
arguments, g_get_home_dir (), "~", NULL); arguments, g_get_home_dir (), "~", NULL);
gchar* architecture, *platform; gchar* architecture, *platform;

View file

@ -2032,7 +2032,7 @@ midori_web_settings_get_property (GObject* object,
GtkSettings* settings = gtk_settings_get_for_screen (screen); GtkSettings* settings = gtk_settings_get_for_screen (screen);
gchar* theme = katze_object_get_string (settings, "gtk-theme-name"); gchar* theme = katze_object_get_string (settings, "gtk-theme-name");
gchar* theme_file = g_build_filename ("themes", theme, "index.theme", NULL); gchar* theme_file = g_build_filename ("themes", theme, "index.theme", NULL);
gchar* filename = sokoke_find_data_filename (theme_file, FALSE); gchar* filename = midori_paths_get_data_filename (theme_file, FALSE);
g_free (theme_file); g_free (theme_file);
web_settings->close_buttons_left = 1; web_settings->close_buttons_left = 1;
if (g_access (filename, F_OK) != 0) if (g_access (filename, F_OK) != 0)

View file

@ -492,7 +492,7 @@ void
sokoke_spawn_app (const gchar* uri, sokoke_spawn_app (const gchar* uri,
gboolean private) gboolean private)
{ {
const gchar* executable = midori_app_get_command_line ()[0]; const gchar* executable = midori_paths_get_command_line (NULL)[0];
gchar* uri_quoted = g_shell_quote (uri); gchar* uri_quoted = g_shell_quote (uri);
gchar* argument; gchar* argument;
if (private) if (private)
@ -1009,92 +1009,6 @@ sokoke_remove_path (const gchar* path,
return TRUE; return TRUE;
} }
/**
* sokoke_find_config_filename:
* @folder: a subfolder
* @filename: a filename or relative path
*
* Looks for the specified filename in the system config
* directories, depending on the platform.
*
* Return value: a full path
**/
gchar*
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;
gchar* path;
if (!folder)
folder = "";
while ((config_dir = config_dirs[i++]))
{
path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
#ifdef G_OS_WIN32
config_dir = g_win32_get_package_installation_directory_of_module (NULL);
path = g_build_filename (config_dir, "etc", "xdg", PACKAGE_NAME, folder, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
#endif
return g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, folder, filename, NULL);
}
/**
* sokoke_find_data_filename:
* @filename: a filename or relative path
*
* Looks for the specified filename in the system data
* directories, depending on the platform.
*
* Return value: a newly allocated full path
**/
gchar*
sokoke_find_data_filename (const gchar* filename,
gboolean res)
{
const gchar* res1 = res ? PACKAGE_NAME : "";
const gchar* res2 = res ? "res" : "";
const gchar* const* data_dirs = g_get_system_data_dirs ();
guint i = 0;
const gchar* data_dir;
gchar* path;
#ifdef G_OS_WIN32
gchar* install_path = g_win32_get_package_installation_directory_of_module (NULL);
path = g_build_filename (install_path, "share", res1, res2, filename, NULL);
g_free (install_path);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
#endif
path = g_build_filename (midori_paths_get_user_data_dir (), res1, res2, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
while ((data_dir = data_dirs[i++]))
{
path = g_build_filename (data_dir, res1, res2, filename, NULL);
if (g_access (path, F_OK) == 0)
return path;
g_free (path);
}
return g_build_filename (MDATADIR, res1, res2, filename, NULL);
}
gchar* gchar*
sokoke_replace_variables (const gchar* template, sokoke_replace_variables (const gchar* template,
const gchar* variable_first, ...) const gchar* variable_first, ...)

View file

@ -134,17 +134,6 @@ gboolean
sokoke_remove_path (const gchar* path, sokoke_remove_path (const gchar* path,
gboolean ignore_errors); gboolean ignore_errors);
gchar*
sokoke_find_config_filename (const gchar* folder,
const gchar* filename);
gchar*
sokoke_find_data_filename (const gchar* filename,
gboolean res);
gchar**
sokoke_get_argv (gchar** argument_vector);
gchar* gchar*
sokoke_replace_variables (const gchar* template, sokoke_replace_variables (const gchar* template,
const gchar* variable_first, ...); const gchar* variable_first, ...);

View file

@ -19,7 +19,7 @@ if progressive or Options.commands['check']:
obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal') obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal')
obj.install_path = None obj.install_path = None
obj.vapi_dirs = '../midori ../katze' obj.vapi_dirs = '../midori ../katze'
obj.packages = 'glib-2.0 gio-2.0 libsoup-2.4' obj.packages = 'glib-2.0 gio-2.0 libsoup-2.4 posix'
if bld.env['HAVE_GTK3']: if bld.env['HAVE_GTK3']:
obj.packages += ' gtk+-3.0 webkitgtk-3.0' obj.packages += ' gtk+-3.0 webkitgtk-3.0'
else: else: