32
32
#include "core/gimplist.h"
33
33
#include "core/gimptoolinfo.h"
34
34
#include "core/gimptooloptions.h"
35
#include "core/gimptoolpresets.h"
36
37
#include "gimpdnd.h"
37
38
#include "gimpdocked.h"
38
39
#include "gimphelp-ids.h"
39
40
#include "gimpmenufactory.h"
41
#include "gimppropwidgets.h"
40
42
#include "gimpview.h"
41
43
#include "gimpviewrenderer.h"
42
#include "gimppropwidgets.h"
43
44
#include "gimptooloptionseditor.h"
44
45
#include "gimpuimanager.h"
45
46
#include "gimpwidgets-utils.h"
47
48
#include "gimp-intl.h"
50
static void gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass);
51
static void gimp_tool_options_editor_init (GimpToolOptionsEditor *editor);
52
static void gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *docked_iface);
51
static void gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *iface);
54
53
static GObject * gimp_tool_options_editor_constructor (GType type,
76
77
GimpToolInfo *tool_info,
77
78
GimpToolOptionsEditor *editor);
79
static void gimp_tool_options_editor_presets_changed (GimpContainer *container,
80
GimpToolOptions *options,
80
static void gimp_tool_options_editor_presets_changed (GimpToolPresets *presets,
81
81
GimpToolOptionsEditor *editor);
84
static GimpEditorClass *parent_class = NULL;
88
gimp_tool_options_editor_get_type (void)
90
static GType type = 0;
94
static const GTypeInfo editor_info =
96
sizeof (GimpToolOptionsEditorClass),
98
NULL, /* base_finalize */
99
(GClassInitFunc) gimp_tool_options_editor_class_init,
100
NULL, /* class_finalize */
101
NULL, /* class_tool */
102
sizeof (GimpToolOptionsEditor),
104
(GInstanceInitFunc) gimp_tool_options_editor_init,
106
static const GInterfaceInfo docked_iface_info =
108
(GInterfaceInitFunc) gimp_tool_options_editor_docked_iface_init,
109
NULL, /* iface_finalize */
110
NULL /* iface_data */
113
type = g_type_register_static (GIMP_TYPE_EDITOR,
114
"GimpToolOptionsEditor",
117
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
82
static void gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor,
83
GimpToolPresets *presets);
84
static void gimp_tool_options_editor_save_presets (GimpToolOptionsEditor *editor);
87
G_DEFINE_TYPE_WITH_CODE (GimpToolOptionsEditor, gimp_tool_options_editor,
89
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
90
gimp_tool_options_editor_docked_iface_init))
92
#define parent_class gimp_tool_options_editor_parent_class
125
96
gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass)
246
220
GimpContext *context,
247
221
GtkIconSize size)
254
screen = gtk_widget_get_screen (GTK_WIDGET (docked));
255
gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
256
size, &width, &height);
258
view = gimp_prop_preview_new (G_OBJECT (context), "tool", height);
223
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (docked));
228
gtk_icon_size_lookup_for_settings (settings, size, &width, &height);
230
view = gimp_prop_view_new (G_OBJECT (context), "tool", context, height);
259
231
GIMP_VIEW (view)->renderer->size = -1;
260
232
gimp_view_renderer_set_size_full (GIMP_VIEW (view)->renderer,
261
233
width, height, 0);
301
273
user_context = gimp_get_user_context (gimp);
303
g_signal_connect_object (user_context, "tool_changed",
275
g_signal_connect_object (user_context, "tool-changed",
304
276
G_CALLBACK (gimp_tool_options_editor_tool_changed),
332
304
GimpEditor *gimp_editor = GIMP_EDITOR (editor);
334
gimp_ui_manager_ui_get (gimp_editor->ui_manager, gimp_editor->ui_path);
306
gtk_ui_manager_get_widget (GTK_UI_MANAGER (gimp_editor->ui_manager),
307
gimp_editor->ui_path);
335
308
gimp_ui_manager_update (gimp_editor->ui_manager, gimp_editor->popup_data);
337
310
gimp_ui_manager_ui_popup (gimp_editor->ui_manager, path,
396
366
GimpToolInfo *tool_info,
397
367
GimpToolOptionsEditor *editor)
399
GimpContainer *presets;
400
GtkWidget *options_gui;
369
GimpToolPresets *presets;
370
GtkWidget *options_gui;
402
372
if (tool_info && tool_info->tool_options == editor->visible_tool_options)
405
375
if (editor->visible_tool_options)
407
presets = editor->visible_tool_options->tool_info->options_presets;
377
presets = editor->visible_tool_options->tool_info->presets;
410
380
g_signal_handlers_disconnect_by_func (presets,
423
393
if (tool_info && tool_info->tool_options)
425
presets = tool_info->options_presets;
395
presets = tool_info->presets;
429
g_signal_connect_object (presets, "add",
430
G_CALLBACK (gimp_tool_options_editor_presets_changed),
431
G_OBJECT (editor), 0);
432
g_signal_connect_object (presets, "remove",
433
G_CALLBACK (gimp_tool_options_editor_presets_changed),
434
G_OBJECT (editor), 0);
398
g_signal_connect_object (presets, "changed",
399
G_CALLBACK (gimp_tool_options_editor_presets_changed),
400
G_OBJECT (editor), 0);
437
402
options_gui = g_object_get_data (G_OBJECT (tool_info->tool_options),
438
403
"gimp-tool-options-gui");
456
gimp_tool_options_editor_presets_changed (presets, NULL, editor);
421
gimp_tool_options_editor_presets_update (editor, presets);
458
423
gimp_docked_title_changed (GIMP_DOCKED (editor));
462
gimp_tool_options_editor_presets_changed (GimpContainer *container,
463
GimpToolOptions *options,
427
gimp_tool_options_editor_save_presets_idle (GimpToolOptionsEditor *editor)
429
editor->save_idle_id = 0;
431
gimp_tool_options_editor_save_presets (editor);
437
gimp_tool_options_editor_queue_save_presets (GimpToolOptionsEditor *editor,
438
GimpToolPresets *presets)
440
if (g_list_find (editor->save_queue, presets))
443
editor->save_queue = g_list_append (editor->save_queue, presets);
445
if (! editor->save_idle_id)
447
editor->save_idle_id =
448
g_idle_add ((GSourceFunc) gimp_tool_options_editor_save_presets_idle,
454
gimp_tool_options_editor_save_presets (GimpToolOptionsEditor *editor)
458
if (editor->save_idle_id)
460
g_source_remove (editor->save_idle_id);
461
editor->save_idle_id = 0;
464
for (list = editor->save_queue; list; list = list->next)
466
GimpToolPresets *presets = list->data;
467
GError *error = NULL;
469
if (! gimp_tool_presets_save (presets, &error))
471
gimp_message (editor->gimp, G_OBJECT (editor), GIMP_MESSAGE_ERROR,
472
_("Error saving tool options presets: %s"),
474
g_error_free (error);
478
g_list_free (editor->save_queue);
480
editor->save_queue = NULL;
484
gimp_tool_options_editor_presets_changed (GimpToolPresets *presets,
464
485
GimpToolOptionsEditor *editor)
487
gimp_tool_options_editor_queue_save_presets (editor, presets);
489
gimp_tool_options_editor_presets_update (editor, presets);
493
gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor,
494
GimpToolPresets *presets)
466
496
gboolean save_sensitive = FALSE;
467
497
gboolean restore_sensitive = FALSE;
468
498
gboolean delete_sensitive = FALSE;
469
499
gboolean reset_sensitive = FALSE;
473
503
save_sensitive = TRUE;
474
504
reset_sensitive = TRUE;
476
if (gimp_container_num_children (container))
506
if (! gimp_container_is_empty (GIMP_CONTAINER (presets)))
478
508
restore_sensitive = TRUE;
479
509
delete_sensitive = TRUE;