gimpguiconfig.c 16.6 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
#include "gimprc-blurbs.h"
35
36
#include "gimpguiconfig.h"

37
#include "gimp-intl.h"
38

39
40

static void  gimp_gui_config_class_init   (GimpGuiConfigClass *klass);
41
static void  gimp_gui_config_finalize     (GObject            *object);
42
43
44
45
46
47
48
49
50
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);

51

Sven Neumann's avatar
Sven Neumann committed
52
#define   DEFAULT_THEME        "Default"
53
54

#ifdef G_OS_WIN32
Sven Neumann's avatar
Sven Neumann committed
55
56
#  define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_WEB_BROWSER
#  define DEFAULT_WEB_BROWSER  "not used on Windows"
57
#else
Sven Neumann's avatar
Sven Neumann committed
58
59
#  define DEFAULT_GIMP_HELP_BROWSER GIMP_HELP_BROWSER_GIMP
#  define DEFAULT_WEB_BROWSER  "mozilla %s"
60
#endif
61

62
63
64
65
66
enum
{
  PROP_0,
  PROP_TRANSPARENCY_SIZE,
  PROP_TRANSPARENCY_TYPE,
67
  PROP_SNAP_DISTANCE,
68
  PROP_DEFAULT_THRESHOLD,
69
  PROP_INFO_WINDOW_PER_DISPLAY,
70
  PROP_TRUST_DIRTY_FLAG,
71
72
73
74
  PROP_SAVE_DEVICE_STATUS,
  PROP_SAVE_SESSION_INFO,
  PROP_RESTORE_SESSION,
  PROP_SHOW_TIPS,
75
  PROP_SHOW_TOOL_TIPS,
76
  PROP_TEAROFF_MENUS,
77
  PROP_CAN_CHANGE_ACCELS,
78
79
  PROP_SAVE_ACCELS,
  PROP_RESTORE_ACCELS,
80
  PROP_LAST_OPENED_SIZE,
81
82
  PROP_MAX_NEW_IMAGE_SIZE,
  PROP_THEME_PATH,
83
  PROP_THEME,
Michael Natterer's avatar
Michael Natterer committed
84
  PROP_USE_HELP,
85
  PROP_HELP_LOCALES,
86
  PROP_HELP_BROWSER,
Sven Neumann's avatar
Sven Neumann committed
87
  PROP_WEB_BROWSER,
88
89
  PROP_TOOLBOX_WINDOW_HINT,
  PROP_DOCK_WINDOW_HINT
90
91
};

92
93
static GObjectClass *parent_class = NULL;

94

95
GType
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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  */
      };

115
116
      config_type = g_type_register_static (GIMP_TYPE_DISPLAY_CONFIG,
                                            "GimpGuiConfig",
117
118
119
120
121
122
123
124
125
126
127
                                            &config_info, 0);
    }

  return config_type;
}

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

128
129
  parent_class = g_type_class_peek_parent (klass);

130
131
  object_class = G_OBJECT_CLASS (klass);

132
  object_class->finalize     = gimp_gui_config_finalize;
133
134
135
136
  object_class->set_property = gimp_gui_config_set_property;
  object_class->get_property = gimp_gui_config_get_property;

  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSPARENCY_SIZE,
137
                                 "transparency-size", TRANSPARENCY_SIZE_BLURB,
138
139
                                 GIMP_TYPE_CHECK_SIZE, GIMP_MEDIUM_CHECKS,
                                 0);
140
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSPARENCY_TYPE,
141
                                 "transparency-type", TRANSPARENCY_TYPE_BLURB,
142
143
                                 GIMP_TYPE_CHECK_TYPE, GIMP_GRAY_CHECKS,
                                 0);
144
145
146
147
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_SNAP_DISTANCE,
                                "snap-distance", DEFAULT_SNAP_DISTANCE_BLURB,
                                1, 255, 8,
                                0);
148
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_DEFAULT_THRESHOLD,
149
                                "default-threshold", DEFAULT_THRESHOLD_BLURB,
150
151
                                0, 255, 15,
                                0);
152
153
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
                                    "info-window-per-display",
154
                                    INFO_WINDOW_PER_DISPLAY_BLURB,
155
156
                                    FALSE,
                                    GIMP_PARAM_RESTART);
157
158
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG,
                                    "trust-dirty-flag",
159
                                    TRUST_DIRTY_FLAG_BLURB,
160
161
                                    FALSE,
                                    0);
162
163
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_DEVICE_STATUS,
                                    "save-device-status",
164
                                    SAVE_DEVICE_STATUS_BLURB,
165
166
                                    FALSE,
                                    0);
167
168
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
                                    "save-session-info",
169
                                    SAVE_SESSION_INFO_BLURB,
170
171
                                    TRUE,
                                    0);
