diff options
Diffstat (limited to 'eel')
-rw-r--r-- | eel/eel-glib-extensions.c | 24 | ||||
-rw-r--r-- | eel/eel-glib-extensions.h | 4 |
2 files changed, 28 insertions, 0 deletions
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index 80180054..1014c2b0 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -1024,6 +1024,30 @@ 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 diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index fc973852..a71c5b4c 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -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 */ |