gimpguiconfig.c 12.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * GimpGuiConfig class
 * Copyright (C) 2001  Sven Neumann <sven@gimp.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <glib-object.h>

#include "libgimpbase/gimpbase.h"

28
29
#include "config-types.h"

30
31
#include "gimpconfig-params.h"
#include "gimpconfig-types.h"
32
#include "gimpconfig-utils.h"
33
34
35
36
37

#include "gimpguiconfig.h"


static void  gimp_gui_config_class_init   (GimpGuiConfigClass *klass);
38
static void  gimp_gui_config_finalize     (GObject            *object);
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
static void  gimp_gui_config_set_property (GObject            *object,
                                           guint               property_id,
                                           const GValue       *value,
                                           GParamSpec         *pspec);
static void  gimp_gui_config_get_property (GObject            *object,
                                           guint               property_id,
                                           GValue             *value,
                                           GParamSpec         *pspec);

enum
{
  PROP_0,
  PROP_LAST_OPENED_SIZE,
  PROP_TRANSPARENCY_SIZE,
  PROP_TRANSPARENCY_TYPE,
  PROP_DEFAULT_THRESHOLD,
  PROP_NAV_PREVIEW_SIZE,
56
  PROP_INFO_WINDOW_PER_DISPLAY,
57
  PROP_TRUST_DIRTY_FLAG,
58
59
60
61
  PROP_SAVE_DEVICE_STATUS,
  PROP_SAVE_SESSION_INFO,
  PROP_RESTORE_SESSION,
  PROP_SHOW_TIPS,
62
  PROP_SHOW_TOOL_TIPS,
63
64
65
  PROP_TEAROFF_MENUS,
  PROP_MAX_NEW_IMAGE_SIZE,
  PROP_THEME_PATH,
66
  PROP_THEME,
Michael Natterer's avatar
Michael Natterer committed
67
68
  PROP_USE_HELP,
  PROP_HELP_BROWSER
69
70
};

71
72
static GObjectClass *parent_class = NULL;

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

GType 
gimp_gui_config_get_type (void)
{
  static GType config_type = 0;

  if (! config_type)
    {
      static const GTypeInfo config_info =
      {
        sizeof (GimpGuiConfigClass),
	NULL,           /* base_init      */
        NULL,           /* base_finalize  */
	(GClassInitFunc) gimp_gui_config_class_init,
	NULL,           /* class_finalize */
	NULL,           /* class_data     */
	sizeof (GimpGuiConfig),
	0,              /* n_preallocs    */
	NULL            /* instance_init  */
      };

94
      config_type = g_type_register_static (GIMP_TYPE_DISPLAY_CONFIG, 
95
96
97
98
99
100
101
102
103
104
105
106
                                            "GimpGuiConfig", 
                                            &config_info, 0);
    }

  return config_type;
}

static void
gimp_gui_config_class_init (GimpGuiConfigClass *klass)
{
  GObjectClass *object_class;

107
108
  parent_class = g_type_class_peek_parent (klass);

109
110
  object_class = G_OBJECT_CLASS (klass);

111
  object_class->finalize     = gimp_gui_config_finalize;
112
113
114
115
116
  object_class->set_property = gimp_gui_config_set_property;
  object_class->get_property = gimp_gui_config_get_property;

  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_LAST_OPENED_SIZE,
                                "last-opened-size",
117
118
                                0, G_MAXINT, 4,
                                GIMP_PARAM_RESTART);
119
120
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSPARENCY_SIZE,
                                 "transparency-size",
121
122
                                 GIMP_TYPE_CHECK_SIZE, GIMP_MEDIUM_CHECKS,
                                 0);
123
124
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSPARENCY_TYPE,
                                 "transparency-type",
125
126
                                 GIMP_TYPE_CHECK_TYPE, GIMP_GRAY_CHECKS,
                                 0);
127
128
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_DEFAULT_THRESHOLD,
                                "default-threshold",
129
130
                                0, 255, 15,
                                0);
131
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_NAV_PREVIEW_SIZE,
132
                                 "navigation-preview-size",
133
134
                                 GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_HUGE,
                                 0);
135
136
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
                                    "info-window-per-display",
137
138
                                    FALSE,
                                    GIMP_PARAM_RESTART);
139
140
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG,
                                    "trust-dirty-flag",
141
142
                                    FALSE,
                                    0);
143
144
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_DEVICE_STATUS,
                                    "save-device-status",
145
146
                                    FALSE,
                                    0);
147
148
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
                                    "save-session-info",
149
150
                                    TRUE,
                                    0);
151
152
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_SESSION,
                                    "restore-session",
153
154
                                    TRUE,
                                    0);
155
156
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
                                    "show-tips",
157
158
                                    TRUE,
                                    0);
159
160
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TOOL_TIPS,
                                    "show-tool-tips",
161
162
                                    TRUE,
                                    0);
163
164
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEAROFF_MENUS,
                                    "tearoff-menus",
165
166
                                    TRUE,
                                    GIMP_PARAM_RESTART);
167
168
  GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
                                   "max-new-image-size",
169
170
                                   0, G_MAXULONG, 1 << 25,
                                    0);
171
172
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
                                 "theme-path",
173
174
                                 gimp_config_build_data_path ("themes"),
                                 GIMP_PARAM_RESTART);
175
176
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_THEME,
                                   "theme",
177
178
                                   NULL,
                                   0);
179
180
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_HELP,
                                    "use-help",
181
182
                                    TRUE,
                                    0);
Michael Natterer's avatar
Michael Natterer committed
183
184
185
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_HELP_BROWSER,
                                 "help-browser",
                                 GIMP_TYPE_HELP_BROWSER_TYPE,
186
187
                                 GIMP_HELP_BROWSER_GIMP,
                                 0);
