mirror of https://github.com/GNOME/gimp.git
Bug 731279 - Tool Preset Editor not working correctly
Have "Save" and "Restore" buttons in both the tool preset list/grid and the tool preset editor. The save button stores the active tool's options in the preset, if possible.
This commit is contained in:
parent
b8db0aa54e
commit
3d1c5641f7
|
@ -172,6 +172,8 @@ libappactions_a_SOURCES = \
|
|||
tool-presets-commands.h \
|
||||
tool-preset-editor-actions.c \
|
||||
tool-preset-editor-actions.h \
|
||||
tool-preset-editor-commands.c \
|
||||
tool-preset-editor-commands.h \
|
||||
tools-actions.c \
|
||||
tools-actions.h \
|
||||
tools-commands.c \
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "data-editor-commands.h"
|
||||
#include "tool-preset-editor-actions.h"
|
||||
#include "tool-preset-editor-commands.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -41,7 +42,20 @@ static const GimpActionEntry tool_preset_editor_actions[] =
|
|||
{
|
||||
{ "tool-preset-editor-popup", GIMP_STOCK_TOOL_PRESET,
|
||||
NC_("tool-preset-editor-action", "Tool Preset Editor Menu"), NULL, NULL, NULL,
|
||||
GIMP_HELP_BRUSH_EDITOR_DIALOG }
|
||||
GIMP_HELP_TOOL_PRESET_EDITOR_DIALOG },
|
||||
|
||||
{ "tool-preset-editor-save", "document-save",
|
||||
NC_("tool-preset-editor-action", "_Save Tool Options to Preset"), NULL,
|
||||
NC_("tool-preset-editor-action", "Save the active tool options to this "
|
||||
"tool preset"),
|
||||
G_CALLBACK (tool_preset_editor_save_cmd_callback),
|
||||
GIMP_HELP_TOOL_PRESET_SAVE },
|
||||
|
||||
{ "tool-preset-editor-restore", "document-revert",
|
||||
NC_("tool-preset-editor-action", "_Restore Tool Preset"), NULL,
|
||||
NC_("tool-preset-editor-action", "Restore this tool preset"),
|
||||
G_CALLBACK (tool_preset_editor_restore_cmd_callback),
|
||||
GIMP_HELP_TOOL_PRESET_RESTORE }
|
||||
};
|
||||
|
||||
|
||||
|
@ -51,7 +65,7 @@ static const GimpToggleActionEntry tool_preset_editor_toggle_actions[] =
|
|||
NC_("tool-preset-editor-action", "Edit Active Tool Preset"), NULL, NULL,
|
||||
G_CALLBACK (data_editor_edit_active_cmd_callback),
|
||||
FALSE,
|
||||
GIMP_HELP_BRUSH_EDITOR_EDIT_ACTIVE }
|
||||
GIMP_HELP_TOOL_PRESET_EDITOR_EDIT_ACTIVE }
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,7 +96,9 @@ tool_preset_editor_actions_update (GimpActionGroup *group,
|
|||
#define SET_ACTIVE(action,condition) \
|
||||
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
||||
|
||||
SET_ACTIVE ("tool-preset-editor-edit-active", edit_active);
|
||||
SET_SENSITIVE ("tool-preset-editor-save", data_editor->data);
|
||||
SET_SENSITIVE ("tool-preset-editor-restore", data_editor->data);
|
||||
SET_ACTIVE ("tool-preset-editor-edit-active", edit_active);
|
||||
|
||||
#undef SET_SENSITIVE
|
||||
#undef SET_ACTIVE
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "actions-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
#include "core/gimptoolpreset.h"
|
||||
|
||||
#include "widgets/gimpdataeditor.h"
|
||||
|
||||
#include "tool-preset-editor-commands.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
tool_preset_editor_save_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataEditor *editor = GIMP_DATA_EDITOR (data);
|
||||
GimpContext *context = editor->context;
|
||||
GimpToolPreset *preset;
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
preset = GIMP_TOOL_PRESET (gimp_data_editor_get_data (editor));
|
||||
tool_info = gimp_context_get_tool (gimp_get_user_context (context->gimp));
|
||||
|
||||
if (tool_info && preset)
|
||||
{
|
||||
GimpToolInfo *preset_tool;
|
||||
|
||||
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
|
||||
|
||||
if (tool_info != preset_tool)
|
||||
{
|
||||
gimp_message (context->gimp,
|
||||
G_OBJECT (editor), GIMP_MESSAGE_WARNING,
|
||||
_("Can't save '%s' tool options to an "
|
||||
"existing '%s' tool preset."),
|
||||
tool_info->blurb,
|
||||
preset_tool->blurb);
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_config_sync (G_OBJECT (tool_info->tool_options),
|
||||
G_OBJECT (preset->tool_options), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tool_preset_editor_restore_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDataEditor *editor = GIMP_DATA_EDITOR (data);
|
||||
GimpContext *context = editor->context;
|
||||
GimpToolPreset *preset;
|
||||
|
||||
preset = GIMP_TOOL_PRESET (gimp_data_editor_get_data (editor));
|
||||
|
||||
if (preset)
|
||||
gimp_context_tool_preset_changed (context);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __TOOL_PRESET_EDITOR_COMMANDS_H__
|
||||
#define __TOOL_PRESET_EDITOR_COMMANDS_H__
|
||||
|
||||
|
||||
void tool_preset_editor_save_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tool_preset_editor_restore_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
|
||||
#endif /* __TOOL_PRESET_EDITOR_COMMANDS_H__ */
|
|
@ -70,6 +70,13 @@ static const GimpActionEntry tool_presets_actions[] =
|
|||
G_CALLBACK (data_show_in_file_manager_cmd_callback),
|
||||
GIMP_HELP_TOOL_PRESET_SHOW_IN_FILE_MANAGER },
|
||||
|
||||
{ "tool-presets-save", "document-save",
|
||||
NC_("tool-presets-action", "_Save Tool Options to Preset"), NULL,
|
||||
NC_("tool-presets-action", "Save the active tool options to this "
|
||||
"tool preset"),
|
||||
G_CALLBACK (tool_presets_save_cmd_callback),
|
||||
GIMP_HELP_TOOL_PRESET_SAVE },
|
||||
|
||||
{ "tool-presets-restore", "document-revert",
|
||||
NC_("tool-presets-action", "_Restore Tool Preset"), NULL,
|
||||
NC_("tool-presets-action", "Restore this tool preset"),
|
||||
|
@ -140,6 +147,7 @@ tool_presets_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("tool-presets-duplicate", tool_preset && GIMP_DATA_GET_CLASS (data)->duplicate);
|
||||
SET_SENSITIVE ("tool-presets-copy-location", file);
|
||||
SET_SENSITIVE ("tool-presets-show-in-file-manager", file);
|
||||
SET_SENSITIVE ("tool-presets-save", tool_preset);
|
||||
SET_SENSITIVE ("tool-presets-restore", tool_preset);
|
||||
SET_SENSITIVE ("tool-presets-delete", tool_preset && gimp_data_is_deletable (data));
|
||||
|
||||
|
|
|
@ -20,20 +20,62 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "actions-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
#include "core/gimptoolpreset.h"
|
||||
|
||||
#include "widgets/gimpcontainereditor.h"
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
|
||||
#include "tool-presets-commands.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
tool_presets_save_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
|
||||
GimpContext *context;
|
||||
GimpToolPreset *preset;
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
context = gimp_container_view_get_context (editor->view);
|
||||
|
||||
preset = gimp_context_get_tool_preset (context);
|
||||
tool_info = gimp_context_get_tool (gimp_get_user_context (context->gimp));
|
||||
|
||||
if (tool_info && preset)
|
||||
{
|
||||
GimpToolInfo *preset_tool;
|
||||
|
||||
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
|
||||
|
||||
if (tool_info != preset_tool)
|
||||
{
|
||||
gimp_message (context->gimp,
|
||||
G_OBJECT (editor), GIMP_MESSAGE_WARNING,
|
||||
_("Can't save '%s' tool options to an "
|
||||
"existing '%s' tool preset."),
|
||||
tool_info->blurb,
|
||||
preset_tool->blurb);
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_config_sync (G_OBJECT (tool_info->tool_options),
|
||||
G_OBJECT (preset->tool_options), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tool_presets_restore_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#define __TOOL_PRESETS_COMMANDS_H__
|
||||
|
||||
|
||||
void tool_presets_save_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void tool_presets_restore_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
|
|
|
@ -352,6 +352,7 @@
|
|||
#define GIMP_HELP_DYNAMICS_EDITOR_DIALOG "gimp-dynamics-editor-dialog"
|
||||
|
||||
#define GIMP_HELP_TOOL_PRESET_EDITOR_DIALOG "gimp-tool-preset-editor-dialog"
|
||||
#define GIMP_HELP_TOOL_PRESET_EDITOR_EDIT_ACTIVE "gimp-tool-preset-editor-edit-active"
|
||||
|
||||
#define GIMP_HELP_DYNAMICS_DIALOG "gimp-dynamics-dialog"
|
||||
#define GIMP_HELP_DYNAMICS_EDIT "gimp-dynamics-edit"
|
||||
|
@ -452,6 +453,7 @@
|
|||
#define GIMP_HELP_TOOL_PRESET_DUPLICATE "gimp-tool-preset-duplicate"
|
||||
#define GIMP_HELP_TOOL_PRESET_COPY_LOCATION "gimp-tool-preset-copy-location"
|
||||
#define GIMP_HELP_TOOL_PRESET_SHOW_IN_FILE_MANAGER "gimp-tool-preset-show-in-file-manager"
|
||||
#define GIMP_HELP_TOOL_PRESET_SAVE "gimp-tool-preset-save"
|
||||
#define GIMP_HELP_TOOL_PRESET_RESTORE "gimp-tool-preset-restore"
|
||||
#define GIMP_HELP_TOOL_PRESET_DELETE "gimp-tool-preset-delete"
|
||||
#define GIMP_HELP_TOOL_PRESET_REFRESH "gimp-tool-preset-refresh"
|
||||
|
|
|
@ -195,6 +195,14 @@ gimp_tool_preset_editor_constructed (GObject *object)
|
|||
gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gimp_editor_add_action_button (GIMP_EDITOR (editor),
|
||||
"tool-preset-editor",
|
||||
"tool-preset-editor-save", NULL);
|
||||
|
||||
button = gimp_editor_add_action_button (GIMP_EDITOR (editor),
|
||||
"tool-preset-editor",
|
||||
"tool-preset-editor-restore", NULL);
|
||||
|
||||
if (data_editor->data)
|
||||
gimp_tool_preset_editor_sync_data (editor);
|
||||
}
|
||||
|
|
|
@ -90,9 +90,14 @@ gimp_tool_preset_factory_view_new (GimpViewType view_type,
|
|||
editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (factory_view)->view);
|
||||
|
||||
button = gimp_editor_add_action_button (editor, "tool-presets",
|
||||
"tool-presets-restore", NULL);
|
||||
"tool-presets-save", NULL);
|
||||
gtk_box_reorder_child (gimp_editor_get_button_box (editor),
|
||||
button, 2);
|
||||
|
||||
button = gimp_editor_add_action_button (editor, "tool-presets",
|
||||
"tool-presets-restore", NULL);
|
||||
gtk_box_reorder_child (gimp_editor_get_button_box (editor),
|
||||
button, 3);
|
||||
|
||||
return GTK_WIDGET (factory_view);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
<ui>
|
||||
<popup action="tool-preset-editor-popup">
|
||||
<menuitem action="tool-preset-editor-save" />
|
||||
<menuitem action="tool-preset-editor-restore" />
|
||||
<separator />
|
||||
<menuitem action="tool-preset-editor-edit-active" />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<menuitem action="tool-presets-duplicate" />
|
||||
<menuitem action="tool-presets-copy-location" />
|
||||
<menuitem action="tool-presets-show-in-file-manager" />
|
||||
<menuitem action="tool-presets-save" />
|
||||
<menuitem action="tool-presets-restore" />
|
||||
<menuitem action="tool-presets-delete" />
|
||||
<separator />
|
||||
|
|
|
@ -76,7 +76,9 @@ app/actions/text-tool-commands.c
|
|||
app/actions/tool-options-actions.c
|
||||
app/actions/tool-options-commands.c
|
||||
app/actions/tool-preset-editor-actions.c
|
||||
app/actions/tool-preset-editor-commands.c
|
||||
app/actions/tool-presets-actions.c
|
||||
app/actions/tool-presets-commands.c
|
||||
app/actions/tools-actions.c
|
||||
app/actions/vectors-actions.c
|
||||
app/actions/vectors-commands.c
|
||||
|
|
Loading…
Reference in New Issue