Typedefs | |
typedef void( | osso_locale_change_cb_f )(const char *new_locale, gpointer data) |
Functions | |
osso_return_t | osso_locale_change_set_notification_cb (osso_context_t *osso, osso_locale_change_cb_f *cb, gpointer data) |
osso_return_t | osso_locale_set (osso_context_t *osso, char *new_locale) |
typedef void( osso_locale_change_cb_f)(const char *new_locale, gpointer data) |
This is the type for the locale change notification callback function.
new_locale | The new locale (e.g. "en_GB") | |
data | An application specific data pointer. |
This is an example implementation of the locale change callback function. It correctly passes the received locale value to gettext and updates the labels for all the text widgets in the application.
#include <libintl.h> #include <locale.h> #include <glib.h> static void locale_changed_cb (char *new_locale, gpointer user_data) { GtkWidget *my_label = GTK_WIDGET (user_data); g_setenv ("LANG", new_locale, TRUE); setlocale (LC_MESSAGES, new_locale); // Here you re-set the text labels for all your widgets. In this example // only one widget is passed into the callback via user_data. gtk_label_set_text (GTK_LABEL (my_label), _("Label Text")); // The label's text will now be rendered in the new language }
osso_return_t osso_locale_change_set_notification_cb | ( | osso_context_t * | osso, | |
osso_locale_change_cb_f * | cb, | |||
gpointer | data | |||
) |
This function registers a callback that is called whenever the locale is changed.
osso | The library context as returned by osso_initialize. | |
cb | Function that is called when the system locale is changed. | |
data | Arbitrary application-specific pointer that will be passed to the callback and ignored by Libosso. |
osso_return_t osso_locale_set | ( | osso_context_t * | osso, | |
char * | new_locale | |||
) |
This function issues a notification over the D-Bus system bus indicating a change of locale. To receive such a notification, install a callback function with osso_locale_change_set_notification_cb.
osso | The library context as returned by osso_initialize. | |
new_locale | The new locale (e.g. "en_GB"). Must not be NULL. |