gimpguiconfig.c 19.2 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
/* 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"
27
#include "libgimpconfig/gimpconfig.h"
28

29
30
#include "config-types.h"

31
#include "gimprc-blurbs.h"
32
33
#include "gimpguiconfig.h"

34
#include "gimp-intl.h"
35

36
37

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
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);

48

Sven Neumann's avatar
Sven Neumann committed
49
#define   DEFAULT_THEME        "Default"
50
51

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

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

94
95
static GObjectClass *parent_class = NULL;

96

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

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

  return config_type;
}

static void
gimp_gui_config_class_init (GimpGuiConfigClass *klass)
{
  GObjectClass *object_class;
129
  gchar        *path;
130

131
132
  parent_class = g_type_class_peek_parent (klass);

133
134
  object_class = G_OBJECT_CLASS (klass);

135
  object_class->finalize     = gimp_gui_config_finalize;
136
137
138
139
  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_DEFAULT_THRESHOLD,
140
                                "default-threshold", DEFAULT_THRESHOLD_BLURB,
141
142
                                0, 255, 15,
                                0);
143
144
145
146
147
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MOVE_TOOL_CHANGES_ACTIVE,
                                    "move-tool-changes-active",
                                    MOVE_TOOL_CHANGES_ACTIVE_BLURB,
                                    FALSE,
                                    0);
148
149
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
                                    "info-window-per-display",
150
                                    INFO_WINDOW_PER_DISPLAY_BLURB,
151
                                    FALSE,
152
                                    GIMP_CONFIG_PARAM_RESTART);
153
154
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TRUST_DIRTY_FLAG,
                                    "trust-dirty-flag",
155
                                    TRUST_DIRTY_FLAG_BLURB,
156
157
                                    FALSE,
                                    0);
158
159
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_DEVICE_STATUS,
                                    "save-device-status",
160
                                    SAVE_DEVICE_STATUS_BLURB,
161
162
                                    FALSE,
                                    0);
163
164
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
                                    "save-session-info",
165
                                    SAVE_SESSION_INFO_BLURB,
166
167
                                    TRUE,
                                    0);
168
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_SESSION,
169
                                    "restore-session", RESTORE_SESSION_BLURB,
170
171
                                    TRUE,
                                    0);
172
173
174
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_TOOL_OPTIONS,
                                    "save-tool-options",
                                    SAVE_TOOL_OPTIONS_BLURB,
175
                                    FALSE,
176
                                    0);
177
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
178
                                    "show-tips", SHOW_TIPS_BLURB,
179
180
                                    TRUE,
                                    0);
181
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TOOL_TIPS,
182
                                    "show-tool-tips", SHOW_TOOL_TIPS_BLURB,
183
184
                                    TRUE,
                                    0);
185
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEAROFF_MENUS,
186
                                    "tearoff-menus", TEAROFF_MENUS_BLURB,
187
                                    TRUE,
188
                                    0);
189
190
191
192
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CAN_CHANGE_ACCELS,
                                    "can-change-accels", CAN_CHANGE_ACCELS_BLURB,
                                    FALSE,
                                    0);
193
194
195
196
197
198
199
200
  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);
201
202
203
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MENU_MNEMONICS,
                                    "menu-mnemonics", MENU_MNEMONICS_BLURB,
                                    TRUE,
204
                                    GIMP_CONFIG_PARAM_RESTART);
205
  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_LAST_OPENED_SIZE,
206
                                "last-opened-size", LAST_OPENED_SIZE_BLURB,
207
                                0, 1024, 10,
208
                                GIMP_CONFIG_PARAM_RESTART);
209
  GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
210
211
                                    "max-new-image-size",
                                    MAX_NEW_IMAGE_SIZE_BLURB,
212
                                    0, GIMP_MAX_MEMSIZE, 1 << 26,
213
                                    0);
214
215
216
217
218
219
220
221
222
223
224
225
226
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_COLOR_AREA,
                                    "toolbox-color-area",
                                    TOOLBOX_COLOR_AREA_BLURB,
                                    TRUE,
                                    0);
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_FOO_AREA,
                                    "toolbox-foo-area",
                                    TOOLBOX_FOO_AREA_BLURB,
                                    TRUE,
                                    0);
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TOOLBOX_IMAGE_AREA,
                                    "toolbox-image-area",
                                    TOOLBOX_IMAGE_AREA_BLURB,
227
                                    FALSE,
228
                                    0);
229
  path = gimp_config_build_data_path ("themes");
230
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
231
                                 "theme-path", THEME_PATH_BLURB,
232
				 GIMP_CONFIG_PATH_DIR_LIST, path,
233
                                 GIMP_CONFIG_PARAM_RESTART);
234
  g_free (path);
235
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_THEME,
236
                                   "theme", THEME_BLURB,
237
                                   DEFAULT_THEME,
238
                                   0);
239
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_HELP,
240
                                    "use-help", USE_HELP_BLURB,
241
242
                                    TRUE,
                                    0);
243
244
245
246
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_HELP_BUTTON,
                                    "show-help-button", SHOW_HELP_BUTTON_BLURB,
                                    TRUE,
                                    0);
247
248
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_HELP_LOCALES,
                                   "help-locales", HELP_LOCALES_BLURB,
249
                                   "",
250
                                   0);
Michael Natterer's avatar
Michael Natterer committed
251
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_HELP_BROWSER,
252
                                 "help-browser", HELP_BROWSER_BLURB,
Michael Natterer's avatar
Michael Natterer committed
253
                                 GIMP_TYPE_HELP_BROWSER_TYPE,
254
                                 DEFAULT_GIMP_HELP_BROWSER,
255
                                 0);
256
257
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_WEB_BROWSER,
                                 "web-browser", WEB_BROWSER_BLURB,
258
                                 GIMP_CONFIG_PATH_FILE,
259
260
                                 DEFAULT_WEB_BROWSER,
                                 0);
261
262
263
264
265
  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,
266
                                 GIMP_CONFIG_PARAM_RESTART);
267
268
269
270
271
  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,
272
                                 GIMP_CONFIG_PARAM_RESTART);
273
274
275
276
277
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CURSOR_FORMAT,
                                 "cursor-format", CURSOR_FORMAT_BLURB,
                                 GIMP_TYPE_CURSOR_FORMAT,
                                 GIMP_CURSOR_FORMAT_PIXBUF,
                                 0);
278
279
}

280
281
282
static void
gimp_gui_config_finalize (GObject *object)
{
283
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
284

285
286
  g_free (gui_config->theme_path);
  g_free (gui_config->theme);
287
  g_free (gui_config->help_locales);
288
  g_free (gui_config->web_browser);
289
290
291
292

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

293
294
295
296
297
298
static void
gimp_gui_config_set_property (GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
299
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
300
301
302
303
304
305

  switch (property_id)
    {
    case PROP_DEFAULT_THRESHOLD:
      gui_config->default_threshold = g_value_get_int (value);
      break;
306
307
308
    case PROP_MOVE_TOOL_CHANGES_ACTIVE:
      gui_config->move_tool_changes_active = g_value_get_boolean (value);
      break;
309
310
    case PROP_INFO_WINDOW_PER_DISPLAY:
      gui_config->info_window_per_display = g_value_get_boolean (value);
311
      break;
312
313
314
    case PROP_TRUST_DIRTY_FLAG:
      gui_config->trust_dirty_flag = g_value_get_boolean (value);
      break;
315
316
317
318
319
320
321
322
323
    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;
324
325
326
    case PROP_SAVE_TOOL_OPTIONS:
      gui_config->save_tool_options = g_value_get_boolean (value);
      break;
327
328
329
    case PROP_SHOW_TIPS:
      gui_config->show_tips = g_value_get_boolean (value);
      break;
330
331
332
    case PROP_SHOW_TOOL_TIPS:
      gui_config->show_tool_tips = g_value_get_boolean (value);
      break;
333
334
335
    case PROP_TEAROFF_MENUS:
      gui_config->tearoff_menus = g_value_get_boolean (value);
      break;
336
337
338
    case PROP_CAN_CHANGE_ACCELS:
      gui_config->can_change_accels = g_value_get_boolean (value);
      break;
339
340
341
342
343
344
    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;
345
346
347
    case PROP_MENU_MNEMONICS:
      gui_config->menu_mnemonics = g_value_get_boolean (value);
      break;
348
349
350
    case PROP_LAST_OPENED_SIZE:
      gui_config->last_opened_size = g_value_get_int (value);
      break;
351
    case PROP_MAX_NEW_IMAGE_SIZE:
352
      gui_config->max_new_image_size = g_value_get_uint64 (value);
353
      break;
354
355
356
357
358
359
360
361
362
    case PROP_TOOLBOX_COLOR_AREA:
      gui_config->toolbox_color_area = g_value_get_boolean (value);
      break;
    case PROP_TOOLBOX_FOO_AREA:
      gui_config->toolbox_foo_area = g_value_get_boolean (value);
      break;
    case PROP_TOOLBOX_IMAGE_AREA:
      gui_config->toolbox_image_area = g_value_get_boolean (value);
      break;
363
364
365
366
367
368
369
370
    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;
371
372
373
    case PROP_USE_HELP:
      gui_config->use_help = g_value_get_boolean (value);
      break;
374
375
376
    case PROP_SHOW_HELP_BUTTON:
      gui_config->show_help_button = g_value_get_boolean (value);
      break;
377
378
379
380
    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
381
382
383
    case PROP_HELP_BROWSER:
      gui_config->help_browser = g_value_get_enum (value);
      break;
384
385
386
387
    case PROP_WEB_BROWSER:
      g_free (gui_config->web_browser);
      gui_config->web_browser = g_value_dup_string (value);
      break;
388
389
    case PROP_TOOLBOX_WINDOW_HINT:
      gui_config->toolbox_window_hint = g_value_get_enum (value);
Sven Neumann's avatar
Sven Neumann committed
390
      break;
391
392
    case PROP_DOCK_WINDOW_HINT:
      gui_config->dock_window_hint = g_value_get_enum (value);
Sven Neumann's avatar
Sven Neumann committed
393
      break;
394
395
396
    case PROP_CURSOR_FORMAT:
      gui_config->cursor_format = g_value_get_enum (value);
      break;
397
398
399
400
401
402
403
404
405
406
407
408
409

    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)
{
410
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object);
411
412
413
414
415
416

  switch (property_id)
    {
    case PROP_DEFAULT_THRESHOLD:
      g_value_set_int (value, gui_config->default_threshold);
      break;
417
418
419
    case PROP_MOVE_TOOL_CHANGES_ACTIVE:
      g_value_set_boolean (value, gui_config->move_tool_changes_active);
      break;
420
421
    case PROP_INFO_WINDOW_PER_DISPLAY:
      g_value_set_boolean (value, gui_config->info_window_per_display);
422
      break;
423
424
425
426
427
428
429
430
431
432
433
434
    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;
435
436
437
    case PROP_SAVE_TOOL_OPTIONS:
      g_value_set_boolean (value, gui_config->save_tool_options);
      break;
438
439
440
    case PROP_SHOW_TIPS:
      g_value_set_boolean (value, gui_config->show_tips);
      break;
441
442
443
    case PROP_SHOW_TOOL_TIPS:
      g_value_set_boolean (value, gui_config->show_tool_tips);
      break;
444
445
446
    case PROP_TEAROFF_MENUS:
      g_value_set_boolean (value, gui_config->tearoff_menus);
      break;
447
448
449
    case PROP_CAN_CHANGE_ACCELS:
      g_value_set_boolean (value, gui_config->can_change_accels);
      break;
450
451
452
453
454
455
    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;
456
457
458
    case PROP_MENU_MNEMONICS:
      g_value_set_boolean (value, gui_config->menu_mnemonics);
      break;
459
460
461
    case PROP_LAST_OPENED_SIZE:
      g_value_set_int (value, gui_config->last_opened_size);
      break;
462
    case PROP_MAX_NEW_IMAGE_SIZE:
463
      g_value_set_uint64 (value, gui_config->max_new_image_size);
464
      break;
465
466
467
468
469
470
471
472
473
    case PROP_TOOLBOX_COLOR_AREA:
      g_value_set_boolean (value, gui_config->toolbox_color_area);
      break;
    case PROP_TOOLBOX_FOO_AREA:
      g_value_set_boolean (value, gui_config->toolbox_foo_area);
      break;
    case PROP_TOOLBOX_IMAGE_AREA:
      g_value_set_boolean (value, gui_config->toolbox_image_area);
      break;
474
475
476
477
478
479
    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;
480
481
482
    case PROP_USE_HELP:
      g_value_set_boolean (value, gui_config->use_help);
      break;
483
484
485
    case PROP_SHOW_HELP_BUTTON:
      g_value_set_boolean (value, gui_config->show_help_button);
      break;
486
487
488
    case PROP_HELP_LOCALES:
      g_value_set_string (value, gui_config->help_locales);
      break;
Michael Natterer's avatar
Michael Natterer committed
489
490
491
    case PROP_HELP_BROWSER:
      g_value_set_enum (value, gui_config->help_browser);
      break;
492
493
494
    case PROP_WEB_BROWSER:
      g_value_set_string (value, gui_config->web_browser);
      break;
495
496
    case PROP_TOOLBOX_WINDOW_HINT:
      g_value_set_enum (value, gui_config->toolbox_window_hint);
Sven Neumann's avatar
Sven Neumann committed
497
      break;
498
499
    case PROP_DOCK_WINDOW_HINT:
      g_value_set_enum (value, gui_config->dock_window_hint);
Sven Neumann's avatar
Sven Neumann committed
500
      break;
501
502
503
    case PROP_CURSOR_FORMAT:
      g_value_set_enum (value, gui_config->cursor_format);
      break;
504
505
506
507
508
509

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