diff options
| author | Aur??lio A. Heckert <aurium@gmail.com> | 2009-01-26 15:02:43 +0000 |
|---|---|---|
| committer | aurium <aurium@users.sourceforge.net> | 2009-01-26 15:02:43 +0000 |
| commit | 1581c2ad3b4e8131fb28fb8f534436571db72e85 (patch) | |
| tree | b77ca80bd478e4a89b2b1964023f8ad07b1300f3 | |
| parent | display guide anchor on canvas; anchor and angle can be edited by mouse (diff) | |
| download | inkscape-1581c2ad3b4e8131fb28fb8f534436571db72e85.tar.gz inkscape-1581c2ad3b4e8131fb28fb8f534436571db72e85.zip | |
adding configurable system encoding input for calendar extension
(bzr r7181)
| -rw-r--r-- | share/extensions/svgcalendar.inx | 136 | ||||
| -rwxr-xr-x | share/extensions/svgcalendar.py | 25 |
2 files changed, 131 insertions, 30 deletions
diff --git a/share/extensions/svgcalendar.inx b/share/extensions/svgcalendar.inx index 7a33639a7..d4bd3dbbe 100644 --- a/share/extensions/svgcalendar.inx +++ b/share/extensions/svgcalendar.inx @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Calendar</_name> + <_name>Calendar</_name>
<id>org.inkscape.calendar</id>
- - <dependency type="executable" location="extensions">svgcalendar.py</dependency> +
+ <dependency type="executable" location="extensions">svgcalendar.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
- +
<param name="tab" type="notebook">
<page name="tab" _gui-text="Configuration">
- <param name="month" type="int" min="0" max="12" _gui-text="Month (0 for all)">0</param> - <param name="year" type="int" min="0" max="3000" _gui-text="Ano (0 for current)">0</param> - <param name="fill-empty-day-boxes" type="boolean" _gui-text="Fill empty day boxes with next month days">true</param> + <param name="month" type="int" min="0" max="12" _gui-text="Month (0 for all)">0</param>
+ <param name="year" type="int" min="0" max="3000" _gui-text="Ano (0 for current)">0</param>
+ <param name="fill-empty-day-boxes" type="boolean" _gui-text="Fill empty day boxes with next month days">true</param>
<param name="start-day" type="enum" _gui-text="Week start day">
<_item value="sun">Sunday</_item>
<_item value="mon">Monday</_item>
@@ -20,29 +20,113 @@ <_item value="sat">Saturday</_item>
<_item value="sun">Sunday</_item>
</param>
- </page> + </page>
<page name="tab" _gui-text="Colors">
- <param name="color-year" type="string" _gui-text="Year color">#808080</param> - <param name="color-month" type="string" _gui-text="Month color">#686868</param> - <param name="color-day-name" type="string" _gui-text="Week day name color ">#909090</param> - <param name="color-day" type="string" _gui-text="Day color">#000000</param> - <param name="color-weekend" type="string" _gui-text="Weekend day color">#787878</param> - <param name="color-nmd" type="string" _gui-text="Next month day color">#B0B0B0</param> - </page> + <param name="color-year" type="string" _gui-text="Year color">#808080</param>
+ <param name="color-month" type="string" _gui-text="Month color">#686868</param>
+ <param name="color-day-name" type="string" _gui-text="Week day name color ">#909090</param>
+ <param name="color-day" type="string" _gui-text="Day color">#000000</param>
+ <param name="color-weekend" type="string" _gui-text="Weekend day color">#787878</param>
+ <param name="color-nmd" type="string" _gui-text="Next month day color">#B0B0B0</param>
+ </page>
<page name="tab" _gui-text="Localization">
<_param name="l10n-help" type="description">You may change the names for other languages:</_param>
- <_param name="month-names" type="string" _gui-text="Month names">January February March April May June July August September October November December</_param> - <_param name="day-names" type="string" _gui-text="Day names">Sun Mon Tue Wed Thu Fri Sat</_param> + <_param name="month-names" type="string" _gui-text="Month names">January February March April May June July August September October November December</_param>
+ <_param name="day-names" type="string" _gui-text="Day names">Sun Mon Tue Wed Thu Fri Sat</_param>
<_param name="day-names-help" type="description">(The day name list must start in sunday)</_param>
- </page> - </param> - <effect> - <object-type>all</object-type> + <param name="encoding" type="enum" _gui-text="Char Encoding">
+ <item>arabic</item>
+ <item>big5-tw</item>
+ <item>big5-hkscs</item>
+ <item>chinese</item>
+ <item>cp737</item>
+ <item>cp856</item>
+ <item>cp874</item>
+ <item>cp875</item>
+ <item>cp1006</item>
+ <item>cyrillic</item>
+ <item>cyrillic-asian</item>
+ <item>eucjis2004</item>
+ <item>eucjisx0213</item>
+ <item>gbk</item>
+ <item>gb18030-2000</item>
+ <item>greek</item>
+ <item>hebrew</item>
+ <item>hz-gb</item>
+ <item>IBM037</item>
+ <item>IBM424</item>
+ <item>IBM437</item>
+ <item>IBM500</item>
+ <item>IBM775</item>
+ <item>IBM850</item>
+ <item>IBM852</item>
+ <item>IBM855</item>
+ <item>IBM857</item>
+ <item>IBM860</item>
+ <item>IBM861</item>
+ <item>IBM862</item>
+ <item>IBM863</item>
+ <item>IBM864</item>
+ <item>IBM865</item>
+ <item>IBM866</item>
+ <item>IBM869</item>
+ <item>IBM1026</item>
+ <item>IBM1140</item>
+ <item>iso-2022-jp</item>
+ <item>iso-2022-jp-1</item>
+ <item>iso-2022-jp-2</item>
+ <item>iso-2022-jp-2004</item>
+ <item>iso-2022-jp-3</item>
+ <item>iso-2022-jp-ext</item>
+ <item>iso-2022-kr</item>
+ <item>johab</item>
+ <item>korean</item>
+ <item>koi8_r</item>
+ <item>koi8_u</item>
+ <item>latin1</item>
+ <item>latin2</item>
+ <item>latin3</item>
+ <item>latin4</item>
+ <item>latin5</item>
+ <item>latin6</item>
+ <item>latin8</item>
+ <item value="iso-8859-15">Latin - iso-8859-15 - Western Europe</item>
+ <item>macgreek</item>
+ <item>maciceland</item>
+ <item>maccentraleurope</item>
+ <item>macroman</item>
+ <item>macturkish</item>
+ <item>ms932</item>
+ <item>ms949</item>
+ <item>ms950</item>
+ <item>sjis</item>
+ <item>sjis2004</item>
+ <item>sjisx0213</item>
+ <item>u-jis</item>
+ <item>us-ascii</item>
+ <item value="windows-1250">Windows - Central and Eastern Europe</item>
+ <item value="windows-1251">Windows - Russian and more</item>
+ <item value="windows-1252">Windows - Western Europe</item>
+ <item value="windows-1253">Windows - Greek</item>
+ <item value="windows-1254">Windows - Turkish</item>
+ <item value="windows-1255">Windows - Hebrew</item>
+ <item value="windows-1256">Windows - Arabic</item>
+ <item value="windows-1257">Windows - Baltic languages</item>
+ <item value="windows-1258">Windows - Vietnamese</item>
+ <item value="utf_32">UTF-32 - All languages</item>
+ <item value="utf_16">UTF-16 - All languages</item>
+ <item value="utf_8">UTF-8 - All languages</item>
+ </param>
+ <_param name="encoding-help" type="description">(Select your system encoding. More information at http://docs.python.org/library/codecs.html#standard-encodings)</_param>
+ </page>
+ </param>
+ <effect>
+ <object-type>all</object-type>
<effects-menu>
<submenu _name="Render"/>
</effects-menu>
- </effect> - <script> - <command reldir="extensions" interpreter="python">svgcalendar.py</command> - </script> -</inkscape-extension> + </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">svgcalendar.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index 0dca58fc5..7ba2f772a 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -22,7 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -__version__ = "0.1" +__version__ = "0.2" import inkex, simplestyle, re, calendar from datetime import * @@ -87,8 +87,13 @@ class SVGCalendar (inkex.Effect): action="store", type="string", dest="day_names", default='Sun Mon Tue Wed Thu Fri Sat', help='The week day names for localization.') + self.OptionParser.add_option("--encoding", + action="store", type="string", + dest="input_encode", default='utf-8', + help='The input encoding of the names.') def validate_options(self): + #inkex.errormsg( self.options.input_encode ) # Convert string names lists in real lists: m = re.match( '\s*(.*[^\s])\s*', self.options.month_names ) self.options.month_names = re.split( '\s+', m.group(1) ) @@ -189,7 +194,11 @@ class SVGCalendar (inkex.Effect): txt_atts = {'style': simplestyle.formatStyle(self.style_month), 'x': str( (self.month_w - self.day_w) / 2 ), 'y': str( self.day_h / 5 ) } - inkex.etree.SubElement(g, 'text', txt_atts).text = unicode(self.options.month_names[m-1], "iso-8859-1") + try: + inkex.etree.SubElement(g, 'text', txt_atts).text = unicode(self.options.month_names[m-1], self.options.input_encode) + except: + inkex.errormsg('You must select your correct system encode.') + exit(1) gw = inkex.etree.SubElement(g, 'g') week_x = 0 if self.options.start_day=='sun': @@ -197,7 +206,11 @@ class SVGCalendar (inkex.Effect): txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), 'x': str( self.day_w * week_x ), 'y': str( self.day_h ) } - inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, "iso-8859-1") + try: + inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, self.options.input_encode) + except: + inkex.errormsg('You must select your correct system encode.') + exit(1) week_x += 1 else: w2 = self.options.day_names[1:] @@ -206,7 +219,11 @@ class SVGCalendar (inkex.Effect): txt_atts = {'style': simplestyle.formatStyle(self.style_day_name), 'x': str( self.day_w * week_x ), 'y': str( self.day_h ) } - inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, "iso-8859-1") + try: + inkex.etree.SubElement(gw, 'text', txt_atts).text = unicode(wday, self.options.input_encode) + except: + inkex.errormsg('You must select your correct system encode.') + exit(1) week_x += 1 def create_month(self, m): |
