/** \file
*
* Inkscape::Extension::Extension:
* the ability to have features that are more modular so that they
* can be added and removed easily. This is the basis for defining
* those actions.
*/
/*
* Authors:
* Ted Gould <ted@gould.cx>
*
* Copyright (C) 2002-2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if WITH_GTKMM_3_0
#else
#endif
#include "inkscape.h"
#include "extension/implementation/implementation.h"
#include "extension.h"
#include "db.h"
#include "dependency.h"
#include "timer.h"
#include "param/parameter.h"
namespace Inkscape {
namespace Extension {
/* Inkscape::Extension::Extension */
/**
\return none
\brief Constructs an Extension from a Inkscape::XML::Node
\param in_repr The repr that should be used to build it
This function is the basis of building an extension for Inkscape. It
currently extracts the fields from the Repr that are used in the
extension. The Repr will likely include other children that are
not related to the module directly. If the Repr does not include
a name and an ID the module will be left in an errored state.
*/
, silent(false)
, _gui(true)
{
parameters = NULL;
} else {
}
// printf("Extension Constructor: ");
/* TODO: Handle what happens if we don't have these two */
while (child_repr != NULL) {
}
chname++;
} /* id */
} /* name */
} /* name */
} /* param || _param */
} /* dependency */
for (Inkscape::XML::Node *child = child_repr->firstChild(); child != NULL ; child = child->next()) {
break;
} /* skip non-element nodes (see LP #1372200) */
}
} /* check command as a dependency (see LP #505920) */
}
}
db.register_ext (this);
}
// printf("%s\n", name);
return;
}
/**
\return none
\brief Destroys the Extension
This function frees all of the strings that could be attached
to the extension and also unreferences the repr. This is better
than freeing it because it may (I wouldn't know why) be referenced
in another place.
*/
{
// printf("Extension Destructor: %s\n", name);
db.unregister_ext(this);
delete timer;
/** \todo Need to do parameters here */
// delete parameters:
delete param;
}
delete _deps[i];
}
return;
}
/**
\return none
\brief A function to set whether the extension should be loaded
or unloaded
\param in_state Which state should the extension be in?
It checks to see if this is a state change or not. If we're changing
states it will call the appropriate function in the implementation,
load or unload. Currently, there is no error checking in this
function. There should be.
*/
void
{
if (_state == STATE_DEACTIVATED) return;
/** \todo Need some more error checking here! */
switch (in_state) {
case STATE_LOADED:
delete timer;
}
timer = new ExpirationTimer(this);
break;
case STATE_UNLOADED:
// std::cout << "Unloading: " << name << std::endl;
delete timer;
}
break;
case STATE_DEACTIVATED:
delete timer;
}
break;
default:
break;
}
}
return;
}
/**
\return The state the extension is in
\brief A getter for the state variable.
*/
{
return _state;
}
/**
\return Whether the extension is loaded or not
\brief A quick function to test the state of the extension
*/
bool
{
return get_state() == STATE_LOADED;
}
/**
\return A boolean saying whether the extension passed the checks
\brief A function to check the validity of the extension
This function chekcs to make sure that there is an id, a name, a
repr and an implemenation for this extension. Then it checks all
of the dependencies to see if they pass. Finally, it asks the
implmentation to do a check of itself.
On each check, if there is a failure, it will print a message to the
error log for that failure. It is important to note that the function
keeps executing if it finds an error, to try and get as many of them
into the error log as possible. This should help people debug
installations, and figure out what they need to get for the full
functionality of Inkscape to be available.
*/
bool
{
bool retval = true;
// static int i = 0;
// std::cout << "Checking module[" << i++ << "]: " << name << std::endl;
" An improper .inx file could have been caused by a faulty installation of Inkscape.");
// No need to include Windows only extensions
// See LP bug #1307554 for details - https://bugs.launchpad.net/inkscape/+bug/1307554
#ifndef WIN32
retval = false;
}
#endif
retval = false;
}
retval = false;
}
retval = false;
}
retval = false;
}
// std::cout << "Failed: " << *(_deps[i]) << std::endl;
retval = false;
}
}
if (retval)
return retval;
}
/** \brief A quick function to print out a standard start of extension
errors in the log.
\param reason A string explaining why this failed
Real simple, just put everything into \c error_file.
*/
void
{
return;
}
/**
\return The XML tree that is used to define the extension
\brief A getter for the internal Repr, does not add a reference.
*/
{
return repr;
}
/**
\return bool
\brief Whether this extension should hide the "working, please wait" dialog
*/
bool
{
return silent;
}
/**
\return The textual id of this extension
\brief Get the ID of this extension - not a copy don't delete!
*/
gchar *
{
return id;
}
/**
\return The textual name of this extension
\brief Get the name of this extension - not a copy don't delete!
*/
gchar *
{
return name;
}
/**
\return None
\brief This function diactivates the extension (which makes it
unusable, but not deleted)
This function is used to removed an extension from functioning, but
not delete it completely. It sets the state to \c STATE_DEACTIVATED to
mark to the world that it has been deactivated. It also removes
the current implementation and replaces it with a standard one. This
makes it so that we don't have to continually check if there is an
implementation, but we are gauranteed to have a benign one.
\warning It is important to note that there is no 'activate' function.
Running this function is irreversable.
*/
void
{
/* Removing the old implementation, and making this use the default. */
/* This should save some memory */
delete imp;
return;
}
/**
\return Whether the extension has been deactivated
\brief Find out the status of the extension
*/
bool
{
return get_state() == STATE_DEACTIVATED;
}
{
throw Extension::param_not_exist();
}
if (this->parameters == NULL) {
// the list of parameters is empty
throw Extension::param_not_exist();
}
g_slist_next(list)) {
return param;
} else {
if (subparam) {
return subparam;
}
}
}
// if execution reaches here, no parameter matching 'name' was found
throw Extension::param_not_exist();
}
{
}
gchar const *Extension::get_param_string(gchar const *name, SPDocument const *doc, Inkscape::XML::Node const *node) const
{
}
const gchar *
Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const
{
}
/**
* This is useful to find out, if a given string \c value is selectable in a ComboBox named \cname.
*
* @param name The name of the enum parameter to get.
* @param doc The document to look in for document specific parameters.
* @param node The node to look in for a specific parameter.
* @return true if value exists, false if not
*/
bool
Extension::get_param_enum_contains(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) const
{
}
gchar const *
Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node) const
{
}
/**
\return The value of the parameter identified by the name
\brief Gets a parameter identified by name with the bool placed
in value.
\param name The name of the parameter to get
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
bool
Extension::get_param_bool (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
}
/**
\return The integer value for the parameter specified
\brief Gets a parameter identified by name with the integer placed
in value.
\param name The name of the parameter to get
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
int
Extension::get_param_int (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
}
/**
\return The float value for the parameter specified
\brief Gets a parameter identified by name with the float placed
in value.
\param name The name of the parameter to get
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
float
Extension::get_param_float (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
}
/**
\return The string value for the parameter specified
\brief Gets a parameter identified by name with the float placed
in value.
\param name The name of the parameter to get
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const
{
}
/**
\return The passed in value
\brief Sets a parameter identified by name with the boolean
in the parameter value.
\param name The name of the parameter to set
\param value The value to set the parameter to
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
bool
Extension::set_param_bool (const gchar * name, bool value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
/**
\return The passed in value
\brief Sets a parameter identified by name with the integer
in the parameter value.
\param name The name of the parameter to set
\param value The value to set the parameter to
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
int
Extension::set_param_int (const gchar * name, int value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
/**
\return The passed in value
\brief Sets a parameter identified by name with the integer
in the parameter value.
\param name The name of the parameter to set
\param value The value to set the parameter to
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
float
Extension::set_param_float (const gchar * name, float value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
/**
\return The passed in value
\brief Sets a parameter identified by name with the string
in the parameter value.
\param name The name of the parameter to set
\param value The value to set the parameter to
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
const gchar *
Extension::set_param_string (const gchar * name, const gchar * value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
gchar const *
Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
gchar const *
Extension::set_param_enum(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node)
{
}
/**
\return The passed in value
\brief Sets a parameter identified by name with the string
in the parameter value.
\param name The name of the parameter to set
\param value The value to set the parameter to
\param doc The document to look in for document specific parameters
\param node The node to look in for a specific parameter
Look up in the parameters list, then execute the function on that
found parameter.
*/
Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, Inkscape::XML::Node * node)
{
}
/** \brief A function to open the error log file. */
void
{
if (!error_file.is_open()) {
g_warning(_("Could not create extension error log file '%s'"),
filename);
}
};
/** \brief A function to close the error log file. */
void
{
error_file.close();
};
/** \brief A widget to represent the inside of an AutoGUI widget */
public:
/** \brief Create an AutoGUI object */
/**
* Adds a widget with a tool tip into the autogui.
*
* If there is no widget, nothing happens. Otherwise it is just
* added into the VBox. If there is a tooltip (non-NULL) then it
* is placed on the widget.
*
* @param widg Widget to add.
* @param tooltip Tooltip for the widget.
*/
if (widg) {
if (tooltip) {
} else {
widg->set_has_tooltip(false);
}
}
};
};
/** \brief A function to automatically generate a GUI using the parameters
\return Generated widget
This function just goes through each parameter, and calls it's 'get_widget'
function to get each widget. Then, each of those is placed into
a Gtk::VBox, which is then returned to the calling function.
If there are no visible parameters, this function just returns NULL.
If all parameters are gui_visible = false NULL is returned as well.
*/
Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
//go through the list of parameters to see if there are any non-hidden ones
}
return agui;
};
/**
\brief A function to get the parameters in a string form
\return An array with all the parameters in it.
*/
void
{
}
return;
}
/* Extension editor dialog stuff */
{
#if WITH_GTKMM_3_0
#else
#endif
int row = 0;
add_val(_("State:"), _state == STATE_LOADED ? _("Loaded") : _state == STATE_UNLOADED ? _("Unloaded") : _("Deactivated"), table, &row);
return retval;
}
#if WITH_GTKMM_3_0
void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row)
#else
void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row)
#endif
{
(*row)++;
#if WITH_GTKMM_3_0
#else
#endif
return;
}
{
Gtk::Label * content = Gtk::manage(new Gtk::Label(_("Currently there is no help available for this Extension. Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension.")));
content->set_line_wrap(true);
} else {
}
return retval;
}
{
return retval;
}
{
unsigned int _visible_count = 0;
}
return _visible_count;
}
} /* namespace Extension */
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :