Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / stable / src / synfigapp / value_desc.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file value_desc.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2008 Chris Moore
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "value_desc.h"
33 #include <string>
34
35 #include "general.h"
36
37 #endif
38
39 /* === U S I N G =========================================================== */
40
41 using namespace std;
42 using namespace etl;
43 using namespace synfig;
44 using namespace synfigapp;
45
46 /* === M A C R O S ========================================================= */
47
48 /* === M E T H O D S ======================================================= */
49
50 String
51 ValueDesc::get_description(bool show_exported_name)const
52 {
53         String description;
54
55         if (show_exported_name && !is_exported())
56                 show_exported_name = false;
57
58         if (parent_is_layer_param())
59         {
60                 description = strprintf("%s (%s):%s", _("Layer Parameter"),
61                                                                 get_layer()->get_non_empty_description().c_str(),
62                                                                 get_layer()->get_param_local_name(get_param_name()).c_str());
63                 if (show_exported_name)
64                         description += strprintf(" (%s)", get_value_node()->get_id().c_str());
65         }
66         else if (parent_is_value_node())
67         {
68                 if (parent_is_linkable_value_node())
69                 {
70                         synfig::LinkableValueNode::Handle value_node(synfig::LinkableValueNode::Handle::cast_reinterpret(get_parent_value_node()));
71                         description = strprintf("%s %s", _("Value Node"),
72                                                                         value_node->get_description(get_index(), show_exported_name).c_str());
73                 }
74                 else
75                 {
76                         warning("%s:%d didn't expect to get here", __FILE__, __LINE__);
77                         assert(0);
78                 }
79         }
80         else if (parent_is_canvas())
81                 description = strprintf("%s (%s)", _("Exported ValueNode"),
82                                                                 get_value_node()->get_id().c_str());
83         else
84         {
85                 error("Unknown ValueDesc type");
86                 assert(0);
87         }
88
89         return description;
90 }