~ubuntu-branches/ubuntu/hardy/gnome-commander/hardy

« back to all changes in this revision

Viewing changes to libgcmd/libgcmd-data.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-06-13 15:39:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060613153948-gvrt3mb2ddk5u62o
Tags: 1.2.0-3
added --disable-scrollkeeper on build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    GNOME Commander - A GNOME based file manager 
 
2
    GNOME Commander - A GNOME based file manager
3
3
    Copyright (C) 2001-2006 Marcus Bjurman
4
4
 
5
5
    This program is free software; you can redistribute it and/or modify
24
24
 
25
25
static void set_string (const gchar *path, const gchar *value)
26
26
{
27
 
        gnome_config_set_string (path, value);
 
27
    gnome_config_set_string (path, value);
28
28
}
29
29
 
30
30
static void set_int    (const gchar *path, int value)
31
31
{
32
 
        gnome_config_set_int (path, value);
 
32
    gnome_config_set_int (path, value);
33
33
}
34
34
 
35
35
static void set_bool (const gchar *path, gboolean value)
36
36
{
37
 
        gnome_config_set_bool (path, value);
 
37
    gnome_config_set_bool (path, value);
38
38
}
39
39
 
40
40
static gchar* get_string (const gchar *path, const gchar *def)
41
41
{
42
 
        gboolean b = FALSE;
43
 
        gchar *value = gnome_config_get_string_with_default (path, &b);
44
 
        if (b)
45
 
                return g_strdup (def);  
46
 
        return value;
 
42
    gboolean b = FALSE;
 
43
    gchar *value = gnome_config_get_string_with_default (path, &b);
 
44
    if (b)
 
45
        return g_strdup (def);
 
46
    return value;
47
47
}
48
48
 
49
49
static gint get_int (const gchar *path, int def)
50
50
{
51
 
        gboolean b = FALSE;
52
 
        gint value = gnome_config_get_int_with_default (path, &b);
53
 
        if (b)
54
 
                return def;
55
 
        return value;
 
51
    gboolean b = FALSE;
 
52
    gint value = gnome_config_get_int_with_default (path, &b);
 
53
    if (b)
 
54
        return def;
 
55
    return value;
56
56
}
57
57
 
58
58
static gboolean get_bool (const gchar *path, gboolean def)
59
59
{
60
 
        gboolean b = FALSE;
61
 
        gboolean value = gnome_config_get_bool_with_default (path, &b);
62
 
        if (b)
63
 
                return def;
64
 
        return value;
 
60
    gboolean b = FALSE;
 
61
    gboolean value = gnome_config_get_bool_with_default (path, &b);
 
62
    if (b)
 
63
        return def;
 
64
    return value;
65
65
}
66
66
 
67
67
 
68
68
static void set_color (const gchar *path, GdkColor *color)
69
69
{
70
 
        gchar *color_str;
71
 
        color_str = g_strdup_printf ("%d %d %d", color->red, color->green, color->blue);
72
 
        set_string (path, color_str);
73
 
        g_free (color_str);
 
70
    gchar *color_str;
 
71
    color_str = g_strdup_printf ("%d %d %d", color->red, color->green, color->blue);
 
72
    set_string (path, color_str);
 
73
    g_free (color_str);
74
74
}
75
75
 
76
76
 
77
77
static void get_color (const gchar *path, GdkColor *color)
78
78
{
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");
85
 
 
86
 
        if (color_str != def)
87
 
                g_free (color_str);
88
 
        
89
 
        color->red   = (gushort)red;
90
 
        color->green = (gushort)green;
91
 
        color->blue  = (gushort)blue;
92
 
 
93
 
        g_free (def);
 
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");
 
85
 
 
86
    if (color_str != def)
 
87
        g_free (color_str);
 
88
 
 
89
    color->red   = (gushort)red;
 
90
    color->green = (gushort)green;
 
91
    color->blue  = (gushort)blue;
 
92
 
 
93
    g_free (def);
94
94
}
95
95
 
96
96
 
97
97
void
98
98
gnome_cmd_data_set_string (const gchar *path, const gchar *value)
99
99
{
100
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
101
 
 
102
 
        set_string (s, value);
103
 
        
104
 
        g_free (s);
 
100
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
101
 
 
102
    set_string (s, value);
 
103
 
 
104
    g_free (s);
105
105
}
106
106
 
107
107
 
108
108
void
109
109
gnome_cmd_data_set_int (const gchar *path, int value)
110
110
{
111
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
112
 
 
113
 
        set_int (s, value);
114
 
        
115
 
        g_free (s);
 
111
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
112
 
 
113
    set_int (s, value);
 
114
 
 
115
    g_free (s);
116
116
}
117
117
 
118
118
void
119
119
gnome_cmd_data_set_bool (const gchar *path, gboolean value)
120
120
{
121
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
122
 
 
123
 
        set_bool (s, value);
124
 
        
125
 
        g_free (s);
 
121
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
122
 
 
123
    set_bool (s, value);
 
124
 
 
125
    g_free (s);
126
126
}
127
127
 
128
128
 
129
129
void
130
130
gnome_cmd_data_set_color (const gchar *path, GdkColor *color)
131
131
{
132
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
133
 
 
134
 
        set_color (s, color);
135
 
        
136
 
        g_free (s);
 
132
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
133
 
 
134
    set_color (s, color);
 
135
 
 
136
    g_free (s);
137
137
}
138
138
 
139
139
 
140
140
gchar*
141
141
gnome_cmd_data_get_string (const gchar *path, const gchar *def)
142
142
{
143
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
144
 
 
145
 
        gchar *v = get_string (s, def);
146
 
        
147
 
        g_free (s);
148
 
 
149
 
        return v;
 
143
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
144
 
 
145
    gchar *v = get_string (s, def);
 
146
 
 
147
    g_free (s);
 
148
 
 
149
    return v;
150
150
}
151
151
 
152
152
 
153
153
gint
154
154
gnome_cmd_data_get_int (const gchar *path, int def)
155
155
{
156
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
157
 
 
158
 
        gint v = get_int (s, def);
159
 
        
160
 
        g_free (s);
161
 
 
162
 
        return v;
 
156
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
157
 
 
158
    gint v = get_int (s, def);
 
159
 
 
160
    g_free (s);
 
161
 
 
162
    return v;
163
163
}
164
164
 
165
165
 
166
166
gboolean
167
167
gnome_cmd_data_get_bool (const gchar *path, gboolean def)
168
168
{
169
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
170
 
 
171
 
        gboolean v = get_bool (s, def);
172
 
        
173
 
        g_free (s);
174
 
 
175
 
        return v;
 
169
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
170
 
 
171
    gboolean v = get_bool (s, def);
 
172
 
 
173
    g_free (s);
 
174
 
 
175
    return v;
176
176
}
177
177
 
178
178
 
179
179
void
180
180
gnome_cmd_data_get_color (const gchar *path, GdkColor *color)
181
181
{
182
 
        gchar *s = g_build_path ("/", PACKAGE, path, NULL);
183
 
 
184
 
        get_color (s, color);
185
 
        
186
 
        g_free (s);
 
182
    gchar *s = g_build_path ("/", PACKAGE, path, NULL);
 
183
 
 
184
    get_color (s, color);
 
185
 
 
186
    g_free (s);
187
187
}
188
188