From fb26d28fffbdc38500e5769325edbe68b7e596cc Mon Sep 17 00:00:00 2001 From: Benedikt Meurer <benny@xfce.org> Date: Wed, 25 Jan 2006 16:06:23 +0000 Subject: [PATCH] 2006-01-25 Benedikt Meurer <benny@xfce.org> * thunar/thunar-enum-types.{c,h}: Import enum types required for the desktop background management. (Old svn revision: 19606) --- ChangeLog | 5 +++ thunar/thunar-enum-types.c | 81 +++++++++++++++++++++++++++++--------- thunar/thunar-enum-types.h | 42 ++++++++++++++++++++ 3 files changed, 110 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3bf67bc3..6a2bfffa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-25 Benedikt Meurer <benny@xfce.org> + + * thunar/thunar-enum-types.{c,h}: Import enum types required for the + desktop background management. + 2006-01-24 Benedikt Meurer <benny@xfce.org> * thunar/thunar-preferences.c(thunar_preferences_set_property): No need diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c index 0ab419e0f..8236af49b 100644 --- a/thunar/thunar-enum-types.c +++ b/thunar/thunar-enum-types.c @@ -27,33 +27,58 @@ -static void thunar_enum_from_string (const GValue *src_value, - GValue *dst_value); +static void thunar_enum_from_string (const GValue *src_value, + GValue *dst_value); +static GType thunar_enum_register_type (const gchar *enum_name, + const GEnumValue *enum_values); GType -thunar_recursive_permissions_get_type (void) +thunar_color_style_get_type (void) { - static GType type = G_TYPE_INVALID; + static const GEnumValue values[] = + { + { THUNAR_COLOR_STYLE_SOLID, "THUNAR_COLOR_STYLE_SOLID", "solid", }, + { THUNAR_COLOR_STYLE_HGRADIENT, "THUNAR_COLOR_STYLE_HGRADIENT", "hgradient", }, + { THUNAR_COLOR_STYLE_VGRADIENT, "THUNAR_COLOR_STYLE_VGRADIENT", "vgradient", }, + { 0, NULL, NULL, }, + }; + + return thunar_enum_register_type (I_("ThunarColorStyle"), values); +} - if (G_UNLIKELY (type == G_TYPE_INVALID)) - { - static const GEnumValue values[] = - { - { THUNAR_RECURSIVE_PERMISSIONS_ASK, "THUNAR_RECURSIVE_PERMISSIONS_ASK", "ask", }, - { THUNAR_RECURSIVE_PERMISSIONS_ALWAYS, "THUNAR_RECURSIVE_PERMISSIONS_ALWAYS", "always", }, - { THUNAR_RECURSIVE_PERMISSIONS_NEVER, "THUNAR_RECURSIVE_PERMISSIONS_NEVER", "never", }, - { 0, NULL, NULL, }, - }; - type = g_enum_register_static (I_("ThunarRecursivePermissions"), values); - /* register transformation function for string->ThunarRecursivePermissions */ - g_value_register_transform_func (G_TYPE_STRING, type, thunar_enum_from_string); - } +GType +thunar_recursive_permissions_get_type (void) +{ + static const GEnumValue values[] = + { + { THUNAR_RECURSIVE_PERMISSIONS_ASK, "THUNAR_RECURSIVE_PERMISSIONS_ASK", "ask", }, + { THUNAR_RECURSIVE_PERMISSIONS_ALWAYS, "THUNAR_RECURSIVE_PERMISSIONS_ALWAYS", "always", }, + { THUNAR_RECURSIVE_PERMISSIONS_NEVER, "THUNAR_RECURSIVE_PERMISSIONS_NEVER", "never", }, + { 0, NULL, NULL, }, + }; + + return thunar_enum_register_type (I_("ThunarRecursivePermissions"), values); +} - return type; + + +GType +thunar_wallpaper_style_get_type (void) +{ + static const GEnumValue values[] = + { + { THUNAR_WALLPAPER_STYLE_CENTERED, "THUNAR_WALLPAPER_STYLE_CENTERED", "centered", }, + { THUNAR_WALLPAPER_STYLE_SCALED, "THUNAR_WALLPAPER_STYLE_SCALED", "scaled", }, + { THUNAR_WALLPAPER_STYLE_STRETCHED, "THUNAR_WALLPAPER_STYLE_STRETCHED", "stretched", }, + { THUNAR_WALLPAPER_STYLE_TILED, "THUNAR_WALLPAPER_STYLE_TILED", "tiled", }, + { 0, NULL, NULL, }, + }; + + return thunar_enum_register_type (I_("ThunarWallpaperStyle"), values); } @@ -82,3 +107,23 @@ thunar_enum_from_string (const GValue *src_value, +static GType +thunar_enum_register_type (const gchar *enum_name, + const GEnumValue *enum_values) +{ + GType type; + + /* check if we already have the type */ + type = g_type_from_name (enum_name); + if (G_UNLIKELY (type == G_TYPE_INVALID)) + { + /* register the type using the specified enum values */ + type = g_enum_register_static (enum_name, enum_values); + + /* register transformation function, that transforms strings to the enum type */ + g_value_register_transform_func (G_TYPE_STRING, type, thunar_enum_from_string); + } + + return type; +} + diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h index 2e94991f8..e119a172d 100644 --- a/thunar/thunar-enum-types.h +++ b/thunar/thunar-enum-types.h @@ -24,6 +24,26 @@ G_BEGIN_DECLS; +#define THUNAR_TYPE_COLOR_STYLE (thunar_color_style_get_type ()) + +/** + * ThunarColorStyle: + * @THUNAR_COLOR_STYLE_SOLID : solid desktop background color. + * @THUNAR_COLOR_STYLE_HGRADIENT : horizontal gradient from color0 to color1. + * @THUNAR_COLOR_STYLE_VGRADIENT : vertical gradient from color0 to color1. + * + * Desktop background color style. + **/ +typedef enum +{ + THUNAR_COLOR_STYLE_SOLID, + THUNAR_COLOR_STYLE_HGRADIENT, + THUNAR_COLOR_STYLE_VGRADIENT, +} ThunarColorStyle; + +GType thunar_color_style_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL; + + #define THUNAR_TYPE_RECURSIVE_PERMISSIONS (thunar_recursive_permissions_get_type ()) /** @@ -43,6 +63,28 @@ typedef enum GType thunar_recursive_permissions_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL; + +#define THUNAR_TYPE_WALLPAPER_STYLE (thunar_wallpaper_style_get_type ()) + +/** + * ThunarWallpaperStyle: + * @THUNAR_WALLPAPER_STYLE_CENTERED : center the wallpaper. + * @THUNAR_WALLPAPER_STYLE_SCALED : scale the wallpaper. + * @THUNAR_WALLPAPER_STYLE_STRETCHED : stretch the wallpaper. + * @THUNAR_WALLPAPER_STYLE_TILED : tile the wallpaper. + * + * Desktop background wallpaper style. + **/ +typedef enum +{ + THUNAR_WALLPAPER_STYLE_CENTERED, + THUNAR_WALLPAPER_STYLE_SCALED, + THUNAR_WALLPAPER_STYLE_STRETCHED, + THUNAR_WALLPAPER_STYLE_TILED, +} ThunarWallpaperStyle; + +GType thunar_wallpaper_style_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL; + G_END_DECLS; #endif /* !__THUNAR_ENUM_TYPES_H__ */ -- GitLab