Commit 92eed69f authored by Michael Natterer's avatar Michael Natterer 😴

app: add new action to restore a tool preset from the list

In order to make things more obvious here. Before, a tool preset could
only be rstored from the list by selecting it, which only worked if
another preset was active before. Now the selected preset can easily
be restored again.
parent e0890956
......@@ -161,6 +161,8 @@ libappactions_a_SOURCES = \
tool-options-commands.h \
tool-presets-actions.c \
tool-presets-actions.h \
tool-presets-commands.c \
tool-presets-commands.h \
tool-preset-editor-actions.c \
tool-preset-editor-actions.h \
tools-actions.c \
......
......@@ -35,6 +35,7 @@
#include "actions.h"
#include "data-commands.h"
#include "tool-presets-actions.h"
#include "tool-presets-commands.h"
#include "gimp-intl.h"
......@@ -69,6 +70,12 @@ 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-restore", "document-revert",
NC_("tool-presets-action", "_Restore Tool Preset"), NULL,
NC_("tool-presets-action", "Restore this tool preset"),
G_CALLBACK (tool_presets_restore_cmd_callback),
GIMP_HELP_TOOL_PRESET_RESTORE },
{ "tool-presets-delete", "edit-delete",
NC_("tool-presets-action", "_Delete Tool Preset"), NULL,
NC_("tool-presets-action", "Delete this tool preset"),
......@@ -133,6 +140,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-restore", tool_preset);
SET_SENSITIVE ("tool-presets-delete", tool_preset && gimp_data_is_deletable (data));
#undef SET_SENSITIVE
......
/* 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 "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimpcontext.h"
#include "widgets/gimpcontainereditor.h"
#include "widgets/gimpcontainerview.h"
#include "tool-presets-commands.h"
/* public functions */
void
tool_presets_restore_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
GimpToolPreset *preset;
context = gimp_container_view_get_context (editor->view);
preset = gimp_context_get_tool_preset (context);
if (preset)
gimp_context_tool_preset_changed (context);
}
/* 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_PRESETS_COMMANDS_H__
#define __TOOL_PRESETS_COMMANDS_H__
void tool_presets_restore_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __TOOL_PRESETS_COMMANDS_H__ */
......@@ -433,6 +433,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_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"
......
......@@ -60,6 +60,8 @@ gimp_tool_preset_factory_view_new (GimpViewType view_type,
GimpMenuFactory *menu_factory)
{
GimpToolPresetFactoryView *factory_view;
GimpEditor *editor;
GtkWidget *button;
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
......@@ -85,5 +87,12 @@ gimp_tool_preset_factory_view_new (GimpViewType view_type,
gtk_widget_hide (gimp_data_factory_view_get_duplicate_button (GIMP_DATA_FACTORY_VIEW (factory_view)));
editor = GIMP_EDITOR (GIMP_CONTAINER_EDITOR (factory_view)->view);
button = gimp_editor_add_action_button (editor, "tool-presets",
"tool-presets-restore", NULL);
gtk_box_reorder_child (gimp_editor_get_button_box (editor),
button, 2);
return GTK_WIDGET (factory_view);
}
......@@ -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-restore" />
<menuitem action="tool-presets-delete" />
<separator />
<menuitem action="tool-presets-refresh" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment