2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-02-13 21:19:55 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-02-13 21:19:55 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-02-13 21:19:55 -08:00
|
|
|
* (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
|
2018-07-11 14:27:07 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-02-13 21:19:55 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2018-04-19 11:52:02 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2001-02-13 21:19:55 -08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2010-04-20 11:11:37 -07:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-02-21 13:56:39 -08:00
|
|
|
|
2001-05-09 15:34:59 -07:00
|
|
|
#include "tools-types.h"
|
2001-02-13 21:19:55 -08:00
|
|
|
|
2001-07-04 12:31:35 -07:00
|
|
|
#include "core/gimp.h"
|
2018-06-30 06:34:54 -07:00
|
|
|
#include "core/gimpcontainer.h"
|
2003-09-18 06:51:10 -07:00
|
|
|
#include "core/gimpimage.h"
|
2020-01-29 10:45:11 -08:00
|
|
|
#include "core/gimptoolgroup.h"
|
2001-05-09 15:34:59 -07:00
|
|
|
#include "core/gimptoolinfo.h"
|
2019-06-02 06:08:36 -07:00
|
|
|
#include "core/gimptooloptions.h"
|
2010-04-20 11:11:37 -07:00
|
|
|
#include "core/gimptoolpreset.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
|
2018-03-31 18:26:01 -07:00
|
|
|
#include "widgets/gimpcairo-wilber.h"
|
|
|
|
|
|
2006-06-18 12:58:49 -07:00
|
|
|
#include "gimptool.h"
|
2002-11-17 16:13:24 -08:00
|
|
|
#include "gimptoolcontrol.h"
|
2022-11-10 14:44:17 -08:00
|
|
|
#include "gimptransformgridtool.h"
|
2002-11-17 16:13:24 -08:00
|
|
|
#include "tool_manager.h"
|
2001-03-31 07:45:05 -08:00
|
|
|
|
2001-02-13 21:19:55 -08:00
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
typedef struct _GimpToolManager GimpToolManager;
|
2001-02-13 21:19:55 -08:00
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
struct _GimpToolManager
|
|
|
|
|
{
|
2020-01-30 06:24:13 -08:00
|
|
|
Gimp *gimp;
|
2001-02-13 21:19:55 -08:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
GimpTool *active_tool;
|
|
|
|
|
GSList *tool_stack;
|
|
|
|
|
|
|
|
|
|
GimpToolGroup *active_tool_group;
|
|
|
|
|
|
2022-11-10 14:44:17 -08:00
|
|
|
GimpImage *image;
|
|
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
GQuark image_clean_handler_id;
|
|
|
|
|
GQuark image_dirty_handler_id;
|
|
|
|
|
GQuark image_saving_handler_id;
|
2001-07-07 10:36:00 -07:00
|
|
|
};
|
2001-02-27 18:29:25 -08:00
|
|
|
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
/* local function prototypes */
|
2001-02-13 21:19:55 -08:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
static GimpToolManager * tool_manager_get (Gimp *gimp);
|
|
|
|
|
|
|
|
|
|
static void tool_manager_select_tool (GimpToolManager *tool_manager,
|
|
|
|
|
GimpTool *tool);
|
|
|
|
|
|
|
|
|
|
static void tool_manager_set_active_tool_group (GimpToolManager *tool_manager,
|
|
|
|
|
GimpToolGroup *tool_group);
|
2018-06-30 06:34:54 -07:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
static void tool_manager_tool_changed (GimpContext *user_context,
|
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_preset_changed (GimpContext *user_context,
|
|
|
|
|
GimpToolPreset *preset,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_image_clean_dirty (GimpImage *image,
|
|
|
|
|
GimpDirtyMask dirty_mask,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_image_saving (GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_tool_ancestry_changed (GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_group_active_tool_changed (GimpToolGroup *tool_group,
|
|
|
|
|
GimpToolManager *tool_manager);
|
2022-11-10 14:44:17 -08:00
|
|
|
static void tool_manager_image_changed (GimpContext *context,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager);
|
|
|
|
|
static void tool_manager_selected_layers_changed (GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager);
|
2010-04-21 11:56:49 -07:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
static void tool_manager_cast_spell (GimpToolInfo *tool_info);
|
2018-03-31 18:26:01 -07:00
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2018-06-30 06:34:54 -07:00
|
|
|
static GQuark tool_manager_quark = 0;
|
|
|
|
|
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tool_manager_init (Gimp *gimp)
|
2001-02-13 21:19:55 -08:00
|
|
|
{
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
GimpContext *user_context;
|
|
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2018-06-30 06:34:54 -07:00
|
|
|
g_return_if_fail (tool_manager_quark == 0);
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2018-06-30 06:34:54 -07:00
|
|
|
tool_manager_quark = g_quark_from_static_string ("gimp-tool-manager");
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2018-06-30 06:34:54 -07:00
|
|
|
tool_manager = g_slice_new0 (GimpToolManager);
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager->gimp = gimp;
|
|
|
|
|
|
2018-06-30 06:34:54 -07:00
|
|
|
g_object_set_qdata (G_OBJECT (gimp), tool_manager_quark, tool_manager);
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2004-07-29 07:16:21 -07:00
|
|
|
tool_manager->image_clean_handler_id =
|
|
|
|
|
gimp_container_add_handler (gimp->images, "clean",
|
2006-04-12 05:49:29 -07:00
|
|
|
G_CALLBACK (tool_manager_image_clean_dirty),
|
|
|
|
|
tool_manager);
|
2001-07-07 11:16:18 -07:00
|
|
|
|
2004-07-29 07:16:21 -07:00
|
|
|
tool_manager->image_dirty_handler_id =
|
|
|
|
|
gimp_container_add_handler (gimp->images, "dirty",
|
2006-04-12 05:49:29 -07:00
|
|
|
G_CALLBACK (tool_manager_image_clean_dirty),
|
|
|
|
|
tool_manager);
|
2003-01-02 05:38:09 -08:00
|
|
|
|
2018-09-28 23:25:34 -07:00
|
|
|
tool_manager->image_saving_handler_id =
|
|
|
|
|
gimp_container_add_handler (gimp->images, "saving",
|
|
|
|
|
G_CALLBACK (tool_manager_image_saving),
|
|
|
|
|
tool_manager);
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
user_context = gimp_get_user_context (gimp);
|
|
|
|
|
|
2005-05-27 09:51:39 -07:00
|
|
|
g_signal_connect (user_context, "tool-changed",
|
2006-04-12 05:49:29 -07:00
|
|
|
G_CALLBACK (tool_manager_tool_changed),
|
|
|
|
|
tool_manager);
|
2010-04-20 11:11:37 -07:00
|
|
|
g_signal_connect (user_context, "tool-preset-changed",
|
|
|
|
|
G_CALLBACK (tool_manager_preset_changed),
|
|
|
|
|
tool_manager);
|
2022-11-10 14:44:17 -08:00
|
|
|
g_signal_connect (user_context, "image-changed",
|
|
|
|
|
G_CALLBACK (tool_manager_image_changed),
|
|
|
|
|
tool_manager);
|
|
|
|
|
|
|
|
|
|
tool_manager_image_changed (user_context,
|
|
|
|
|
gimp_context_get_image (user_context),
|
|
|
|
|
tool_manager);
|
|
|
|
|
tool_manager_selected_layers_changed (gimp_context_get_image (user_context),
|
|
|
|
|
tool_manager);
|
2018-06-29 03:31:32 -07:00
|
|
|
|
|
|
|
|
tool_manager_tool_changed (user_context,
|
|
|
|
|
gimp_context_get_tool (user_context),
|
|
|
|
|
tool_manager);
|
2001-07-07 05:17:23 -07:00
|
|
|
}
|
|
|
|
|
|
2003-02-10 03:46:10 -08:00
|
|
|
void
|
|
|
|
|
tool_manager_exit (Gimp *gimp)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
2010-04-20 11:11:37 -07:00
|
|
|
GimpContext *user_context;
|
2003-02-10 03:46:10 -08:00
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
2018-06-30 06:34:54 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (tool_manager != NULL);
|
2003-02-10 03:46:10 -08:00
|
|
|
|
2010-04-20 11:11:37 -07:00
|
|
|
user_context = gimp_get_user_context (gimp);
|
|
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (user_context,
|
|
|
|
|
tool_manager_tool_changed,
|
|
|
|
|
tool_manager);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (user_context,
|
|
|
|
|
tool_manager_preset_changed,
|
|
|
|
|
tool_manager);
|
2022-11-10 14:44:17 -08:00
|
|
|
g_signal_handlers_disconnect_by_func (user_context,
|
|
|
|
|
tool_manager_image_changed,
|
|
|
|
|
tool_manager);
|
2010-04-20 11:11:37 -07:00
|
|
|
|
2003-02-10 03:46:10 -08:00
|
|
|
gimp_container_remove_handler (gimp->images,
|
2006-04-12 05:49:29 -07:00
|
|
|
tool_manager->image_clean_handler_id);
|
2003-02-10 03:46:10 -08:00
|
|
|
gimp_container_remove_handler (gimp->images,
|
2006-04-12 05:49:29 -07:00
|
|
|
tool_manager->image_dirty_handler_id);
|
2018-09-28 23:25:34 -07:00
|
|
|
gimp_container_remove_handler (gimp->images,
|
|
|
|
|
tool_manager->image_saving_handler_id);
|
2003-02-10 03:46:10 -08:00
|
|
|
|
2020-01-29 10:45:11 -08:00
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
|
tool_manager->active_tool->tool_info,
|
|
|
|
|
tool_manager_tool_ancestry_changed,
|
|
|
|
|
tool_manager);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&tool_manager->active_tool);
|
|
|
|
|
}
|
2011-06-02 11:16:54 -07:00
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager_set_active_tool_group (tool_manager, NULL);
|
|
|
|
|
|
2007-05-23 06:49:06 -07:00
|
|
|
g_slice_free (GimpToolManager, tool_manager);
|
2018-06-30 06:34:54 -07:00
|
|
|
|
|
|
|
|
g_object_set_qdata (G_OBJECT (gimp), tool_manager_quark, NULL);
|
2003-02-10 03:46:10 -08:00
|
|
|
}
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpTool *
|
|
|
|
|
tool_manager_get_active (Gimp *gimp)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
return tool_manager->active_tool;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-27 18:29:25 -08:00
|
|
|
void
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager_push_tool (Gimp *gimp,
|
2006-04-12 05:49:29 -07:00
|
|
|
GimpTool *tool)
|
2001-02-27 18:29:25 -08:00
|
|
|
{
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpToolManager *tool_manager;
|
2006-09-13 14:28:17 -07:00
|
|
|
GimpDisplay *focus_display = NULL;
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2001-10-29 03:47:11 -08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2001-02-27 18:29:25 -08:00
|
|
|
g_return_if_fail (GIMP_IS_TOOL (tool));
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
2001-02-27 18:29:25 -08:00
|
|
|
{
|
2006-09-13 14:28:17 -07:00
|
|
|
focus_display = tool_manager->active_tool->focus_display;
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager->tool_stack = g_slist_prepend (tool_manager->tool_stack,
|
2006-04-12 05:49:29 -07:00
|
|
|
tool_manager->active_tool);
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2003-01-05 14:07:10 -08:00
|
|
|
g_object_ref (tool_manager->tool_stack->data);
|
2001-02-27 18:29:25 -08:00
|
|
|
}
|
|
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager_select_tool (tool_manager, tool);
|
2006-09-13 14:28:17 -07:00
|
|
|
|
|
|
|
|
if (focus_display)
|
|
|
|
|
tool_manager_focus_display_active (gimp, focus_display);
|
2001-02-27 18:29:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager_pop_tool (Gimp *gimp)
|
2001-02-27 18:29:25 -08:00
|
|
|
{
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->tool_stack)
|
2001-02-27 18:29:25 -08:00
|
|
|
{
|
2011-04-06 11:40:26 -07:00
|
|
|
GimpTool *tool = tool_manager->tool_stack->data;
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager->tool_stack = g_slist_remove (tool_manager->tool_stack,
|
2006-05-21 13:22:09 -07:00
|
|
|
tool);
|
|
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager_select_tool (tool_manager, tool);
|
2006-09-13 14:28:17 -07:00
|
|
|
|
2011-04-06 11:40:26 -07:00
|
|
|
g_object_unref (tool);
|
2001-02-27 18:29:25 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-21 08:07:48 -08:00
|
|
|
gboolean
|
2001-11-08 11:14:51 -08:00
|
|
|
tool_manager_initialize_active (Gimp *gimp,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
2001-02-21 04:18:09 -08:00
|
|
|
{
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2004-01-21 08:07:48 -08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
2006-03-28 09:55:52 -08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
|
2001-02-21 04:18:09 -08:00
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
tool_manager = tool_manager_get (gimp);
|
2001-07-07 15:49:01 -07:00
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
if (tool_manager->active_tool)
|
2001-07-07 15:49:01 -07:00
|
|
|
{
|
2006-05-21 13:22:09 -07:00
|
|
|
GimpTool *tool = tool_manager->active_tool;
|
2001-02-21 04:18:09 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
if (gimp_tool_initialize (tool, display))
|
2004-01-21 08:07:48 -08:00
|
|
|
{
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
|
2020-05-25 02:30:31 -07:00
|
|
|
g_list_free (tool->drawables);
|
|
|
|
|
tool->drawables = gimp_image_get_selected_drawables (image);
|
2001-02-21 04:18:09 -08:00
|
|
|
|
2004-01-21 08:07:48 -08:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2001-02-21 04:18:09 -08:00
|
|
|
}
|
2004-01-21 08:07:48 -08:00
|
|
|
|
|
|
|
|
return FALSE;
|
2001-02-21 04:18:09 -08:00
|
|
|
}
|
|
|
|
|
|
2001-02-13 21:19:55 -08:00
|
|
|
void
|
2002-02-18 09:00:09 -08:00
|
|
|
tool_manager_control_active (Gimp *gimp,
|
2006-04-12 05:49:29 -07:00
|
|
|
GimpToolAction action,
|
|
|
|
|
GimpDisplay *display)
|
2001-02-13 21:19:55 -08:00
|
|
|
{
|
2001-07-07 10:36:00 -07:00
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
2006-05-21 13:22:09 -07:00
|
|
|
if (tool_manager->active_tool)
|
2002-02-17 03:46:39 -08:00
|
|
|
{
|
2006-05-21 13:22:09 -07:00
|
|
|
GimpTool *tool = tool_manager->active_tool;
|
|
|
|
|
|
2006-06-18 12:58:49 -07:00
|
|
|
if (display && gimp_tool_has_display (tool, display))
|
2006-05-21 13:22:09 -07:00
|
|
|
{
|
|
|
|
|
gimp_tool_control (tool, action, display);
|
|
|
|
|
}
|
2006-05-21 14:12:01 -07:00
|
|
|
else if (action == GIMP_TOOL_ACTION_HALT)
|
2006-05-21 13:22:09 -07:00
|
|
|
{
|
|
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
|
|
|
|
gimp_tool_control_halt (tool->control);
|
|
|
|
|
}
|
2001-02-21 04:18:09 -08:00
|
|
|
}
|
2001-02-13 21:19:55 -08:00
|
|
|
}
|
|
|
|
|
|
2001-11-14 09:12:51 -08:00
|
|
|
void
|
2009-06-20 08:37:31 -07:00
|
|
|
tool_manager_button_press_active (Gimp *gimp,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_button_press (tool_manager->active_tool,
|
2009-06-20 08:37:31 -07:00
|
|
|
coords, time, state, press_type,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-11-01 08:17:36 -07:00
|
|
|
tool_manager_button_release_active (Gimp *gimp,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_button_release (tool_manager->active_tool,
|
|
|
|
|
coords, time, state,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-11-01 08:17:36 -07:00
|
|
|
tool_manager_motion_active (Gimp *gimp,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_motion (tool_manager->active_tool,
|
|
|
|
|
coords, time, state,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-24 03:16:08 -07:00
|
|
|
gboolean
|
2004-06-12 11:03:48 -07:00
|
|
|
tool_manager_key_press_active (Gimp *gimp,
|
2001-11-14 09:12:51 -08:00
|
|
|
GdkEventKey *kevent,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2004-06-24 03:16:08 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
2001-11-14 09:12:51 -08:00
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
2004-06-24 03:16:08 -07:00
|
|
|
return gimp_tool_key_press (tool_manager->active_tool,
|
|
|
|
|
kevent,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
2004-06-24 03:16:08 -07:00
|
|
|
|
|
|
|
|
return FALSE;
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
|
2010-02-18 11:50:11 -08:00
|
|
|
gboolean
|
|
|
|
|
tool_manager_key_release_active (Gimp *gimp,
|
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
return gimp_tool_key_release (tool_manager->active_tool,
|
|
|
|
|
kevent,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-14 09:12:51 -08:00
|
|
|
void
|
2003-10-14 04:14:28 -07:00
|
|
|
tool_manager_focus_display_active (Gimp *gimp,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
2018-03-19 07:14:36 -07:00
|
|
|
if (tool_manager->active_tool &&
|
|
|
|
|
! gimp_tool_control_is_active (tool_manager->active_tool->control))
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
2003-10-14 04:14:28 -07:00
|
|
|
gimp_tool_set_focus_display (tool_manager->active_tool,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2003-10-14 04:14:28 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tool_manager_modifier_state_active (Gimp *gimp,
|
|
|
|
|
GdkModifierType state,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
2003-10-14 04:14:28 -07:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
2018-04-03 15:26:41 -07:00
|
|
|
if (tool_manager->active_tool &&
|
|
|
|
|
! gimp_tool_control_is_active (tool_manager->active_tool->control))
|
2003-10-14 04:14:28 -07:00
|
|
|
{
|
|
|
|
|
gimp_tool_set_modifier_state (tool_manager->active_tool,
|
|
|
|
|
state,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-12 11:41:09 -07:00
|
|
|
void
|
|
|
|
|
tool_manager_active_modifier_state_active (Gimp *gimp,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_set_active_modifier_state (tool_manager->active_tool,
|
|
|
|
|
state,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-14 09:12:51 -08:00
|
|
|
void
|
2008-11-01 08:17:36 -07:00
|
|
|
tool_manager_oper_update_active (Gimp *gimp,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
2018-03-19 07:14:36 -07:00
|
|
|
if (tool_manager->active_tool &&
|
|
|
|
|
! gimp_tool_control_is_active (tool_manager->active_tool->control))
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
gimp_tool_oper_update (tool_manager->active_tool,
|
2006-03-25 06:23:09 -08:00
|
|
|
coords, state, proximity,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-11-01 08:17:36 -07:00
|
|
|
tool_manager_cursor_update_active (Gimp *gimp,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
2018-03-19 07:14:36 -07:00
|
|
|
if (tool_manager->active_tool &&
|
|
|
|
|
! gimp_tool_control_is_active (tool_manager->active_tool->control))
|
2001-11-14 09:12:51 -08:00
|
|
|
{
|
|
|
|
|
gimp_tool_cursor_update (tool_manager->active_tool,
|
|
|
|
|
coords, state,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2001-11-14 09:12:51 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-12 10:51:52 -07:00
|
|
|
const gchar *
|
2017-07-04 09:48:03 -07:00
|
|
|
tool_manager_can_undo_active (Gimp *gimp,
|
|
|
|
|
GimpDisplay *display)
|
2013-05-12 10:51:52 -07:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
2017-07-04 09:48:03 -07:00
|
|
|
return gimp_tool_can_undo (tool_manager->active_tool,
|
|
|
|
|
display);
|
2013-05-12 10:51:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const gchar *
|
2017-07-04 09:48:03 -07:00
|
|
|
tool_manager_can_redo_active (Gimp *gimp,
|
|
|
|
|
GimpDisplay *display)
|
2013-05-12 10:51:52 -07:00
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
2017-07-04 09:48:03 -07:00
|
|
|
return gimp_tool_can_redo (tool_manager->active_tool,
|
|
|
|
|
display);
|
2013-05-12 10:51:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
tool_manager_undo_active (Gimp *gimp,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
return gimp_tool_undo (tool_manager->active_tool,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
tool_manager_redo_active (Gimp *gimp,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
return gimp_tool_redo (tool_manager->active_tool,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-26 09:25:24 -07:00
|
|
|
GimpUIManager *
|
|
|
|
|
tool_manager_get_popup_active (Gimp *gimp,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2008-10-26 09:25:24 -07:00
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display,
|
|
|
|
|
const gchar **ui_path)
|
|
|
|
|
{
|
|
|
|
|
GimpToolManager *tool_manager;
|
|
|
|
|
|
2008-10-26 09:31:52 -07:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2008-10-26 09:25:24 -07:00
|
|
|
|
|
|
|
|
tool_manager = tool_manager_get (gimp);
|
|
|
|
|
|
|
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
return gimp_tool_get_popup (tool_manager->active_tool,
|
|
|
|
|
coords, state,
|
|
|
|
|
display,
|
|
|
|
|
ui_path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
2001-07-07 10:36:00 -07:00
|
|
|
static GimpToolManager *
|
|
|
|
|
tool_manager_get (Gimp *gimp)
|
|
|
|
|
{
|
2003-05-25 10:16:59 -07:00
|
|
|
return g_object_get_qdata (G_OBJECT (gimp), tool_manager_quark);
|
2001-07-07 10:36:00 -07:00
|
|
|
}
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2014-04-04 07:47:51 -07:00
|
|
|
static void
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager_select_tool (GimpToolManager *tool_manager,
|
|
|
|
|
GimpTool *tool)
|
2014-04-04 07:47:51 -07:00
|
|
|
{
|
2020-01-30 06:24:13 -08:00
|
|
|
Gimp *gimp = tool_manager->gimp;
|
2014-04-04 07:47:51 -07:00
|
|
|
|
|
|
|
|
/* reset the previously selected tool, but only if it is not only
|
|
|
|
|
* temporarily pushed to the tool stack
|
|
|
|
|
*/
|
2016-05-13 04:13:22 -07:00
|
|
|
if (tool_manager->active_tool)
|
2014-04-04 07:47:51 -07:00
|
|
|
{
|
2016-05-13 04:13:22 -07:00
|
|
|
if (! tool_manager->tool_stack ||
|
|
|
|
|
tool_manager->active_tool != tool_manager->tool_stack->data)
|
|
|
|
|
{
|
|
|
|
|
GimpTool *active_tool = tool_manager->active_tool;
|
|
|
|
|
GimpDisplay *display;
|
2014-04-04 07:47:51 -07:00
|
|
|
|
2016-05-13 04:13:22 -07:00
|
|
|
/* NULL image returns any display (if there is any) */
|
|
|
|
|
display = gimp_tool_has_image (active_tool, NULL);
|
2014-04-04 07:47:51 -07:00
|
|
|
|
2016-05-13 04:13:22 -07:00
|
|
|
tool_manager_control_active (gimp, GIMP_TOOL_ACTION_HALT, display);
|
|
|
|
|
tool_manager_focus_display_active (gimp, NULL);
|
|
|
|
|
}
|
2014-04-04 07:47:51 -07:00
|
|
|
}
|
|
|
|
|
|
2018-06-01 03:59:52 -07:00
|
|
|
g_set_object (&tool_manager->active_tool, tool);
|
2014-04-04 07:47:51 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
static void
|
|
|
|
|
tool_manager_set_active_tool_group (GimpToolManager *tool_manager,
|
|
|
|
|
GimpToolGroup *tool_group)
|
|
|
|
|
{
|
|
|
|
|
if (tool_group != tool_manager->active_tool_group)
|
|
|
|
|
{
|
|
|
|
|
if (tool_manager->active_tool_group)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (
|
|
|
|
|
tool_manager->active_tool_group,
|
|
|
|
|
tool_manager_group_active_tool_changed,
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-01 02:41:11 -08:00
|
|
|
g_set_weak_pointer (&tool_manager->active_tool_group, tool_group);
|
2020-01-30 06:24:13 -08:00
|
|
|
|
|
|
|
|
if (tool_manager->active_tool_group)
|
|
|
|
|
{
|
|
|
|
|
g_signal_connect (
|
|
|
|
|
tool_manager->active_tool_group, "active-tool-changed",
|
|
|
|
|
G_CALLBACK (tool_manager_group_active_tool_changed),
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
static void
|
2010-04-20 11:11:37 -07:00
|
|
|
tool_manager_tool_changed (GimpContext *user_context,
|
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolManager *tool_manager)
|
2001-07-07 05:17:23 -07:00
|
|
|
{
|
2010-04-20 11:11:37 -07:00
|
|
|
GimpTool *new_tool = NULL;
|
2001-07-07 05:17:23 -07:00
|
|
|
|
|
|
|
|
if (! tool_info)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-01-25 03:18:44 -08:00
|
|
|
if (! g_type_is_a (tool_info->tool_type, GIMP_TYPE_TOOL))
|
|
|
|
|
{
|
|
|
|
|
g_warning ("%s: tool_info->tool_type is no GimpTool subclass",
|
|
|
|
|
G_STRFUNC);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
/* FIXME: gimp_busy HACK */
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-10 12:16:16 -07:00
|
|
|
if (user_context->gimp->busy)
|
2001-07-07 05:17:23 -07:00
|
|
|
{
|
2005-05-27 09:51:39 -07:00
|
|
|
/* there may be contexts waiting for the user_context's "tool-changed"
|
2001-07-07 05:17:23 -07:00
|
|
|
* signal, so stop emitting it.
|
|
|
|
|
*/
|
2005-05-27 09:51:39 -07:00
|
|
|
g_signal_stop_emission_by_name (user_context, "tool-changed");
|
2001-07-07 05:17:23 -07:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 14:27:11 -07:00
|
|
|
if (G_TYPE_FROM_INSTANCE (tool_manager->active_tool) !=
|
2006-04-12 05:49:29 -07:00
|
|
|
tool_info->tool_type)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_block_by_func (user_context,
|
|
|
|
|
tool_manager_tool_changed,
|
2010-04-20 11:11:37 -07:00
|
|
|
tool_manager);
|
2006-04-12 05:49:29 -07:00
|
|
|
|
|
|
|
|
/* explicitly set the current tool */
|
|
|
|
|
gimp_context_set_tool (user_context,
|
2001-10-29 03:47:11 -08:00
|
|
|
tool_manager->active_tool->tool_info);
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2006-04-12 05:49:29 -07:00
|
|
|
g_signal_handlers_unblock_by_func (user_context,
|
|
|
|
|
tool_manager_tool_changed,
|
2010-04-20 11:11:37 -07:00
|
|
|
tool_manager);
|
2006-04-12 05:49:29 -07:00
|
|
|
}
|
2001-07-07 05:17:23 -07:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 10:45:11 -08:00
|
|
|
g_return_if_fail (tool_manager->tool_stack == NULL);
|
|
|
|
|
|
2016-01-24 17:51:45 -08:00
|
|
|
if (tool_manager->active_tool)
|
|
|
|
|
{
|
|
|
|
|
GimpTool *active_tool = tool_manager->active_tool;
|
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
|
|
|
|
|
/* NULL image returns any display (if there is any) */
|
|
|
|
|
display = gimp_tool_has_image (active_tool, NULL);
|
|
|
|
|
|
|
|
|
|
/* commit the old tool's operation before creating the new tool
|
|
|
|
|
* because creating a tool might mess with the old tool's
|
|
|
|
|
* options (old and new tool might be the same)
|
|
|
|
|
*/
|
|
|
|
|
if (display)
|
|
|
|
|
tool_manager_control_active (user_context->gimp, GIMP_TOOL_ACTION_COMMIT,
|
|
|
|
|
display);
|
2020-01-29 10:45:11 -08:00
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (active_tool->tool_info,
|
|
|
|
|
tool_manager_tool_ancestry_changed,
|
|
|
|
|
tool_manager);
|
2002-03-12 13:02:10 -08:00
|
|
|
}
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2020-01-29 10:45:11 -08:00
|
|
|
g_signal_connect (tool_info, "ancestry-changed",
|
|
|
|
|
G_CALLBACK (tool_manager_tool_ancestry_changed),
|
|
|
|
|
tool_manager);
|
|
|
|
|
|
|
|
|
|
tool_manager_tool_ancestry_changed (tool_info, tool_manager);
|
|
|
|
|
|
2016-01-25 03:18:44 -08:00
|
|
|
new_tool = g_object_new (tool_info->tool_type,
|
|
|
|
|
"tool-info", tool_info,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2020-01-30 06:24:13 -08:00
|
|
|
tool_manager_select_tool (tool_manager, new_tool);
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2022-11-10 14:44:17 -08:00
|
|
|
/* Auto-activate any transform tools */
|
|
|
|
|
if (GIMP_IS_TRANSFORM_GRID_TOOL (new_tool))
|
|
|
|
|
{
|
|
|
|
|
GimpDisplay *new_display;
|
|
|
|
|
|
|
|
|
|
new_display = gimp_context_get_display (user_context);
|
|
|
|
|
if (new_display && gimp_display_get_image (new_display))
|
|
|
|
|
tool_manager_initialize_active (user_context->gimp, new_display);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-05 14:07:10 -08:00
|
|
|
g_object_unref (new_tool);
|
2018-03-31 18:26:01 -07:00
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
|
tool_manager_cast_spell (tool_info);
|
2001-07-07 05:17:23 -07:00
|
|
|
}
|
2001-07-07 11:16:18 -07:00
|
|
|
|
2019-06-02 06:08:36 -07:00
|
|
|
static void
|
|
|
|
|
tool_manager_copy_tool_options (GObject *src,
|
|
|
|
|
GObject *dest)
|
|
|
|
|
{
|
|
|
|
|
GList *diff;
|
|
|
|
|
|
|
|
|
|
diff = gimp_config_diff (src, dest, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
|
|
if (diff)
|
|
|
|
|
{
|
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
|
|
g_object_freeze_notify (dest);
|
|
|
|
|
|
|
|
|
|
for (list = diff; list; list = list->next)
|
|
|
|
|
{
|
|
|
|
|
GParamSpec *prop_spec = list->data;
|
|
|
|
|
|
|
|
|
|
if (g_type_is_a (prop_spec->owner_type, GIMP_TYPE_TOOL_OPTIONS) &&
|
|
|
|
|
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
|
|
|
|
{
|
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, prop_spec->value_type);
|
|
|
|
|
|
|
|
|
|
g_object_get_property (src, prop_spec->name, &value);
|
|
|
|
|
g_object_set_property (dest, prop_spec->name, &value);
|
|
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_thaw_notify (dest);
|
|
|
|
|
|
|
|
|
|
g_list_free (diff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-20 11:11:37 -07:00
|
|
|
static void
|
|
|
|
|
tool_manager_preset_changed (GimpContext *user_context,
|
|
|
|
|
GimpToolPreset *preset,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
GimpToolInfo *preset_tool;
|
|
|
|
|
|
|
|
|
|
if (! preset || user_context->gimp->busy)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
|
|
|
|
|
|
2019-06-02 06:08:36 -07:00
|
|
|
/* first, select the preset's tool, even if it's already the active
|
|
|
|
|
* tool
|
|
|
|
|
*/
|
|
|
|
|
gimp_context_set_tool (user_context, preset_tool);
|
2010-04-24 07:55:54 -07:00
|
|
|
|
2019-06-02 06:08:36 -07:00
|
|
|
/* then, copy the context properties the preset remembers, possibly
|
|
|
|
|
* changing some tool options due to the "link brush stuff to brush
|
|
|
|
|
* defaults" settings in gimptooloptions.c
|
|
|
|
|
*/
|
2010-04-24 07:55:54 -07:00
|
|
|
gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options),
|
|
|
|
|
user_context,
|
|
|
|
|
gimp_tool_preset_get_prop_mask (preset));
|
2011-06-08 12:34:43 -07:00
|
|
|
|
2019-06-02 06:08:36 -07:00
|
|
|
/* finally, copy all tool options properties, overwriting any
|
|
|
|
|
* changes resulting from setting the context properties above, we
|
|
|
|
|
* really want exactly what is in the preset and nothing else
|
|
|
|
|
*/
|
|
|
|
|
tool_manager_copy_tool_options (G_OBJECT (preset->tool_options),
|
|
|
|
|
G_OBJECT (preset_tool->tool_options));
|
2010-04-20 11:11:37 -07:00
|
|
|
}
|
|
|
|
|
|
2001-07-07 11:16:18 -07:00
|
|
|
static void
|
2006-03-28 09:08:36 -08:00
|
|
|
tool_manager_image_clean_dirty (GimpImage *image,
|
2004-07-29 07:16:21 -07:00
|
|
|
GimpDirtyMask dirty_mask,
|
|
|
|
|
GimpToolManager *tool_manager)
|
2001-07-07 11:16:18 -07:00
|
|
|
{
|
2006-05-21 13:22:09 -07:00
|
|
|
GimpTool *tool = tool_manager->active_tool;
|
2001-07-07 11:16:18 -07:00
|
|
|
|
2006-05-21 13:22:09 -07:00
|
|
|
if (tool &&
|
|
|
|
|
! gimp_tool_control_get_preserve (tool->control) &&
|
|
|
|
|
(gimp_tool_control_get_dirty_mask (tool->control) & dirty_mask))
|
2003-01-02 05:38:09 -08:00
|
|
|
{
|
2006-09-08 06:42:00 -07:00
|
|
|
GimpDisplay *display = gimp_tool_has_image (tool, image);
|
2003-07-14 07:02:34 -07:00
|
|
|
|
2006-06-18 12:58:49 -07:00
|
|
|
if (display)
|
2018-09-29 09:25:51 -07:00
|
|
|
{
|
|
|
|
|
tool_manager_control_active (
|
|
|
|
|
image->gimp,
|
|
|
|
|
gimp_tool_control_get_dirty_action (tool->control),
|
|
|
|
|
display);
|
|
|
|
|
}
|
2003-01-02 05:38:09 -08:00
|
|
|
}
|
|
|
|
|
}
|
2010-04-21 11:56:49 -07:00
|
|
|
|
2018-09-28 23:25:34 -07:00
|
|
|
static void
|
|
|
|
|
tool_manager_image_saving (GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
GimpTool *tool = tool_manager->active_tool;
|
|
|
|
|
|
|
|
|
|
if (tool &&
|
|
|
|
|
! gimp_tool_control_get_preserve (tool->control))
|
|
|
|
|
{
|
|
|
|
|
GimpDisplay *display = gimp_tool_has_image (tool, image);
|
|
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
|
tool_manager_control_active (image->gimp, GIMP_TOOL_ACTION_COMMIT,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 10:45:11 -08:00
|
|
|
static void
|
|
|
|
|
tool_manager_tool_ancestry_changed (GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
GimpViewable *parent;
|
|
|
|
|
|
|
|
|
|
parent = gimp_viewable_get_parent (GIMP_VIEWABLE (tool_info));
|
|
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_group_set_active_tool_info (GIMP_TOOL_GROUP (parent),
|
|
|
|
|
tool_info);
|
|
|
|
|
}
|
2020-01-30 06:24:13 -08:00
|
|
|
|
|
|
|
|
tool_manager_set_active_tool_group (tool_manager, GIMP_TOOL_GROUP (parent));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tool_manager_group_active_tool_changed (GimpToolGroup *tool_group,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
gimp_context_set_tool (tool_manager->gimp->user_context,
|
|
|
|
|
gimp_tool_group_get_active_tool_info (tool_group));
|
2020-01-29 10:45:11 -08:00
|
|
|
}
|
|
|
|
|
|
2022-11-10 14:44:17 -08:00
|
|
|
static void
|
|
|
|
|
tool_manager_image_changed (GimpContext *context,
|
|
|
|
|
GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
if (tool_manager->image)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (tool_manager->image,
|
|
|
|
|
tool_manager_selected_layers_changed,
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tool_manager->image = image;
|
|
|
|
|
|
|
|
|
|
/* Re-activate transform tools when switching images */
|
|
|
|
|
if (image &&
|
|
|
|
|
GIMP_IS_TRANSFORM_GRID_TOOL (tool_manager->active_tool))
|
|
|
|
|
{
|
|
|
|
|
gimp_context_set_tool (context,
|
|
|
|
|
tool_manager->active_tool->tool_info);
|
|
|
|
|
|
|
|
|
|
tool_manager_tool_changed (context,
|
|
|
|
|
gimp_context_get_tool (context),
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
|
g_signal_connect (tool_manager->image, "selected-layers-changed",
|
|
|
|
|
G_CALLBACK (tool_manager_selected_layers_changed),
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
tool_manager_selected_layers_changed (GimpImage *image,
|
|
|
|
|
GimpToolManager *tool_manager)
|
|
|
|
|
{
|
|
|
|
|
/* Re-activate transform tools when changing selected layers */
|
|
|
|
|
if (image &&
|
|
|
|
|
GIMP_IS_TRANSFORM_GRID_TOOL (tool_manager->active_tool))
|
|
|
|
|
{
|
|
|
|
|
gimp_context_set_tool (tool_manager->gimp->user_context,
|
|
|
|
|
tool_manager->active_tool->tool_info);
|
|
|
|
|
|
|
|
|
|
tool_manager_tool_changed (tool_manager->gimp->user_context,
|
|
|
|
|
gimp_context_get_tool (
|
|
|
|
|
tool_manager->gimp->user_context),
|
|
|
|
|
tool_manager);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 18:26:01 -07:00
|
|
|
static void
|
|
|
|
|
tool_manager_cast_spell (GimpToolInfo *tool_info)
|
|
|
|
|
{
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const gchar *sequence;
|
|
|
|
|
GCallback func;
|
|
|
|
|
} Spell;
|
|
|
|
|
|
|
|
|
|
static const Spell spells[] =
|
|
|
|
|
{
|
|
|
|
|
{ .sequence = "gimp-warp-tool\0"
|
|
|
|
|
"gimp-iscissors-tool\0"
|
2018-04-13 15:52:20 -07:00
|
|
|
"gimp-gradient-tool\0"
|
2018-03-31 18:26:01 -07:00
|
|
|
"gimp-vector-tool\0"
|
|
|
|
|
"gimp-ellipse-select-tool\0"
|
|
|
|
|
"gimp-rect-select-tool\0",
|
|
|
|
|
.func = gimp_cairo_wilber_toggle_pointer_eyes
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const gchar *spell_progress[G_N_ELEMENTS (spells)];
|
|
|
|
|
const gchar *tool_name;
|
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
|
|
tool_name = gimp_object_get_name (GIMP_OBJECT (tool_info));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (spells); i++)
|
|
|
|
|
{
|
|
|
|
|
if (! spell_progress[i])
|
|
|
|
|
spell_progress[i] = spells[i].sequence;
|
|
|
|
|
|
|
|
|
|
while (spell_progress[i])
|
|
|
|
|
{
|
|
|
|
|
if (! strcmp (tool_name, spell_progress[i]))
|
|
|
|
|
{
|
|
|
|
|
spell_progress[i] += strlen (spell_progress[i]) + 1;
|
|
|
|
|
|
|
|
|
|
if (! *spell_progress[i])
|
|
|
|
|
{
|
|
|
|
|
spell_progress[i] = NULL;
|
|
|
|
|
|
|
|
|
|
spells[i].func ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (spell_progress[i] == spells[i].sequence)
|
|
|
|
|
spell_progress[i] = NULL;
|
|
|
|
|
else
|
|
|
|
|
spell_progress[i] = spells[i].sequence;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|