Mercurial > geeqie
view src/debug.c @ 1149:c4fcf8001574
Implement preliminary support for XDG Base Directory Specification.
See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html.
This feature was requested for a long time (feature requests #1950978 and #2289481).
For now, it is disabled since it breaks compatibility with previous versions.
To be able to test it, you have to enable it by defining USE_XDG to 1 in main.h.
geeqierc and other conf files are going to:
$XDG_CONFIG_HOME/geeqie/ (default to $HOME/.config/geeqie/).
metadata and thumbnails cache (if std is not used) are going to:
$XDG_CACHE_HOME/geeqie/metadata/ (default to $HOME/.cache/geeqie/metadata/)
and $XDG_CACHE_HOME/geeqie/thumbnails/ (default to $HOME/.cache/geeqie/thumbnails/)
collections are going to:
$XDG_DATA_HOME/geeqie/collections/ (default to $HOME/.local/share/geeqie/collections/)
Please test and report any issue.
author | zas_ |
---|---|
date | Sat, 15 Nov 2008 20:17:14 +0000 |
parents | 1646720364cf |
children | 8b89e3ff286b |
line wrap: on
line source
/* * Geeqie * Copyright (C) 2008 The Geeqie Team * * Authors: Vladimir Nadvornik, Laurent Monin * * This software is released under the GNU General Public License (GNU GPL). * Please read the included file COPYING for more information. * This software comes with no warranty of any kind, use at your own risk! */ #include "main.h" #include "debug.h" #include "logwindow.h" #include "ui_fileops.h" /* * Logging functions */ gint log_domain_printf(const gchar *domain, const gchar *format, ...) { va_list ap; gchar buf[4096]; gint ret; va_start(ap, format); ret = vsnprintf(buf, sizeof(buf), format, ap); va_end(ap); print_term(buf); if (strcmp(domain, DOMAIN_INFO) == 0) log_window_append(buf, LOG_NORMAL); else log_window_append(buf, LOG_MSG); return ret; } /* * Debugging only functions */ #ifdef DEBUG static gint debug_level = DEBUG_LEVEL_MIN; gint get_debug_level(void) { return debug_level; } void set_debug_level(gint new_level) { debug_level = CLAMP(new_level, DEBUG_LEVEL_MIN, DEBUG_LEVEL_MAX); } void debug_level_add(gint delta) { set_debug_level(debug_level + delta); } gint required_debug_level(gint level) { return (debug_level >= level); } static gint timeval_delta(struct timeval *result, struct timeval *x, struct timeval *y) { if (x->tv_usec < y->tv_usec) { gint nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; y->tv_usec -= 1000000 * nsec; y->tv_sec += nsec; } if (x->tv_usec - y->tv_usec > 1000000) { gint nsec = (x->tv_usec - y->tv_usec) / 1000000; y->tv_usec += 1000000 * nsec; y->tv_sec -= nsec; } result->tv_sec = x->tv_sec - y->tv_sec; result->tv_usec = x->tv_usec - y->tv_usec; return x->tv_sec < y->tv_sec; } const gchar *get_exec_time(void) { static gchar timestr[30]; static struct timeval start_tv = {0, 0}; static struct timeval previous = {0, 0}; static gint started = 0; struct timeval tv = {0, 0}; static struct timeval delta = {0, 0}; gettimeofday(&tv, NULL); if (start_tv.tv_sec == 0) start_tv = tv; tv.tv_sec -= start_tv.tv_sec; if (tv.tv_usec >= start_tv.tv_usec) tv.tv_usec -= start_tv.tv_usec; else { tv.tv_usec += 1000000 - start_tv.tv_usec; tv.tv_sec -= 1; } if (started) timeval_delta(&delta, &tv, &previous); previous = tv; started = 1; g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (gint)tv.tv_sec, (gint)tv.tv_usec, (gint)delta.tv_sec, (gint)delta.tv_usec); return timestr; } void init_exec_time(void) { get_exec_time(); } #endif /* DEBUG */ /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */