From bca369672136e5ff831ece9832afd42085808fba Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Tue, 07 Jun 2005 23:28:54 +0000 Subject: PageCache and EvJobs are moved from backend to shell. Two new jobs to load document in background and a statusbar to display this process. FileChooser now can select multiple uris. --- (limited to 'lib') diff --git a/lib/ev-file-helpers.c b/lib/ev-file-helpers.c index d9daf6a..b093853 100644 --- a/lib/ev-file-helpers.c +++ b/lib/ev-file-helpers.c @@ -25,10 +25,13 @@ #include #include #include +#include #include "ev-file-helpers.h" static char *dot_dir = NULL; +static char *tmp_dir = NULL; +static int count = 0; static gboolean ensure_dir_exists (const char *dir) @@ -77,7 +80,47 @@ ev_file_helpers_init (void) void ev_file_helpers_shutdown (void) -{ +{ + rmdir (tmp_dir); + + g_free (tmp_dir); g_free (dot_dir); + dot_dir = NULL; + tmp_dir = NULL; +} + +gchar* +ev_tmp_filename (void) +{ + gchar *basename; + gchar *filename = NULL; + + if (tmp_dir == NULL) { + gboolean exists; + gchar *dirname; + + dirname = g_strdup_printf ("evince-%u", getpid()); + tmp_dir = g_build_filename (g_get_tmp_dir (), + dirname, + NULL); + g_free (dirname); + + exists = ensure_dir_exists (tmp_dir); + g_assert (exists); + } + + + do { + if (filename != NULL) + g_free (filename); + + basename = g_strdup_printf ("document-%d", count ++); + + filename = g_build_filename (tmp_dir, basename, NULL); + + g_free (basename); + } while (g_file_test (filename, G_FILE_TEST_EXISTS)); + + return filename; } diff --git a/lib/ev-file-helpers.h b/lib/ev-file-helpers.h index 43dc75c..1d19c6d 100644 --- a/lib/ev-file-helpers.h +++ b/lib/ev-file-helpers.h @@ -31,6 +31,8 @@ void ev_file_helpers_init (void); void ev_file_helpers_shutdown (void); +gchar* ev_tmp_filename (void); + G_END_DECLS #endif /* EPHY_FILE_HELPERS_H */ -- cgit v0.9.1