Sending/receiving locale change notifications


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 Documentation

typedef void( osso_locale_change_cb_f)(const char *new_locale, gpointer data)

This is the type for the locale change notification callback function.

Parameters:
new_locale The new locale (e.g. "en_GB")
data An application specific data pointer.

Example

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
}


Function Documentation

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.

Parameters:
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.
Returns:
OSSO_OK if all goes well, OSSO_ERROR if an error occurred, or OSSO_INVALID if some parameter is invalid.

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.

Parameters:
osso The library context as returned by osso_initialize.
new_locale The new locale (e.g. "en_GB"). Must not be NULL.
Returns:
OSSO_OK if all goes well, OSSO_ERROR if an error occurred, or OSSO_INVALID if new_locale is NULL or the osso context is invalid.


Generated on Thu Oct 4 11:35:32 2007 for Libosso by  doxygen 1.5.1