app: unlink transform directions on tool halt; make chain button insensitive

In GimpTransformGridTool, keep the transform-direction chain-button
insensitive while the tool is not active, and always unlink the
button when halting the tool.  This avoids the directions from
accidentally being kept linked, resulting in the tool seemingly
having no effect.

(cherry picked from commit 9f6af7dbd3)
This commit is contained in:
Ell
2020-04-27 16:41:43 +03:00
parent 9ee2b6685e
commit a4296bb6bb
3 changed files with 36 additions and 14 deletions

View File

@ -100,11 +100,12 @@ gimp_transform_grid_options_class_init (GimpTransformGridOptionsClass *klass)
g_object_class_override_property (object_class, PROP_DIRECTION,
"direction");
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DIRECTION_LINKED,
"direction-linked",
NULL, NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DIRECTION_LINKED,
g_param_spec_boolean ("direction-linked",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_PREVIEW,
"show-preview",
@ -390,7 +391,8 @@ gimp_transform_grid_options_get_property (GObject *object,
GtkWidget *
gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GObject *config = G_OBJECT (tool_options);
GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_OPTIONS (tool_options);
GimpTransformGridToolClass *tg_class;
GtkWidget *vbox;
GtkWidget *vbox2;
@ -426,6 +428,7 @@ gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
button = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE);
gimp_chain_button_set_icon_size (GIMP_CHAIN_BUTTON (button),
GTK_ICON_SIZE_MENU);
gtk_widget_show (button);
@ -434,6 +437,8 @@ gimp_transform_grid_options_gui (GimpToolOptions *tool_options)
button, "active",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
options->direction_chain_button = button;
}
g_type_class_unref (tg_class);

View File

@ -55,6 +55,9 @@ struct _GimpTransformGridOptions
gboolean frompivot_perspective;
gboolean cornersnap;
gboolean fixedpivot;
/* options gui */
GtkWidget *direction_chain_button;
};
struct _GimpTransformGridOptionsClass

View File

@ -332,12 +332,13 @@ gimp_transform_grid_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpObject *object;
UndoInfo *undo_info;
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
GimpTransformGridOptions *tg_options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpObject *object;
UndoInfo *undo_info;
object = gimp_transform_tool_check_active_object (tr_tool, display, error);
@ -384,6 +385,9 @@ gimp_transform_grid_tool_initialize (GimpTool *tool,
memcpy (undo_info->trans_infos, tg_tool->trans_infos,
sizeof (tg_tool->trans_infos));
if (tg_options->direction_chain_button)
gtk_widget_set_sensitive (tg_options->direction_chain_button, TRUE);
g_signal_connect (
image, "linked-items-changed",
G_CALLBACK (gimp_transform_grid_tool_image_linked_items_changed),
@ -1149,8 +1153,9 @@ gimp_transform_grid_tool_image_linked_items_changed (GimpImage *imag
static void
gimp_transform_grid_tool_halt (GimpTransformGridTool *tg_tool)
{
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpTransformGridOptions *tg_options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
if (tool->display)
{
@ -1188,6 +1193,15 @@ gimp_transform_grid_tool_halt (GimpTransformGridTool *tg_tool)
gimp_transform_grid_tool_show_active_object (tg_tool);
if (tg_options->direction_chain_button)
{
g_object_set (tg_options,
"direction-linked", FALSE,
NULL);
gtk_widget_set_sensitive (tg_options->direction_chain_button, FALSE);
}
tool->display = NULL;
tool->drawable = NULL;