Commit 6b2ca702 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/paint/Makefile.am removed... ...and added.

2003-09-18  Michael Natterer  <mitch@gimp.org>

	* app/paint/Makefile.am
	* app/paint/paint.[ch]: removed...
	* app/paint/gimp-paint.[ch]: ...and added.

	* app/core/gimp.c: changed accordingly.

	* app/tools/Makefile.am
	* app/tools/tools.[ch]: removed...

	* app/tools/gimp-tools.[ch]: ...and added. Added
	gimp_tools_restore() and gimp_tools_save() and moved the entire
	tool registering and tool_options loading/saving code here. Call
	tool_manager_init() from gimp_tools_init() and tool_manager_exit()
	from gimp_tools_exit().

	* app/tools/tool_manager.[ch]: removed the code which now lives
	in gimp-tools.[ch]. The tool manager now has no knowledge about
	individual tools any more and just handles the active_tool
	and the tool part of tool <-> display interaction.
	Removed tool_manager_get_info_by_type().

	* app/tools/gimpvectortool.c (gimp_vector_tool_register): the
	tool's identifier is "gimp-vector-tool", not "gimp-path-tool".

	* app/app_procs.c
	* app/display/gimpdisplayshell-callbacks.c
	* app/gui/vectors-commands.c
	* app/tools/gimppainttool.c: changed accordingly.
