25
25
static void set_string (const gchar *path, const gchar *value)
27
gnome_config_set_string (path, value);
27
gnome_config_set_string (path, value);
30
30
static void set_int (const gchar *path, int value)
32
gnome_config_set_int (path, value);
32
gnome_config_set_int (path, value);
35
35
static void set_bool (const gchar *path, gboolean value)
37
gnome_config_set_bool (path, value);
37
gnome_config_set_bool (path, value);
40
40
static gchar* get_string (const gchar *path, const gchar *def)
43
gchar *value = gnome_config_get_string_with_default (path, &b);
45
return g_strdup (def);
43
gchar *value = gnome_config_get_string_with_default (path, &b);
45
return g_strdup (def);
49
49
static gint get_int (const gchar *path, int def)
52
gint value = gnome_config_get_int_with_default (path, &b);
52
gint value = gnome_config_get_int_with_default (path, &b);
58
58
static gboolean get_bool (const gchar *path, gboolean def)
61
gboolean value = gnome_config_get_bool_with_default (path, &b);
61
gboolean value = gnome_config_get_bool_with_default (path, &b);
68
68
static void set_color (const gchar *path, GdkColor *color)
71
color_str = g_strdup_printf ("%d %d %d", color->red, color->green, color->blue);
72
set_string (path, color_str);
71
color_str = g_strdup_printf ("%d %d %d", color->red, color->green, color->blue);
72
set_string (path, color_str);
77
77
static void get_color (const gchar *path, GdkColor *color)
79
gint red, green, blue;
80
gchar *def = g_strdup_printf ("%d %d %d",
81
color->red, color->green, color->blue);
82
gchar *color_str = get_string (path, def);
83
if (sscanf (color_str, "%u %u %u", &red, &green, &blue) != 3)
84
g_printerr ("Illegal color in config file\n");
89
color->red = (gushort)red;
90
color->green = (gushort)green;
91
color->blue = (gushort)blue;
79
gint red, green, blue;
80
gchar *def = g_strdup_printf ("%d %d %d",
81
color->red, color->green, color->blue);
82
gchar *color_str = get_string (path, def);
83
if (sscanf (color_str, "%u %u %u", &red, &green, &blue) != 3)
84
g_printerr ("Illegal color in config file\n");
89
color->red = (gushort)red;
90
color->green = (gushort)green;
91
color->blue = (gushort)blue;
98
98
gnome_cmd_data_set_string (const gchar *path, const gchar *value)
100
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
102
set_string (s, value);
100
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
102
set_string (s, value);
109
109
gnome_cmd_data_set_int (const gchar *path, int value)
111
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
111
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
119
119
gnome_cmd_data_set_bool (const gchar *path, gboolean value)
121
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
121
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
130
130
gnome_cmd_data_set_color (const gchar *path, GdkColor *color)
132
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
134
set_color (s, color);
132
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
134
set_color (s, color);
141
141
gnome_cmd_data_get_string (const gchar *path, const gchar *def)
143
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
145
gchar *v = get_string (s, def);
143
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
145
gchar *v = get_string (s, def);
154
154
gnome_cmd_data_get_int (const gchar *path, int def)
156
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
158
gint v = get_int (s, def);
156
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
158
gint v = get_int (s, def);
167
167
gnome_cmd_data_get_bool (const gchar *path, gboolean def)
169
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
171
gboolean v = get_bool (s, def);
169
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
171
gboolean v = get_bool (s, def);
180
180
gnome_cmd_data_get_color (const gchar *path, GdkColor *color)
182
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
184
get_color (s, color);
182
gchar *s = g_build_path ("/", PACKAGE, path, NULL);
184
get_color (s, color);