30 #include "gnc-help-utils.h" 33 parse_hhmap_file(
const gchar *chmfile)
35 gchar *mapfile = NULL, *dot;
36 GKeyFile *keyfile = NULL;
38 gchar **keys = NULL, **key;
40 GHashTable *ctxtmap = NULL;
42 g_return_val_if_fail(chmfile, NULL);
44 mapfile = g_new(gchar, strlen(chmfile) + 7);
45 strcpy(mapfile, chmfile);
46 dot = strrchr(mapfile,
'.');
48 strcpy(dot,
".hhmap");
50 strcat(mapfile,
".hhmap");
52 keyfile = g_key_file_new();
53 if (!g_key_file_load_from_file(keyfile, mapfile, G_KEY_FILE_NONE, &error))
56 if (NULL == (keys = g_key_file_get_keys(keyfile,
"MAP", NULL, &error)))
59 ctxtmap = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
60 for (key = keys; *key; key++)
62 value = g_key_file_get_integer(keyfile,
"MAP", *key, &error);
66 g_hash_table_insert(ctxtmap, g_strdup(*key), GINT_TO_POINTER(value));
72 g_warning(
"Could not load help map file: %s", error->message);
75 g_hash_table_destroy(ctxtmap);
81 g_key_file_free (keyfile);
89 gnc_show_htmlhelp(
const gchar *chmfile,
const gchar *anchor)
91 static GHashTable *chmfile_ctxtmap_map;
92 G_LOCK_DEFINE_STATIC(chmfile_ctxtmap_map);
94 gboolean create_map = FALSE;
98 g_return_if_fail(chmfile);
102 G_LOCK(chmfile_ctxtmap_map);
103 if (!chmfile_ctxtmap_map)
105 chmfile_ctxtmap_map = g_hash_table_new(g_str_hash, g_str_equal);
110 create_map = !g_hash_table_lookup_extended(
111 chmfile_ctxtmap_map, chmfile, NULL, (gpointer) & ctxtmap);
116 ctxtmap = parse_hhmap_file(chmfile);
117 g_hash_table_insert(chmfile_ctxtmap_map, g_strdup(chmfile), ctxtmap);
122 gpointer ptr = g_hash_table_lookup(ctxtmap, anchor);
124 id = GPOINTER_TO_INT(ptr);
126 G_UNLOCK(chmfile_ctxtmap_map);
129 g_warning(
"Could not find anchor '%s'", anchor);
132 wpath = g_utf8_to_utf16(chmfile, -1, NULL, NULL, NULL);
133 HtmlHelpW(GetDesktopWindow(), wpath, HH_HELP_CONTEXT,
id);