Commit 4c3067f8 authored by Alexander Larsson's avatar Alexander Larsson

Add eel_g_settings_add_auto_enum

parent 7abbb99a
......@@ -969,6 +969,31 @@ eel_get_filename_charset (const gchar **filename_charset)
return cache->is_utf8;
}
static void
update_auto_enum (GSettings *settings,
const gchar *key,
gpointer user_data)
{
int *storage = user_data;
*storage = g_settings_get_enum (settings, key);
}
void
eel_g_settings_add_auto_enum (GSettings *settings,
const char *key,
int *storage)
{
char *signal;
*storage = g_settings_get_enum (settings, key);
signal = g_strconcat ("changed::", key, NULL);
g_signal_connect (settings, signal,
G_CALLBACK(update_auto_enum),
storage);
}
#if !defined (EEL_OMIT_SELF_CHECK)
static void
......
......@@ -28,6 +28,7 @@
#define EEL_GLIB_EXTENSIONS_H
#include <glib.h>
#include <gio/gio.h>
/* A gboolean variant for bit fields. */
typedef guint eel_boolean_bit;
......@@ -124,5 +125,8 @@ void eel_remove_weak_pointer (gpointer
/* Get the filename encoding, returns TRUE if utf8 */
gboolean eel_get_filename_charset (const gchar **filename_charset);
void eel_g_settings_add_auto_enum (GSettings *settings,
const char *key,
int *storage);
#endif /* EEL_GLIB_EXTENSIONS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment