57 GdkScreen *screen = gtk_widget_get_screen(widget);
59 screen = gdk_screen_get_default();
63 CGDirectDisplayID
id = CGMainDisplayID();
64 CGSize size_in_mm = CGDisplayScreenSize(
id);
65 int width = CGDisplayPixelsWide(
id);
66 int height = CGDisplayPixelsHigh(
id);
67 gdk_screen_set_resolution(screen,
69 / sqrt(size_in_mm.width * size_in_mm.width + size_in_mm.height * size_in_mm.height));
118 NSFileManager *fm = [NSFileManager defaultManager];
121 NSURL *url = [NSURL fileURLWithPath:@(filename)];
123 if ([fm respondsToSelector:
@selector(trashItemAtURL:resultingItemURL:
error:)]) {
124 if (![fm trashItemAtURL:url resultingItemURL:nil
error:&err]) {
126 *
error = g_error_new_literal(G_IO_ERROR, err.code == NSFileNoSuchFileError ? G_IO_ERROR_NOT_FOUND : G_IO_ERROR_FAILED, err.localizedDescription.UTF8String);
131 *
error = g_error_new_literal(G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"trash not supported on OS X versions < 10.8");
164 NSLocale* locale_ns = [NSLocale currentLocale];
166 if([locale_ns respondsToSelector:
@selector(languageCode)] && [locale_ns respondsToSelector:
@selector(countryCode)])
168 locale_c = [NSString stringWithFormat:
@"%@_%@", [locale_ns languageCode], [locale_ns countryCode]];
173 locale_c = [locale_ns localeIdentifier];
175 return strdup([locale_c UTF8String]);
182 gchar*
const hash = g_compute_checksum_for_string(G_CHECKSUM_SHA1, res_path, strlen(res_path));
183 gchar*
const file_path = g_build_filename(g_get_user_data_dir(),
"ansel",
"pkcs11", hash,
"p11-kit-trust.module", NULL);
186 GFile*
const cfg_file = g_file_new_for_path(file_path);
188 GFile*
const cfg_dir = g_file_get_parent(cfg_file);
189 g_file_make_directory_with_parents(cfg_dir, NULL, NULL);
191 const char*
const dir_path = g_file_get_path(cfg_dir);
192 p11_kit_override_system_files(
"", NULL,
"", dir_path, NULL);
196 g_object_unref(cfg_dir);
199 gchar*
const buf = g_strdup_printf(
"module: %s/lib/pkcs11/p11-kit-trust.so\n"
200 "trust-policy: yes\n"
201 "x-init-reserved: paths=%s/share/curl/curl-ca-bundle.crt\n",
203 g_file_replace_contents(cfg_file, buf, strlen(buf), NULL,
FALSE, G_FILE_CREATE_NONE, NULL, NULL, NULL);
206 g_object_unref(cfg_file);
221 const gchar* ctype = g_getenv(
"LC_CTYPE");
224 char *saved_locale = strdup(setlocale(LC_ALL, NULL));
225 if(!setlocale(LC_ALL, ctype))
227 g_unsetenv(
"LC_CTYPE");
231 setlocale(LC_ALL, saved_locale);
239 g_setenv(
"LANG", user_locale,
FALSE);
245 g_setenv(
"GTK_DATA_PREFIX", res_path,
TRUE);
246 g_setenv(
"GTK_EXE_PREFIX", res_path,
TRUE);
247 g_setenv(
"GTK_PATH", res_path,
TRUE);
248 gchar* etc_path = g_build_filename(res_path,
"etc", NULL);
249 gchar* lib_path = g_build_filename(res_path,
"lib", NULL);
251 g_setenv(
"XDG_CONFIG_DIRS", etc_path,
TRUE);
253 gchar* gtk_im_path = g_build_filename(etc_path,
"gtk-3.0",
"gtk.immodules", NULL);
254 g_setenv(
"GTK_IM_MODULE_FILE", gtk_im_path,
TRUE);
258 gchar* pixbuf_path = g_build_filename(etc_path,
"gtk-3.0",
"loaders.cache", NULL);
259 g_setenv(
"GDK_PIXBUF_MODULE_FILE", pixbuf_path,
TRUE);
264 gchar* share_path = g_build_filename(res_path,
"share", NULL);
265 g_setenv(
"XDG_DATA_DIRS", share_path,
TRUE);
267 gchar* schema_path = g_build_filename(share_path,
"glib-2.0",
"schemas", NULL);
268 g_setenv(
"GSETTINGS_SCHEMA_DIR", schema_path,
TRUE);
275 gchar* gio_path = g_build_filename(lib_path,
"gio",
"modules", NULL);
276 g_setenv(
"GIO_MODULE_DIR", gio_path,
TRUE);
281#ifdef HAVE_IMAGEMAGICK7
283 g_setenv(
"MAGICK_HOME", res_path,
TRUE);
284 gchar* im_config_path = g_build_filename(etc_path,
"ImageMagick-7", NULL);
285 g_setenv(
"MAGICK_CONFIGURE_PATH", im_config_path,
TRUE);
287 gchar* im_modules_path = g_build_filename(lib_path,
"ImageMagick",
"modules-Q16HDRI", NULL);
288 g_setenv(
"MAGICK_CODER_MODULE_PATH", im_modules_path,
TRUE);
289 g_setenv(
"MAGICK_CODER_FILTER_PATH", im_modules_path,
TRUE);