18#include <glibmm/i18n.h>
19#include <sigc++/sigc++.h>
48class ParamDescription :
public virtual WidgetLabel,
public virtual InxParameter {
55 Gtk::Widget *
get_widget(sigc::signal<
void ()> *changeSignal)
override
61 std::string value_to_string()
const override {
return ""; }
71 const char *type = in_repr->
attribute(
"type");
74 g_warning(
"Parameter without type in extension '%s'.", in_ext->
get_id());
75 }
else if(!strcmp(type,
"bool") || !strcmp(type,
"boolean")) {
77 }
else if (!strcmp(type,
"int")) {
78 param =
new ParamInt(in_repr, in_ext);
79 }
else if (!strcmp(type,
"float")) {
81 }
else if (!strcmp(type,
"string")) {
83 }
else if (!strcmp(type,
"path")) {
85 }
else if (!strcmp(type,
"description")) {
88 param =
new ParamDescription(in_repr, in_ext);
89 }
else if (!strcmp(type,
"notebook")) {
92 }
else if (!strcmp(type,
"optiongroup")) {
94 }
else if (!strcmp(type,
"enum")) {
97 }
else if (!strcmp(type,
"color")) {
100 g_warning(
"Unknown parameter type ('%s') in extension '%s'", type, in_ext->
get_id());
116 return boolpntr->
get();
127 return intpntr->
get();
136 return floatpntr->
get();
145 return stringpntr->
get().c_str();
154 return param->
get().c_str();
178 if (boolpntr ==
nullptr)
180 return boolpntr->
set(in);
186 if (intpntr ==
nullptr)
188 return intpntr->
set(in);
195 if (floatpntr ==
nullptr)
197 return floatpntr->
set(in);
203 if (stringpntr ==
nullptr)
205 return stringpntr->
set(in).c_str();
214 return param->
set(in).c_str();
220 if (param ==
nullptr)
222 return param->
set(in);
235 g_warning(
"Parameter without name in extension '%s'.",
_extension->
get_id());
240 const char *gui_text = in_repr->
attribute(
"gui-text");
242 gui_text = in_repr->
attribute(
"_gui-text");
248 _text = g_strdup(gui_text);
251 g_warning(
"Parameter '%s' in extension '%s' is visible but does not have a 'gui-text'.",
257 const char *gui_description = in_repr->
attribute(
"gui-description");
258 if (!gui_description) {
259 gui_description = in_repr->
attribute(
"_gui-description");
261 if (gui_description) {
289 g_critical(
"InxParameter::value_to_string called from parameter '%s' in extension '%s'",
_name,
_extension->
get_id());
290 g_assert_not_reached();
296 g_critical(
"InxParameter::string_to_value called from parameter '%s' in extension '%s'",
_name,
298 g_assert_not_reached();
The object that is the basis for the Extension system.
char const * get_id() const
Get the ID of this extension - not a copy don't delete!
An error class for when a parameter is called on a type it is not.
A class to represent the parameter of an extension.
bool get_bool() const
Wrapper to cast to the object and use its function.
double set_float(double in)
Wrapper to cast to the object and use it's function.
const char * get_optiongroup() const
Wrapper to cast to the object and use it's function.
unsigned int set_color(unsigned int in)
Wrapper to cast to the object and use it's function.
bool get_optiongroup_contains(const char *value) const
char * _name
The name of this parameter.
unsigned int get_color() const
Wrapper to cast to the object and use it's function.
virtual const std::string & set(const std::string &in)
Calls string_to_value and then saves the result in the prefs.
static InxParameter * make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext)
Creates a new extension parameter for usage in a prefdialog.
const char * set_optiongroup(const char *in)
Wrapper to cast to the object and use it's function.
virtual std::string value_to_string() const
Gets the current value of the parameter in a string form.
int set_int(int in)
Wrapper to cast to the object and use it's function.
const char * get_string() const
Wrapper to cast to the object and use it's function.
double get_float() const
Wrapper to cast to the object and use it's function.
char const * name() const
char * _description
Extended description of the parameter (currently shown as tooltip on hover).
const char * set_string(const char *in)
Wrapper to cast to the object and use it's function.
int get_int() const
Wrapper to cast to the object and use it's function.
Glib::ustring pref_name() const
Build preference name for the current parameter.
InxParameter(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext)
char * _text
Parameter text to show as the GUI label.
bool set_bool(bool in)
Wrapper to cast to the object and use it's function.
virtual void string_to_value(const std::string &in)
Sets the current value of the parameter from a string.
bool set(bool in)
A function to set the state/value.
bool get() const
Returns the current state/value.
unsigned int get() const
Returns _value, with a \i const to protect it.
unsigned int set(unsigned int in)
double get() const
Returns _value.
double set(double in)
A function to set the _value.
int get() const
Returns _value.
int set(int in)
A function to set the _value.
A class to represent a notebook parameter of an extension.
const Glib::ustring & get() const
bool contains(const Glib::ustring text) const
const Glib::ustring & set(const Glib::ustring &in)
A function to set the _value.
const Glib::ustring & get() const
Returns _value, with a \i const to protect it.
const Glib::ustring & set(Glib::ustring in)
A function to set the _value.
Preference storage class.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
void setString(Glib::ustring const &pref_path, Glib::ustring const &value)
Set an UTF-8 string value.
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
A notebook with RGB, CMYK, CMS, HSL, and Wheel pages.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
D2< T > compose(D2< T > const &a, T const &b)
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
CMYK to sRGB conversion routines.
Notebook parameter for extensions.
extension parameter for options with multiple predefined value choices
Path parameter for extensions.