[Github-comments] [geany/geany] Modify/Extend Stash Settings API (PR #3000)

xiota notifications at xxxxx
Sat Nov 13 23:18:10 UTC 2021


`stash-example.c` using `stash_group_add_comment()` and `stash_group_add_double()`.
```C
StashGroup *group;
gboolean porcelain_enabled;
gchar *potter_name;
gint stock;
gdouble price;
const gchar filename[] = "/path/data.conf";

/* setup the group */
group = stash_group_new("cup");
stash_group_add_boolean(group, &porcelain_enabled, "porcelain", TRUE);
stash_group_add_comment(group, "porcelain", "Is the cup made of porcelain?");

stash_group_add_string(group, &potter_name, "potter_name", "Miss Clay");
stash_group_add_comment(group, "potter_name", "Who made the cup?");

stash_group_add_integer(group, &stock, "stock", 5);
stash_group_add_comment(group, "stock", "How many do we have?");

stash_group_add_double(group, &price, "price", 1.50);
stash_group_add_comment(group, "price", "How much does the cup cost?");

/* load the settings from a file */
if (!stash_group_load_from_file(group, filename))
	g_warning(_("Could not load keyfile %s!"), filename);

/* now use settings porcelain_enabled, potter_name, stock, and price */
/* ... */

/* save settings to file */
if (stash_group_save_to_file(group, filename, G_KEY_FILE_NONE) != 0)
	g_error(_("Could not save keyfile %s!"), filename);

/* free memory */
stash_group_free(group);
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3000#issuecomment-968173574
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211113/da851f1b/attachment.htm>


More information about the Github-comments mailing list