index 78380dde1d71a74d4f36909d46535df6cbf5dbdb..1fef1a9db9f0f8032099dd84a45504417cf13636 100644 (file)
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
* Authors:
* Ted Gould <ted@gould.cx>
*
* 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
*/
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
if (!strcmp(this->get_id(), "org.inkscape.filter.dropshadow"))
return;
if (!strcmp(this->get_id(), "org.inkscape.filter.dropshadow"))
return;
+ bool hidden = false;
+
+ no_doc = false;
+
if (repr != NULL) {
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);
+
+ for (Inkscape::XML::Node *child = sp_repr_children(repr); child != NULL; child = child->next()) {
+ if (!strcmp(child->name(), "effect")) {
+ if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "no")) {
+ no_doc = true;
+ }
+ for (Inkscape::XML::Node *effect_child = sp_repr_children(child); effect_child != NULL; effect_child = effect_child->next()) {
+ if (!strcmp(effect_child->name(), "effects-menu")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ local_effects_menu = sp_repr_children(effect_child);
+ if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "yes")) {
+ hidden = true;
+ }
+ }
+ if (!strcmp(effect_child->name(), "menu-name") ||
+ !strcmp(effect_child->name(), "_menu-name")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ _verb.set_name(sp_repr_children(effect_child)->content());
+ }
+ if (!strcmp(effect_child->name(), "menu-tip") ||
+ !strcmp(effect_child->name(), "_menu-tip")) {
+ // printf("Found local effects menu in %s\n", this->get_name());
+ _verb.set_tip(sp_repr_children(effect_child)->content());
}
} // children of "effect"
break; // there can only be one effect
}
} // children of "effect"
break; // there can only be one effect
find_effects_list(inkscape_get_menus(INKSCAPE));
if (_effects_list != NULL) {
find_effects_list(inkscape_get_menus(INKSCAPE));
if (_effects_list != NULL) {
- _menu_node = sp_repr_new("verb");
+ Inkscape::XML::Document *xml_doc;
+ xml_doc = _effects_list->document();
+ _menu_node = xml_doc->createElement("verb");
_menu_node->setAttribute("verb-id", this->get_id(), false);
_menu_node->setAttribute("verb-id", this->get_id(), false);
- merge_menu(_effects_list, local_effects_menu, _menu_node);
- if (!strcmp(this->get_id(), "org.ekips.filter.interp"))
- sp_repr_print(_effects_list->parent());
+ if (!hidden)
+ merge_menu(_effects_list->parent(), _effects_list, local_effects_menu, _menu_node);
}
return;
}
return;
void
Effect::merge_menu (Inkscape::XML::Node * base,
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 * 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",
/* printf("Merge menu with '%s' '%s' '%s'\n",
base != NULL ? base->name() : "NULL",
gchar const * menuname = patern->attribute("name");
if (menuname == NULL) menuname = patern->attribute("_name");
if (menuname == NULL) return;
gchar const * menuname = patern->attribute("name");
if (menuname == NULL) menuname = patern->attribute("_name");
if (menuname == NULL) return;
-
- tomerge = sp_repr_new("submenu");
+
+ Inkscape::XML::Document *xml_doc;
+ xml_doc = base->document();
+ tomerge = xml_doc->createElement("submenu");
tomerge->setAttribute("name", menuname, false);
mergename = _(menuname);
}
tomerge->setAttribute("name", menuname, false);
mergename = _(menuname);
}
- base->parent()->appendChild(tomerge);
- Inkscape::GC::release(tomerge);
-
- Inkscape::XML::Node * menupass;
- for (menupass = base->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) {
- printf("Unable to find verb\n");
- return;
+ 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");
}
}
- compare_char = verb->get_name();
- } else { // submenu
- compare_char = menupass->attribute("name");
- if (compare_char == NULL)
- compare_char = menupass->attribute("_name");
- }
- if (compare_char == NULL) {
- printf("Nothing to compare against\n");
- return;
- }
+ /* This will cause us to skip tags we don't understand */
+ if (compare_char == NULL) {
+ continue;
+ }
- Glib::ustring compare(_(compare_char));
+ Glib::ustring compare(_(compare_char));
- if (mergename < compare) {
- tomerge->setPosition(menupass->position());
- break;
- }
+ 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 (patern != NULL) {
- merge_menu(tomerge, patern->firstChild(), mergee);
+ if (submenu == NULL)
+ submenu = tomerge;
+ merge_menu(submenu, submenu->firstChild(), patern->firstChild(), mergee);
}
return;
}
return;
return true;
}
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();
int response = dialog->run();
dialog->hide();
set_last_effect(this);
imp->effect(this, doc);
set_last_effect(this);
imp->effect(this, doc);
- sp_document_done(doc->doc());
+ sp_document_done(doc->doc(), SP_VERB_NONE, _(this->get_name()));
return;
}
return;
}
return false;
}
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.
/** \brief Create an action for a \c EffectVerb
\param view Which view the action should be created for
\return The built action.
* is called.
*/
SPActionEventVector Effect::EffectVerb::vector =
* is called.
*/
SPActionEventVector Effect::EffectVerb::vector =
- {{NULL},Effect::EffectVerb::perform, NULL, NULL, NULL};
+ {{NULL}, Effect::EffectVerb::perform, NULL, NULL, NULL, NULL};
} } /* namespace Inkscape, Extension */
} } /* namespace Inkscape, Extension */