1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "create_object.h"
23 #include "modify_tool.h"
24 #include "scroll_tool.h"
25 #include "interface.h"
28 Tool
*active_tool
= NULL
;
29 Tool
*transient_tool
= NULL
;
30 static GtkWidget
*active_button
= NULL
;
31 static GtkWidget
*former_button
= NULL
;
34 tool_select_former(void)
37 gtk_signal_emit_by_name(GTK_OBJECT(former_button
), "clicked",
38 GTK_BUTTON(former_button
), NULL
);
45 gtk_signal_emit_by_name(GTK_OBJECT(modify_tool_button
), "clicked",
46 GTK_BUTTON(modify_tool_button
), NULL
);
50 tool_get(ToolState
*state
)
52 state
->type
= active_tool
->type
;
53 state
->button
= active_button
;
54 if (state
->type
== CREATE_OBJECT_TOOL
) {
55 state
->user_data
= ((CreateObjectTool
*)active_tool
)->user_data
;
56 state
->extra_data
= ((CreateObjectTool
*)active_tool
)->objtype
->name
;
57 state
->invert_persistence
= ((CreateObjectTool
*)active_tool
)->invert_persistence
;
61 state
->user_data
= NULL
;
62 state
->extra_data
= NULL
;
63 state
->invert_persistence
= 0;
68 tool_restore(const ToolState
*state
)
70 tool_select(state
->type
, state
->extra_data
, state
->user_data
, state
->button
,
71 state
->invert_persistence
);
79 free_modify_tool(tool
);
81 case CREATE_OBJECT_TOOL
:
82 free_create_object_tool(tool
);
85 free_magnify_tool(tool
);
88 free_scroll_tool(tool
);
96 tool_select(ToolType type
, gpointer extra_data
,
97 gpointer user_data
, GtkWidget
*button
,
98 int invert_persistence
)
101 former_button
= active_button
;
103 tool_free(active_tool
);
106 active_tool
= create_modify_tool();
108 case CREATE_OBJECT_TOOL
:
110 create_create_object_tool(object_get_type((char *)extra_data
),
111 (void *) user_data
, invert_persistence
);
114 active_tool
= create_magnify_tool();
117 active_tool
= create_scroll_tool();
123 active_button
= button
;
127 tool_options_dialog_show(ToolType type
, gpointer extra_data
,
128 gpointer user_data
, GtkWidget
*button
,
129 int invert_persistence
)
133 if (active_tool
->type
!= type
)
134 tool_select(type
,extra_data
,user_data
,button
,invert_persistence
);
139 case CREATE_OBJECT_TOOL
:
140 objtype
= object_get_type((char *)extra_data
);
141 defaults_show(objtype
);