enum.cpp revision f1ec1be29a388dbf184f6190302a357fe67070ac
/** \file
* extension parameter for enumerations.
*
* It uses a Gtk:ComboBoxText widget in the extension UI.
*/
/*
* Author:
* Johan Engelen <johan@shouraizou.nl>
*
* Copyright (C) 2006-2007 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gtkmm/comboboxtext.h>
#include <gtkmm/tooltips.h>
#include <extension/extension.h>
#include <prefs-utils.h>
#include <document-private.h>
#include <sp-object.h>
#include "enum.h"
/** \brief The root directory in the preferences database for extension
related parameters. */
#define PREF_DIR "extensions"
namespace Inkscape {
namespace Extension {
/* For internal use only.
Note that value and guitext MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */
class enumentry {
public:
}
~enumentry() {
delete value;
delete guitext;
}
};
ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
{
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
while (child_repr != NULL) {
// don't translate when 'item' but do translate when '_item'
// NOTE: internal extensions use build_from_mem and don't need _item but
// still need to include if are to be localized
else
continue;
else
}
}
}
}
// Initialize _value with the default value from xml
// for simplicity : default to the contents of the first xml-child
const char * defaultval = NULL;
if (defaultval != NULL)
return;
}
ParamComboBox::~ParamComboBox (void)
{
//destroy choice strings
}
}
/** \brief A function to set the \c _value
\param in The value to set
\param doc A document that should be used to set the value.
\param node The node where the value may be placed
This function sets ONLY the internal value, but it also sets the value
in the preferences structure. To put it in the right place, \c PREF_DIR
and \c pref_name() are used.
To copy the data into _value the old memory must be free'd first.
It is important to note that \c g_free handles \c NULL just fine. Then
the passed in value is duplicated using \c g_strdup().
*/
const gchar *
{
break; // break out of for loop
}
}
if (settext) {
}
return _value;
}
void
ParamComboBox::changed (void) {
}
/**
\brief A function to get the value of the parameter in string form
\return A string with the 'value' as command line argument
*/
void
{
return;
}
/** \brief A special category of Gtk::Entry to handle string parameteres */
private:
SPDocument * _doc;
public:
/** \brief Build a string preference for the given parameter
\param pref Where to get the string from, and where to put it
when it changes.
*/
ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
};
void changed (void);
};
/** \brief Respond to the text box changing
This function responds to the box changing by grabbing the value
from the text box and putting it in the parameter.
*/
void
ParamComboBoxEntry::changed (void)
{
if (_changeSignal != NULL) {
_changeSignal->emit();
}
}
/**
\brief Creates a combobox widget for an enumeration parameter
*/
ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
if (_gui_hidden) return NULL;
// add choice strings:
}
}
}
} /* namespace Extension */
} /* namespace Inkscape */