172
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_SESSION,
173
                                    "restore-session", RESTORE_SESSION_BLURB,
174
175
                                    TRUE,
                                    0);
176
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
177
                                    "show-tips", SHOW_TIPS_BLURB,
178
179
                                    TRUE,
                                    0);
180
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TOOL_TIPS,
181
                                    "show-tool-tips", SHOW_TOOL_TIPS_BLURB,
182
183
                                    TRUE,
                                    0);
184
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEAROFF_MENUS,
185
                                    "tearoff-menus", TEAROFF_MENUS_BLURB,
186
187
                                    TRUE,
                                    GIMP_PARAM_RESTART);
188
189
190
191
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CAN_CHANGE_ACCELS,
                                    "can-change-accels", CAN_CHANGE_ACCELS_BLURB,
                                    FALSE,
                                    0);
192
193
194
195
196
197
198
199
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_ACCELS,
                                    "save-accels", SAVE_ACCELS_BLURB,
                                    TRUE,
                                    0);
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_ACCELS,
                                    "restore-accels", RESTORE_ACCELS_BLURB,
                                    TRUE,
                                    0);
200
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_LAST_OPENED_SIZE,
201
                                "last-opened-size", LAST_OPENED_SIZE_BLURB,
202
                                0, 1024, 10,
203
                                GIMP_PARAM_RESTART);
204
  GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
205
206
                                    "max-new-image-size",
                                    MAX_NEW_IMAGE_SIZE_BLURB,
207
                                    0, GIMP_MAX_MEMSIZE, 1 << 26,
208
                                    0);
209
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
210
                                 "theme-path", THEME_PATH_BLURB,
Sven Neumann's avatar
Sven Neumann committed
211
				 GIMP_PARAM_PATH_DIR_LIST,
212
213
                                 gimp_config_build_data_path ("themes"),
                                 GIMP_PARAM_RESTART);
214
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_THEME,
215
                                   "theme", THEME_BLURB,
216
                                   DEFAULT_THEME,
217
                                   0);
218
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_HELP,
219
                                    "use-help", USE_HELP_BLURB,
220
221
                                    TRUE,
                                    0);
222
223
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_HELP_LOCALES,
                                   "help-locales", HELP_LOCALES_BLURB,
224
                                   "",
225
                                   0);
Michael Natterer's avatar
Michael Natterer committed
226
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_HELP_BROWSER,
227
                                 "help-browser", HELP_BROWSER_BLURB,
Michael Natterer's avatar
Michael Natterer committed
228
                                 GIMP_TYPE_HELP_BROWSER_TYPE,
229
                                 DEFAULT_GIMP_HELP_BROWSER,
230
                                 0);
231
232
233
234
235
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_WEB_BROWSER,
                                 "web-browser", WEB_BROWSER_BLURB,
                                 GIMP_PARAM_PATH_FILE,
                                 DEFAULT_WEB_BROWSER,
                                 0);
236
237
238
239
240
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TOOLBOX_WINDOW_HINT,
                                 "toolbox-window-hint",
                                 TOOLBOX_WINDOW_HINT_BLURB,
                                 GIMP_TYPE_WINDOW_HINT,
                                 GIMP_WINDOW_HINT_NORMAL,
Sven Neumann's avatar
Sven Neumann committed
241
                                 GIMP_PARAM_RESTART);
242
243
244
245
246
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DOCK_WINDOW_HINT,
                                 "dock-window-hint",
                                 DOCK_WINDOW_HINT_BLURB,
                                 GIMP_TYPE_WINDOW_HINT,
                                 GIMP_WINDOW_HINT_NORMAL,
Sven Neumann's avatar
Sven Neumann committed
247
                                 GIMP_PARAM_RESTART);
248
249
}

