Add Stylize layers icons. Thanks to Bertrand Grégoire (berteh)
[synfig.git] / synfig-studio / src / gtkmm / iconcontroller.cpp
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 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 "iconcontroller.h"
38 #include <synfig/valuenode_const.h>
39 #include <gtkmm/button.h>
40 #include <gtkmm/window.h>
41 #include <synfigapp/action.h>
42
43 #include "general.h"
44
45 #endif
46
47 /* === U S I N G =========================================================== */
48
49 using namespace etl;
50 using namespace std;
51 using namespace studio;
52 using namespace synfig;
53
54 /* === M A C R O S ========================================================= */
55
56 #ifdef WIN32
57 #       ifdef IMAGE_DIR
58 #               undef IMAGE_DIR
59 #               define IMAGE_DIR "share\\pixmaps"
60 #       endif
61 #endif
62
63 #ifndef IMAGE_DIR
64 #       define IMAGE_DIR "/usr/local/share/pixmaps"
65 #endif
66
67
68 #ifndef IMAGE_EXT
69 #       define IMAGE_EXT        "png"
70 #endif
71
72 /* === M E T H O D S ======================================================= */
73
74 static Glib::RefPtr<Gdk::Pixbuf> _tree_pixbuf_table_value_type[(int)synfig::ValueBase::TYPE_END];
75
76 #ifdef WIN32
77 IconController::IconController(const synfig::String& basepath)
78 #else
79 IconController::IconController(const synfig::String& /*basepath*/)
80 #endif
81 {
82         Gtk::IconSource icon_source;
83         icon_source.set_direction_wildcarded();
84         icon_source.set_state_wildcarded();
85         icon_source.set_size_wildcarded();
86         icon_factory=Gtk::IconFactory::create();
87
88         std::string path_to_icons;
89 #ifdef WIN32
90         path_to_icons=basepath+ETL_DIRECTORY_SEPARATOR+".."+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
91 #else
92         path_to_icons=IMAGE_DIR;
93 #endif
94
95         char* synfig_root=getenv("SYNFIG_ROOT");
96         if(synfig_root) {
97                 path_to_icons=synfig_root;
98                 path_to_icons+=ETL_DIRECTORY_SEPARATOR;
99                 path_to_icons+="share";
100                 path_to_icons+=ETL_DIRECTORY_SEPARATOR;
101                 path_to_icons+="pixmaps";
102                 path_to_icons+=ETL_DIRECTORY_SEPARATOR;
103                 path_to_icons+="synfigstudio";
104         }
105         path_to_icons+=ETL_DIRECTORY_SEPARATOR;
106
107         try{
108         Gtk::Window::set_default_icon_from_file(path_to_icons+"synfig_icon."+IMAGE_EXT);
109         } catch(...)
110         {
111                 synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
112         }
113
114 /*
115 #define INIT_STOCK_ICON(name,iconfile,desc)                                                     \
116         stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc);                        \
117         Gtk::Stock::add(stock_##name);                                                          \
118         icon_source.set_filename(path_to_icons+iconfile);                                                       \
119         icon_##name.add_source(icon_source);                                            \
120         icon_factory->add(stock_##name.get_stock_id(),icon_##name)
121 */
122 #define INIT_STOCK_ICON(name,iconfile,desc){                                                    \
123         Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
124         Gtk::Stock::add(stockitem);                                                             \
125         Gtk::IconSet icon_set;                                                                  \
126         icon_source.set_filename(path_to_icons+iconfile);                                                       \
127         icon_set.add_source(icon_source);                                               \
128         icon_factory->add(stockitem.get_stock_id(),icon_set); \
129         }
130
131 #define INIT_STOCK_ICON_CLONE(name,stockid,desc){                                                       \
132         Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
133         Gtk::Stock::add(stockitem);                                                             \
134         Gtk::IconSet icon_set;                                                                  \
135         if(Gtk::Stock::lookup(stockitem.get_stock_id(),icon_set))       \
136         icon_factory->add(stockitem.get_stock_id(),icon_set); \
137         }
138
139 #define INIT_STOCK_ITEM(name,desc)                                                      \
140         stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc);                        \
141         Gtk::Stock::add(stock_##name);
142
143         INIT_STOCK_ICON(bool,"bool_icon."IMAGE_EXT,_("Bool"));
144         INIT_STOCK_ICON(integer,"integer_icon."IMAGE_EXT,_("Integer"));
145         INIT_STOCK_ICON(angle,"angle_icon."IMAGE_EXT,_("Angle"));
146         INIT_STOCK_ICON(time,"time_icon."IMAGE_EXT,_("Time"));
147         INIT_STOCK_ICON(real,"real_icon."IMAGE_EXT,_("Real"));
148         INIT_STOCK_ICON(vector,"vector_icon."IMAGE_EXT,_("Vector"));
149         INIT_STOCK_ICON(color,"color_icon."IMAGE_EXT,_("Color"));
150         INIT_STOCK_ICON(segment,"segment_icon."IMAGE_EXT,_("Segment"));
151         INIT_STOCK_ICON(blinepoint,"blinepoint_icon."IMAGE_EXT,_("BLine Point"));
152         INIT_STOCK_ICON(list,"list_icon."IMAGE_EXT,_("Rename"));
153         INIT_STOCK_ICON(canvas,"canvas_icon."IMAGE_EXT,_("Canvas"));
154         INIT_STOCK_ICON(string,"string_icon."IMAGE_EXT,_("Rename"));
155
156         INIT_STOCK_ICON(reset_colors,"reset_colors_icon."IMAGE_EXT,_("Reset Colors"));
157         INIT_STOCK_ICON(swap_colors,"swap_colors_icon."IMAGE_EXT,_("Swap Colors"));
158         INIT_STOCK_ICON(value_node,"valuenode_icon."IMAGE_EXT,_("ValueNode"));
159         INIT_STOCK_ICON(about,"about_icon."IMAGE_EXT,_("About"));
160         INIT_STOCK_ICON(rename,"rename_icon."IMAGE_EXT,_("Rename"));
161         INIT_STOCK_ICON(canvas_pointer,"canvas_pointer_icon."IMAGE_EXT,_("Rename"));
162         INIT_STOCK_ICON(canvas_new,"canvas_icon."IMAGE_EXT,_("New Canvas"));
163         INIT_STOCK_ICON(saveall,"saveall_icon."IMAGE_EXT,_("Save All"));
164
165         INIT_STOCK_ICON(layer,"layer_icon."IMAGE_EXT,_("Layer"));
166         INIT_STOCK_ICON(layer_pastecanvas,"pastecanvas_icon."IMAGE_EXT,_("Paste Canvas"));
167         INIT_STOCK_ICON(layer_duplicate,"layer_duplicate_icon."IMAGE_EXT,_("Duplicate Layer"));
168         INIT_STOCK_ICON(layer_gradient_lineal,"gradient_icon."IMAGE_EXT,_("Lineal Gradient Layer"));
169         INIT_STOCK_ICON(layer_gradient_radial,"layer_gradient_radial_icon."IMAGE_EXT,_("Radial Gradient Layer"));
170         INIT_STOCK_ICON(layer_gradient_spiral,"layer_gradient_spiral_icon."IMAGE_EXT,_("Spiral Gradient Layer"));
171         INIT_STOCK_ICON(layer_gradient_curve,"layer_gradient_curve_icon."IMAGE_EXT,_("Curve Gradient Layer"));
172         INIT_STOCK_ICON(layer_gradient_conical,"layer_gradient_conical_icon."IMAGE_EXT,_("Conical Gradient Layer"));
173         INIT_STOCK_ICON(layer_gradient_noise,"layer_gradient_noise_icon."IMAGE_EXT,_("Noise Gradient Layer"));
174         INIT_STOCK_ICON(layer_checkerboard,"layer_checkerboard_icon."IMAGE_EXT,_("Checker Board Layer"));
175         INIT_STOCK_ICON(layer_blur,"layer_blur_icon."IMAGE_EXT,_("Blur Layer"));
176         INIT_STOCK_ICON(layer_blur_motion,"layer_blur_motion_icon."IMAGE_EXT,_("Motion Blur Layer"));
177         INIT_STOCK_ICON(layer_blur_radial,"layer_blur_radial_icon."IMAGE_EXT,_("Radial Blur Layer"));
178         INIT_STOCK_ICON(layer_distortion_curvewarp,"layer_distortion_curvewarp_icon."IMAGE_EXT,_("Curve Warp Layer"));
179         INIT_STOCK_ICON(layer_distortion_insideout,"layer_distortion_insideout_icon."IMAGE_EXT,_("Inside Out Layer"));
180         INIT_STOCK_ICON(layer_distortion_noise,"layer_distortion_noise_icon."IMAGE_EXT,_("Noise Distort Layer"));
181         INIT_STOCK_ICON(layer_distortion_spherize,"layer_distortion_spherize_icon."IMAGE_EXT,_("Spherize Layer"));
182         INIT_STOCK_ICON(layer_distortion_stretch,"layer_distortion_stretch_icon."IMAGE_EXT,_("Stretch Layer"));
183         INIT_STOCK_ICON(layer_distortion_twirl,"layer_distortion_twirl_icon."IMAGE_EXT,_("Twirl Layer"));
184         INIT_STOCK_ICON(layer_distortion_warp,"layer_distortion_warp_icon."IMAGE_EXT,_("Warp Layer"));
185         INIT_STOCK_ICON(layer_filter_clamp,"layer_filter_clamp_icon."IMAGE_EXT,_("Clamp Layer"));
186         INIT_STOCK_ICON(layer_filter_colorcorrect,"layer_filter_colorcorrect_icon."IMAGE_EXT,_("Color Correct Layer"));
187         INIT_STOCK_ICON(layer_filter_halftone2,"layer_filter_halftone2_icon."IMAGE_EXT,_("Half Tone 2 Layer"));
188         INIT_STOCK_ICON(layer_filter_halftone3,"layer_filter_halftone3_icon."IMAGE_EXT,_("Half Tone 3 Layer"));
189         INIT_STOCK_ICON(layer_filter_luma,"layer_filter_luma_icon."IMAGE_EXT,_("Luma Layer"));
190         INIT_STOCK_ICON(layer_fractal_mandelbrot,"layer_fractal_mandelbrot_icon."IMAGE_EXT,_("Mandelbrot Set Layer"));
191         INIT_STOCK_ICON(layer_fractal_julia,"layer_fractal_julia_icon."IMAGE_EXT,_("Julia Set Layer"));
192         INIT_STOCK_ICON(layer_stylize_bevel,"layer_stylize_bevel_icon."IMAGE_EXT,_("Bevel Layer"));
193         INIT_STOCK_ICON(layer_stylize_shade,"layer_stylize_shade_icon."IMAGE_EXT,_("Shade Layer"));
194
195         INIT_STOCK_ICON(plant,"plant_icon."IMAGE_EXT,"");
196
197         INIT_STOCK_ICON(group,"group_icon."IMAGE_EXT,_("Group"));
198         INIT_STOCK_ICON(grid_enable,"grid_enable_icon."IMAGE_EXT,_("Show Grid"));
199         INIT_STOCK_ICON(grid_disable,"grid_disable_icon."IMAGE_EXT,_("Hide Grid"));
200         INIT_STOCK_ICON(grid_snap_enable,"grid_snap_enable_icon."IMAGE_EXT,_("Enable Grid Snap"));
201         INIT_STOCK_ICON(grid_snap_disable,"grid_snap_disable_icon."IMAGE_EXT,_("Disable Grid Snap"));
202         INIT_STOCK_ICON(duplicate,"duplicate_icon."IMAGE_EXT,_("Duplicate"));
203         INIT_STOCK_ICON(encapsulate,"encapsulate_icon."IMAGE_EXT,_("Encapsulate"));
204         INIT_STOCK_ICON(select_all_child_layers,"select_all_child_layers_icon."IMAGE_EXT,_("Select All Child Layers"));
205
206         INIT_STOCK_ICON(clear_undo,"clear_undo_icon."IMAGE_EXT,_("Clear Undo Stack"));
207         INIT_STOCK_ICON(clear_redo,"clear_redo_icon."IMAGE_EXT,_("Clear Redo Stack"));
208
209         INIT_STOCK_ICON(children,"children_icon."IMAGE_EXT,_("Children"));
210         INIT_STOCK_ICON(curves,"curves_icon."IMAGE_EXT,_("Curves"));
211         INIT_STOCK_ICON(keyframes,"keyframe_icon."IMAGE_EXT,_("Keyframes"));
212         INIT_STOCK_ICON(meta_data,"meta_data_icon."IMAGE_EXT,_("MetaData"));
213         INIT_STOCK_ICON(navigator,"navigator_icon."IMAGE_EXT,_("Navigator"));
214         INIT_STOCK_ICON(timetrack,"time_track_icon."IMAGE_EXT,_("Time Track"));
215
216         INIT_STOCK_ICON(keyframe_lock_all,"keyframe_lock_all."IMAGE_EXT,_("All Keyframes Locked"));
217         INIT_STOCK_ICON(keyframe_lock_past,"keyframe_lock_past."IMAGE_EXT,_("Past Keyframes Locked"));
218         INIT_STOCK_ICON(keyframe_lock_future,"keyframe_lock_future."IMAGE_EXT,_("Future Keyframes Locked"));
219         INIT_STOCK_ICON(keyframe_lock_none,"keyframe_lock_none."IMAGE_EXT,_("No Keyframes Locked"));
220
221         INIT_STOCK_ICON(set_outline_color,"set_outline_color."IMAGE_EXT,_("Set as Outline"));
222         INIT_STOCK_ICON(set_fill_color,"set_fill_color."IMAGE_EXT,_("Set as Fill"));
223
224         INIT_STOCK_ICON(seek_begin,"seek_begin."IMAGE_EXT,_("Seek to Begin"));
225         INIT_STOCK_ICON(seek_prev_frame,"seek_prev_frame."IMAGE_EXT,_("Previous Frame"));
226         INIT_STOCK_ICON(seek_next_frame,"seek_next_frame."IMAGE_EXT,_("Next Frame"));
227         INIT_STOCK_ICON(seek_end,"seek_end."IMAGE_EXT,_("Seek to End"));
228         INIT_STOCK_ICON(add_to_group,"action_add_to_group_icon."IMAGE_EXT,_("Add Layer to Group"));
229         INIT_STOCK_ICON(remove_from_group,"action_remove_from_group_icon."IMAGE_EXT,_("Remove Layer from Group"));
230         INIT_STOCK_ICON(set_desc,"action_set_layer_description_icon."IMAGE_EXT,_("Set Layer Description"));
231         INIT_STOCK_ICON(export,"action_export_icon."IMAGE_EXT,_("Export Value Node"));
232         INIT_STOCK_ICON(unexport,"action_unexport_icon."IMAGE_EXT,_("Unexport Value Node"));
233
234         INIT_STOCK_ICON(toggle_duck_position,"duck_position_icon."IMAGE_EXT,_("Toggle position ducks"));
235         INIT_STOCK_ICON(toggle_duck_vertex,"duck_vertex_icon."IMAGE_EXT,_("Toggle vertex ducks"));
236         INIT_STOCK_ICON(toggle_duck_tangent,"duck_tangent_icon."IMAGE_EXT,_("Toggle tangent ducks"));
237         INIT_STOCK_ICON(toggle_duck_radius,"duck_radius_icon."IMAGE_EXT,_("Toggle radius ducks"));
238         INIT_STOCK_ICON(toggle_duck_width,"duck_width_icon."IMAGE_EXT,_("Toggle width ducks"));
239         INIT_STOCK_ICON(toggle_duck_angle,"duck_angle_icon."IMAGE_EXT,_("Toggle angle ducks"));
240
241         INIT_STOCK_ICON(toggle_show_grid,"show_grid_icon."IMAGE_EXT,_("Toggle show grid"));
242         INIT_STOCK_ICON(toggle_snap_grid,"snap_grid_icon."IMAGE_EXT,_("Toggle snap grid"));
243
244         INIT_STOCK_ICON(toggle_onion_skin,"onion_skin_icon."IMAGE_EXT,_("Toggle onion skin"));
245
246         INIT_STOCK_ICON(increase_resolution,"incr_resolution_icon."IMAGE_EXT,_("Increase resolution"));
247         INIT_STOCK_ICON(decrease_resolution,"decr_resolution_icon."IMAGE_EXT,_("Decrease resolution"));
248
249         INIT_STOCK_ICON(preview_options,"preview_options_icon."IMAGE_EXT,_("Preview Options Dialog"));
250         INIT_STOCK_ICON(render_options,"render_options_icon."IMAGE_EXT,_("Render Options Dialog"));
251
252         INIT_STOCK_ICON_CLONE(cvs_add,"gtk-add",_("CVS Add"));
253         INIT_STOCK_ICON_CLONE(cvs_update,"gtk-open",_("CVS Update"));
254         INIT_STOCK_ICON_CLONE(cvs_commit,"gtk-save",_("CVS Commit"));
255         INIT_STOCK_ICON_CLONE(cvs_revert,"gtk-revert",_("CVS Revert"));
256
257         // Tools
258         INIT_STOCK_ICON(normal,"normal_icon."IMAGE_EXT,_("Normal Tool"));
259         INIT_STOCK_ICON(transform,"transform_icon."IMAGE_EXT,_("Transform Tool"));
260         INIT_STOCK_ICON(polygon,"polyline_icon."IMAGE_EXT,_("Polygon Tool"));
261         INIT_STOCK_ICON(bline,"bline_icon."IMAGE_EXT,_("BLine Tool"));
262         INIT_STOCK_ICON(eyedrop,"eyedrop_icon."IMAGE_EXT,_("Eyedrop Tool"));
263         INIT_STOCK_ICON(fill,"fill_icon."IMAGE_EXT,_("Fill Tool"));
264         INIT_STOCK_ICON(draw,"draw_icon."IMAGE_EXT,_("Draw Tool"));
265         INIT_STOCK_ICON(sketch,"sketch_icon."IMAGE_EXT,_("Sketch Tool"));
266         INIT_STOCK_ICON(circle,"circle_icon."IMAGE_EXT,_("Circle Tool"));
267         INIT_STOCK_ICON(rectangle,"rectangle_icon."IMAGE_EXT,_("Rectangle Tool"));
268         INIT_STOCK_ICON(smooth_move,"smooth_move_icon."IMAGE_EXT,_("SmoothMove Tool"));
269         INIT_STOCK_ICON(rotate,"rotate_icon."IMAGE_EXT,"Rotate Tool");
270         INIT_STOCK_ICON(width,"width_icon."IMAGE_EXT,_("Width Tool"));
271         INIT_STOCK_ICON(scale,"scale_icon."IMAGE_EXT,"Scale Tool");
272         INIT_STOCK_ICON(zoom,"zoom_icon."IMAGE_EXT,_("Zoom Tool"));
273         INIT_STOCK_ICON(info,"info_icon."IMAGE_EXT,_("Info Tool"));
274         INIT_STOCK_ICON(mirror,"mirror_icon."IMAGE_EXT,_("Mirror Tool"));
275         INIT_STOCK_ICON(text,"text_icon."IMAGE_EXT,"Text Tool");
276         INIT_STOCK_ICON(gradient,"gradient_icon."IMAGE_EXT,_("Gradient Tool"));
277         INIT_STOCK_ICON(star,"star_icon."IMAGE_EXT,_("Star Tool"));
278
279         icon_factory->add_default();
280
281         Gtk::IconSize::register_new("synfig-small_icon",12,12);
282         Gtk::IconSize::register_new("synfig-small_icon_16x16",16,16);
283
284         for(int i(0);i<(int)ValueBase::TYPE_END;i++)
285                 _tree_pixbuf_table_value_type[i]=Gtk::Button().render_icon(value_icon(ValueBase::Type(i)),Gtk::ICON_SIZE_SMALL_TOOLBAR);
286
287 }
288
289 IconController::~IconController()
290 {
291         for(int i(0);i<(int)ValueBase::TYPE_END;i++)
292                 _tree_pixbuf_table_value_type[i]=Glib::RefPtr<Gdk::Pixbuf>();
293
294         icon_factory->remove_default();
295 }
296
297 Gdk::Cursor
298 IconController::get_normal_cursor()
299 {
300         return Gdk::Cursor(Gdk::TOP_LEFT_ARROW);
301 }
302
303 Gdk::Cursor
304 IconController::get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window)
305 {
306         Glib::RefPtr<Gdk::Pixmap> pixmap;
307         pixmap=Gdk::Pixmap::create(window, 64, 64, 8);
308         pixmap->set_colormap(window->get_colormap());
309         //pixmap->set_colormap(Gdk::Colormap::create(pixmap->get_visual(),false));
310         Glib::RefPtr<Gdk::Pixbuf> pixbuf;
311         pixbuf=Gtk::Button().render_icon(Gtk::StockID("synfig-"+name),Gtk::ICON_SIZE_SMALL_TOOLBAR);
312
313         pixbuf->render_to_drawable_alpha(
314                 pixmap,
315                 0,0,    // SOURCE X,Y
316                 0,0,    // DEST X Y
317                 -1,-1,  // WIDTH HEIGHT
318                 Gdk::PIXBUF_ALPHA_FULL, // (ignored)
319                 64,             //int alpha_threshold,
320                 Gdk::RGB_DITHER_MAX,            //RgbDither dither,
321                 2,2     //int x_dither, int y_dither
322         );
323 /*
324         pixmap->draw_pixbuf(
325                 Glib::RefPtr<const Gdk::GC>(0), // GC
326                 pixbuf,
327                 0, 0, // Source X,Y
328                 0, 0, // Dest X,Y
329                 -1, -1, // Width, Height
330                 Gdk::RGB_DITHER_MAX, // Dither
331                 0,0 // Dither X,Y
332         );
333 */
334
335         Gdk::Color FG("#000000");
336         Gdk::Color BG("#FF00FF");
337
338         return Gdk::Cursor(pixmap, pixmap, FG, BG, 0, 0);
339 }
340
341 Gtk::StockID
342 studio::value_icon(synfig::ValueBase::Type type)
343 {
344                 switch(type)
345                 {
346                 case ValueBase::TYPE_BOOL:
347                         return Gtk::StockID("synfig-bool");
348                         break;
349                 case ValueBase::TYPE_INTEGER:
350                         return Gtk::StockID("synfig-integer");
351                         break;
352                 case ValueBase::TYPE_ANGLE:
353                         return Gtk::StockID("synfig-angle");
354                         break;
355                 case ValueBase::TYPE_TIME:
356                         return Gtk::StockID("synfig-time");
357                         break;
358                 case ValueBase::TYPE_REAL:
359                         return Gtk::StockID("synfig-real");
360                         break;
361                 case ValueBase::TYPE_VECTOR:
362                         return Gtk::StockID("synfig-vector");
363                         break;
364                 case ValueBase::TYPE_COLOR:
365                         return Gtk::StockID("synfig-color");
366                         break;
367                 case ValueBase::TYPE_SEGMENT:
368                         return Gtk::StockID("synfig-segment");
369                         break;
370                 case ValueBase::TYPE_BLINEPOINT:
371                         return Gtk::StockID("synfig-blinepoint");
372                         break;
373                 case ValueBase::TYPE_LIST:
374                         return Gtk::StockID("synfig-list");
375                         break;
376                 case ValueBase::TYPE_CANVAS:
377                         return Gtk::StockID("synfig-canvas_pointer");
378                         break;
379                 case ValueBase::TYPE_STRING:
380                         return Gtk::StockID("synfig-string");
381                         break;
382                 case ValueBase::TYPE_GRADIENT:
383                         return Gtk::StockID("synfig-gradient");
384                         break;
385                 case ValueBase::TYPE_NIL:
386                 default:
387                         return Gtk::StockID("synfig-unknown");
388                         break;
389                 }
390 }
391
392 Gtk::StockID
393 studio::valuenode_icon(etl::handle<synfig::ValueNode> value_node)
394 {
395         if(handle<ValueNode_Const>::cast_dynamic(value_node))
396         {
397                 return value_icon(value_node->get_type());
398         }
399         else
400         {
401                 return Gtk::StockID("synfig-value_node");
402         }
403 }
404
405 Glib::RefPtr<Gdk::Pixbuf>
406 studio::get_tree_pixbuf(synfig::ValueBase::Type type)
407 {
408         //return Gtk::Button().render_icon(value_icon(type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
409         return _tree_pixbuf_table_value_type[int(type)];
410 }
411
412 #ifdef WIN32
413 #define TEMPORARY_DELETE_MACRO DELETE
414 #undef DELETE
415 #endif
416
417 Gtk::StockID
418 studio::get_action_stock_id(const synfigapp::Action::BookEntry& action)
419 {
420         Gtk::StockID stock_id;
421         if(action.task=="add")                          stock_id=Gtk::Stock::ADD;
422         else if(action.task=="connect")         stock_id=Gtk::Stock::CONNECT;
423         else if(action.task=="disconnect")      stock_id=Gtk::Stock::DISCONNECT;
424         else if(action.task=="insert")          stock_id=Gtk::Stock::ADD;
425         else if(action.task=="lower")           stock_id=Gtk::Stock::GO_DOWN;
426         else if(action.task=="move_bottom")     stock_id=Gtk::Stock::GOTO_BOTTOM;
427         else if(action.task=="move_top")        stock_id=Gtk::Stock::GOTO_TOP;
428         else if(action.task=="raise")           stock_id=Gtk::Stock::GO_UP;
429         else if(action.task=="remove")          stock_id=Gtk::Stock::DELETE;
430         else if(action.task=="set_off")         stock_id=Gtk::Stock::NO;
431         else if(action.task=="set_on")          stock_id=Gtk::Stock::YES;
432         else                                                            stock_id=Gtk::StockID("synfig-"+
433                                                                                                                           action.task);
434         return stock_id;
435 }
436
437 #ifdef WIN32
438 #define DELETE TEMPORARY_DELETE_MACRO
439 #undef TEMPORARY_DELETE_MACRO
440 #endif
441
442 Gtk::StockID
443 studio::layer_icon(const synfig::String &layer)
444 {
445         if(layer=="PasteCanvas" || layer=="pastecanvas" || layer=="paste_canvas")
446                 return Gtk::StockID("synfig-layer_pastecanvas");
447         else if(layer=="rotate")
448                 return Gtk::StockID("synfig-rotate");
449         else if(layer=="zoom")
450                 return Gtk::StockID("synfig-zoom");
451         else if(layer=="region")
452                 return Gtk::StockID("synfig-bline");
453         else if(layer=="polygon")
454                 return Gtk::StockID("synfig-polygon");
455         else if(layer=="outline")
456                 return Gtk::StockID("synfig-width");
457         else if(layer=="circle")
458                 return Gtk::StockID("synfig-circle");
459         else if(layer=="rectangle")
460                 return Gtk::StockID("synfig-rectangle");
461         else if(layer=="star")
462                 return Gtk::StockID("synfig-star");
463         else if(layer=="plant")
464                 return Gtk::StockID("synfig-plant");
465         else if(layer=="text")
466                 return Gtk::StockID("synfig-text");
467         else if(layer=="checker_board")
468                 return Gtk::StockID("synfig-layer_checkerboard");
469         else if(layer=="duplicate")
470                 return Gtk::StockID("synfig-layer_duplicate");
471         else if(layer=="linear_gradient")
472                 return Gtk::StockID("synfig-layer_gradient_lineal");
473         else if(layer=="radial_gradient")
474                 return Gtk::StockID("synfig-layer_gradient_radial");
475         else if(layer=="spiral_gradient")
476                 return Gtk::StockID("synfig-layer_gradient_spiral");
477         else if(layer=="curve_gradient")
478                 return Gtk::StockID("synfig-layer_gradient_curve");
479         else if(layer=="conical_gradient")
480                 return Gtk::StockID("synfig-layer_gradient_conical");
481         else if(layer=="noise")
482                 return Gtk::StockID("synfig-layer_gradient_noise");
483         else if(layer=="blur")
484                 return Gtk::StockID("synfig-layer_blur");
485         else if(layer=="radial_blur")
486                 return Gtk::StockID("synfig-layer_blur_radial");
487         else if(layer=="MotionBlur") // in the future should be "motion_blur"
488                 return Gtk::StockID("synfig-layer_blur_motion");
489         else if(layer=="curve_warp")
490                 return Gtk::StockID("synfig-layer_distortion_curvewarp");
491         else if(layer=="inside_out")
492                 return Gtk::StockID("synfig-layer_distortion_insideout");
493         else if(layer=="noise_distort")
494                 return Gtk::StockID("synfig-layer_distortion_noise");
495         else if(layer=="spherize")
496                 return Gtk::StockID("synfig-layer_distortion_spherize");
497         else if(layer=="stretch")
498                 return Gtk::StockID("synfig-layer_distortion_stretch");
499         else if(layer=="twirl")
500                 return Gtk::StockID("synfig-layer_distortion_twirl");
501         else if(layer=="warp")
502                 return Gtk::StockID("synfig-layer_distortion_warp");
503         else if(layer=="clamp")
504                 return Gtk::StockID("synfig-layer_filter_clamp");
505         else if(layer=="colorcorrect")
506                 return Gtk::StockID("synfig-layer_filter_colorcorrect");
507         else if(layer=="halftone2")
508                 return Gtk::StockID("synfig-layer_filter_halftone2");
509         else if(layer=="halftone3")
510                 return Gtk::StockID("synfig-layer_filter_halftone3");
511         else if(layer=="lumakey")
512                 return Gtk::StockID("synfig-layer_filter_luma");
513         else if(layer=="mandelbrot")
514                 return Gtk::StockID("synfig-layer_fractal_mandelbrot");
515         else if(layer=="julia")
516                 return Gtk::StockID("synfig-layer_fractal_julia");
517         else if(layer=="bevel")
518                 return Gtk::StockID("synfig-layer_stylize_bevel");
519         else if(layer=="shade")
520                 return Gtk::StockID("synfig-layer_stylize_shade");
521         else
522                 return Gtk::StockID("synfig-layer");
523 }
524
525 Glib::RefPtr<Gdk::Pixbuf>
526 studio::get_tree_pixbuf_layer(const synfig::String &layer)
527 {
528         return Gtk::Button().render_icon(layer_icon(layer),Gtk::ICON_SIZE_SMALL_TOOLBAR);
529 }