static ArCardThemeInfo * ar_card_theme_kde_class_get_theme_info (ArCardThemeClass *klass, const char *path, const char *filename) { ArCardThemeInfo *info = NULL; char *base_path = NULL, *key_file_path = NULL; char *back_name; GKeyFile *key_file = NULL; char *svg_filename = NULL, *name = NULL, *display_name, *pref_name; if (get_is_blacklisted (filename)) { ar_debug_print (AR_DEBUG_CARD_THEME, "KDE card theme %s is blacklisted\n", filename); return NULL; } base_path = g_build_filename (path, filename, NULL); if (!g_file_test (path, G_FILE_TEST_IS_DIR)) goto out; key_file_path = g_build_filename (base_path, KDE_BACKDECK_FILENAME, NULL); key_file = g_key_file_new (); if (!g_key_file_load_from_file (key_file, key_file_path, 0, NULL)) goto out; if (!g_key_file_has_group (key_file, KDE_BACKDECK_GROUP)) goto out; name = g_key_file_get_locale_string (key_file, KDE_BACKDECK_GROUP, KDE_BACKDECK_NAME_KEY, NULL, NULL); svg_filename = g_key_file_get_string (key_file, KDE_BACKDECK_GROUP, KDE_BACKDECK_SVG_KEY, NULL); if (!name || !name[0] || !svg_filename || !svg_filename[0]) goto out; back_name = g_key_file_get_string (key_file, KDE_BACKDECK_GROUP, KDE_BACKDECK_BACK_KEY, NULL); display_name = g_strdup_printf ("%s (KDE)", name); pref_name = g_strdup_printf ("kde:%s", filename); info = _ar_card_theme_info_new (G_OBJECT_CLASS_TYPE (klass), base_path, svg_filename, display_name /* adopts */, pref_name /* adopts */, TRUE /* scalable */, back_name, g_free); out: g_free (base_path); g_free (key_file_path); g_free (name); g_free (svg_filename); if (key_file) { g_key_file_free (key_file); } return info; }
static cairo_rectangle_t * ar_card_theme_kde_get_card_extents (ArCardThemeKDE *theme, int card_id, const char *node) { ArSvg *svg; cairo_rectangle_t *card_extents; cairo_rectangle_t rect; cairo_surface_t *surface; cairo_t *cr; card_extents = &theme->card_extents[card_id]; /* Is it initalised yet? */ if (card_extents->width != 0. && card_extents->height != 0.) return card_extents; svg = ((ArCardThemePreimage *) theme)->cards_svg; surface = cairo_recording_surface_create (CAIRO_CONTENT_ALPHA, NULL); cr = cairo_create (surface); cairo_set_tolerance (cr, 1.); ar_profilestart ("getting ink extents for node %s", node); rsvg_handle_render_cairo_sub (RSVG_HANDLE (svg), cr, node); ar_profileend ("getting ink extents for node %s", node); cairo_destroy (cr); cairo_recording_surface_ink_extents (surface, &rect.x, &rect.y, &rect.width, &rect.height); cairo_surface_destroy (surface); ar_debug_print (AR_DEBUG_CARD_THEME, "card %s %.3f x%.3f at (%.3f | %.3f)\n", node, card_extents->width, card_extents->height, card_extents->x, card_extents->y); *card_extents = rect; /* Sanity check; necessary? */ if (rect.width == 0. || rect.height == 0.) return NULL; return card_extents; }
static void ar_card_surface_cache_finalize (GObject *object) { ArCardSurfaceCache *cache = AR_CARD_SURFACE_CACHE (object); ArCardSurfaceCachePrivate *priv = cache->priv; g_free (priv->cards); #ifdef GNOME_ENABLE_DEBUG _AR_DEBUG_IF (AR_DEBUG_CARD_CACHE) { ar_debug_print (AR_DEBUG_CARD_CACHE, "ArCardSurfaceCache %p statistics: %u calls with %u hits and %u misses for a hit/total of %.3f\n", cache, priv->n_calls, priv->cache_hits, priv->n_calls - priv->cache_hits, priv->n_calls > 0 ? (double) priv->cache_hits / (double) priv->n_calls : 0.0); } #endif G_OBJECT_CLASS (ar_card_surface_cache_parent_class)->finalize (object); }
static void ar_card_surface_cache_clear (ArCardSurfaceCache *cache) { ArCardSurfaceCachePrivate *priv = cache->priv; int i; ar_debug_print (AR_DEBUG_CARD_CACHE, "ar_card_surface_cache_clear\n"); for (i = 0; i < AR_CARDS_TOTAL; i++) { cairo_surface_t *surface = priv->cards[i]; if (surface != NULL && !IS_FAILED_SURFACE (surface)) { cairo_surface_destroy (surface); } priv->cards[i] = NULL; } }
/** * ar_runtime_init: * * Initialises the runtime file localisator. This also calls setlocale, * and initialises gettext support and gnome-games debug support. * * NOTE: This must be called before using ANY other glib/gtk/etc function! * * Returns: %TRUE iff initialisation succeeded */ gboolean ar_runtime_init (const char *name) { gboolean retval; setlocale (LC_ALL, ""); #ifdef G_OS_WIN32 /* On Windows, when called from a console, get console output. This works * only with Windows XP or higher; Windows 2000 will not have console * output but it will just work fine. */ if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) { /* stdout is fine, presumably redirected to a file or pipe. * Make sure stdout goes somewhere, too. */ if (_get_osfhandle (fileno (stderr)) == -1) { dup2 (fileno (stdout), fileno (stderr)); } } else { typedef BOOL (* WINAPI AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) { freopen ("CONOUT$", "w", stdout); dup2 (fileno (stdout), 1); freopen ("CONOUT$", "w", stderr); dup2 (fileno (stderr), 2); } } #endif /* G_OS_WIN32 */ #if !GLIB_CHECK_VERSION(2, 35, 0) /* This also initialises gthread */ g_type_init (); #endif /* May call any glib function after this point */ ar_profilestart ("ar_runtime_init"); ar_debug_init (); app_name = g_strdup (name); bindtextdomain (GETTEXT_PACKAGE, ar_runtime_get_directory (AR_RUNTIME_LOCALE_DIRECTORY)); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #ifdef ENABLE_BINRELOC { const char *path; /* Now check that we can get the module installation directory */ path = ar_runtime_get_directory (AR_RUNTIME_PREFIX); ar_debug_print (AR_DEBUG_RUNTIME, "Relocation path: %s\n", path ? path : "(null)"); retval = path != NULL; } #else /* !ENABLE_BINRELOC */ retval = TRUE; #endif /* ENABLE_BINRELOC */ ar_profileend ("ar_runtime_init"); return retval; }