I have an application that uses gsettings in order to save the font as a preference. I want to bind the font property of the gsettings, which is a string, to a font property of a widget. This widget only accept a property “font-desc” which type is PangoFontDescription.
I try to use g_settings_bind_with_mapping:
void
g_settings_bind_with_mapping (GSettings *settings,
const gchar *key,
gpointer object,
const gchar *property,
GSettingsBindFlags flags,
GSettingsBindGetMapping get_mapping,
GSettingsBindSetMapping set_mapping,
gpointer user_data,
GDestroyNotify destroy);
I know the basic usage of this function will be:
g_settings_bind_with_mapping (settings, "font",
mywidget, "font-desc",
G_SETTINGS_BIND_GET,
get_mapping,
NULL,
NULL,
NULL
)
but I have a hard time to figure out how to write the get_mapping
function, with (pango_font_description_from_string ()
as the converter) following the documentation:
gboolean
(*GSettingsBindGetMapping) (GValue *value,
GVariant *variant,
gpointer user_data);