21
21
#include <gtk/gtk.h>
23
23
#include "libgimpbase/gimpbase.h"
24
#include "libgimpconfig/gimpconfig.h"
25
#include "libgimpwidgets/gimpwidgets.h"
25
27
#include "tools-types.h"
27
#include "config/gimpconfig.h"
28
#include "config/gimpconfig-utils.h"
30
29
#include "core/gimp.h"
31
#include "core/gimplist.h"
30
#include "core/gimp-contexts.h"
32
31
#include "core/gimptoolinfo.h"
33
32
#include "core/gimptooloptions.h"
33
#include "core/gimptoolpresets.h"
35
35
#include "gimp-tools.h"
36
36
#include "gimptooloptions-gui.h"
37
37
#include "tool_manager.h"
39
39
#include "gimpairbrushtool.h"
40
#include "gimpaligntool.h"
40
41
#include "gimpblendtool.h"
41
42
#include "gimpbrightnesscontrasttool.h"
42
43
#include "gimpbucketfilltool.h"
53
54
#include "gimperasertool.h"
54
55
#include "gimpfliptool.h"
55
56
#include "gimpfreeselecttool.h"
57
#include "gimpforegroundselecttool.h"
56
58
#include "gimpfuzzyselecttool.h"
59
#include "gimphealtool.h"
57
60
#include "gimphuesaturationtool.h"
58
61
#include "gimpinktool.h"
59
62
#include "gimpiscissorstool.h"
63
66
#include "gimpmovetool.h"
64
67
#include "gimppaintbrushtool.h"
65
68
#include "gimppenciltool.h"
69
#include "gimpperspectiveclonetool.h"
66
70
#include "gimpperspectivetool.h"
67
71
#include "gimpposterizetool.h"
68
#include "gimprectselecttool.h"
69
72
#include "gimpthresholdtool.h"
73
#include "gimprectangleselecttool.h"
70
74
#include "gimprotatetool.h"
71
75
#include "gimpscaletool.h"
72
76
#include "gimpsheartool.h"
118
127
gimp_dodge_burn_tool_register,
119
128
gimp_smudge_tool_register,
120
129
gimp_convolve_tool_register,
130
gimp_perspective_clone_tool_register,
131
gimp_heal_tool_register,
121
132
gimp_clone_tool_register,
122
133
gimp_ink_tool_register,
123
134
gimp_airbrush_tool_register,
258
276
list = g_list_next (list))
260
GimpToolInfo *tool_info;
278
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
280
/* get default values from prefs (see bug #120832) */
281
gimp_tool_options_reset (tool_info->tool_options);
284
gimp_contexts_load (gimp);
286
for (list = GIMP_LIST (gimp->tool_info_list)->list;
288
list = g_list_next (list))
290
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
261
291
GimpToolOptionsGUIFunc options_gui_func;
262
292
GtkWidget *options_gui;
264
tool_info = GIMP_TOOL_INFO (list->data);
266
/* get default values from prefs (see bug #120832) */
267
gimp_tool_options_reset (tool_info->tool_options);
269
gimp_tool_options_deserialize (tool_info->tool_options, NULL, NULL);
294
gimp_context_copy_properties (gimp_get_user_context (gimp),
295
GIMP_CONTEXT (tool_info->tool_options),
296
GIMP_CONTEXT_ALL_PROPS_MASK);
298
gimp_tool_options_deserialize (tool_info->tool_options, NULL);
271
300
options_gui_func = g_object_get_data (G_OBJECT (tool_info),
272
301
"gimp-tool-options-gui-func");
282
311
options_gui = gimp_tool_options_gui (tool_info->tool_options);
284
label = gtk_label_new (_("This tool has no options."));
313
label = gtk_label_new (_("This tool has\nno options."));
314
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
315
gimp_label_set_attributes (GTK_LABEL (label),
316
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
285
318
gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6);
286
319
gtk_widget_show (label);
289
322
g_object_set_data (G_OBJECT (tool_info->tool_options),
290
323
"gimp-tool-options-gui", options_gui);
292
if (tool_info->options_presets)
297
filename = gimp_tool_options_build_filename (tool_info->tool_options,
299
gimp_config_deserialize_file (GIMP_CONFIG (tool_info->options_presets),
304
gimp_list_reverse (GIMP_LIST (tool_info->options_presets));
306
for (list = GIMP_LIST (tool_info->options_presets)->list;
308
list = g_list_next (list))
310
g_object_set (list->data, "tool-info", tool_info, NULL);
325
if (tool_info->presets)
326
gimp_tool_presets_load (tool_info->presets, NULL);
317
gimp_tools_save (Gimp *gimp)
331
gimp_tools_save (Gimp *gimp,
332
gboolean save_tool_options,
333
gboolean always_save)
322
337
g_return_if_fail (GIMP_IS_GIMP (gimp));
324
for (list = GIMP_LIST (gimp->tool_info_list)->list;
326
list = g_list_next (list))
339
if (save_tool_options && (! tool_options_deleted || always_save))
328
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
330
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
332
if (tool_info->options_presets)
343
gimp_contexts_save (gimp);
345
gimp_tool_options_create_folder ();
347
for (list = GIMP_LIST (gimp->tool_info_list)->list;
349
list = g_list_next (list))
338
filename = gimp_tool_options_build_filename (tool_info->tool_options,
341
header = g_strdup_printf ("GIMP %s options presets",
342
GIMP_OBJECT (tool_info)->name);
343
footer = g_strdup_printf ("end of %s options presets",
344
GIMP_OBJECT (tool_info)->name);
346
gimp_config_serialize_to_file (GIMP_CONFIG (tool_info->options_presets),
347
filename, header, footer,
351
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
353
gimp_tool_options_serialize (tool_info->tool_options, NULL);
356
357
filename = gimp_personal_rc_file ("toolrc");
359
if (gimp->be_verbose)
360
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
357
362
gimp_config_serialize_to_file (GIMP_CONFIG (gimp->tool_info_list),
362
367
g_free (filename);
371
gimp_tools_clear (Gimp *gimp,
375
gboolean success = TRUE;
377
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
379
for (list = GIMP_LIST (gimp->tool_info_list)->list;
381
list = g_list_next (list))
383
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
385
success = gimp_tool_options_delete (tool_info->tool_options, NULL);
389
success = gimp_contexts_clear (gimp, error);
392
tool_options_deleted = TRUE;
366
398
gimp_tools_get_default_order (Gimp *gimp)
404
437
if (tool_type == GIMP_TYPE_PENCIL_TOOL)
406
paint_core_name = "GimpPencil";
439
paint_core_name = "gimp-pencil";
408
441
else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
410
paint_core_name = "GimpPaintbrush";
443
paint_core_name = "gimp-paintbrush";
412
445
else if (tool_type == GIMP_TYPE_ERASER_TOOL)
414
paint_core_name = "GimpEraser";
447
paint_core_name = "gimp-eraser";
416
449
else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL)
418
paint_core_name = "GimpAirbrush";
451
paint_core_name = "gimp-airbrush";
420
453
else if (tool_type == GIMP_TYPE_CLONE_TOOL)
422
paint_core_name = "GimpClone";
455
paint_core_name = "gimp-clone";
457
else if (tool_type == GIMP_TYPE_HEAL_TOOL)
459
paint_core_name = "gimp-heal";
461
else if (tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL)
463
paint_core_name = "gimp-perspective-clone";
424
465
else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL)
426
paint_core_name = "GimpConvolve";
467
paint_core_name = "gimp-convolve";
428
469
else if (tool_type == GIMP_TYPE_SMUDGE_TOOL)
430
paint_core_name = "GimpSmudge";
471
paint_core_name = "gimp-smudge";
432
473
else if (tool_type == GIMP_TYPE_DODGE_BURN_TOOL)
434
paint_core_name = "GimpDodgeBurn";
475
paint_core_name = "gimp-dodge-burn";
436
477
else if (tool_type == GIMP_TYPE_INK_TOOL)
438
paint_core_name = "GimpInk";
479
paint_core_name = "gimp-ink";
442
paint_core_name = "GimpPaintbrush";
483
paint_core_name = "gimp-paintbrush";
445
486
tool_info = gimp_tool_info_new (gimp,
447
488
tool_options_type,
459
if (tool_type == GIMP_TYPE_TEXT_TOOL)
460
gimp_config_connect (G_OBJECT (tool_info->tool_options),
461
G_OBJECT (gimp_get_user_context (gimp)),
464
if (g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL))
465
g_object_set (tool_info, "visible", FALSE, NULL);
500
visible = (! g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL));
502
g_object_set (tool_info, "visible", visible, NULL);
503
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-default-visible",
504
GINT_TO_POINTER (visible));
467
506
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
468
507
options_gui_func);