1 /* === S Y N F I G ========================================================= */
2 /*!	\file iconcontroller.cpp
3 **	\brief Template File
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2007, 2008 Chris Moore
10 **  Copyright (c) 2008 Paul Wise
11 **  Copyright (c) 2009 Gerco Ballintijn
12 **	Copyright (c) 2009, 2011 Carlos López
13 **	Copyright (c) 2009 Nikita Kitaev
14 **
15 **	This package is free software; you can redistribute it and/or
16 **	modify it under the terms of the GNU General Public License as
17 **	published by the Free Software Foundation; either version 2 of
18 **	the License, or (at your option) any later version.
19 **
20 **	This package is distributed in the hope that it will be useful,
21 **	but WITHOUT ANY WARRANTY; without even the implied warranty of
22 **	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 **	General Public License for more details.
24 **	\endlegal
25 */
26 /* ========================================================================= */
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #ifdef USING_PCH
31 #	include "pch.h"
32 #else
33 #ifdef HAVE_CONFIG_H
34 #	include <config.h>
35 #endif
36 
37 #include <synfig/general.h>
38 
39 #include "iconcontroller.h"
40 #include <synfig/valuenodes/valuenode_const.h>
41 #include <gtkmm/button.h>
42 #include <gtkmm/window.h>
43 #include <synfigapp/action.h>
44 #include <synfig/interpolation.h>
45 
46 #include <gdkmm.h>
47 
48 #include <gui/localization.h>
49 
50 #endif
51 
52 /* === U S I N G =========================================================== */
53 
54 using namespace etl;
55 using namespace std;
56 using namespace studio;
57 using namespace synfig;
58 
59 /* === M A C R O S ========================================================= */
60 
61 #ifdef _WIN32
62 #	ifdef IMAGE_DIR
63 #		undef IMAGE_DIR
64 #		define IMAGE_DIR "share\\pixmaps"
65 #	endif
66 #endif
67 
68 #ifndef IMAGE_DIR
69 #	define IMAGE_DIR "/usr/local/share/pixmaps"
70 #endif
71 
72 
73 #ifndef IMAGE_EXT
74 #	define IMAGE_EXT	"png"
75 #endif
76 
77 /* === M E T H O D S ======================================================= */
78 
79 static std::map< int, Glib::RefPtr<Gdk::Pixbuf> > _tree_pixbuf_table_value_type;
80 static Glib::RefPtr<Gdk::Pixbuf> _tree_pixbuf_table_interpolation[(int)INTERPOLATION_CLAMPED+1];
81 
82 #ifdef _WIN32
IconController(const synfig::String & basepath)83 IconController::IconController(const synfig::String& basepath)
84 #else
85 IconController::IconController(const synfig::String& /*basepath*/)
86 #endif
87 {
88 
89 	icon_factory=Gtk::IconFactory::create();
90 }
91 
~IconController()92 IconController::~IconController()
93 {
94 	_tree_pixbuf_table_value_type.clear();
95 	for(int i(0);i<((int)INTERPOLATION_CLAMPED+1);i++)
96 		_tree_pixbuf_table_interpolation[i]=Glib::RefPtr<Gdk::Pixbuf>();
97 
98 	icon_factory->remove_default();
99 }
100 
101 void
init_icon(const synfig::String & name,const synfig::String & iconfile,const synfig::String & desc)102 IconController::init_icon(const synfig::String &name, const synfig::String &iconfile, const synfig::String& desc)
103 {
104 	Gtk::StockItem stockitem(Gtk::StockID("synfig-" + name), desc);
105 	Gtk::Stock::add(stockitem);
106 	Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
107 	Gtk::IconSource icon_source;
108 	icon_source.set_direction_wildcarded();
109 	icon_source.set_state_wildcarded();
110 	icon_source.set_size_wildcarded();
111 	icon_source.set_filename(iconfile);
112 	icon_set->add_source(icon_source);
113 	icon_factory->add(stockitem.get_stock_id(), icon_set);
114 }
115 
116 void
init_icon_clone(const synfig::String & name,const synfig::String & desc)117 IconController::init_icon_clone(const synfig::String &name, const synfig::String& desc)
118 {
119 	Gtk::StockItem stockitem(Gtk::StockID("synfig-" + name), desc);
120 	Gtk::Stock::add(stockitem);
121 	Glib::RefPtr<Gtk::IconSet> icon_set = Gtk::IconSet::create();
122 	if (Gtk::Stock::lookup(stockitem.get_stock_id(), icon_set))
123 		icon_factory->add(stockitem.get_stock_id(), icon_set);
124 }
125 
126 void
init_icons(const synfig::String & path_to_icons)127 IconController::init_icons(const synfig::String& path_to_icons)
128 {
129 	try{
130 	Gtk::Window::set_default_icon_from_file(path_to_icons+"synfig_icon."+IMAGE_EXT);
131 	} catch(...)
132 	{
133 		synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
134 	}
135 
136 #define INIT_STOCK_ICON(name,iconfile,desc) \
137 	init_icon(#name, (path_to_icons) + (iconfile), (desc));
138 
139 #define INIT_STOCK_ICON_CLONE(name,desc) \
140 	init_icon_clone(#name, (desc));
141 
142 #define INIT_STOCK_ITEM(name,desc) \
143 	stock_##name = Gtk::StockItem(Gtk::StockID("synfig-" #name),desc); \
144 	Gtk::Stock::add(stock_##name);
145 
146 	// Types
147 	INIT_STOCK_ICON(type_bool, "type_bool_icon." IMAGE_EXT, _("Bool"));
148 	INIT_STOCK_ICON(type_integer, "type_integer_icon." IMAGE_EXT, _("Integer"));
149 	INIT_STOCK_ICON(type_angle, "type_angle_icon." IMAGE_EXT, _("Angle"));
150 	INIT_STOCK_ICON(type_time, "type_time_icon." IMAGE_EXT, _("Time"));
151 	INIT_STOCK_ICON(type_real, "type_real_icon." IMAGE_EXT, _("Real"));
152 	INIT_STOCK_ICON(type_vector, "type_vector_icon." IMAGE_EXT, _("Vector"));
153 	INIT_STOCK_ICON(type_color, "type_color_icon." IMAGE_EXT, _("Color"));
154 	INIT_STOCK_ICON(type_segment, "type_segment_icon." IMAGE_EXT, _("Segment"));
155 	INIT_STOCK_ICON(type_blinepoint, "type_splinepoint_icon." IMAGE_EXT, _("Spline Point"));
156 	INIT_STOCK_ICON(type_list, "type_list_icon." IMAGE_EXT, _("List"));
157 	INIT_STOCK_ICON(type_string, "type_string_icon." IMAGE_EXT, _("String"));
158 	INIT_STOCK_ICON(type_canvas, "type_canvas_icon." IMAGE_EXT, _("Canvas"));
159 	INIT_STOCK_ICON(type_gradient, "type_gradient_icon." IMAGE_EXT, _("Gradient"))
160 
161 	// ToolBox Tools
162 	INIT_STOCK_ICON(normal, "tool_normal_icon." IMAGE_EXT, _("Transform Tool"));
163 	INIT_STOCK_ICON(polygon, "tool_polyline_icon." IMAGE_EXT, _("Polygon Tool"));
164 	INIT_STOCK_ICON(bline, "tool_spline_icon." IMAGE_EXT, _("Spline Tool"));
165 	INIT_STOCK_ICON(eyedrop, "tool_eyedrop_icon." IMAGE_EXT, _("Eyedrop Tool"));
166 	INIT_STOCK_ICON(fill, "tool_fill_icon." IMAGE_EXT, _("Fill Tool"));
167 	INIT_STOCK_ICON(draw, "tool_draw_icon." IMAGE_EXT, _("Draw Tool"));
168 	INIT_STOCK_ICON(lasso, "tool_cutout_icon." IMAGE_EXT, _("Cutout Tool"));
169 	INIT_STOCK_ICON(brush, "tool_brush_icon." IMAGE_EXT, _("Brush Tool"));
170 	INIT_STOCK_ICON(sketch, "tool_sketch_icon." IMAGE_EXT, _("Sketch Tool"));
171 	INIT_STOCK_ICON(circle, "tool_circle_icon." IMAGE_EXT, _("Circle Tool"));
172 	INIT_STOCK_ICON(rectangle, "tool_rectangle_icon." IMAGE_EXT, _("Rectangle Tool"));
173 	INIT_STOCK_ICON(smooth_move, "tool_smooth_move_icon." IMAGE_EXT, _("SmoothMove Tool"));
174 	INIT_STOCK_ICON(rotate, "tool_rotate_icon." IMAGE_EXT, _("Rotate Tool"));
175 	INIT_STOCK_ICON(width, "tool_width_icon." IMAGE_EXT, _("Width Tool"));
176 	INIT_STOCK_ICON(scale, "tool_scale_icon." IMAGE_EXT, _("Scale Tool"));
177 	INIT_STOCK_ICON(zoom, "tool_zoom_icon." IMAGE_EXT, _("Zoom Tool"));
178 	INIT_STOCK_ICON(mirror, "tool_mirror_icon." IMAGE_EXT, _("Mirror Tool"));
179 	INIT_STOCK_ICON(text, "tool_text_icon." IMAGE_EXT, _("Text Tool"));
180 	INIT_STOCK_ICON(gradient, "tool_gradient_icon." IMAGE_EXT, _("Gradient Tool"));
181 	INIT_STOCK_ICON(star, "tool_star_icon." IMAGE_EXT, _("Star Tool"));
182 	// ToolBox Others
183 	INIT_STOCK_ICON(reset_colors, "reset_colors_icon." IMAGE_EXT, _("Reset Colors"));
184 	INIT_STOCK_ICON(swap_colors, "swap_colors_icon." IMAGE_EXT, _("Swap Colors"));
185 	INIT_STOCK_ICON(value_node, "valuenode_icon." IMAGE_EXT, _("ValueNode"));
186 	INIT_STOCK_ICON(valuenode_forbidanimation, "valuenode_forbidanimation_icon." IMAGE_EXT, _("ValueNode Forbid Animation"));
187 	INIT_STOCK_ICON(rename, "rename_icon." IMAGE_EXT, _("Rename"));
188 	INIT_STOCK_ICON(canvas, "canvas_icon." IMAGE_EXT, _("Canvas"));
189 	INIT_STOCK_ICON(canvas_new, "canvas_icon." IMAGE_EXT, _("New Canvas"));
190 
191 	// Document Related Actions
192 	INIT_STOCK_ICON(about, "about_icon." IMAGE_EXT, _("About"));
193 	INIT_STOCK_ICON(new_doc, "action_doc_new_icon." IMAGE_EXT, _("New"));
194 	INIT_STOCK_ICON(open, "action_doc_open_icon." IMAGE_EXT, _("Open"));
195 	INIT_STOCK_ICON(save, "action_doc_save_icon." IMAGE_EXT, _("Save"));
196 	INIT_STOCK_ICON(save_as, "action_doc_saveas_icon." IMAGE_EXT, _("Save As"));
197 	INIT_STOCK_ICON(save_all, "action_doc_saveall_icon." IMAGE_EXT, _("Save All"));
198 	INIT_STOCK_ICON(redo, "action_doc_redo_icon." IMAGE_EXT, _("Redo"));
199 	INIT_STOCK_ICON(undo, "action_doc_undo_icon." IMAGE_EXT, _("Undo"));
200 
201 	// Layers
202 	INIT_STOCK_ICON(layer, "layer_icon." IMAGE_EXT, _("Layer"));
203 	// Blur Layers
204 	INIT_STOCK_ICON(layer_blur_blur, "layer_blur_blur_icon." IMAGE_EXT, _("Blur Layer"));
205 	INIT_STOCK_ICON(layer_blur_motion, "layer_blur_motion_icon." IMAGE_EXT, _("Motion Blur Layer"));
206 	INIT_STOCK_ICON(layer_blur_radial, "layer_blur_radial_icon." IMAGE_EXT, _("Radial Blur Layer"));
207 	// Distortion Layers
208 	INIT_STOCK_ICON(layer_distortion_curvewarp, "layer_distortion_curvewarp_icon." IMAGE_EXT, _("Curve Warp Layer"));
209 	INIT_STOCK_ICON(layer_distortion_insideout, "layer_distortion_insideout_icon." IMAGE_EXT, _("Inside Out Layer"));
210 	INIT_STOCK_ICON(layer_distortion_noise, "layer_distortion_noise_icon." IMAGE_EXT, _("Noise Distort Layer"));
211 	INIT_STOCK_ICON(layer_distortion_spherize, "layer_distortion_spherize_icon." IMAGE_EXT, _("Spherize Layer"));
212 	INIT_STOCK_ICON(layer_distortion_stretch, "layer_distortion_stretch_icon." IMAGE_EXT, _("Stretch Layer"));
213 	INIT_STOCK_ICON(layer_distortion_twirl, "layer_distortion_twirl_icon." IMAGE_EXT, _("Twirl Layer"));
214 	INIT_STOCK_ICON(layer_distortion_warp, "layer_distortion_warp_icon." IMAGE_EXT, _("Warp Layer"));
215 	// Example Layers
216 	INIT_STOCK_ICON(layer_example_filledrectangle, "layer_example_filledrectangle_icon." IMAGE_EXT, _("Filled Rectangle Layer"));
217 	INIT_STOCK_ICON(layer_example_metaballs, "layer_example_metaballs_icon." IMAGE_EXT, _("Metallballs Layer"));
218 	INIT_STOCK_ICON(layer_example_simplecircle, "layer_example_simplecircle_icon." IMAGE_EXT, _("Simple Circle Layer"));
219 	// Filter Layers
220 	INIT_STOCK_ICON(layer_filter_clamp, "layer_filter_clamp_icon." IMAGE_EXT, _("Clamp Layer"));
221 	INIT_STOCK_ICON(layer_filter_colorcorrect, "layer_filter_colorcorrect_icon." IMAGE_EXT, _("Color Correct Layer"));
222 	INIT_STOCK_ICON(layer_filter_halftone2, "layer_filter_halftone2_icon." IMAGE_EXT, _("Halftone 2 Layer"));
223 	INIT_STOCK_ICON(layer_filter_halftone3, "layer_filter_halftone3_icon." IMAGE_EXT, _("Halftone 3 Layer"));
224 	INIT_STOCK_ICON(layer_filter_lumakey, "layer_filter_lumakey_icon." IMAGE_EXT, _("Luma Key Layer"));
225 	// Fractal Layers
226 	INIT_STOCK_ICON(layer_fractal_julia, "layer_fractal_julia_icon." IMAGE_EXT, _("Julia Set Layer"));
227 	INIT_STOCK_ICON(layer_fractal_mandelbrot, "layer_fractal_mandelbrot_icon." IMAGE_EXT, _("Mandelbrot Set Layer"));
228 	// Geometry Layers
229 	INIT_STOCK_ICON(layer_geometry_checkerboard, "layer_geometry_checkerboard_icon." IMAGE_EXT, _("Checker Board Layer"));
230 	INIT_STOCK_ICON(layer_geometry_circle, "layer_geometry_circle_icon." IMAGE_EXT, _("Circle Layer"));
231 	INIT_STOCK_ICON(layer_geometry_outline, "layer_geometry_outline_icon." IMAGE_EXT, _("Outline Layer"));
232 	INIT_STOCK_ICON(layer_geometry_advanced_outline, "layer_geometry_advanced_outline_icon." IMAGE_EXT, _("Advanced Outline Layer"));
233 	INIT_STOCK_ICON(layer_geometry_polygon, "layer_geometry_polygon_icon." IMAGE_EXT, _("Polygon Layer"));
234 	INIT_STOCK_ICON(layer_geometry_rectangle, "layer_geometry_rectangle_icon." IMAGE_EXT, _("Rectangle Layer"));
235 	INIT_STOCK_ICON(layer_geometry_region, "layer_geometry_region_icon." IMAGE_EXT, _("Region Layer"));
236 	INIT_STOCK_ICON(layer_geometry_solidcolor, "layer_geometry_solidcolor_icon." IMAGE_EXT, _("Solid Color Layer"));
237 	INIT_STOCK_ICON(layer_geometry_star, "layer_geometry_star_icon." IMAGE_EXT, _("Star Layer"));
238 	// Gradient Layers
239 	INIT_STOCK_ICON(layer_gradient_conical, "layer_gradient_conical_icon." IMAGE_EXT, _("Conical Gradient Layer"));
240 	INIT_STOCK_ICON(layer_gradient_curve, "layer_gradient_curve_icon." IMAGE_EXT, _("Curve Gradient Layer"));
241 	INIT_STOCK_ICON(layer_gradient_noise, "layer_gradient_noise_icon." IMAGE_EXT, _("Noise Gradient Layer"));
242 	INIT_STOCK_ICON(layer_gradient_linear, "layer_gradient_linear_icon." IMAGE_EXT, _("Linear Gradient Layer"));
243 	INIT_STOCK_ICON(layer_gradient_radial, "layer_gradient_radial_icon." IMAGE_EXT, _("Radial Gradient Layer"));
244 	INIT_STOCK_ICON(layer_gradient_spiral, "layer_gradient_spiral_icon." IMAGE_EXT, _("Spiral Gradient Layer"));
245 	// Other Layers
246 	INIT_STOCK_ICON(layer_other_duplicate, "layer_other_duplicate_icon." IMAGE_EXT, _("Duplicate Layer"));
247 	INIT_STOCK_ICON(layer_other_importimage, "layer_other_importimage_icon." IMAGE_EXT, _("Import Image Layer"));
248 	INIT_STOCK_ICON(layer_other_pastecanvas, "layer_other_group_icon." IMAGE_EXT, _("Group Layer"));
249 	INIT_STOCK_ICON(layer_other_plant, "layer_other_plant_icon." IMAGE_EXT, _("Plant Layer"));
250 	INIT_STOCK_ICON(layer_other_stroboscope, "layer_other_stroboscope_icon." IMAGE_EXT, _("Stroboscope Layer"));
251 	INIT_STOCK_ICON(layer_other_supersample, "layer_other_supersample_icon." IMAGE_EXT, _("Super Sample Layer"));
252 	INIT_STOCK_ICON(layer_other_sound, "layer_other_sound_icon." IMAGE_EXT, _("Sound Layer"));
253 	INIT_STOCK_ICON(layer_other_switch, "layer_other_switch_icon." IMAGE_EXT, _("Switch Layer"));
254 	INIT_STOCK_ICON(layer_other_skeleton, "layer_other_skeleton_icon." IMAGE_EXT, _("Skeleton Layer"));
255 	INIT_STOCK_ICON(layer_other_text, "layer_other_text_icon." IMAGE_EXT, _("Text Layer"));
256 	INIT_STOCK_ICON(layer_other_timeloop, "layer_other_timeloop_icon." IMAGE_EXT, _("Time Loop Layer"));
257 	INIT_STOCK_ICON(layer_other_xorpattern, "layer_other_xorpattern_icon." IMAGE_EXT, _("XOR Pattern Layer"));
258 	// Stylize Layers
259 	INIT_STOCK_ICON(layer_stylize_bevel, "layer_stylize_bevel_icon." IMAGE_EXT, _("Bevel Layer"));
260 	INIT_STOCK_ICON(layer_stylize_shade, "layer_stylize_shade_icon." IMAGE_EXT, _("Shade Layer"));
261 	// Transform Layers
262 	INIT_STOCK_ICON(layer_transform_rotate, "layer_transform_rotate_icon." IMAGE_EXT, _("Rotate Layer"));
263 	INIT_STOCK_ICON(layer_transform_translate, "layer_transform_translate_icon." IMAGE_EXT, _("Translate Layer"));
264 	INIT_STOCK_ICON(layer_transform_scale, "layer_transform_scale_icon." IMAGE_EXT, _("Scale Layer"));
265 
266 	// Ghost Layers
267 	// TODO: icon for ghost group
268 	INIT_STOCK_ICON(layer_ghost_group, "layer_other_group_icon." IMAGE_EXT, _("Group Ghost"));
269 	//INIT_STOCK_ICON(layer_ghost_group, "layer_ghost_group_icon." IMAGE_EXT, _("Group Ghost"));
270 
271 	INIT_STOCK_ICON(layer_new, "grid_enable_icon." IMAGE_EXT, _("Show Grid"));
272 
273 	INIT_STOCK_ICON(info, "info_icon." IMAGE_EXT, _("Info Tool"));
274 	INIT_STOCK_ICON(group, "set_icon." IMAGE_EXT, _("Set"));
275 
276 	INIT_STOCK_ICON(grid_enable, "grid_enable_icon." IMAGE_EXT, _("Show Grid"));
277 	INIT_STOCK_ICON(grid_disable, "grid_disable_icon." IMAGE_EXT, _("Hide Grid"));
278 	INIT_STOCK_ICON(grid_snap_enable, "grid_snap_enable_icon." IMAGE_EXT, _("Enable Grid Snap"));
279 	INIT_STOCK_ICON(grid_snap_disable, "grid_snap_disable_icon." IMAGE_EXT, _("Disable Grid Snap"));
280 	INIT_STOCK_ICON(duplicate, "duplicate_icon." IMAGE_EXT, _("Duplicate"));
281 	INIT_STOCK_ICON(encapsulate, "group_icon." IMAGE_EXT, _("Group"));
282 	// TODO: icon for 'Group Layer into Switch' action
283 	INIT_STOCK_ICON(encapsulate_switch, "layer_other_switch_icon." IMAGE_EXT, _("Group into Switch"));
284 	// TODO: icon for 'Group Layer into Filter' action
285 	INIT_STOCK_ICON(encapsulate_filter, "layer_icon." IMAGE_EXT, _("Group into Filter"));
286 	INIT_STOCK_ICON(select_all_child_layers, "select_all_child_layers_icon." IMAGE_EXT, _("Select All Child Layers"));
287 
288 	INIT_STOCK_ICON(clear_undo, "clear_undo_icon." IMAGE_EXT, _("Clear Undo Stack"));
289 	INIT_STOCK_ICON(clear_redo, "clear_redo_icon." IMAGE_EXT, _("Clear Redo Stack"));
290 
291 	INIT_STOCK_ICON(children, "library_icon." IMAGE_EXT, _("Library"));
292 	INIT_STOCK_ICON(curves, "graphs_icon." IMAGE_EXT, _("Graphs"));
293 	INIT_STOCK_ICON(keyframes, "keyframe_icon." IMAGE_EXT, _("Keyframes"));
294 	INIT_STOCK_ICON(meta_data, "meta_data_icon." IMAGE_EXT, _("MetaData"));
295 	INIT_STOCK_ICON(navigator, "navigator_icon." IMAGE_EXT, _("Navigator"));
296 	INIT_STOCK_ICON(timetrack, "time_track_icon." IMAGE_EXT, _("Time Track"));
297 	INIT_STOCK_ICON(history, "history_icon." IMAGE_EXT, _("History"));
298 	INIT_STOCK_ICON(palette, "palette_icon." IMAGE_EXT, _("Palette"));
299 	INIT_STOCK_ICON(params, "parameters_icon." IMAGE_EXT, _("Parameters"));
300 
301 	INIT_STOCK_ICON(keyframe_lock_past_off, "keyframe_lock_past_off_icon." IMAGE_EXT, _("Past keyframes unlocked"));
302 	INIT_STOCK_ICON(keyframe_lock_past_on, "keyframe_lock_past_on_icon." IMAGE_EXT, _("Past keyframes locked"));
303 	INIT_STOCK_ICON(keyframe_lock_future_off, "keyframe_lock_future_off_icon." IMAGE_EXT, _("Future keyframes unlocked"));
304 	INIT_STOCK_ICON(keyframe_lock_future_on, "keyframe_lock_future_on_icon." IMAGE_EXT, _("Future keyframes locked"));
305 
306 	INIT_STOCK_ICON(animate_mode_off, "animate_mode_off_icon." IMAGE_EXT, _("Animate Mode Off"));
307 	INIT_STOCK_ICON(animate_mode_on, "animate_mode_on_icon." IMAGE_EXT, _("Animate Mode On"));
308 
309 	INIT_STOCK_ICON(jack, "jack_icon." IMAGE_EXT, _("JACK"));
310 
311 	INIT_STOCK_ICON(set_outline_color, "set_outline_color." IMAGE_EXT, _("Set as Outline"));
312 	INIT_STOCK_ICON(set_fill_color, "set_fill_color." IMAGE_EXT, _("Set as Fill"));
313 
314 	INIT_STOCK_ICON(animate_seek_begin, "animate_seek_begin_icon." IMAGE_EXT, _("Seek to Begin"));
315 	INIT_STOCK_ICON(animate_seek_prev_keyframe, "animate_seek_prev_keyframe_icon." IMAGE_EXT, _("Seek to Previous Keyframe"));
316 	INIT_STOCK_ICON(animate_seek_prev_frame, "animate_seek_prev_frame_icon." IMAGE_EXT, _("Seek to Previous Frame"));
317 	INIT_STOCK_ICON(animate_play, "animate_play_icon." IMAGE_EXT, _("Play"));
318 	INIT_STOCK_ICON(animate_stop, "animate_stop_icon." IMAGE_EXT, _("Stop"));
319 	INIT_STOCK_ICON(animate_pause, "animate_pause_icon." IMAGE_EXT, _("Pause"));
320 	INIT_STOCK_ICON(animate_seek_next_frame, "animate_seek_next_frame_icon." IMAGE_EXT, _("Seek to Next frame"));
321 	INIT_STOCK_ICON(animate_seek_next_keyframe, "animate_seek_next_keyframe_icon." IMAGE_EXT, _("Seek to Next Keyframe"));
322 	INIT_STOCK_ICON(animate_seek_end, "animate_seek_end_icon." IMAGE_EXT, _("Seek to End"));
323 	INIT_STOCK_ICON(animate_loop, "animate_loop_icon." IMAGE_EXT, _("Animate Loop"));
324 
325 	INIT_STOCK_ICON(add_to_group, "action_add_to_set_icon." IMAGE_EXT, _("Add Layer to Set"));
326 	INIT_STOCK_ICON(remove_from_group, "action_remove_from_set_icon." IMAGE_EXT, _("Remove Layer from Set"));
327 	INIT_STOCK_ICON(set_desc, "action_set_layer_description_icon." IMAGE_EXT, _("Set Layer Description"));
328 	INIT_STOCK_ICON(export, "action_export_icon." IMAGE_EXT, _("Export Value Node"));
329 	INIT_STOCK_ICON(unexport, "action_unexport_icon." IMAGE_EXT, _("Unexport Value Node"));
330 	INIT_STOCK_ICON(flat_interpolation, "action_flat_interpolation_icon." IMAGE_EXT, _("Set Interpolation to Flat"));
331 	INIT_STOCK_ICON(interpolate_interpolation, "action_interpolate_interpolation_icon." IMAGE_EXT, _("Set Interpolation to Interpolate"));
332 	INIT_STOCK_ICON(peak_interpolation, "action_peak_interpolation_icon." IMAGE_EXT, _("Set Interpolation to Peak"));
333 	INIT_STOCK_ICON(rounded_interpolation, "action_rounded_interpolation_icon." IMAGE_EXT, _("Set Interpolation to Rounded"));
334 	INIT_STOCK_ICON(squared_interpolation, "action_squared_interpolation_icon." IMAGE_EXT, _("Set Interpolation to Squared"));
335 
336 	INIT_STOCK_ICON(toggle_duck_position, "duck_position_icon." IMAGE_EXT, _("Toggle position handles"));
337 	INIT_STOCK_ICON(toggle_duck_vertex, "duck_vertex_icon." IMAGE_EXT, _("Toggle vertex handles"));
338 	INIT_STOCK_ICON(toggle_duck_tangent, "duck_tangent_icon." IMAGE_EXT, _("Toggle tangent handles"));
339 	INIT_STOCK_ICON(toggle_duck_radius, "duck_radius_icon." IMAGE_EXT, _("Toggle radius handles"));
340 	INIT_STOCK_ICON(toggle_duck_width, "duck_width_icon." IMAGE_EXT, _("Toggle width handles"));
341 	INIT_STOCK_ICON(toggle_duck_angle, "duck_angle_icon." IMAGE_EXT, _("Toggle angle handles"));
342 
343 	INIT_STOCK_ICON(toggle_show_grid, "show_grid_icon." IMAGE_EXT, _("Toggle show grid"));
344 	INIT_STOCK_ICON(toggle_snap_grid, "snap_grid_icon." IMAGE_EXT, _("Toggle snap grid"));
345 	INIT_STOCK_ICON(toggle_show_guide, "show_guide_icon." IMAGE_EXT, _("Toggle show guide"));
346 	INIT_STOCK_ICON(toggle_snap_guide, "snap_guide_icon." IMAGE_EXT, _("Toggle snap guide"));
347 
348 	INIT_STOCK_ICON(toggle_onion_skin, "onion_skin_icon." IMAGE_EXT, _("Toggle onion skin"));
349 
350 	INIT_STOCK_ICON(increase_resolution, "incr_resolution_icon." IMAGE_EXT, _("Increase resolution"));
351 	INIT_STOCK_ICON(decrease_resolution, "decr_resolution_icon." IMAGE_EXT, _("Decrease resolution"));
352 
353 	INIT_STOCK_ICON(preview_options, "preview_options_icon." IMAGE_EXT, _("Preview Options Dialog"));
354 	INIT_STOCK_ICON(render_options, "render_options_icon." IMAGE_EXT, _("Render Options Dialog"));
355 
356 	INIT_STOCK_ICON(interpolation_type_tcb, "interpolation_type_tcb_icon." IMAGE_EXT, _("TCB interpolation"));
357 	INIT_STOCK_ICON(interpolation_type_ease, "interpolation_type_ease_icon." IMAGE_EXT, _("Ease In/Out interpolation"));
358 	INIT_STOCK_ICON(interpolation_type_const, "interpolation_type_const_icon." IMAGE_EXT, _("Const interpolation"));
359 	INIT_STOCK_ICON(interpolation_type_linear, "interpolation_type_linear_icon." IMAGE_EXT, _("Linear interpolation"));
360 	INIT_STOCK_ICON(interpolation_type_clamped, "interpolation_type_clamped_icon." IMAGE_EXT, _("Clamped interpolation"));
361 
362 	INIT_STOCK_ICON(utils_chain_link_on, "utils_chain_link_on_icon." IMAGE_EXT, _("Linked"));
363 	INIT_STOCK_ICON(utils_chain_link_off, "utils_chain_link_off_icon." IMAGE_EXT, _("Unlinked"));
364 	INIT_STOCK_ICON(utils_timetrack_align, "utils_timetrack_align_icon." IMAGE_EXT, _("Utils Timetrack align"));
365 
366 	INIT_STOCK_ICON_CLONE(cvs_add, _("CVS Add"));
367 	INIT_STOCK_ICON_CLONE(cvs_update, _("CVS Update"));
368 	INIT_STOCK_ICON_CLONE(cvs_commit, _("CVS Commit"));
369 	INIT_STOCK_ICON_CLONE(cvs_revert, _("CVS Revert"));
370 
371 #undef INIT_STOCK_ICON
372 #undef INIT_STOCK_ICON_CLONE
373 #undef INIT_STOCK_ITEM
374 
375 	icon_factory->add_default();
376 
377 	Gtk::IconSize::register_new("synfig-tiny_icon", 8, 8);
378 	Gtk::IconSize::register_new("synfig-small_icon",12,12);
379 	Gtk::IconSize::register_new("synfig-small_icon_16x16",16,16);
380 
381 	for(Type *type = Type::get_first(); type != NULL; type = type->get_next())
382 		_tree_pixbuf_table_value_type[type->identifier]=Gtk::Button().render_icon_pixbuf(value_icon(*type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
383 
384 	for(int i(0);i<((int)INTERPOLATION_CLAMPED+1);i++)
385 		_tree_pixbuf_table_interpolation[i]=Gtk::Button().render_icon_pixbuf(interpolation_icon(Interpolation(i)),Gtk::ICON_SIZE_SMALL_TOOLBAR);
386 }
387 
388 Glib::RefPtr<Gdk::Cursor>
get_normal_cursor()389 IconController::get_normal_cursor()
390 {
391 	return Gdk::Cursor::create(Gdk::TOP_LEFT_ARROW);
392 }
393 
394 Glib::RefPtr<Gdk::Cursor>
get_tool_cursor(const Glib::ustring & name,const Glib::RefPtr<Gdk::Window> & window)395 IconController::get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window)
396 {
397 	//this function is never called
398 	//it is commented out in WorkArea::refresh_cursor()
399 	assert(0);
400 	// \todo Do we still need it?
401 
402 	Glib::RefPtr<Gdk::Pixbuf> pixbuf =
403 		Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-"+name),Gtk::ICON_SIZE_SMALL_TOOLBAR);
404   	return Gdk::Cursor::create(window->get_display(), pixbuf, 0, 0);
405 }
406 
407 Gtk::StockID
value_icon(Type & type)408 studio::value_icon(Type &type)
409 {
410 	if (type == type_bool)
411 		return Gtk::StockID("synfig-type_bool");
412 	if (type == type_integer)
413 		return Gtk::StockID("synfig-type_integer");
414 	if (type == type_angle)
415 		return Gtk::StockID("synfig-type_angle");
416 	if (type == type_time)
417 		return Gtk::StockID("synfig-type_time");
418 	if (type == type_real)
419 		return Gtk::StockID("synfig-type_real");
420 	if (type == type_vector)
421 		return Gtk::StockID("synfig-type_vector");
422 	if (type == type_color)
423 		return Gtk::StockID("synfig-type_color");
424 	if (type == type_segment)
425 		return Gtk::StockID("synfig-type_segment");
426 	if (type == type_bline_point)
427 		return Gtk::StockID("synfig-type_blinepoint");
428 	if (type == type_list)
429 		return Gtk::StockID("synfig-type_list");
430 	if (type == type_canvas)
431 		return Gtk::StockID("synfig-type_canvas");
432 	if (type == type_string)
433 		return Gtk::StockID("synfig-type_string");
434 	if (type == type_gradient)
435 		return Gtk::StockID("synfig-type_gradient");
436 
437 	return Gtk::StockID("synfig-unknown");
438 }
439 
440 Gtk::StockID
interpolation_icon(synfig::Interpolation type)441 studio::interpolation_icon(synfig::Interpolation type)
442 {
443 	switch(type)
444 	{
445 		case INTERPOLATION_TCB:
446 			return Gtk::StockID("synfig-interpolation_type_tcb");
447 		case INTERPOLATION_CONSTANT:
448 			return Gtk::StockID("synfig-interpolation_type_const");
449 		case INTERPOLATION_LINEAR:
450 			return Gtk::StockID("synfig-interpolation_type_linear");
451 		case INTERPOLATION_HALT:
452 			return Gtk::StockID("synfig-interpolation_type_ease");
453 		case INTERPOLATION_CLAMPED:
454 			return Gtk::StockID("synfig-interpolation_type_clamped");
455 		case INTERPOLATION_MANUAL:
456 		case INTERPOLATION_UNDEFINED:
457 		case INTERPOLATION_NIL:
458 		default:
459 			break;
460 	}
461 	return Gtk::StockID();
462 }
463 
464 
465 Gtk::StockID
valuenode_icon(etl::handle<synfig::ValueNode> value_node)466 studio::valuenode_icon(etl::handle<synfig::ValueNode> value_node)
467 {
468 	if(handle<ValueNode_Const>::cast_dynamic(value_node))
469 	{
470 		return value_icon(value_node->get_type());
471 	}
472 	else
473 	{
474 		return Gtk::StockID("synfig-value_node");
475 	}
476 }
477 
478 Glib::RefPtr<Gdk::Pixbuf>
get_tree_pixbuf(Type & type)479 studio::get_tree_pixbuf(Type &type)
480 {
481 	//return Gtk::Button().render_icon_pixbuf(value_icon(type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
482 	return _tree_pixbuf_table_value_type[type.identifier];
483 }
484 
485 Glib::RefPtr<Gdk::Pixbuf>
get_interpolation_pixbuf(synfig::Interpolation type)486 studio::get_interpolation_pixbuf(synfig::Interpolation type)
487 {
488 	return _tree_pixbuf_table_interpolation[int(type)];
489 }
490 
491 #ifdef _WIN32
492 #define TEMPORARY_DELETE_MACRO DELETE
493 #undef DELETE
494 #endif
495 
496 Gtk::StockID
get_action_stock_id(const synfigapp::Action::BookEntry & action)497 studio::get_action_stock_id(const synfigapp::Action::BookEntry& action)
498 {
499 	Gtk::StockID stock_id;
500 	if(action.task=="add")				stock_id=Gtk::Stock::ADD;
501 	else if(action.task=="connect")		stock_id=Gtk::Stock::CONNECT;
502 	else if(action.task=="disconnect")	stock_id=Gtk::Stock::DISCONNECT;
503 	else if(action.task=="insert")		stock_id=Gtk::Stock::ADD;
504 	else if(action.task=="lower")		stock_id=Gtk::Stock::GO_DOWN;
505 	else if(action.task=="move_bottom")	stock_id=Gtk::Stock::GOTO_BOTTOM;
506 	else if(action.task=="move_top")	stock_id=Gtk::Stock::GOTO_TOP;
507 	else if(action.task=="raise")		stock_id=Gtk::Stock::GO_UP;
508 	else if(action.task=="remove")		stock_id=Gtk::Stock::DELETE;
509 	else if(action.task=="set_off")		stock_id=Gtk::Stock::NO;
510 	else if(action.task=="set_on")		stock_id=Gtk::Stock::YES;
511 	else								stock_id=Gtk::StockID("synfig-"+
512 															  action.task);
513 	return stock_id;
514 }
515 
516 #ifdef _WIN32
517 #define DELETE TEMPORARY_DELETE_MACRO
518 #undef TEMPORARY_DELETE_MACRO
519 #endif
520 
521 Gtk::StockID
layer_icon(const synfig::String & layer)522 studio::layer_icon(const synfig::String &layer)
523 {
524 	// Blur Layers
525 	if(layer=="blur")
526 		return Gtk::StockID("synfig-layer_blur_blur");
527 	else if(layer=="MotionBlur") // in the future should be "motion_blur"
528 		return Gtk::StockID("synfig-layer_blur_motion");
529 	else if(layer=="radial_blur")
530 		return Gtk::StockID("synfig-layer_blur_radial");
531 	// Distortion Layers
532 	else if(layer=="curve_warp")
533 		return Gtk::StockID("synfig-layer_distortion_curvewarp");
534 	else if(layer=="inside_out")
535 		return Gtk::StockID("synfig-layer_distortion_insideout");
536 	else if(layer=="noise_distort")
537 		return Gtk::StockID("synfig-layer_distortion_noise");
538 	else if(layer=="spherize")
539 		return Gtk::StockID("synfig-layer_distortion_spherize");
540 	else if(layer=="stretch")
541 		return Gtk::StockID("synfig-layer_distortion_stretch");
542 	else if(layer=="twirl")
543 		return Gtk::StockID("synfig-layer_distortion_twirl");
544 	else if(layer=="warp")
545 		return Gtk::StockID("synfig-layer_distortion_warp");
546 	// Example Layers
547 	else if(layer=="filled_rectangle")
548 		return Gtk::StockID("synfig-layer_example_filledrectangle");
549 	else if(layer=="metaballs")
550 		return Gtk::StockID("synfig-layer_example_metaballs");
551 	else if(layer=="simple_circle")
552 		return Gtk::StockID("synfig-layer_example_simplecircle");
553 	// Filter Layers
554 	else if(layer=="clamp")
555 		return Gtk::StockID("synfig-layer_filter_clamp");
556 	else if(layer=="colorcorrect")
557 		return Gtk::StockID("synfig-layer_filter_colorcorrect");
558 	else if(layer=="halftone2")
559 		return Gtk::StockID("synfig-layer_filter_halftone2");
560 	else if(layer=="halftone3")
561 		return Gtk::StockID("synfig-layer_filter_halftone3");
562 	else if(layer=="lumakey")
563 		return Gtk::StockID("synfig-layer_filter_lumakey");
564 	// Fractal Layers
565 	else if(layer=="mandelbrot")
566 		return Gtk::StockID("synfig-layer_fractal_mandelbrot");
567 	else if(layer=="julia")
568 		return Gtk::StockID("synfig-layer_fractal_julia");
569 	// Geometry Layers
570 	else if(layer=="checker_board")
571 		return Gtk::StockID("synfig-layer_geometry_checkerboard");
572 	else if(layer=="circle")
573 		return Gtk::StockID("synfig-layer_geometry_circle");
574 	else if(layer=="outline")
575 		return Gtk::StockID("synfig-layer_geometry_outline");
576 	else if(layer=="advanced_outline")
577 		return Gtk::StockID("synfig-layer_geometry_advanced_outline");
578 	else if(layer=="polygon")
579 		return Gtk::StockID("synfig-layer_geometry_polygon");
580 	else if(layer=="rectangle")
581 		return Gtk::StockID("synfig-layer_geometry_rectangle");
582 	else if(layer=="region")
583 		return Gtk::StockID("synfig-layer_geometry_region");
584 	else if(layer=="solid_color" || layer=="SolidColor")
585 		return Gtk::StockID("synfig-layer_geometry_solidcolor");
586 	else if(layer=="star")
587 		return Gtk::StockID("synfig-layer_geometry_star");
588 	// Gradient Layers
589 	else if(layer=="conical_gradient")
590 		return Gtk::StockID("synfig-layer_gradient_conical");
591 	else if(layer=="curve_gradient")
592 		return Gtk::StockID("synfig-layer_gradient_curve");
593 	else if(layer=="noise")
594 		return Gtk::StockID("synfig-layer_gradient_noise");
595 	else if(layer=="linear_gradient")
596 		return Gtk::StockID("synfig-layer_gradient_linear");
597 	else if(layer=="radial_gradient")
598 		return Gtk::StockID("synfig-layer_gradient_radial");
599 	else if(layer=="spiral_gradient")
600 		return Gtk::StockID("synfig-layer_gradient_spiral");
601 	// Other Layers
602 	else if(layer=="duplicate")
603 		return Gtk::StockID("synfig-layer_other_duplicate");
604 	else if(layer=="importimage" || layer=="import")
605 		return Gtk::StockID("synfig-layer_other_importimage");
606 	else if(layer=="group" || layer=="PasteCanvas" || layer=="pastecanvas" || layer=="paste_canvas")
607 		return Gtk::StockID("synfig-layer_other_pastecanvas");
608 	else if(layer=="plant")
609 		return Gtk::StockID("synfig-layer_other_plant");
610 	else if(layer=="stroboscope")
611 		return Gtk::StockID("synfig-layer_other_stroboscope");
612 	else if(layer=="skeleton")
613 		return Gtk::StockID("synfig-layer_other_skeleton");
614 	else if(layer=="super_sample")
615 		return Gtk::StockID("synfig-layer_other_supersample");
616 	else if(layer=="switch")
617 		return Gtk::StockID("synfig-layer_other_switch");
618 	else if(layer=="text")
619 		return Gtk::StockID("synfig-layer_other_text");
620 	else if(layer=="sound")
621 		return Gtk::StockID("synfig-layer_other_sound");
622 	else if(layer=="timeloop")
623 		return Gtk::StockID("synfig-layer_other_timeloop");
624 	else if(layer=="xor_pattern")
625 		return Gtk::StockID("synfig-layer_other_xorpattern");
626 	// Stylize Layers
627 	else if(layer=="bevel")
628 		return Gtk::StockID("synfig-layer_stylize_bevel");
629 	else if(layer=="shade")
630 		return Gtk::StockID("synfig-layer_stylize_shade");
631 	// Transform Layers
632 	else if(layer=="rotate")
633 		return Gtk::StockID("synfig-layer_transform_rotate");
634 	else if(layer=="translate")
635 		return Gtk::StockID("synfig-layer_transform_translate");
636 	else if(layer=="zoom")
637 		return Gtk::StockID("synfig-layer_transform_scale");
638 	else if(layer=="ghost_group")
639 		return Gtk::StockID("synfig-layer_ghost_group");
640 	else
641 		return Gtk::StockID("synfig-layer");
642 }
643 
644 Glib::RefPtr<Gdk::Pixbuf>
get_tree_pixbuf_layer(const synfig::String & layer)645 studio::get_tree_pixbuf_layer(const synfig::String &layer)
646 {
647 	return Gtk::Button().render_icon_pixbuf(layer_icon(layer),Gtk::ICON_SIZE_SMALL_TOOLBAR);
648 }
649 
650