From: gouldtj Date: Thu, 24 Apr 2008 06:36:02 +0000 (+0000) Subject: r19125@shi: ted | 2008-04-23 23:32:56 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b072c06020eee6a127ae1e893a3e8db21c4ce128;p=inkscape.git r19125@shi: ted | 2008-04-23 23:32:56 -0700 Cleaning up a couple things. Making sure we don't leak memory through the destructor (rarely used in reality, but we should be clean about these things, that's what destructors are for). r19126@shi: ted | 2008-04-23 23:33:30 -0700 Making it so that snow has a parameter for drift size. It seems like that is what most people would want to change on this relatively complex filter. --- diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index b19adffa2..7516bacf9 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -22,13 +22,12 @@ namespace Internal { namespace Filter { class DropShadow : public Inkscape::Extension::Internal::Filter::Filter { - int myvar; protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: DropShadow ( ) : Filter() { }; - //virtual ~DropShadow ( ) { if (_filter != NULL) g_free(_filter); return; } + virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h index 0b99cbc86..366bdcf1f 100644 --- a/src/extension/internal/filter/snow.h +++ b/src/extension/internal/filter/snow.h @@ -18,30 +18,56 @@ namespace Internal { namespace Filter { class Snow : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Snow ( ) : Filter() { }; + virtual ~Snow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + public: static void init (void) { - filter_init("snow", /* ID -- should be unique */ - N_("Snow"), /* Name in the menus, should have a N_() around it for translation */ - N_("When the weather outside is frightening..."), - /* Menu tooltip to help users understand the name. Should also have a N_() */ - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"); - /* The XML of the filter that should be added. There - * should be a surrounding what you'd like - * to be added with this effect. */ + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Snow") "\n" + "org.inkscape.effect.filter.snow\n" + "3.5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "" N_("When the weather outside is frightening...") "\n" + "\n" + "\n", new Snow()); }; + +}; + +gchar const * +Snow::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + float drift = ext->get_param_float("drift"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", drift); + + return _filter; }; }; /* namespace Filter */