250
251
252
static void
gimp_gui_config_finalize (GObject *object)
{
253
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
254

255
256
  g_free (gui_config->theme_path);
  g_free (gui_config->theme);
257
  g_free (gui_config->help_locales);
258
  g_free (gui_config->web_browser);
259
260
261
262

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

263
264
265
266
267
268
static void
gimp_gui_config_set_property (GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
269
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
270
271
272
273
274
275
276
277
278

  switch (property_id)
    {
    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;
279
280
281
    case PROP_SNAP_DISTANCE:
      gui_config->snap_distance = g_value_get_int (value);
      break;
282
283
284
    case PROP_DEFAULT_THRESHOLD:
      gui_config->default_threshold = g_value_get_int (value);
      break;
285
286
    case PROP_INFO_WINDOW_PER_DISPLAY:
      gui_config->info_window_per_display = g_value_get_boolean (value);
287
      break;
288
289
290
    case PROP_TRUST_DIRTY_FLAG:
      gui_config->trust_dirty_flag = g_value_get_boolean (value);
      break;
291
292
293
294
295
296
297
298
299
300
301
302
    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;
303
304
305
    case PROP_SHOW_TOOL_TIPS:
      gui_config->show_tool_tips = g_value_get_boolean (value);
      break;
306
307
308
    case PROP_TEAROFF_MENUS:
      gui_config->tearoff_menus = g_value_get_boolean (value);
      break;
309
310
311
    case PROP_CAN_CHANGE_ACCELS:
      gui_config->can_change_accels = g_value_get_boolean (value);
      break;
312
313
314
315
316
317
    case PROP_SAVE_ACCELS:
      gui_config->save_accels = g_value_get_boolean (value);
      break;
    case PROP_RESTORE_ACCELS:
      gui_config->restore_accels = g_value_get_boolean (value);
      break;
318
319
320
    case PROP_LAST_OPENED_SIZE:
      gui_config->last_opened_size = g_value_get_int (value);
      break;
321
    case PROP_MAX_NEW_IMAGE_SIZE:
322
      gui_config->max_new_image_size = g_value_get_uint64 (value);
323
324
325
326
327
328
329
330
331
      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;
332
333
334
    case PROP_USE_HELP:
      gui_config->use_help = g_value_get_boolean (value);
      break;
335
336
337
338
    case PROP_HELP_LOCALES:
      g_free (gui_config->help_locales);
      gui_config->help_locales = g_value_dup_string (value);
      break;
Michael Natterer's avatar
Michael Natterer committed
339
340
341
    case PROP_HELP_BROWSER:
      gui_config->help_browser = g_value_get_enum (value);
      break;
342
343
344
345
    case PROP_WEB_BROWSER:
      g_free (gui_config->web_browser);
      gui_config->web_browser = g_value_dup_string (value);
      break;
346
347
    case PROP_TOOLBOX_WINDOW_HINT:
      gui_config->toolbox_window_hint = g_value_get_enum (value);
Sven Neumann's avatar
Sven Neumann committed
348
      break;
349
350
    case PROP_DOCK_WINDOW_HINT:
      gui_config->dock_window_hint = g_value_get_enum (value);
Sven Neumann's avatar
Sven Neumann committed
351
      break;
352
353
354
355
356
357
358
359
360
361
362
363
364

    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)
{
365
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
366
367
368
369
370
371
372
373
374

  switch (property_id)
    {
    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;
375
376
377
    case PROP_SNAP_DISTANCE:
      g_value_set_int (value, gui_config->snap_distance);
      break;
378
379
380
    case PROP_DEFAULT_THRESHOLD:
      g_value_set_int (value, gui_config->default_threshold);
      break;
381
382
    case PROP_INFO_WINDOW_PER_DISPLAY:
      g_value_set_boolean (value, gui_config->info_window_per_display);
383
      break;
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
    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;
399
400
401
    case PROP_SHOW_TOOL_TIPS:
      g_value_set_boolean (value, gui_config->show_tool_tips);
      break;
402
403
404
    case PROP_TEAROFF_MENUS:
      g_value_set_boolean (value, gui_config->tearoff_menus);
      break;
405
406
407
    case PROP_CAN_CHANGE_ACCELS:
      g_value_set_boolean (value, gui_config->can_change_accels);
      break;
408
409
410
411
412
413
    case PROP_SAVE_ACCELS:
      g_value_set_boolean (value, gui_config->save_accels);
      break;
    case PROP_RESTORE_ACCELS:
      g_value_set_boolean (value, gui_config->restore_accels);
      break;
414
415
416
    case PROP_LAST_OPENED_SIZE:
      g_value_set_int (value, gui_config->last_opened_size);
      break;
417
    case PROP_MAX_NEW_IMAGE_SIZE:
418
      g_value_set_uint64 (value, gui_config->max_new_image_size);
419
420
421
422
423
424
425
      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;
426
427
428
    case PROP_USE_HELP:
      g_value_set_boolean (value, gui_config->use_help);
      break;
429
430
431
    case PROP_HELP_LOCALES:
      g_value_set_string (value, gui_config->help_locales);
      break;
Michael Natterer's avatar
Michael Natterer committed
432
433
434
    case PROP_HELP_BROWSER:
      g_value_set_enum (value, gui_config->help_browser);
      break;
435
436
437
    case PROP_WEB_BROWSER:
      g_value_set_string (value, gui_config->web_browser);
      break;
438
439
    case PROP_TOOLBOX_WINDOW_HINT:
      g_value_set_enum (value, gui_config->toolbox_window_hint);
Sven Neumann's avatar
Sven Neumann committed
440
      break;
441
442
    case PROP_DOCK_WINDOW_HINT:
      g_value_set_enum (value, gui_config->dock_window_hint);
Sven Neumann's avatar
Sven Neumann committed
443
      break;
444
445
446
447
448
449

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