parent 5daa59df
2003-09-18 Michael Natterer <mitch@gimp.org>
* app/paint/Makefile.am
* app/paint/paint.[ch]: removed...
* app/paint/gimp-paint.[ch]: ...and added.
* app/core/gimp.c: changed accordingly.
* app/tools/Makefile.am
* app/tools/tools.[ch]: removed...
* app/tools/gimp-tools.[ch]: ...and added. Added
gimp_tools_restore() and gimp_tools_save() and moved the entire
tool registering and tool_options loading/saving code here. Call
tool_manager_init() from gimp_tools_init() and tool_manager_exit()
from gimp_tools_exit().
* app/tools/tool_manager.[ch]: removed the code which now lives
in gimp-tools.[ch]. The tool manager now has no knowledge about
individual tools any more and just handles the active_tool
and the tool part of tool <-> display interaction.
Removed tool_manager_get_info_by_type().
* app/tools/gimpvectortool.c (gimp_vector_tool_register): the
tool's identifier is "gimp-vector-tool", not "gimp-path-tool".
* app/app_procs.c
* app/display/gimpdisplayshell-callbacks.c
* app/gui/vectors-commands.c
* app/tools/gimppainttool.c: changed accordingly.
2003-09-18 Sven Neumann <sven@gimp.org>
* plug-ins/common/screenshot.c (create_image): rewritten pixel
......@@ -28,6 +28,7 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
......@@ -328,19 +329,26 @@ vectors_vectors_tool (GimpVectors *vectors)
if (! GIMP_IS_VECTOR_TOOL (active_tool))
{
GimpToolInfo *tool_info;
GimpContainer *tool_info_list;
GimpToolInfo *tool_info;
tool_info = tool_manager_get_info_by_type (gimage->gimp,
GIMP_TYPE_VECTOR_TOOL);
tool_info_list = gimage->gimp->tool_info_list;
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-vector-tool");
active_tool = tool_manager_get_active (gimage->gimp);
if (GIMP_IS_TOOL_INFO (tool_info))
{
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gimage->gimp);
}
}
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool),
vectors);
if (GIMP_IS_VECTOR_TOOL (active_tool))
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors);
}
/**********************************/
......
......@@ -48,7 +48,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "tools/tool_manager.h"
#include "tools/gimp-tools.h"
#include "gui/gui.h"
#include "gui/splash.h"
......@@ -250,7 +250,7 @@ app_init (const gchar *full_prog_name,
if (! no_interface)
{
gui_environ_init (the_gimp);
tool_manager_init (the_gimp);
gimp_tools_init (the_gimp);
}
/* Load all data files
......@@ -260,7 +260,7 @@ app_init (const gchar *full_prog_name,
if (! no_interface)
{
gui_init (the_gimp);
tool_manager_restore (the_gimp);
gimp_tools_restore (the_gimp);
}
/* Initialize the plug-in structures
......@@ -401,8 +401,8 @@ app_exit_callback (Gimp *gimp,
if (! gimp->no_interface)
{
tool_manager_save (gimp);
tool_manager_exit (gimp);
gimp_tools_save (gimp);
gimp_tools_exit (gimp);
}
return FALSE; /* continue exiting */
......@@ -417,8 +417,8 @@ app_exit_finish_callback (Gimp *gimp,
base_exit ();
/* There used to be foo_main_quit() here, but there's a chance
* that foo_main() was never called before we reach this point. --Sven
/* There used to be foo_main_quit() here, but there's a chance
* that foo_main() was never called before we reach this point. --Sven
*/
exit (0);
......@@ -455,7 +455,7 @@ gimprc_notify_callback (GObject *object,
}
else
{
g_print (" %s changed but we failed to serialize its value!\n",
g_print (" %s changed but we failed to serialize its value!\n",
pspec->name);
}
......
......@@ -34,7 +34,7 @@
#include "pdb/procedural_db.h"
#include "pdb/internal_procs.h"
#include "paint/paint.h"
#include "paint/gimp-paint.h"
#include "text/gimp-fonts.h"
......@@ -425,7 +425,7 @@ gimp_finalize (GObject *object)
if (gimp->module_db)
gimp_modules_exit (gimp);
paint_exit (gimp);
gimp_paint_exit (gimp);
if (gimp->parasites)
{
......@@ -735,7 +735,7 @@ gimp_initialize (Gimp *gimp,
gimp_palette_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->palette_factory), "palette factory");
paint_init (gimp);
gimp_paint_init (gimp);
/* Set the last values used to default values. */
......
......@@ -1004,20 +1004,23 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
space_shaded_tool = active_tool->tool_info;
space_press_state = state;
g_print ("%s: pushing move tool\n", G_GNUC_FUNCTION);
move_tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-move-tool");
gdk_keyboard_grab (canvas->window, FALSE, time);
if (GIMP_IS_TOOL_INFO (move_tool_info))
{
g_print ("%s: pushing move tool\n", G_GNUC_FUNCTION);
move_tool_info =
tool_manager_get_info_by_type (gimp,
GIMP_TYPE_MOVE_TOOL);
gdk_keyboard_grab (canvas->window, FALSE, time);
gimp_context_set_tool (gimp_get_user_context (gimp),
move_tool_info);
gimp_context_set_tool (gimp_get_user_context (gimp),
move_tool_info);
gimp_display_shell_update_tool_modifiers (shell, 0, state);
gimp_display_shell_update_tool_modifiers (shell, 0, state);
shell->space_pressed = TRUE;
shell->space_pressed = TRUE;
}
}
}
......
......@@ -28,6 +28,7 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
......@@ -328,19 +329,26 @@ vectors_vectors_tool (GimpVectors *vectors)
if (! GIMP_IS_VECTOR_TOOL (active_tool))
{
GimpToolInfo *tool_info;
GimpContainer *tool_info_list;
GimpToolInfo *tool_info;
tool_info = tool_manager_get_info_by_type (gimage->gimp,
GIMP_TYPE_VECTOR_TOOL);
tool_info_list = gimage->gimp->tool_info_list;
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-vector-tool");
active_tool = tool_manager_get_active (gimage->gimp);
if (GIMP_IS_TOOL_INFO (tool_info))
{
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
tool_info);
active_tool = tool_manager_get_active (gimage->gimp);
}
}
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool),
vectors);
if (GIMP_IS_VECTOR_TOOL (active_tool))
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors);
}
/**********************************/
......
......@@ -18,8 +18,8 @@ noinst_LIBRARIES = libapppaint.a
libapppaint_a_sources = \
paint-enums.h \
paint-types.h \
paint.c \
paint.h \
gimp-paint.c \
gimp-paint.h \
gimpairbrush.c \
gimpairbrush.h \
gimpairbrushoptions.c \
......
......@@ -26,7 +26,7 @@
#include "core/gimplist.h"
#include "core/gimppaintinfo.h"
#include "paint.h"
#include "gimp-paint.h"
#include "gimpairbrush.h"
#include "gimpclone.h"
#include "gimpconvolve.h"
......@@ -39,16 +39,16 @@
/* local function prototypes */
static void paint_register (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *blurb);
static void gimp_paint_register (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *blurb);
/* public functions */
void
paint_init (Gimp *gimp)
gimp_paint_init (Gimp *gimp)
{
GimpPaintRegisterFunc register_funcs[] =
{
......@@ -72,12 +72,12 @@ paint_init (Gimp *gimp)
for (i = 0; i < G_N_ELEMENTS (register_funcs); i++)
{
register_funcs[i] (gimp, paint_register);
register_funcs[i] (gimp, gimp_paint_register);
}
}
void
paint_exit (Gimp *gimp)
gimp_paint_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -92,10 +92,10 @@ paint_exit (Gimp *gimp)
/* private functions */
static void
paint_register (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *blurb)
gimp_paint_register (Gimp *gimp,
GType paint_type,
GType paint_options_type,
const gchar *blurb)
{
GimpPaintInfo *paint_info;
......
......@@ -16,12 +16,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PAINT_H__
#define __PAINT_H__
#ifndef __GIMP_PAINT_H__
#define __GIMP_PAINT_H__
void paint_init (Gimp *gimp);
void paint_exit (Gimp *gimp);
void gimp_paint_init (Gimp *gimp);
void gimp_paint_exit (Gimp *gimp);
#endif /* __PAINT_H__ */
#endif /* __GIMP_PAINT_H__ */
......@@ -5,8 +5,11 @@ noinst_LIBRARIES = libapptools.a
libapptools_a_sources = \
tools-enums.h \
tools-types.h \
tools.c \
tools.h \
gimp-tools.c \
gimp-tools.h \
tool_manager.c \
tool_manager.h \
\
gimpairbrushtool.c \
gimpairbrushtool.h \
gimpblendoptions.c \
......@@ -136,9 +139,7 @@ libapptools_a_sources = \
gimpvectoroptions.c \
gimpvectoroptions.h \
gimpvectortool.c \
gimpvectortool.h \
tool_manager.c \
tool_manager.h
gimpvectortool.h
libapptools_a_built_sources = tools-enums.c
......
......@@ -24,6 +24,13 @@
#include "tools-types.h"
#include "core/gimp.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimptooloptions.h"
#include "gimp-tools.h"
#include "gimptooloptions-gui.h"
#include "tool_manager.h"
#include "gimpairbrushtool.h"
......@@ -65,9 +72,30 @@
#include "gimptexttool.h"
#include "gimpvectortool.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gimp_tools_register (GType tool_type,
GType tool_options_type,
GimpToolOptionsGUIFunc options_gui_func,
GimpContextPropMask context_props,
const gchar *identifier,
const gchar *blurb,
const gchar *help,
const gchar *menu_path,
const gchar *menu_accel,
const gchar *help_domain,
const gchar *help_data,
const gchar *stock_id,
gpointer data);
/* public functions */
void
tools_init (Gimp *gimp)
gimp_tools_init (Gimp *gimp)
{
GimpToolRegisterFunc register_funcs[] =
{
......@@ -131,13 +159,186 @@ tools_init (Gimp *gimp)
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
tool_manager_init (gimp);
for (i = 0; i < G_N_ELEMENTS (register_funcs); i++)
{
register_funcs[i] (tool_manager_register_tool, gimp);
register_funcs[i] (gimp_tools_register, gimp);
}
gimp_container_thaw (gimp->tool_info_list);
}
void
tools_exit (Gimp *gimp)
gimp_tools_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
tool_manager_exit (gimp);
}
void
gimp_tools_restore (Gimp *gimp)
{
GimpToolInfo *tool_info;
GList *list;
g_return_if_fail (GIMP_IS_GIMP (gimp));
for (list = GIMP_LIST (gimp->tool_info_list)->list;
list;
list = g_list_next (list))
{
GimpToolOptionsGUIFunc options_gui_func;
GtkWidget *options_gui;
tool_info = GIMP_TOOL_INFO (list->data);
gimp_tool_options_deserialize (tool_info->tool_options, NULL, NULL);
options_gui_func = g_object_get_data (G_OBJECT (tool_info),
"gimp-tool-options-gui-func");
if (options_gui_func)
{
options_gui = (* options_gui_func) (tool_info->tool_options);
}
else
{
GtkWidget *label;
options_gui = gimp_tool_options_gui (tool_info->tool_options);
label = gtk_label_new (_("This tool has no options."));
gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6);
gtk_widget_show (label);
}
g_object_set_data (G_OBJECT (tool_info->tool_options),
"gimp-tool-options-gui", options_gui);
}
}
void
gimp_tools_save (Gimp *gimp)
{
GimpToolInfo *tool_info;
GList *list;
g_return_if_fail (GIMP_IS_GIMP (gimp));
for (list = GIMP_LIST (gimp->tool_info_list)->list;
list;
list = g_list_next (list))
{
tool_info = GIMP_TOOL_INFO (list->data);
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
}
}
/* private functions */
static void
gimp_tools_register (GType tool_type,
GType tool_options_type,
GimpToolOptionsGUIFunc options_gui_func,
GimpContextPropMask context_props,
const gchar *identifier,
const gchar *blurb,
const gchar *help,
const gchar *menu_path,
const gchar *menu_accel,
const gchar *help_domain,
const gchar *help_data,
const gchar *stock_id,
gpointer data)
{
Gimp *gimp = (Gimp *) data;
GimpToolInfo *tool_info;
const gchar *paint_core_name;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (g_type_is_a (tool_type, GIMP_TYPE_TOOL));
g_return_if_fail (tool_options_type == G_TYPE_NONE ||
g_type_is_a (tool_options_type, GIMP_TYPE_TOOL_OPTIONS));
if (tool_options_type == G_TYPE_NONE)
tool_options_type = GIMP_TYPE_TOOL_OPTIONS;
if (tool_type == GIMP_TYPE_PENCIL_TOOL)
{
paint_core_name = "GimpPencil";
}
else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
{
paint_core_name = "GimpPaintbrush";
}
else if (tool_type == GIMP_TYPE_ERASER_TOOL)
{
paint_core_name = "GimpEraser";
}
else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL)
{
paint_core_name = "GimpAirbrush";
}
else if (tool_type == GIMP_TYPE_CLONE_TOOL)
{
paint_core_name = "GimpClone";
}
else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL)
{
paint_core_name = "GimpConvolve";
}
else if (tool_type == GIMP_TYPE_SMUDGE_TOOL)
{
paint_core_name = "GimpSmudge";
}
else if (tool_type == GIMP_TYPE_DODGEBURN_TOOL)
{
paint_core_name = "GimpDodgeBurn";
}
else
{
paint_core_name = "GimpPaintbrush";
}
tool_info = gimp_tool_info_new (gimp,
tool_type,
tool_options_type,
context_props,
identifier,
blurb,
help,
menu_path,
menu_accel,
help_domain,
help_data,
paint_core_name,
stock_id);
if (g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL))
tool_info->in_toolbox = FALSE;
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
options_gui_func);
if (tool_info->context_props)
{
gimp_context_define_properties (GIMP_CONTEXT (tool_info->tool_options),
tool_info->context_props, FALSE);
gimp_context_copy_properties (gimp_get_user_context (gimp),
GIMP_CONTEXT (tool_info->tool_options),
GIMP_CONTEXT_ALL_PROPS_MASK);
}
gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info));
g_object_unref (tool_info);
if (tool_type == GIMP_TYPE_RECT_SELECT_TOOL)
gimp_tool_info_set_standard (gimp, tool_info);
}
......@@ -16,12 +16,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __TOOLS_H__
#define __TOOLS_H__
#ifndef __GIMP_TOOLS_H__
#define __GIMP_TOOLS_H__
void tools_init (Gimp *gimp);
void tools_exit (Gimp *gimp);
void gimp_tools_init (Gimp *gimp);
void gimp_tools_exit (Gimp *gimp);
void gimp_tools_restore (Gimp *gimp);
void gimp_tools_save (Gimp *gimp);
#endif /* __TOOLS_H__ */
#endif /* __GIMP_TOOLS_H__ */
......@@ -37,6 +37,7 @@
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppaintinfo.h"
......@@ -55,7 +56,6 @@
#include "gimpcolorpickertool.h"
#include "gimppainttool.h"
#include "gimptoolcontrol.h"
#include "tool_manager.h"
#include "gimp-intl.h"
......@@ -567,20 +567,28 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
{
if (press)
{
GimpToolInfo *info;
GimpContainer *tool_info_list;
GimpToolInfo *info;
info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_COLOR_PICKER_TOOL);
tool_info_list = gdisp->gimage->gimp->tool_info_list;
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-color-picker-tool");
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
if (GIMP_IS_TOOL_INFO (info))
{
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
}
}
else
{
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
}
}
}
......
......@@ -37,6 +37,7 @@
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppaintinfo.h"
......@@ -55,7 +56,6 @@
#include "gimpcolorpickertool.h"
#include "gimppainttool.h"
#include "gimptoolcontrol.h"
#include "tool_manager.h"
#include "gimp-intl.h"
......@@ -567,20 +567,28 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
{
if (press)
{
GimpToolInfo *info;
GimpContainer *tool_info_list;
GimpToolInfo *info;
info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_COLOR_PICKER_TOOL);
tool_info_list = gdisp->gimage->gimp->tool_info_list;
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
"gimp-color-picker-tool");
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
if (GIMP_IS_TOOL_INFO (info))
{
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
}
}
else
{
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
}
}
}
......
......@@ -138,7 +138,7 @@ gimp_vector_tool_register (GimpToolRegisterCallback callback,
GIMP_TYPE_VECTOR_OPTIONS,
gimp_vector_options_gui,
0,
"gimp-path-tool",
"gimp-vector-tool",
_("Paths"),
_("Create and edit paths"),
N_("/Tools/_Paths"), NULL,
......
......@@ -25,27 +25,17 @@
#include "tools-types.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "core/gimptooloptions.h"
#include "display/gimpdisplay.h"
#include "gimpairbrushtool.h"
#include "gimpclonetool.h"
#include "gimpconvolvetool.h"
#include "gimpdodgeburntool.h"
#include "gimperasertool.h"
#include "gimpimagemaptool.h"
#include "gimppaintbrushtool.h"
#include "gimppenciltool.h"
#include "gimprectselecttool.h"
#include "gimpsmudgetool.h"
#include "gimpdrawtool.h"
#include "gimptoolcontrol.h"
#include "gimptooloptions-gui.h"
#include "tool_manager.h"
#include "tools.h"
#include "gimp-intl.h"
......@@ -110,24 +100,6 @@ tool_manager_init (Gimp *gimp)
g_signal_connect (user_context, "tool_changed",