diff options
| author | Aur??lio A. Heckert <aurium@gmail.com> | 2009-04-04 15:38:23 +0000 |
|---|---|---|
| committer | aurium <aurium@users.sourceforge.net> | 2009-04-04 15:38:23 +0000 |
| commit | ad1d53e4b2aa047d2b03a2b4801c2092025f45ee (patch) | |
| tree | 12b59df97873c0507fd1723cbff2c2102886511c | |
| parent | Some extra comments. (diff) | |
| download | inkscape-ad1d53e4b2aa047d2b03a2b4801c2092025f45ee.tar.gz inkscape-ad1d53e4b2aa047d2b03a2b4801c2092025f45ee.zip | |
More options for Calendar extension
(bzr r7623)
| -rw-r--r-- | share/extensions/svgcalendar.inx | 7 | ||||
| -rwxr-xr-x | share/extensions/svgcalendar.py | 37 |
2 files changed, 39 insertions, 5 deletions
diff --git a/share/extensions/svgcalendar.inx b/share/extensions/svgcalendar.inx index e2368965e..8d8f2d567 100644 --- a/share/extensions/svgcalendar.inx +++ b/share/extensions/svgcalendar.inx @@ -21,6 +21,13 @@ <_item value="sun">Sunday</_item>
</param>
</page>
+ <page name="tab" _gui-text="Organization">
+ <param name="auto-organize" type="boolean" _gui-text="Set authomaticaly the size and positions">true</param>
+ <_param name="organize-help" type="description">The options above has no value with the upper checked.</_param>
+ <param name="months-per-line" type="int" min="1" max="12" _gui-text="Months per line">3</param> + <param name="month-width" type="string" _gui-text="Month Width">6cm</param> + <param name="month-margin" type="string" _gui-text="Month Margin">1cm</param>
+ </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>
diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index 7ba2f772a..5f70bc3c6 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -54,6 +54,22 @@ class SVGCalendar (inkex.Effect): action="store", type="string", dest="weekend", default="sat+sun", help='Define the weekend days. ("sat+sun" or "sat" or "sun")') + self.OptionParser.add_option("--auto-organize", + action="store", type="inkbool", + dest="auto_organize", default=True, + help='Authomaticaly set the size and positions.') + self.OptionParser.add_option("--months-per-line", + action="store", type="int", + dest="months_per_line", default=3, + help='Number of months side by side.') + self.OptionParser.add_option("--month-width", + action="store", type="string", + dest="month_width", default="6cm", + help='The width of the month days box.') + self.OptionParser.add_option("--month-margin", + action="store", type="string", + dest="month_margin", default="1cm", + help='The space between the month boxes.') self.OptionParser.add_option("--color-year", action="store", type="string", dest="color_year", default="#888", @@ -120,21 +136,32 @@ class SVGCalendar (inkex.Effect): calendar.setfirstweekday(6) else: calendar.setfirstweekday(0) + # Convert string numbers with unit to user space float numbers: + self.options.month_width = inkex.unittouu( self.options.month_width ) + self.options.month_margin = inkex.unittouu( self.options.month_margin ) # initial values: month_x_pos = 0 month_y_pos = 0 def calculate_size_and_positions(self): + #month_margin month_width months_per_line auto_organize self.doc_w = inkex.unittouu(self.document.getroot().get('width')) self.doc_h = inkex.unittouu(self.document.getroot().get('height')) - if self.doc_h > self.doc_w: - self.months_per_line = 3 + if self.options.auto_organize: + if self.doc_h > self.doc_w: + self.months_per_line = 3 + else: + self.months_per_line = 4 else: - self.months_per_line = 4 + self.months_per_line = self.options.months_per_line #self.month_w = self.doc_w / self.months_per_line - self.month_w = (self.doc_w * 0.8) / self.months_per_line - self.month_margin = self.month_w / 10 + if self.options.auto_organize: + self.month_w = (self.doc_w * 0.8) / self.months_per_line + self.month_margin = self.month_w / 10 + else: + self.month_w = self.options.month_width + self.month_margin = self.options.month_margin self.day_w = self.month_w / 7 self.day_h = self.month_w / 9 self.month_h = self.day_w * 7 |
