index 5a43cd74c084cbfbbac70e4ec9ee898163747c42..aefdeefa75a875de03056715fad4f150fe794a69 100644 (file)
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
* Authors:
* Ted Gould <ted@gould.cx>
*
- * Copyright (C) 2002-2005 Authors
+ * Copyright (C) 2002-2006 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
: Extension(in_repr, in_imp), _verb(get_id(), get_name(), NULL, NULL, this), _menu_node(NULL)
{
+ Inkscape::XML::Node * local_effects_menu = NULL;
+
+ // This is a weird hack
+ if (!strcmp(this->get_id(), "org.inkscape.filter.dropshadow"))
+ return;
+
+ if (repr != NULL) {
+ Inkscape::XML::Node * child_repr;
+
+ for (child_repr = sp_repr_children(repr); child_repr != NULL; child_repr = child_repr->next()) {
+ if (!strcmp(child_repr->name(), "effect")) {
+ for (child_repr = sp_repr_children(child_repr); child_repr != NULL; child_repr = child_repr->next()) {
+ if (!strcmp(child_repr->name(), "effects-menu")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ local_effects_menu = sp_repr_children(child_repr);
+ }
+ if (!strcmp(child_repr->name(), "menu-name") ||
+ !strcmp(child_repr->name(), "_menu-name")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ _verb.set_name(sp_repr_children(child_repr)->content());
+ }
+ if (!strcmp(child_repr->name(), "menu-tip") ||
+ !strcmp(child_repr->name(), "_menu-tip")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ _verb.set_tip(sp_repr_children(child_repr)->content());
+ }
+ } // children of "effect"
+ break; // there can only be one effect
+ } // find "effect"
+ } // children of "inkscape-extension"
+ } // if we have an XML file
+
if (_effects_list == NULL)
find_effects_list(inkscape_get_menus(INKSCAPE));
if (_effects_list != NULL) {
_menu_node = sp_repr_new("verb");
_menu_node->setAttribute("verb-id", this->get_id(), false);
- _effects_list->parent()->appendChild(_menu_node);
- Inkscape::GC::release(_menu_node);
- } /*else {
- printf("Effect %s not added\n", get_name());
- }*/
+
+ merge_menu(_effects_list->parent(), _effects_list, local_effects_menu, _menu_node);
+ }
+
+ return;
+}
+
+void
+Effect::merge_menu (Inkscape::XML::Node * base,
+ Inkscape::XML::Node * start,
+ Inkscape::XML::Node * patern,
+ Inkscape::XML::Node * mergee) {
+ Glib::ustring mergename;
+ Inkscape::XML::Node * tomerge = NULL;
+ Inkscape::XML::Node * submenu = NULL;
+
+ /* printf("Merge menu with '%s' '%s' '%s'\n",
+ base != NULL ? base->name() : "NULL",
+ patern != NULL ? patern->name() : "NULL",
+ mergee != NULL ? mergee->name() : "NULL"); */
+
+ if (patern == NULL) {
+ // Merge the verb name
+ tomerge = mergee;
+ mergename = _(this->get_name());
+ } else {
+ gchar const * menuname = patern->attribute("name");
+ if (menuname == NULL) menuname = patern->attribute("_name");
+ if (menuname == NULL) return;
+
+ tomerge = sp_repr_new("submenu");
+ tomerge->setAttribute("name", menuname, false);
+
+ mergename = _(menuname);
+ }
+
+ int position = -1;
+
+ if (start != NULL) {
+ Inkscape::XML::Node * menupass;
+ for (menupass = start->next(); menupass != NULL; menupass = menupass->next()) {
+ gchar const * compare_char = NULL;
+ if (!strcmp(menupass->name(), "verb")) {
+ gchar const * verbid = menupass->attribute("verb-id");
+ Inkscape::Verb * verb = Inkscape::Verb::getbyid(verbid);
+ if (verb == NULL) {
+ continue;
+ }
+ compare_char = verb->get_name();
+ } else if (!strcmp(menupass->name(), "submenu")) {
+ compare_char = menupass->attribute("name");
+ if (compare_char == NULL)
+ compare_char = menupass->attribute("_name");
+ }
+
+ /* This will cause us to skip tags we don't understand */
+ if (compare_char == NULL) {
+ continue;
+ }
+
+ Glib::ustring compare(_(compare_char));
+
+ if (mergename == compare) {
+ Inkscape::GC::release(tomerge);
+ tomerge = NULL;
+ submenu = menupass;
+ break;
+ }
+
+ if (mergename < compare) {
+ position = menupass->position();
+ break;
+ }
+ } // for menu items
+ } // start != NULL
+
+ if (tomerge != NULL) {
+ base->appendChild(tomerge);
+ Inkscape::GC::release(tomerge);
+ if (position != -1)
+ tomerge->setPosition(position);
+ }
+
+ if (patern != NULL) {
+ if (submenu == NULL)
+ submenu = tomerge;
+ merge_menu(submenu, submenu->firstChild(), patern->firstChild(), mergee);
+ }
return;
}
return true;
}
- PrefDialog * dialog = new PrefDialog(this->get_name(), controls);
+ PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls);
int response = dialog->run();
dialog->hide();
child != NULL;
child = child->next()) {
if (!strcmp(child->name(), EFFECTS_LIST)) {
- _effects_list = menustruct;
+ _effects_list = child;
return true;
}
Inkscape::XML::Node * firstchild = child->firstChild();
return false;
}
+Gtk::VBox *
+Effect::get_info_widget(void)
+{
+ return Extension::get_info_widget();
+}
+
/** \brief Create an action for a \c EffectVerb
\param view Which view the action should be created for
\return The built action.