188
189
}

190
191
192
193
194
195
196
197
198
199
200
201
202
static void
gimp_gui_config_finalize (GObject *object)
{
  GimpGuiConfig *gui_config;

  gui_config = GIMP_GUI_CONFIG (object);
  
  g_free (gui_config->theme_path);
  g_free (gui_config->theme);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
static void
gimp_gui_config_set_property (GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
  GimpGuiConfig *gui_config;

  gui_config = GIMP_GUI_CONFIG (object);

  switch (property_id)
    {
    case PROP_LAST_OPENED_SIZE:
      gui_config->last_opened_size = g_value_get_int (value);
      break;
    case PROP_TRANSPARENCY_SIZE:
      gui_config->transparency_size = g_value_get_enum (value);
      break;
    case PROP_TRANSPARENCY_TYPE:
      gui_config->transparency_type = g_value_get_enum (value);
      break;
    case PROP_DEFAULT_THRESHOLD:
      gui_config->default_threshold = g_value_get_int (value);
      break;
    case PROP_NAV_PREVIEW_SIZE:
      gui_config->nav_preview_size = g_value_get_enum (value);
      break;
230
231
232
    case PROP_INFO_WINDOW_PER_DISPLAY:
      gui_config->info_window_per_display = g_value_get_boolean (value);
      break;      
233
234
235
    case PROP_TRUST_DIRTY_FLAG:
      gui_config->trust_dirty_flag = g_value_get_boolean (value);
      break;
236
237
238
239
240
241
242
243
244
245
246
247
    case PROP_SAVE_DEVICE_STATUS:
      gui_config->save_device_status = g_value_get_boolean (value);
      break;
    case PROP_SAVE_SESSION_INFO:
      gui_config->save_session_info = g_value_get_boolean (value);
      break;
    case PROP_RESTORE_SESSION:
      gui_config->restore_session = g_value_get_boolean (value);
      break;
    case PROP_SHOW_TIPS:
      gui_config->show_tips = g_value_get_boolean (value);
      break;
248
249
250
    case PROP_SHOW_TOOL_TIPS:
      gui_config->show_tool_tips = g_value_get_boolean (value);
      break;
251
252
253
254
    case PROP_TEAROFF_MENUS:
      gui_config->tearoff_menus = g_value_get_boolean (value);
      break;
    case PROP_MAX_NEW_IMAGE_SIZE:
255
      gui_config->max_new_image_size = g_value_get_ulong (value);
256
257
258
259
260
261
262
263
264
      break;
    case PROP_THEME_PATH:
      g_free (gui_config->theme_path);
      gui_config->theme_path = g_value_dup_string (value);
      break;
    case PROP_THEME:
      g_free (gui_config->theme);
      gui_config->theme = g_value_dup_string (value);
      break;
265
266
267
    case PROP_USE_HELP:
      gui_config->use_help = g_value_get_boolean (value);
      break;
Michael Natterer's avatar
Michael Natterer committed
268
269
270
    case PROP_HELP_BROWSER:
      gui_config->help_browser = g_value_get_enum (value);
      break;
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}

static void
gimp_gui_config_get_property (GObject    *object,
                              guint       property_id,
                              GValue     *value,
                              GParamSpec *pspec)
{
  GimpGuiConfig *gui_config;

  gui_config = GIMP_GUI_CONFIG (object);

  switch (property_id)
    {
    case PROP_LAST_OPENED_SIZE:
      g_value_set_int (value, gui_config->last_opened_size);
      break;
    case PROP_TRANSPARENCY_SIZE:
      g_value_set_enum (value, gui_config->transparency_size);
      break;
    case PROP_TRANSPARENCY_TYPE:
      g_value_set_enum (value, gui_config->transparency_type);
      break;
    case PROP_DEFAULT_THRESHOLD:
      g_value_set_int (value, gui_config->default_threshold);
      break;
    case PROP_NAV_PREVIEW_SIZE:
      g_value_set_enum (value, gui_config->nav_preview_size);
      break;
305
306
    case PROP_INFO_WINDOW_PER_DISPLAY:
      g_value_set_boolean (value, gui_config->info_window_per_display);
307
      break;
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
    case PROP_TRUST_DIRTY_FLAG:
      g_value_set_boolean (value, gui_config->trust_dirty_flag);
      break;
    case PROP_SAVE_DEVICE_STATUS:
      g_value_set_boolean (value, gui_config->save_device_status);
      break;
    case PROP_SAVE_SESSION_INFO:
      g_value_set_boolean (value, gui_config->save_session_info);
      break;
    case PROP_RESTORE_SESSION:
      g_value_set_boolean (value, gui_config->restore_session);
      break;
    case PROP_SHOW_TIPS:
      g_value_set_boolean (value, gui_config->show_tips);
      break;
323
324
325
    case PROP_SHOW_TOOL_TIPS:
      g_value_set_boolean (value, gui_config->show_tool_tips);
      break;
326
327
328
329
    case PROP_TEAROFF_MENUS:
      g_value_set_boolean (value, gui_config->tearoff_menus);
      break;
    case PROP_MAX_NEW_IMAGE_SIZE:
330
      g_value_set_ulong (value, gui_config->max_new_image_size);
331
332
333
334
335
336
337
      break;
    case PROP_THEME_PATH:
      g_value_set_string (value, gui_config->theme_path);
      break;
    case PROP_THEME:
      g_value_set_string (value, gui_config->theme);
      break;
338
339
340
    case PROP_USE_HELP:
      g_value_set_boolean (value, gui_config->use_help);
      break;
Michael Natterer's avatar
Michael Natterer committed
341
342
343
    case PROP_HELP_BROWSER:
      g_value_set_enum (value, gui_config->help_browser);
      break;
344
345
346
347
348
349

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}