Also introduce initial "portable" mode on Win32.
See the file COPYING for the full license text.
*/
#include <midori/midori.h>
+#include "midori-core.h"
#include <glib/gstdio.h>
#include "config.h"
if (!strncmp (uri, "file", 4))
return g_strndup (uri + 7, strlen (uri) - 7);
- folder = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
- "adblock", NULL);
+ folder = g_build_filename (midori_paths_get_cache_dir (), "adblock", NULL);
katze_mkdir_with_parents (folder, 0700);
filename = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
/* This extensions add support for user addons: userscripts and userstyles */
#include <midori/midori.h>
+#include "midori-core.h"
#include <glib/gstdio.h>
#include "config.h"
if (!filename)
filename = g_path_get_basename (uri);
- folder_path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
- PACKAGE_NAME, folder, NULL);
+ folder_path = g_build_path (G_DIR_SEPARATOR_S,
+ midori_paths_get_user_data_dir (), PACKAGE_NAME, folder, NULL);
if (!g_file_test (folder_path, G_FILE_TEST_EXISTS))
katze_mkdir_with_parents (folder_path, 0700);
if (addons->kind == ADDONS_USER_SCRIPTS)
{
addons_type = g_strdup ("userscripts");
- path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
PACKAGE_NAME, "scripts", NULL);
}
else if (addons->kind == ADDONS_USER_STYLES)
{
addons_type = g_strdup ("userstyles");
- path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
PACKAGE_NAME, "styles", NULL);
}
else
}
else
{
- folder = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
- PACKAGE_NAME,
- addons->kind == ADDONS_USER_SCRIPTS
- ? "scripts" : "styles", NULL);
-
- if (!g_file_test (folder, G_FILE_TEST_EXISTS))
- katze_mkdir_with_parents (folder, 0700);
+ folder = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
+ PACKAGE_NAME, addons->kind == ADDONS_USER_SCRIPTS
+ ? "scripts" : "styles", NULL);
+ katze_mkdir_with_parents (folder, 0700);
}
folder_uri = g_filename_to_uri (folder, NULL, NULL);
else
g_assert_not_reached ();
- path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ path = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_user_data_dir (),
PACKAGE_NAME, folder_name, NULL);
directories = g_slist_prepend (directories, path);
{
static gchar* cache_dir = NULL;
if (!cache_dir)
- cache_dir = g_build_filename (g_get_user_cache_dir (),
+ cache_dir = g_build_filename (sokoke_get_user_cache_dir (),
PACKAGE_NAME, "web", NULL);
return cache_dir;
}
#include "katze-net.h"
#include "midori-core.h"
+#include "sokoke.h"
#include <glib/gstdio.h>
#include <libsoup/soup.h>
{
GObject parent_instance;
- gchar* cache_path;
guint cache_size;
};
static void
katze_net_init (KatzeNet* net)
{
- net->cache_path = g_build_filename (g_get_user_cache_dir (),
- PACKAGE_NAME, NULL);
}
static void
katze_net_finalize (GObject* object)
{
- KatzeNet* net = KATZE_NET (object);
-
- katze_assign (net->cache_path, NULL);
-
G_OBJECT_CLASS (katze_net_parent_class)->finalize (object);
}
net = katze_net_new ();
if (subfolder)
- cache_path = g_build_filename (net->cache_path, subfolder, NULL);
+ cache_path = g_build_filename (midori_paths_get_cache_dir (), subfolder, NULL);
else
- cache_path = net->cache_path;
+ cache_path = midori_paths_get_cache_dir ();
katze_mkdir_with_parents (cache_path, 0700);
checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
#include "katze-utils.h"
#include "katze-array.h"
#include "midori-core.h"
+#include "sokoke.h"
#include <glib/gstdio.h>
#include <glib/gi18n.h>
filename = g_strdup_printf ("%s%s", checksum, ext ? ext : "");
g_free (icon_uri);
g_free (checksum);
- path = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
- "icons", filename, NULL);
+ path = g_build_filename (midori_paths_get_cache_dir (), "icons", filename, NULL);
g_free (filename);
if ((icon = gdk_pixbuf_new_from_file_at_size (path, 16, 16, NULL)))
{
--- /dev/null
+/*
+ Copyright (C) 2012 Christian Dywan <christian@twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+namespace GLib {
+ #if HAVE_WIN32
+ extern static string win32_get_package_installation_directory_of_module (void* hmodule = null);
+ #endif
+}
+
+namespace Midori {
+ public enum RuntimeMode {
+ UNDEFINED,
+ NORMAL,
+ APP,
+ PRIVATE,
+ PORTABLE
+ }
+
+ namespace Paths {
+ static RuntimeMode mode = RuntimeMode.UNDEFINED;
+ static string? config_dir = null;
+ static string? cache_dir = null;
+ static string? user_data_dir = null;
+ static string? tmp_dir = null;
+
+ public static string get_readonly_config_dir (RuntimeMode new_mode) {
+ assert (mode == RuntimeMode.UNDEFINED);
+ 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,
+ profile, "profile", "config");
+ }
+ return Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_config_dir (), "midori");
+ }
+
+ public static void init (RuntimeMode new_mode, string? config_base) {
+ assert (mode == RuntimeMode.UNDEFINED);
+ assert (new_mode != RuntimeMode.UNDEFINED);
+ mode = new_mode;
+ 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,
+ profile, "profile", "config");
+ cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ profile, "profile", "cache");
+ user_data_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ profile, "profile", "misc");
+ tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ profile, "profile", "tmp");
+ }
+ else if (mode == RuntimeMode.PRIVATE || mode == RuntimeMode.APP) {
+ config_dir = "private-or-app://";
+ cache_dir = "private-or-app://";
+ user_data_dir = "private-or-app://";
+ tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
+ }
+ else {
+ if (config_base != null)
+ config_dir = config_base;
+ else
+ config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_config_dir (), "midori");
+ cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_user_cache_dir (), "midori");
+ user_data_dir = Environment.get_user_data_dir ();
+ tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
+ Environment.get_tmp_dir (), "midori-" + Environment.get_user_name ());
+ }
+ if (strcmp (Environment.get_variable ("MIDORI_DEBUG"), "paths") == 0) {
+ stdout.printf ("config: %s\ncache: %s\nuser_data: %s\ntmp: %s\n",
+ config_dir, cache_dir, user_data_dir, tmp_dir);
+ }
+ }
+
+ public bool is_readonly () {
+ return mode == RuntimeMode.APP || mode == RuntimeMode.PRIVATE;
+ }
+
+ public static string get_config_dir () {
+ assert (config_dir != null);
+ return config_dir;
+ }
+
+ public static string get_cache_dir () {
+ assert (cache_dir != null);
+ return cache_dir;
+ }
+
+ public static string get_user_data_dir () {
+ assert (user_data_dir != null);
+ return user_data_dir;
+ }
+
+ public static string get_tmp_dir () {
+ assert (tmp_dir != null);
+ return tmp_dir;
+ }
+ }
+}
static gchar*
build_config_filename (const gchar* filename)
{
- return g_build_filename (sokoke_set_config_dir (NULL), filename, NULL);
+ return g_build_filename (midori_paths_get_config_dir (), filename, NULL);
}
static MidoriWebSettings*
#endif
#if WEBKIT_CHECK_VERSION (1, 8, 0)
- gchar* cache = g_build_filename (g_get_user_data_dir (),
+ gchar* cache = g_build_filename (midori_paths_get_user_data_dir (),
"webkit", "icondatabase", NULL);
webkit_favicon_database_set_path (webkit_get_favicon_database (), cache);
g_free (cache);
}
#if WEBKIT_CHECK_VERSION (1, 3, 11)
- katze_assign (config_file, g_build_filename (g_get_user_cache_dir (),
- PACKAGE_NAME, "web", NULL));
+ katze_assign (config_file, g_build_filename (midori_paths_get_cache_dir (), "web", NULL));
feature = SOUP_SESSION_FEATURE (soup_cache_new (config_file, 0));
soup_session_add_feature (session, feature);
soup_cache_set_max_size (SOUP_CACHE (feature),
g_key_file_load_from_data (key_file, keyfile, -1, 0, NULL);
g_free (keyfile);
tiles = g_key_file_get_groups (key_file, NULL);
- thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
- PACKAGE_NAME, "thumbnails", NULL);
+ thumb_dir = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_cache_dir (), "thumbnails", NULL);
if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS))
katze_mkdir_with_parents (thumb_dir, 0700);
g_free (thumb_dir);
midori_clear_saved_logins_cb (void)
{
sqlite3* db;
- gchar* path = g_build_filename (sokoke_set_config_dir (NULL), "logins", NULL);
+ gchar* path = g_build_filename (midori_paths_get_config_dir (), "logins", NULL);
g_unlink (path);
/* Form History database, written by the extension */
- katze_assign (path, g_build_filename (sokoke_set_config_dir (NULL),
+ katze_assign (path, g_build_filename (midori_paths_get_config_dir (),
"extensions", MIDORI_MODULE_PREFIX "formhistory." G_MODULE_SUFFIX, "forms.db", NULL));
if (sqlite3_open (path, &db) == SQLITE_OK)
{
{
SoupSession* session = webkit_get_default_session ();
SoupSessionFeature* feature = soup_session_get_feature (session, SOUP_TYPE_CACHE);
- gchar* cache = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME, "web", NULL);
+ gchar* cache = g_build_filename (midori_paths_get_cache_dir (), "web", NULL);
soup_cache_clear (SOUP_CACHE (feature));
soup_cache_flush (SOUP_CACHE (feature));
sokoke_remove_path (cache, TRUE);
static void
midori_clear_page_icons_cb (void)
{
- gchar* cache = g_build_filename (g_get_user_cache_dir (),
- PACKAGE_NAME, "icons", NULL);
+ gchar* cache = g_build_filename (midori_paths_get_cache_dir (), "icons", NULL);
/* FIXME: Exclude search engine icons */
sokoke_remove_path (cache, TRUE);
g_free (cache);
- cache = g_build_filename (g_get_user_data_dir (),
- "webkit", "icondatabase", NULL);
+ cache = g_build_filename (midori_paths_get_user_data_dir (), "webkit", "icondatabase", NULL);
sokoke_remove_path (cache, TRUE);
g_free (cache);
#if WEBKIT_CHECK_VERSION (1, 8, 0)
gchar* webapp;
gchar* config;
gboolean private;
+ gboolean portable;
gboolean diagnostic_dialog;
gboolean back_from_crash;
gboolean run;
#endif
{ "private", 'p', 0, G_OPTION_ARG_NONE, &private,
N_("Private browsing, no changes are saved"), NULL },
+ #ifdef G_OS_WIN32
+ { "portable", 't', 0, G_OPTION_ARG_NONE, &portable,
+ N_("Portable mode, all runtime files are stored in one place"), NULL },
+ #endif
{ "diagnostic-dialog", 'd', 0, G_OPTION_ARG_NONE, &diagnostic_dialog,
N_("Show a diagnostic dialog"), NULL },
{ "run", 'r', 0, G_OPTION_ARG_NONE, &run,
webapp = NULL;
config = NULL;
private = FALSE;
+ portable = FALSE;
back_from_crash = FALSE;
diagnostic_dialog = FALSE;
run = FALSE;
if (private)
{
if (!config && !webapp)
- config = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
+ config = midori_paths_get_readonly_config_dir (MIDORI_RUNTIME_MODE_PRIVATE);
/* Mask the timezone, which can be read by Javascript */
g_setenv ("TZ", "UTC", TRUE);
}
"gtk-application-prefer-dark-theme", TRUE,
NULL);
#endif
- }
- if (private || !config)
- {
- /* Disable saving by setting an unwritable folder */
- sokoke_set_config_dir ("/");
+ midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, "private://");
}
+ else if (webapp)
+ midori_paths_init (MIDORI_RUNTIME_MODE_APP, config ? config : "app://");
+ else if (portable)
+ midori_paths_init (MIDORI_RUNTIME_MODE_PORTABLE, "portable://");
midori_load_soup_session (settings);
if (block_uris)
if (inactivity_reset > 0)
g_error ("--inactivity-reset is currently only supported with --app.");
- sokoke_set_config_dir (config);
+ midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, config);
app = midori_app_new ();
- katze_assign (config, (gchar*)sokoke_set_config_dir (NULL));
+ katze_assign (config, g_strdup (midori_paths_get_config_dir ()));
midori_startup_timer ("App created: \t%f");
/* FIXME: The app might be 'running' but actually showing a dialog
#include "midori-app.h"
#include "midori-platform.h"
+#include "midori-core.h"
#include <string.h>
#include <gtk/gtk.h>
{
#if HAVE_UNIQUE
- const gchar* config = sokoke_set_config_dir (NULL);
+ const gchar* config = midori_paths_get_config_dir ();
gchar* name_hash;
name_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, config, -1);
katze_assign (app_name, g_strconcat ("midori", "_", name_hash, NULL));
g_signal_connect (instance, "message-received",
G_CALLBACK (midori_browser_message_received_cb), app);
#else
- instance = socket_init (instance_name, sokoke_set_config_dir (NULL), &exists);
+ instance = socket_init (instance_name, midori_paths_get_config_dir (), &exists);
g_object_set_data (G_OBJECT (app), "sock-exists",
exists ? (gpointer)0xdeadbeef : NULL);
if (instance != MidoriAppInstanceNull)
{
static const gchar* debug_token = NULL;
const gchar* debug = g_getenv ("MIDORI_DEBUG");
- const gchar* debug_tokens = "soup soup:1 soup:2 soup:3 cookies ";
+ const gchar* debug_tokens = "soup soup:1 soup:2 soup:3 cookies paths ";
const gchar* full_debug_tokens = "adblock:1 adblock:2 startup bookmarks ";
if (debug_token == NULL)
{
#include "panels/midori-bookmarks.h"
#include "midori-array.h"
#include "sokoke.h"
+#include "midori-core.h"
#include <glib/gstdio.h>
#include <glib/gi18n.h>
g_return_val_if_fail (errmsg != NULL, NULL);
- oldfile = g_build_filename (sokoke_set_config_dir (NULL), "bookmarks.db", NULL);
+ oldfile = g_build_filename (midori_paths_get_config_dir (), "bookmarks.db", NULL);
oldfile_exists = g_access (oldfile, F_OK) == 0;
- newfile = g_build_filename (sokoke_set_config_dir (NULL), "bookmarks_v2.db", NULL);
+ newfile = g_build_filename (midori_paths_get_config_dir (), "bookmarks_v2.db", NULL);
newfile_did_exist = g_access (newfile, F_OK) == 0;
/* sqlite3_open will create the file if it did not exists already */
if (midori_browser_get_current_tab (browser) != (GtkWidget*)view)
return;
- if (sokoke_is_app_or_private ())
+ if (midori_paths_is_readonly () /* APP, PRIVATE */)
gtk_window_set_icon (GTK_WINDOW (browser), midori_view_get_icon (view));
}
GKeyFile* key_file;
gchar* dial_id = g_strdup_printf ("Dial %s", slot_id + 1);
gchar* file_path = sokoke_build_thumbnail_path (uri);
- gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
- PACKAGE_NAME, "thumbnails", NULL);
+ gchar* thumb_dir = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_cache_dir (), "thumbnails", NULL);
g_object_get (browser, "speed-dial", &key_file, NULL);
g_key_file_set_string (key_file, dial_id, "uri", uri);
gchar* suggested_filename;
GFile* file_source;
gchar* file_basename;
- gchar* download_dir = NULL;
+ const gchar* download_dir = NULL;
gchar* destination_uri;
gchar* destination_filename;
g_free (suggested_filename);
file_basename = g_file_get_basename (file_source);
if (folder == NULL)
- download_dir = midori_view_get_tmp_dir ();
+ download_dir = midori_paths_get_tmp_dir ();
else
- download_dir = (gchar*)folder;
+ download_dir = folder;
destination_filename = g_build_filename (download_dir, file_basename, NULL);
destination_filename = midori_browser_download_prepare_filename (destination_filename);
destination_uri = g_filename_to_uri (destination_filename, NULL, NULL);
g_free (file_basename);
- if (folder == NULL)
- g_free (download_dir);
g_free (destination_filename);
g_object_unref (file_source);
GtkWidget* widget = midori_browser_get_current_tab (browser);
MidoriView* view = MIDORI_VIEW (widget);
gboolean last_tab = midori_browser_get_n_pages (browser) == 1;
- if (last_tab && sokoke_is_app_or_private ())
+ if (last_tab && midori_paths_is_readonly () /* APP, PRIVATE */)
{
gtk_widget_destroy (GTK_WIDGET (browser));
return;
midori_browser_set_title (browser, midori_view_get_display_title (new_view));
action = _action_by_name (browser, "Location");
midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
- if (sokoke_is_app_or_private ())
+ if (midori_paths_is_readonly () /* APP, PRIVATE */)
gtk_window_set_icon (GTK_WINDOW (browser), midori_view_get_icon (new_view));
if (browser->proxy_array)
#include <katze/katze.h>
#include "midori-platform.h"
+#include "midori-core.h"
#include <glib/gi18n.h>
G_DEFINE_TYPE (MidoriExtension, midori_extension, G_TYPE_OBJECT);
if (!filename)
return "/";
extension->priv->config_dir = g_build_filename (
- sokoke_set_config_dir (NULL), "extensions", filename, NULL);
+ midori_paths_get_config_dir (), "extensions", filename, NULL);
}
return extension->priv->config_dir;
#include "midori-preferences.h"
#include "midori-app.h"
+#include "midori-core.h"
#include "midori-platform.h"
#include <string.h>
#define SPANNED_ADD(__widget) \
katze_preferences_add_widget (_preferences, __widget, "spanned")
/* Page "General" */
- if (!sokoke_is_app_or_private ())
+ if (!midori_paths_is_readonly ())
{
PAGE_NEW (GTK_STOCK_HOME, _("Startup"));
FRAME_NEW (NULL);
gtk_action_group_get_action (actions, "BookmarkAdd"));
gtk_menu_shell_append (menu_shell, menuitem);
- if (!midori_view_is_blank (view) && !sokoke_is_app_or_private ())
+ if (!midori_view_is_blank (view) && !midori_paths_is_readonly ())
{
menuitem = sokoke_action_create_popup_menu_item (
gtk_action_group_get_action (actions, "AddSpeedDial"));
g_string_append_printf (markup,
"%s<style>.cross { display:none }</style>%s"
"<style> div.shortcut { height: %d%%; width: %d%%; }</style>\n",
- sokoke_is_app_or_private () ? "" : "<noscript>",
- sokoke_is_app_or_private () ? "" : "</noscript>",
+ midori_paths_is_readonly () ? "" : "<noscript>",
+ midori_paths_is_readonly () ? "" : "</noscript>",
slot_size + 1, slot_size - 4);
/* Combined width of slots should always be less than 100%.
{
gchar* res_dir = midori_app_find_res_filename ("");
gchar* lib_dir = midori_app_get_lib_path (PACKAGE_NAME);
- gchar* tmp_dir = midori_view_get_tmp_dir ();
data = g_strdup_printf ("<body><h1>%s</h1>"
"<p>config: %s</p>"
"<p>res: %s</p>"
"<p>cache: %s</p>"
"<p>tmp: %s</p>"
"</body>",
- uri, sokoke_set_config_dir (NULL), res_dir, lib_dir, g_get_user_cache_dir (), tmp_dir);
+ uri, midori_paths_get_config_dir (), res_dir,
+ lib_dir, midori_paths_get_cache_dir (), midori_paths_get_tmp_dir ());
g_free (res_dir);
g_free (lib_dir);
- g_free (tmp_dir);
katze_assign (view->uri, g_strdup (uri));
}
else if (!strcmp (uri, "about:") || !strcmp (uri, "about:version"))
return "";
}
-gchar*
-midori_view_get_tmp_dir (void)
-{
- gchar* tmpdir = g_strdup_printf ("%s/midori-%s",
- g_get_tmp_dir (), g_get_user_name ());
- g_mkdir (tmpdir, 0700);
- return tmpdir;
-}
-
/**
* midori_view_save_source:
* @view: a #MidoriView
if (!outfile)
{
gchar* extension = midori_view_get_uri_extension (uri);
- gchar* tmpdir = midori_view_get_tmp_dir ();
- unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", tmpdir,
+ unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", midori_paths_get_tmp_dir (),
g_str_hash (uri), midori_view_fallback_extension (view, extension));
- g_free (tmpdir);
g_free (extension);
fd = g_mkstemp (unique_filename);
}
img = midori_view_web_view_get_snapshot (thumb_view, 240, 160);
#endif
file_path = sokoke_build_thumbnail_path (url);
- thumb_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_cache_dir (),
- PACKAGE_NAME, "thumbnails", NULL);
+ thumb_dir = g_build_path (G_DIR_SEPARATOR_S, midori_paths_get_cache_dir (), "thumbnails", NULL);
if (!g_file_test (thumb_dir, G_FILE_TEST_EXISTS))
katze_mkdir_with_parents (thumb_dir, 0700);
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
GtkWidget* tab;
- config_file = g_build_filename (sokoke_set_config_dir (NULL), "speeddial", NULL);
+ config_file = g_build_filename (midori_paths_get_config_dir (), "speeddial", NULL);
sokoke_key_file_save_to_file (key_file, config_file, NULL);
g_free (config_file);
midori_view_fallback_extension (MidoriView* view,
const gchar* extension);
-gchar*
-midori_view_get_tmp_dir (void);
-
G_END_DECLS
#endif /* __MIDORI_VIEW_H__ */
gchar* argument;
if (private)
{
- gchar* config_quoted = g_shell_quote (sokoke_set_config_dir (NULL));
+ gchar* config_quoted = g_shell_quote (midori_paths_get_config_dir ());
argument = g_strconcat ("-c ", config_quoted,
" -p ", uri_quoted, NULL);
}
return julian;
}
-/**
- * sokoke_set_config_dir:
- * @new_config_dir: an absolute path, or %NULL
- *
- * Retrieves and/ or sets the base configuration folder.
- *
- * "/" means no configuration is saved.
- *
- * Return value: the configuration folder, or %NULL
- **/
-const gchar*
-sokoke_set_config_dir (const gchar* new_config_dir)
-{
- static gchar* config_dir = NULL;
-
- if (config_dir)
- return config_dir;
-
- if (!new_config_dir)
- config_dir = g_build_filename (g_get_user_config_dir (),
- PACKAGE_NAME, NULL);
- else
- {
- g_return_val_if_fail (g_path_is_absolute (new_config_dir), NULL);
- katze_assign (config_dir, g_strdup (new_config_dir));
- }
-
- return config_dir;
-}
-
-gboolean
-sokoke_is_app_or_private (void)
-{
- return !strcmp ("/", sokoke_set_config_dir (NULL));
-}
-
/**
* sokoke_remove_path:
* @path: an absolute path
g_free (path);
#endif
- path = g_build_filename (g_get_user_data_dir (), res1, res2, filename, NULL);
+ 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);
gchar* checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, name, -1);
gchar* filename = g_strdup_printf ("%s.png", checksum);
- path = g_build_filename (g_get_user_cache_dir (), "midori", "thumbnails",
- filename, NULL);
+ path = g_build_filename (midori_paths_get_cache_dir (), "thumbnails", filename, NULL);
g_free (filename);
g_free (checksum);
gint64
sokoke_time_t_to_julian (const time_t* timestamp);
-const gchar*
-sokoke_set_config_dir (const gchar* new_config_dir);
-
-gboolean
-sokoke_is_app_or_private (void);
-
gboolean
sokoke_remove_path (const gchar* path,
gboolean ignore_errors);
{
g_test_init (&argc, &argv, NULL);
midori_app_setup (&argc, &argv, NULL, NULL);
+ midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
"midori-session-initialized", (void*)1);
{
g_test_init (&argc, &argv, NULL);
midori_app_setup (&argc, &argv, NULL, NULL);
+ midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
soup_session_add_feature_by_type (webkit_get_default_session (),
SOUP_TYPE_COOKIE_JAR);
{
g_test_init (&argc, &argv, NULL);
midori_app_setup (&argc, &argv, NULL, NULL);
+ midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
g_object_set_data (G_OBJECT (webkit_get_default_session ()),
"midori-session-initialized", (void*)1);
g_free (fingerprint);
if (verified)
{
- if (!sokoke_is_app_or_private ())
+ if (!midori_paths_is_readonly ())
gtk_recent_manager_add_item (gtk_recent_manager_get_default (),
webkit_download_get_destination_uri (download));
}
args = ''
if Options.platform == 'win32':
args = '--define-variable=target=win32'
+ conf.env.append_value ('VALAFLAGS', '-D HAVE_WIN32')
elif sys.platform != 'darwin':
check_pkg ('x11')
# Pass /usr/X11R6/include for OpenBSD