2 # Copyright (c) 2002, 2003, 2004, 2006 Art Haas
4 # This file is part of PythonCAD.
6 # PythonCAD is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # PythonCAD is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with PythonCAD; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # code for setting the preferences of an image
31 from PythonCAD
.Generic
import globals
32 from PythonCAD
.Generic
.text
import TextStyle
33 from PythonCAD
.Generic
import units
34 from PythonCAD
.Generic
.image
import Image
35 from PythonCAD
.Generic
.color
import get_color
36 from PythonCAD
.Generic
import preferences
37 from PythonCAD
.Generic
.dimension
import Dimension
39 _font_styles
= TextStyle
.getStyleStrings()
40 _font_weights
= TextStyle
.getWeightStrings()
41 _text_align
= TextStyle
.getAlignmentStrings()
43 _dim_endpoints
= Dimension
.getEndpointTypeStrings()
44 _dim_positions
= Dimension
.getPositionStrings()
46 ################################################################
48 # New and improved preferences code ...
50 ################################################################
52 class Prefstate(object):
53 """A class for storing and retriving preference values.
55 The Prefstate class stores references to the widgets used in
56 making the preference dialog screens. When the dialog is closed
57 the widgets stored in the Prefstate class are examined for their
58 values if the user wants to set new preference values.
60 The Prefstate class has the following methods:
62 {set/get}TreeView(): Set/Get a gtk.TreeView for the Prefstate instance.
63 {set/get}HBox(): Set/Get a gtk.HBox for the Prefstate instance.
64 {set/get}Container(): Set/Get a reference to a gtk.Container instance.
65 {set/get}PrefKey(): Set/Get a key used for storing preference widget sets.
66 {set/get}Widget(): Set/Get a keyed reference to a widget.
67 hasWidgetKey(): Test if a key is used to store a widget reference.
68 getWidgetKeys(): Return the keys used to refer to stored widgets.
69 {set/get}Image(): Set/Get the Image used for preference adjustment.
70 {set/get}Window(): Set/Get the gtk.Window displaying the preference dialog.
71 {set/get}Families(): Set/Get the font families for text selection screens
72 clear(): Clear all storage of widgets
75 self
.__tree
_view
= None
82 self
.__families
= None
84 def setTreeView(self
, treeview
):
85 """Store a reference to a TreeView widget.
89 The argument 'treeview' must be a gtk.TreeView instance.
91 if not isinstance(treeview
, gtk
.TreeView
):
92 raise TypeError, "Invalid TreeView: " + `
type(treeview
)`
93 self
.__tree
_view
= treeview
95 def getTreeView(self
):
96 """Return the stored TreeView widget.
100 If no gtk.TreeView has been stored this method returns None.
102 return self
.__tree
_view
104 def setHBox(self
, hbox
):
105 """Store a reference to a gtk.HBox widget.
109 The argument 'hbox' must be a gtk.HBox instance.
111 if not isinstance(hbox
, gtk
.HBox
):
112 raise TypeError, "Invalid HBox: " + `
type(hbox
)`
116 """Return the stored gtk.HBox.
120 If no gtk.HBox has been stored this method returns None.
124 def setContainer(self
, key
, container
):
125 """Store a keyed reference to a gtk.Container instance.
127 setContainer(key, container)
129 Argument 'key' is a text string, and the container must be
130 an instance of gtk.Container.
132 if not isinstance(container
, gtk
.Container
):
133 raise TypeError, "Invalid container: " + `
type(container
)`
134 self
.__prefkeys
[key
] = container
136 def getContainer(self
, key
):
137 """Retrieve the gtk.Container referenced by a key.
141 If the key has been used to store a gtk.Container instance, the
142 stored container is returned. If not, None is returned.
144 if key
in self
.__prefkeys
:
145 _container
= self
.__prefkeys
[key
]
150 def setPrefKey(self
, key
):
151 """Store a key representing a screenful of preference widgets.
155 Argument 'key' should be a string.
157 if key
not in self
.__prefkeys
:
158 raise ValueError, "No container stored for key."
161 def getPrefKey(self
):
162 """Return the current key giving the preference widget screen.
166 This method returns the key last set by setPrefKey(). If that method
167 has not been invoked None is returned.
169 return self
.__prefkey
171 def delPrefKey(self
):
172 self
.__prefkey
= None
174 def setWidget(self
, key
, widget
):
175 """Store a widget reference in the Prefstate.
177 setWidget(key, widget)
179 Argument 'key' should be a string. Argument 'widget' must be an
180 instance of gtk.Widget. Trying to use the same key twice will
181 raise a ValueError exception.
183 if not isinstance(widget
, gtk
.Widget
):
184 raise TypeError, "Invalid widget: " + `
type(widget
)`
185 if key
in self
.__widgets
:
186 raise ValueError, "Duplicate key: " + key
187 self
.__widgets
[key
] = widget
189 def getWidget(self
, key
):
190 """Return the widget associated with a key
194 Argument 'key' should be a string. Using a key that has not
195 been used with setWidget() results in a KeyError exception.
197 return self
.__widgets
[key
]
199 def hasWidgetKey(self
, key
):
200 """Test if a key is used for widget association.
204 This method returns True if the key has already been used to
207 return key
in self
.__widgets
209 def getWidgetKeys(self
):
210 """Return all the keys used to store widgets.
214 This method returns a list of strings.
216 return self
.__widgets
.keys()
218 def setImage(self
, image
):
219 """Store a reference to the image used for preference adjustment.
223 Argument 'image' must be an instance of image.Image.
225 if not isinstance(image
, Image
):
226 raise TypeError, "Invalid image: " + `
type(image
)`
230 """Retrieve the image used for this Prefstate instance.
234 This method raises a ValueError exception if it is called before
237 if self
.__image
is None:
238 raise ValueError, "Image not set."
241 def setWindow(self
, window
):
242 """Store a reference to a gtk.Window.
246 Argument 'window' must be an instance of gtk.Window.
248 if not isinstance(window
, gtk
.Window
):
249 raise TypeError, "Invalid window: " + `
type(window
)`
250 self
.__window
= window
253 """Return the stored window for the Prefstate instance.
257 This method raises a ValueError exception if it is invoked before
258 setWindow() has been called.
260 if self
.__window
is None:
261 raise ValueError, "Window not set."
264 def setFamilies(self
, families
):
265 """Store a list of font families.
267 setFamilies(families)
269 Argument 'families' should be a list.
271 if not isinstance(families
, list):
272 raise TypeError, "Invalid families list: " + `
type(families
)`
273 self
.__families
= families
275 def getFamilies(self
):
276 """Return the list of families stored in the Prefstate instance.
280 If setFamilies() has not been called, this method returns None
282 return self
.__families
285 """Release all widget references.
289 This method should only be called once the usage of a Prefstate
290 instance is completed.
292 self
.__tree
_view
= None
294 self
.__prefkeys
.clear()
295 self
.__prefkey
= None
296 self
.__widgets
.clear()
299 self
.__families
= None
301 def entry_activate(entry
):
302 _text
= entry
.get_text()
303 entry
.delete_text(0, -1)
305 if _text
== '-' or _text
== '+':
306 sys
.stderr
.write("Incomplete value: '%s'\n" % _text
)
309 _value
= float(_text
)
310 print "value: %g" % _value
312 sys
.stderr
.write("Invalid float: '%s'\n" % _text
)
314 sys
.stderr
.write("Empty entry box.")
317 # use focus-out events to reset the value in entry boxes
318 # to their previous value if the entry box text is invalid
321 def _leader_entry_focus_out(entry
, event
, prefstate
):
322 _text
= entry
.get_text()
323 if _text
== '' or _text
== '+':
324 entry
.delete_text(0, -1)
325 _size
= "%f" % globals.prefs
['LEADER_ARROW_SIZE']
326 entry
.set_text(_size
)
329 def _dim_offset_entry_focus_out(entry
, event
, prefstate
):
330 _text
= entry
.get_text()
331 if _text
== '' or _text
== '+':
332 entry
.delete_text(0, -1)
333 _size
= "%f" % globals.prefs
['DIM_OFFSET']
334 entry
.set_text(_size
)
337 def _dim_marker_entry_focus_out(entry
, event
, prefstate
):
338 _text
= entry
.get_text()
339 if _text
== '' or _text
== '+':
340 entry
.delete_text(0, -1)
341 _size
= "%f" % globals.prefs
['DIM_ENDPOINT_SIZE']
342 entry
.set_text(_size
)
345 def _dim_extlen_entry_focus_out(entry
, event
, prefstate
):
346 _text
= entry
.get_text()
347 if _text
== '' or _text
== '+':
348 entry
.delete_text(0, -1)
349 _size
= "%f" % globals.prefs
['DIM_EXTENSION']
350 entry
.set_text(_size
)
353 def _thickness_entry_focus_out(entry
, event
, prefstate
):
354 _text
= entry
.get_text()
355 if _text
== '' or _text
== '+':
356 entry
.delete_text(0, -1)
357 _size
= "%f" % globals.prefs
['LINE_THICKNESS']
358 entry
.set_text(_size
)
361 def _chamfer_entry_focus_out(entry
, event
, prefstate
):
362 _text
= entry
.get_text()
363 if _text
== '' or _text
== '+':
364 entry
.delete_text(0, -1)
365 _size
= "%f" % globals.prefs
['CHAMFER_LENGTH']
366 entry
.set_text(_size
)
369 def _fillet_entry_focus_out(entry
, event
, prefstate
):
370 _text
= entry
.get_text()
371 if _text
== '' or _text
== '+':
372 entry
.delete_text(0, -1)
373 _size
= "%f" % globals.prefs
['FILLET_RADIUS']
374 entry
.set_text(_size
)
377 def _textsize_entry_focus_out(entry
, event
, prefstate
):
378 _text
= entry
.get_text()
379 if _text
== '' or _text
== '+':
380 entry
.delete_text(0, -1)
381 _size
= "%f" % globals.prefs
['TEXT_SIZE']
382 entry
.set_text(_size
)
385 def _dim_primary_textsize_entry_focus_out(entry
, event
, prefstate
):
386 _text
= entry
.get_text()
387 if _text
== '' or _text
== '+':
388 entry
.delete_text(0, -1)
389 _size
= "%f" % globals.prefs
['DIM_PRIMARY_TEXT_SIZE']
390 entry
.set_text(_size
)
393 def _dim_secondary_textsize_entry_focus_out(entry
, event
, prefstate
):
394 _text
= entry
.get_text()
395 if _text
== '' or _text
== '+':
396 entry
.delete_text(0, -1)
397 _size
= "%f" % globals.prefs
['DIM_SECONDARY_TEXT_SIZE']
398 entry
.set_text(_size
)
401 def entry_focus_out(entry
, event
):
402 _text
= entry
.get_text()
403 if _text
== '-' or _text
== '+':
404 entry
.delete_text(0, -1)
408 # color change button handlers
411 def _get_rgb_values(color
):
412 if not isinstance(color
, gtk
.gdk
.Color
):
413 raise TypeError, "Unexpected color type: " + `
type(color
)`
414 _r
= int(round((color
.red
/65535.0) * 255.0))
415 _g
= int(round((color
.green
/65535.0) * 255.0))
416 _b
= int(round((color
.blue
/65535.0) * 255.0))
419 def _select_background_color(button
):
420 _da
= button
.get_child().get_child()
421 _color
= _da
.get_style().bg
[gtk
.STATE_NORMAL
]
422 _dialog
= gtk
.ColorSelectionDialog(_('Choose New Color'))
423 _colorsel
= _dialog
.colorsel
424 _colorsel
.set_previous_color(_color
)
425 _colorsel
.set_current_color(_color
)
426 _colorsel
.set_has_palette(True)
427 _response
= _dialog
.run()
428 if _response
== gtk
.RESPONSE_OK
:
429 _r
, _g
, _b
= _get_rgb_values(_colorsel
.get_current_color())
430 _str
= "#%02x%02x%02x" % (_r
, _g
, _b
)
431 _color
= gtk
.gdk
.color_parse(_str
)
432 _da
.modify_bg(gtk
.STATE_NORMAL
, _color
)
435 def _select_dimbar_color(button
):
436 _da
= button
.get_child().get_child()
437 _color
= _da
.get_style().bg
[gtk
.STATE_NORMAL
]
438 _dialog
= gtk
.ColorSelectionDialog(_('Set Dimension Bar Color'))
439 _colorsel
= _dialog
.colorsel
440 _colorsel
.set_previous_color(_color
)
441 _colorsel
.set_current_color(_color
)
442 _colorsel
.set_has_palette(True)
443 _response
= _dialog
.run()
444 if _response
== gtk
.RESPONSE_OK
:
445 _r
, _g
, _b
= _get_rgb_values(_colorsel
.get_current_color())
446 _str
= "#%02x%02x%02x" % (_r
, _g
, _b
)
447 _color
= gtk
.gdk
.color_parse(_str
)
448 _da
.modify_bg(gtk
.STATE_NORMAL
, _color
)
451 def _select_font_color(button
):
452 _da
= button
.get_child().get_child()
453 _color
= _da
.get_style().bg
[gtk
.STATE_NORMAL
]
454 _dialog
= gtk
.ColorSelectionDialog(_('Set Font Color'))
455 _colorsel
= _dialog
.colorsel
456 _colorsel
.set_previous_color(_color
)
457 _colorsel
.set_current_color(_color
)
458 _colorsel
.set_has_palette(True)
459 _response
= _dialog
.run()
460 if _response
== gtk
.RESPONSE_OK
:
461 _r
, _g
, _b
= _get_rgb_values(_colorsel
.get_current_color())
462 _str
= "#%02x%02x%02x" % (_r
, _g
, _b
)
463 _color
= gtk
.gdk
.color_parse(_str
)
464 _da
.modify_bg(gtk
.STATE_NORMAL
, _color
)
469 def _toggle_widgets_on(widget
, checkbox
):
470 if widget
is not checkbox
:
471 widget
.set_sensitive(True)
473 def _toggle_widgets_off(widget
, checkbox
):
474 if widget
is not checkbox
:
475 widget
.set_sensitive(False)
477 def _toggle_secondary_dim_opts(checkbox
, vbox
):
478 if checkbox
.get_active():
479 vbox
.foreach(_toggle_widgets_on
, checkbox
)
481 vbox
.foreach(_toggle_widgets_off
, checkbox
)
483 def move_cursor(entry
):
484 entry
.set_position(-1)
487 def entry_insert_text(entry
, new_text
, new_text_length
, position
):
488 if (new_text
.isdigit() or
491 _string
= entry
.get_text() + new_text
[:new_text_length
]
492 _hid
= entry
.get_data('handlerid')
494 entry
.handler_block(_hid
)
496 _pos
= entry
.get_position()
498 _pos
= entry
.insert_text(new_text
, _pos
)
501 _val
= float(_string
)
502 _pos
= entry
.insert_text(new_text
, _pos
)
503 except StandardError, e
:
505 sys
.stdout
.write("exception: '%s'\n" % e
)
507 entry
.handler_unblock(_hid
)
509 if hasattr(gobject
, 'idle_add'):
510 gobject
.idle_add(move_cursor
, entry
)
512 gtk
.idle_add(move_cursor
, entry
)
513 entry
.stop_emission("insert-text")
515 def tree_select_cb(selection
, prefstate
):
516 if selection
is not None:
517 _model
, _iter
= selection
.get_selected()
518 if _iter
is not None:
519 _hbox
= prefstate
.getHBox()
520 _prefkey
= prefstate
.getPrefKey()
521 if _prefkey
is not None:
522 _old_container
= prefstate
.getContainer(_prefkey
)
523 assert _old_container
is not None, "No container: " + _prefkey
524 _pstring
= _model
.get_value(_iter
, 1)
525 # print "second field: '%s'" % _pstring
526 _new_container
= prefstate
.getContainer(_pstring
)
527 if _new_container
is None:
528 if _pstring
== 'dimensions':
529 _new_container
= _make_dimension_opts(prefstate
)
530 elif _pstring
== 'linear':
531 _new_container
= _make_linear_opts(prefstate
)
532 elif _pstring
== 'radial':
533 _new_container
= _make_radial_opts(prefstate
)
534 elif _pstring
== 'angular':
535 _new_container
= _make_angular_opts(prefstate
)
536 elif _pstring
== 'basic':
537 _new_container
= _make_basic_opts(prefstate
)
538 elif _pstring
== 'sizes':
539 _new_container
= _make_size_opts(prefstate
)
540 elif _pstring
== 'chamfers':
541 _new_container
= None
542 elif _pstring
== 'fillets':
543 _new_container
= None
544 elif _pstring
== 'text':
545 _new_container
= _make_text_opts(prefstate
)
546 elif _pstring
== 'primary':
547 _new_container
= _make_primary_opts(prefstate
)
548 elif _pstring
== 'secondary':
549 _new_container
= _make_secondary_opts(prefstate
)
551 print "unexpected string: '%s'" % _pstring
552 if _new_container
is not None:
554 if _pstring
== 'linear':
555 _frame
= prefstate
.getWidget('LINEAR_SECONDARY_FRAME')
556 elif _pstring
== 'radial':
557 _frame
= prefstate
.getWidget('RADIAL_SECONDARY_FRAME')
558 elif _pstring
== 'angular':
559 _frame
= prefstate
.getWidget('ANGULAR_SECONDARY_FRAME')
562 if _frame
is not None:
564 if prefstate
.hasWidgetKey('DIM_DUAL_MODE'):
565 _cb
= prefstate
.getWidget('DIM_DUAL_MODE')
566 _flag
= _cb
.get_active()
568 _frame
.foreach(_toggle_widgets_on
, _frame
)
570 _frame
.foreach(_toggle_widgets_off
, _frame
)
571 if _prefkey
is not None:
572 _old_container
.hide_all()
573 _hbox
.remove(_old_container
)
574 _new_container
.show_all()
575 prefstate
.setContainer(_pstring
, _new_container
)
576 prefstate
.setPrefKey(_pstring
)
577 _hbox
.pack_start(_new_container
, True, True, 5)
579 # the second time a new container is shown it may not
580 # redraw completely - why?
584 def _make_dimension_opts(prefstate
):
585 _vbox
= gtk
.VBox(False, 5)
588 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
589 _text
= "<span weight='bold' size='16000'>%s</span>" % _('General Dimension Options')
590 _label
= gtk
.Label(_text
)
591 _label
.set_use_markup(True)
593 _vbox
.pack_start(_frame
, False, False, 5)
595 _size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
597 # options for dimension bars
599 _frame
= gtk
.Frame(_('Dimension Bar Options'))
600 _table
= gtk
.Table(5, 2, False)
601 _table
.set_border_width(5)
602 _table
.set_row_spacings(5)
603 _table
.set_col_spacings(5)
605 _label
= gtk
.Label(_('Offset length:'))
606 _table
.attach(_label
, 0, 1, 0, 1,
611 _length
= "%f" % globals.prefs
['DIM_OFFSET']
612 _entry
.set_text(_length
)
613 if not prefstate
.hasWidgetKey('DIM_OFFSET'):
614 prefstate
.setWidget('DIM_OFFSET', _entry
)
615 _entry
.connect("activate", entry_activate
)
616 _entry
.connect("focus-out-event", _dim_offset_entry_focus_out
, prefstate
)
617 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
618 _entry
.set_data('handlerid', _handlerid
)
619 _size_group
.add_widget(_entry
)
620 _table
.attach(_entry
, 1, 2, 0, 1,
621 gtk
.FILL | gtk
.EXPAND
,
622 gtk
.FILL | gtk
.EXPAND
,
624 _thbox
= gtk
.HBox(False)
625 _thbox
.set_border_width(2)
626 _label
= gtk
.Label(_('The offset length is the distance between the dimension point and the start of the dimension bar.'))
627 _thbox
.pack_start(_label
, False, False)
628 _label
.set_line_wrap(True)
629 _table
.attach(_thbox
, 0, 2, 1, 2,
630 gtk
.FILL | gtk
.EXPAND
,
631 gtk
.FILL | gtk
.EXPAND
,
634 _label
= gtk
.Label(_('Extension length:'))
635 _table
.attach(_label
, 0, 1, 2, 3,
640 _length
= "%f" % globals.prefs
['DIM_EXTENSION']
641 _entry
.set_text(_length
)
642 if not prefstate
.hasWidgetKey('DIM_EXTENSION'):
643 prefstate
.setWidget('DIM_EXTENSION', _entry
)
644 _entry
.connect("activate", entry_activate
)
645 _entry
.connect("focus-out-event", _dim_extlen_entry_focus_out
, prefstate
)
646 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
647 _entry
.set_data('handlerid', _handlerid
)
648 _size_group
.add_widget(_entry
)
649 _table
.attach(_entry
, 1, 2, 2, 3,
650 gtk
.FILL | gtk
.EXPAND
,
651 gtk
.FILL | gtk
.EXPAND
,
653 _thbox
= gtk
.HBox(False)
654 _thbox
.set_border_width(2)
655 _label
= gtk
.Label(_('The extension length is the distance the dimension bars extend beyond the dimension crossbar/crossarc.'))
656 _label
.set_line_wrap(True)
657 _thbox
.pack_start(_label
, False, False)
658 _table
.attach(_thbox
, 0, 2, 3, 4,
659 gtk
.FILL | gtk
.EXPAND
,
660 gtk
.FILL | gtk
.EXPAND
,
662 _fhbox
= gtk
.HBox(False, 5)
663 _label
= gtk
.Label(_('Dimension bar color:'))
664 _fhbox
.pack_start(_label
, False, False, 5)
665 _color
= globals.prefs
['DIM_COLOR']
666 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
667 if hasattr(gtk
, 'ColorButton'):
668 _button
= gtk
.ColorButton(color
=_gtkcolor
)
669 _button
.set_title(_('Select Dimension Color'))
670 if not prefstate
.hasWidgetKey('DIM_COLOR'):
671 prefstate
.setWidget('DIM_COLOR', _button
)
673 _button
= gtk
.Button()
674 _bframe
= gtk
.Frame()
675 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
676 _bframe
.set_border_width(5)
678 _da
= gtk
.DrawingArea()
679 _da
.set_size_request(20, 10)
680 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
681 if not prefstate
.hasWidgetKey('DIM_COLOR'):
682 prefstate
.setWidget('DIM_COLOR', _da
)
683 _button
.connect("clicked", _select_dimbar_color
)
685 _fhbox
.pack_start(_button
, False, False, 5)
686 _table
.attach(_fhbox
, 0, 2, 4, 5,
687 gtk
.FILL | gtk
.EXPAND
,
688 gtk
.FILL | gtk
.EXPAND
,
690 _vbox
.pack_start(_frame
, False, False, 5)
692 # options for dimension text position
694 _frame
= gtk
.Frame(_('Dimension Text Position'))
695 _fhbox
= gtk
.HBox(False, 5)
696 _fhbox
.set_border_width(5)
698 _label
= gtk
.Label(_('Text Location at crossbar:'))
699 _fhbox
.pack_start(_label
, False, False, 5)
701 _cur_pos
= globals.prefs
['DIM_POSITION']
702 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
703 _widget
= gtk
.combo_box_new_text()
704 for _i
in range(len(_dim_positions
)):
705 _name
= _dim_positions
[_i
]
706 if _cur_pos
== Dimension
.getPositionFromString(_name
):
708 _widget
.append_text(_name
)
709 _widget
.set_active(_idx
)
712 for _i
in range(len(_dim_positions
)):
713 _name
= _dim_positions
[_i
]
714 if _cur_pos
== Dimension
.getPositionFromString(_name
):
716 _item
= gtk
.MenuItem(_name
)
718 _widget
= gtk
.OptionMenu()
719 _widget
.set_menu(_menu
)
720 _widget
.set_history(_idx
)
721 if not prefstate
.hasWidgetKey('DIM_POSITION'):
722 prefstate
.setWidget('DIM_POSITION', _widget
)
723 _fhbox
.pack_start(_widget
, False, False, 0)
724 _vbox
.pack_start(_frame
, False, False, 5)
726 # options for dimension crossbar/crossarc markers
728 _frame
= gtk
.Frame(_('Dimension Crossbar Markers'))
729 _table
= gtk
.Table(2, 2, False)
730 _table
.set_border_width(5)
731 _table
.set_row_spacings(5)
732 _table
.set_col_spacings(5)
734 _label
= gtk
.Label(_('Dimension marker:'))
735 _table
.attach(_label
, 0, 1, 0, 1,
741 _endpt
= globals.prefs
['DIM_ENDPOINT']
742 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
743 _widget
= gtk
.combo_box_new_text()
744 for _i
in range(len(_dim_endpoints
)):
745 _name
= _dim_endpoints
[_i
]
746 if _endpt
== Dimension
.getEndpointTypeFromString(_name
):
748 _widget
.append_text(_name
)
749 _widget
.set_active(_idx
)
752 for _i
in range(len(_dim_endpoints
)):
753 _name
= _dim_endpoints
[_i
]
754 if _endpt
== Dimension
.getEndpointTypeFromString(_name
):
756 _item
= gtk
.MenuItem(_name
)
758 _widget
= gtk
.OptionMenu()
759 _widget
.set_menu(_menu
)
760 _widget
.set_history(_idx
)
761 if not prefstate
.hasWidgetKey('DIM_ENDPOINT'):
762 prefstate
.setWidget('DIM_ENDPOINT', _widget
)
763 _table
.attach(_widget
, 1, 2, 0, 1,
768 _label
= gtk
.Label(_('Marker size:'))
769 _table
.attach(_label
, 0, 1, 1, 2,
774 _size
= "%f" % globals.prefs
['DIM_ENDPOINT_SIZE']
775 _entry
.set_text(_size
)
776 if not prefstate
.hasWidgetKey('DIM_ENDPOINT_SIZE'):
777 prefstate
.setWidget('DIM_ENDPOINT_SIZE', _entry
)
778 _entry
.connect("activate", entry_activate
)
779 _entry
.connect("focus-out-event", _dim_marker_entry_focus_out
, prefstate
)
780 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
781 _entry
.set_data('handlerid', _handlerid
)
782 _size_group
.add_widget(_entry
)
783 _table
.attach(_entry
, 1, 2, 1, 2,
787 _vbox
.pack_start(_frame
, False, False, 5)
790 def _make_primary_opts(prefstate
):
791 _vbox
= gtk
.VBox(False, 2)
794 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
795 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Primary Dimension Options')
796 _label
= gtk
.Label(_text
)
797 _label
.set_use_markup(True)
799 _vbox
.pack_start(_frame
, False, False, 5)
801 _frame
= gtk
.Frame(_('Units'))
802 _frame
.set_border_width(2)
803 _fhbox
= gtk
.HBox(False, 5)
804 _fhbox
.set_border_width(2)
806 _label
= gtk
.Label(_('Primary dimension units:'))
807 _fhbox
.pack_start(_label
, False, False, 5)
810 _units
= units
.get_all_units()
811 _cur_unit
= globals.prefs
['DIM_PRIMARY_UNITS']
812 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
813 _widget
= gtk
.combo_box_new_text()
814 for _i
in range(len(_units
)):
817 _widget
.append_text(_units
[_i
])
818 _widget
.set_active(_idx
)
821 for _i
in range(len(_units
)):
824 _item
= gtk
.MenuItem(_units
[_i
])
826 _widget
= gtk
.OptionMenu()
827 _widget
.set_menu(_menu
)
828 _widget
.set_history(_idx
)
829 if not prefstate
.hasWidgetKey('DIM_PRIMARY_UNITS'):
830 prefstate
.setWidget('DIM_PRIMARY_UNITS', _widget
)
831 _fhbox
.pack_start(_widget
, False, False, 5)
832 _vbox
.pack_start(_frame
, False, False, 5)
834 _label_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
835 _menu_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
837 _frame
= gtk
.Frame(_('Font Properties'))
838 _frame
.set_border_width(2)
839 _fvbox
= gtk
.VBox(False, 5)
840 _fvbox
.set_border_width(2)
842 _fhbox
= gtk
.HBox(False, 5)
843 _fhbox
.set_border_width(5)
844 _fvbox
.pack_start(_fhbox
, False, False, 5)
845 _label
= gtk
.Label(_('Family:'))
846 _label_size_group
.add_widget(_label
)
847 _fhbox
.pack_start(_label
, False, False, 5)
848 _families
= prefstate
.getFamilies()
849 if _families
is None:
851 _window
= prefstate
.getWindow()
852 for _family
in _window
.get_pango_context().list_families():
853 _families
.append(_family
.get_name())
855 prefstate
.setFamilies(_families
)
858 _family
= globals.prefs
['DIM_PRIMARY_FONT_FAMILY']
859 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
860 _widget
= gtk
.combo_box_new_text()
861 for _i
in range(len(_families
)):
865 _widget
.append_text(_f
)
866 _widget
.set_active(_idx
)
869 for _i
in range(len(_families
)):
873 _item
= gtk
.MenuItem(_f
)
875 _widget
= gtk
.OptionMenu()
876 _widget
.set_menu(_menu
)
877 _widget
.set_history(_idx
)
878 if not prefstate
.hasWidgetKey('DIM_PRIMARY_FONT_FAMILY'):
879 prefstate
.setWidget('DIM_PRIMARY_FONT_FAMILY', _widget
)
880 _menu_size_group
.add_widget(_widget
)
881 _fhbox
.pack_start(_widget
, False, False, 5)
883 _fhbox
= gtk
.HBox(False, 5)
884 _fhbox
.set_border_width(5)
885 _fvbox
.pack_start(_fhbox
, False, False, 5)
886 _label
= gtk
.Label(_('Style:'))
887 _label_size_group
.add_widget(_label
)
888 _fhbox
.pack_start(_label
, False, False, 5)
891 _style
= globals.prefs
['DIM_PRIMARY_FONT_STYLE']
892 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
893 _widget
= gtk
.combo_box_new_text()
894 for _i
in range(len(_font_styles
)):
895 _name
= _font_styles
[_i
]
896 if _style
== TextStyle
.getStyleFromString(_name
):
898 _widget
.append_text(_name
)
899 _widget
.set_active(_idx
)
902 for _i
in range(len(_font_styles
)):
903 _name
= _font_styles
[_i
]
904 if _style
== TextStyle
.getStyleFromString(_name
):
906 _item
= gtk
.MenuItem(_name
)
908 _widget
= gtk
.OptionMenu()
909 _widget
.set_menu(_menu
)
910 _widget
.set_history(_idx
)
911 if not prefstate
.hasWidgetKey('DIM_PRIMARY_FONT_STYLE'):
912 prefstate
.setWidget('DIM_PRIMARY_FONT_STYLE', _widget
)
913 _menu_size_group
.add_widget(_widget
)
914 _fhbox
.pack_start(_widget
, False, False, 5)
916 _fhbox
= gtk
.HBox(False, 5)
917 _fhbox
.set_border_width(5)
918 _fvbox
.pack_start(_fhbox
, False, False, 5)
919 _label
= gtk
.Label(_('Weight:'))
920 _label_size_group
.add_widget(_label
)
921 _fhbox
.pack_start(_label
, False, False, 5)
923 _weight
= globals.prefs
['DIM_PRIMARY_FONT_WEIGHT']
924 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
925 _widget
= gtk
.combo_box_new_text()
926 for _i
in range(len(_font_weights
)):
927 _name
= _font_weights
[_i
]
928 if _weight
== TextStyle
.getWeightFromString(_name
):
930 _widget
.append_text(_name
)
931 _widget
.set_active(_idx
)
934 for _i
in range(len(_font_weights
)):
935 _name
=_font_weights
[_i
]
936 if _weight
== TextStyle
.getWeightFromString(_name
):
938 _item
= gtk
.MenuItem(_name
)
940 _widget
= gtk
.OptionMenu()
941 _widget
.set_menu(_menu
)
942 _widget
.set_history(_idx
)
943 if not prefstate
.hasWidgetKey('DIM_PRIMARY_FONT_WEIGHT'):
944 prefstate
.setWidget('DIM_PRIMARY_FONT_WEIGHT', _widget
)
945 _menu_size_group
.add_widget(_widget
)
946 _fhbox
.pack_start(_widget
, False, False, 5)
948 _fhbox
= gtk
.HBox(False, 5)
949 _fhbox
.set_border_width(5)
950 _fvbox
.pack_start(_fhbox
, False, False, 5)
951 _label
= gtk
.Label(_('Alignment:'))
952 _label_size_group
.add_widget(_label
)
953 _fhbox
.pack_start(_label
, False, False, 5)
955 _align
= globals.prefs
['DIM_PRIMARY_TEXT_ALIGNMENT']
956 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
957 _widget
= gtk
.combo_box_new_text()
958 for _i
in range(len(_text_align
)):
959 _name
= _text_align
[_i
]
960 if _align
== TextStyle
.getAlignmentFromString(_name
):
962 _widget
.append_text(_name
)
963 _widget
.set_active(_idx
)
966 for _i
in range(len(_text_align
)):
967 _name
= _text_align
[_i
]
968 if _align
== TextStyle
.getAlignmentFromString(_name
):
970 _item
= gtk
.MenuItem(_name
)
972 _widget
= gtk
.OptionMenu()
973 _widget
.set_menu(_menu
)
974 _widget
.set_history(_idx
)
975 if not prefstate
.hasWidgetKey('DIM_PRIMARY_TEXT_ALIGNMENT'):
976 prefstate
.setWidget('DIM_PRIMARY_TEXT_ALIGNMENT', _widget
)
977 _menu_size_group
.add_widget(_widget
)
978 _fhbox
.pack_start(_widget
, False, False, 5)
980 _fhbox
= gtk
.HBox(False, 5)
981 _fhbox
.set_border_width(5)
982 _fvbox
.pack_start(_fhbox
, False, False, 5)
983 _label
= gtk
.Label(_('Size:'))
984 _label_size_group
.add_widget(_label
)
985 _fhbox
.pack_start(_label
, False, False, 5)
987 _size
= "%f" % globals.prefs
['DIM_PRIMARY_TEXT_SIZE']
988 _entry
.set_text(_size
)
989 if not prefstate
.hasWidgetKey('DIM_PRIMARY_TEXT_SIZE'):
990 prefstate
.setWidget('DIM_PRIMARY_TEXT_SIZE', _entry
)
991 _entry
.connect("activate", entry_activate
)
992 _entry
.connect("focus-out-event",
993 _dim_primary_textsize_entry_focus_out
,
995 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
996 _entry
.set_data('handlerid', _handlerid
)
997 # _entry_size_group.add_widget(_entry)
998 _fhbox
.pack_start(_entry
, False, False, 5)
1000 _fhbox
= gtk
.HBox(False, 5)
1001 _fhbox
.set_border_width(2)
1002 _label
= gtk
.Label(_('Color:'))
1003 _fhbox
.pack_start(_label
, False, False, 5)
1004 _color
= globals.prefs
['DIM_PRIMARY_FONT_COLOR']
1005 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1006 if hasattr(gtk
, 'ColorButton'):
1007 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1008 _button
.set_title(_('Select Primary Dimension Font Color'))
1009 if not prefstate
.hasWidgetKey('DIM_PRIMARY_FONT_COLOR'):
1010 prefstate
.setWidget('DIM_PRIMARY_FONT_COLOR', _button
)
1012 _button
= gtk
.Button()
1013 _bframe
= gtk
.Frame()
1014 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1015 _bframe
.set_border_width(5)
1016 _button
.add(_bframe
)
1017 _da
= gtk
.DrawingArea()
1018 _da
.set_size_request(20, 10)
1019 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1020 if not prefstate
.hasWidgetKey('DIM_PRIMARY_FONT_COLOR'):
1021 prefstate
.setWidget('DIM_PRIMARY_FONT_COLOR', _da
)
1022 _button
.connect("clicked", _select_font_color
)
1024 _fhbox
.pack_start(_button
, False, False, 5)
1025 _fvbox
.pack_start(_fhbox
, True, True, 5)
1026 _vbox
.pack_start(_frame
, False, False, 5)
1028 _frame
= gtk
.Frame(_('Format Options'))
1029 _frame
.set_border_width(2)
1030 _table
= gtk
.Table(3, 1, False)
1031 _table
.set_border_width(5)
1032 _table
.set_row_spacings(5)
1033 _table
.set_col_spacings(5)
1035 _cb
= gtk
.CheckButton(_('Print leading 0'))
1036 _state
= globals.prefs
['DIM_PRIMARY_LEADING_ZERO']
1037 _cb
.set_active(_state
)
1038 if not prefstate
.hasWidgetKey('DIM_PRIMARY_LEADING_ZERO'):
1039 prefstate
.setWidget('DIM_PRIMARY_LEADING_ZERO', _cb
)
1040 _table
.attach(_cb
, 0, 1, 0, 1,
1041 gtk
.FILL | gtk
.EXPAND
,
1042 gtk
.FILL | gtk
.EXPAND
,
1045 _cb
= gtk
.CheckButton(_('Print trailing decimal point'))
1046 _state
= globals.prefs
['DIM_PRIMARY_TRAILING_DECIMAL']
1047 _cb
.set_active(_state
)
1048 if not prefstate
.hasWidgetKey('DIM_PRIMARY_TRAILING_DECIMAL'):
1049 prefstate
.setWidget('DIM_PRIMARY_TRAILING_DECIMAL', _cb
)
1050 _table
.attach(_cb
, 0, 1, 1, 2,
1051 gtk
.FILL | gtk
.EXPAND
,
1052 gtk
.FILL | gtk
.EXPAND
,
1055 _thbox
= gtk
.HBox(False, 5)
1056 _label
= gtk
.Label(_('Display precision:'))
1057 _thbox
.pack_start(_label
, False, False, 5)
1058 _prec
= globals.prefs
['DIM_PRIMARY_PRECISION']
1059 _adj
= gtk
.Adjustment(_prec
, 0, 15, 1, 1, 1)
1060 _sb
= gtk
.SpinButton(_adj
)
1062 _sb
.set_numeric(True)
1063 if not prefstate
.hasWidgetKey('DIM_PRIMARY_PRECISION'):
1064 prefstate
.setWidget('DIM_PRIMARY_PRECISION', _sb
)
1065 _thbox
.pack_start(_sb
, False, False, 5)
1066 _table
.attach(_thbox
, 0, 1, 2, 3,
1067 gtk
.FILL | gtk
.EXPAND
,
1068 gtk
.FILL | gtk
.EXPAND
,
1070 _vbox
.pack_start(_frame
, False, False, 5)
1073 def _make_secondary_opts(prefstate
):
1074 _vbox
= gtk
.VBox(False, 2)
1076 _frame
= gtk
.Frame()
1077 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1078 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Secondary Dimension Options')
1079 _label
= gtk
.Label(_text
)
1080 _label
.set_use_markup(True)
1082 _vbox
.pack_start(_frame
, True, True, 5)
1084 # it would be good to allow the widgets to be used if
1085 # the check box is active ...
1087 _cb
= gtk
.CheckButton(_('Display secondary dimension text'))
1088 _state
= globals.prefs
['DIM_DUAL_MODE']
1089 _cb
.set_active(_state
)
1090 _cb
.connect("toggled", _toggle_secondary_dim_opts
, _vbox
)
1091 if not prefstate
.hasWidgetKey('DIM_DUAL_MODE'):
1092 prefstate
.setWidget('DIM_DUAL_MODE', _cb
)
1093 _vbox
.pack_start(_cb
, False, False, 5)
1095 _frame
= gtk
.Frame(_('Units'))
1096 _frame
.set_border_width(2)
1097 _fhbox
= gtk
.HBox(False, 5)
1098 _fhbox
.set_border_width(2)
1100 _label
= gtk
.Label(_('Secondary dimension units:'))
1101 _fhbox
.pack_start(_label
, False, False, 5)
1103 _units
= units
.get_all_units()
1104 _cur_unit
= globals.prefs
['DIM_SECONDARY_UNITS']
1105 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1106 _widget
= gtk
.combo_box_new_text()
1107 for _i
in range(len(_units
)):
1110 _widget
.append_text(_units
[_i
])
1111 _widget
.set_active(_idx
)
1114 for _i
in range(len(_units
)):
1117 _item
= gtk
.MenuItem(_units
[_i
])
1119 _widget
= gtk
.OptionMenu()
1120 _widget
.set_menu(_menu
)
1121 _widget
.set_history(_idx
)
1122 if not prefstate
.hasWidgetKey('DIM_SECONDARY_UNITS'):
1123 prefstate
.setWidget('DIM_SECONDARY_UNITS', _widget
)
1124 _fhbox
.pack_start(_widget
, False, False, 5)
1125 _vbox
.pack_start(_frame
, False, False, 5)
1127 _label_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1128 _menu_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1130 _frame
= gtk
.Frame(_('Font Properties'))
1131 _frame
.set_border_width(2)
1132 _fvbox
= gtk
.VBox(False, 5)
1133 _fvbox
.set_border_width(2)
1135 _fhbox
= gtk
.HBox(False, 5)
1136 _fhbox
.set_border_width(5)
1137 _fvbox
.pack_start(_fhbox
, False, False, 5)
1138 _label
= gtk
.Label(_('Family:'))
1139 _label_size_group
.add_widget(_label
)
1140 _fhbox
.pack_start(_label
, False, False, 5)
1141 _families
= prefstate
.getFamilies()
1142 if _families
is None:
1144 _window
= prefstate
.getWindow()
1145 for _family
in _window
.get_pango_context().list_families():
1146 _families
.append(_family
.get_name())
1148 prefstate
.setFamilies(_families
)
1150 _family
= globals.prefs
['DIM_SECONDARY_FONT_FAMILY']
1151 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1152 _widget
= gtk
.combo_box_new_text()
1153 for _i
in range(len(_families
)):
1157 _widget
.append_text(_f
)
1158 _widget
.set_active(_idx
)
1161 for _i
in range(len(_families
)):
1165 _item
= gtk
.MenuItem(_f
)
1167 _widget
= gtk
.OptionMenu()
1168 _widget
.set_menu(_menu
)
1169 _widget
.set_history(_idx
)
1170 if not prefstate
.hasWidgetKey('DIM_SECONDARY_FONT_FAMILY'):
1171 prefstate
.setWidget('DIM_SECONDARY_FONT_FAMILY', _widget
)
1172 _menu_size_group
.add_widget(_widget
)
1173 _fhbox
.pack_start(_widget
, False, False, 5)
1175 _fhbox
= gtk
.HBox(False, 5)
1176 _fhbox
.set_border_width(5)
1177 _fvbox
.pack_start(_fhbox
, False, False, 5)
1178 _label
= gtk
.Label(_('Style:'))
1179 _label_size_group
.add_widget(_label
)
1180 _fhbox
.pack_start(_label
, False, False, 5)
1182 _style
= globals.prefs
['DIM_SECONDARY_FONT_STYLE']
1183 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1184 _widget
= gtk
.combo_box_new_text()
1185 for _i
in range(len(_font_styles
)):
1186 _name
= _font_styles
[_i
]
1187 if _style
== TextStyle
.getStyleFromString(_name
):
1189 _widget
.append_text(_name
)
1190 _widget
.set_active(_idx
)
1193 for _i
in range(len(_font_styles
)):
1194 _name
= _font_styles
[_i
]
1195 if _style
== TextStyle
.getStyleFromString(_name
):
1197 _item
= gtk
.MenuItem(_name
)
1199 _widget
= gtk
.OptionMenu()
1200 _widget
.set_menu(_menu
)
1201 _widget
.set_history(_idx
)
1202 if not prefstate
.hasWidgetKey('DIM_SECONDARY_FONT_STYLE'):
1203 prefstate
.setWidget('DIM_SECONDARY_FONT_STYLE', _widget
)
1204 _menu_size_group
.add_widget(_widget
)
1205 _fhbox
.pack_start(_widget
, False, False, 5)
1207 _fhbox
= gtk
.HBox(False, 5)
1208 _fhbox
.set_border_width(5)
1209 _fvbox
.pack_start(_fhbox
, False, False, 5)
1210 _label
= gtk
.Label(_('Weight:'))
1211 _label_size_group
.add_widget(_label
)
1212 _fhbox
.pack_start(_label
, False, False, 5)
1214 _weight
= globals.prefs
['DIM_SECONDARY_FONT_WEIGHT']
1215 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1216 _widget
= gtk
.combo_box_new_text()
1217 for _i
in range(len(_font_weights
)):
1218 _name
= _font_weights
[_i
]
1219 if _weight
== TextStyle
.getWeightFromString(_name
):
1221 _widget
.append_text(_name
)
1222 _widget
.set_active(_idx
)
1225 for _i
in range(len(_font_weights
)):
1226 _name
= _font_weights
[_i
]
1227 if _weight
== TextStyle
.getWeightFromString(_name
):
1229 _item
= gtk
.MenuItem(_name
)
1231 _widget
= gtk
.OptionMenu()
1232 _widget
.set_menu(_menu
)
1233 _widget
.set_history(_idx
)
1234 if not prefstate
.hasWidgetKey('DIM_SECONDARY_FONT_WEIGHT'):
1235 prefstate
.setWidget('DIM_SECONDARY_FONT_WEIGHT', _widget
)
1236 _menu_size_group
.add_widget(_widget
)
1237 _fhbox
.pack_start(_widget
, False, False, 5)
1239 _fhbox
= gtk
.HBox(False, 5)
1240 _fhbox
.set_border_width(5)
1241 _fvbox
.pack_start(_fhbox
, False, False, 5)
1242 _label
= gtk
.Label(_('Alignment:'))
1243 _label_size_group
.add_widget(_label
)
1244 _fhbox
.pack_start(_label
, False, False, 5)
1246 _align
= globals.prefs
['DIM_SECONDARY_TEXT_ALIGNMENT']
1247 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1248 _widget
= gtk
.combo_box_new_text()
1249 for _i
in range(len(_text_align
)):
1250 _name
= _text_align
[_i
]
1251 if _align
== TextStyle
.getAlignmentFromString(_name
):
1253 _widget
.append_text(_name
)
1254 _widget
.set_active(_idx
)
1257 for _i
in range(len(_text_align
)):
1258 _name
= _text_align
[_i
]
1259 if _align
== TextStyle
.getAlignmentFromString(_name
):
1261 _item
= gtk
.MenuItem(_name
)
1263 _widget
= gtk
.OptionMenu()
1264 _widget
.set_menu(_menu
)
1265 _widget
.set_history(_idx
)
1266 if not prefstate
.hasWidgetKey('DIM_SECONDARY_TEXT_ALIGNMENT'):
1267 prefstate
.setWidget('DIM_SECONDARY_TEXT_ALIGNMENT', _widget
)
1268 _menu_size_group
.add_widget(_widget
)
1269 _fhbox
.pack_start(_widget
, False, False, 5)
1271 _fhbox
= gtk
.HBox(False, 5)
1272 _fhbox
.set_border_width(5)
1273 _fvbox
.pack_start(_fhbox
, False, False, 5)
1274 _label
= gtk
.Label(_('Size:'))
1275 _label_size_group
.add_widget(_label
)
1276 _fhbox
.pack_start(_label
, False, False, 5)
1277 _entry
= gtk
.Entry()
1278 _size
= "%f" % globals.prefs
['DIM_SECONDARY_TEXT_SIZE']
1279 _entry
.set_text(_size
)
1280 if not prefstate
.hasWidgetKey('DIM_SECONDARY_TEXT_SIZE'):
1281 prefstate
.setWidget('DIM_SECONDARY_TEXT_SIZE', _entry
)
1282 _entry
.connect("activate", entry_activate
)
1283 _entry
.connect("focus-out-event",
1284 _dim_secondary_textsize_entry_focus_out
,
1286 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
1287 _entry
.set_data('handlerid', _handlerid
)
1288 # _entry_size_group.add_widget(_entry)
1289 _fhbox
.pack_start(_entry
, False, False, 5)
1291 _fhbox
= gtk
.HBox(False, 5)
1292 _fhbox
.set_border_width(2)
1293 _label
= gtk
.Label(_('Color:'))
1294 _fhbox
.pack_start(_label
, False, False, 5)
1295 _color
= globals.prefs
['DIM_SECONDARY_FONT_COLOR']
1296 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1297 if hasattr(gtk
, 'ColorButton'):
1298 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1299 _button
.set_title(_('Select Secondary Dimension Font Color'))
1300 if not prefstate
.hasWidgetKey('DIM_SECONDARY_FONT_COLOR'):
1301 prefstate
.setWidget('DIM_SECONDARY_FONT_COLOR', _button
)
1303 _button
= gtk
.Button()
1304 _bframe
= gtk
.Frame()
1305 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1306 _bframe
.set_border_width(5)
1307 _button
.add(_bframe
)
1308 _da
= gtk
.DrawingArea()
1309 _da
.set_size_request(20, 10)
1310 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1311 if not prefstate
.hasWidgetKey('DIM_SECONDARY_FONT_COLOR'):
1312 prefstate
.setWidget('DIM_SECONDARY_FONT_COLOR', _da
)
1313 _button
.connect("clicked", _select_font_color
)
1315 _fhbox
.pack_start(_button
, False, False, 5)
1316 _fvbox
.pack_start(_fhbox
, True, True, 5)
1317 _vbox
.pack_start(_frame
, False, False, 5)
1319 _frame
= gtk
.Frame(_('Format Options'))
1320 _frame
.set_border_width(2)
1321 _table
= gtk
.Table(3, 1, False)
1322 _table
.set_border_width(5)
1323 _table
.set_row_spacings(5)
1324 _table
.set_col_spacings(5)
1326 _cb
= gtk
.CheckButton(_('Print leading 0'))
1327 _state
= globals.prefs
['DIM_SECONDARY_LEADING_ZERO']
1328 _cb
.set_active(_state
)
1329 if not prefstate
.hasWidgetKey('DIM_SECONDARY_LEADING_ZERO'):
1330 prefstate
.setWidget('DIM_SECONDARY_LEADING_ZERO', _cb
)
1331 _table
.attach(_cb
, 0, 1, 0, 1,
1332 gtk
.FILL | gtk
.EXPAND
,
1333 gtk
.FILL | gtk
.EXPAND
,
1336 _cb
= gtk
.CheckButton(_('Print trailing decimal point'))
1337 _state
= globals.prefs
['DIM_SECONDARY_TRAILING_DECIMAL']
1338 _cb
.set_active(_state
)
1339 if not prefstate
.hasWidgetKey('DIM_SECONDARY_TRAILING_DECIMAL'):
1340 prefstate
.setWidget('DIM_SECONDARY_TRAILING_DECIMAL', _cb
)
1341 _table
.attach(_cb
, 0, 1, 1, 2,
1342 gtk
.FILL | gtk
.EXPAND
,
1343 gtk
.FILL | gtk
.EXPAND
,
1346 _thbox
= gtk
.HBox(False, 5)
1347 _label
= gtk
.Label(_('Display precision:'))
1348 _thbox
.pack_start(_label
, False, False, 5)
1349 _prec
= globals.prefs
['DIM_SECONDARY_PRECISION']
1350 _adj
= gtk
.Adjustment(_prec
, 0, 15, 1, 1, 1)
1351 _sb
= gtk
.SpinButton(_adj
)
1353 _sb
.set_numeric(True)
1354 if not prefstate
.hasWidgetKey('DIM_SECONDARY_PRECISION'):
1355 prefstate
.setWidget('DIM_SECONDARY_PRECISION', _sb
)
1356 _thbox
.pack_start(_sb
, False, False, 5)
1357 _table
.attach(_thbox
, 0, 1, 2, 3,
1358 gtk
.FILL | gtk
.EXPAND
,
1359 gtk
.FILL | gtk
.EXPAND
,
1361 _vbox
.pack_start(_frame
, False, False, 5)
1362 _cb
= prefstate
.getWidget('DIM_DUAL_MODE')
1366 def _make_linear_opts(prefstate
):
1367 _vbox
= gtk
.VBox(False, 5)
1369 _frame
= gtk
.Frame()
1370 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1372 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Linear Dimension Options')
1373 _label
= gtk
.Label(_text
)
1374 _label
.set_use_markup(True)
1376 _vbox
.pack_start(_frame
, False, False, 5)
1378 _size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1380 _frame
= gtk
.Frame(_('Primary Dimension Text Options'))
1381 _table
= gtk
.Table(2, 2, False)
1382 _table
.set_border_width(5)
1383 _table
.set_row_spacings(5)
1384 _table
.set_col_spacings(5)
1386 _label
= gtk
.Label(_('Default prefix:'))
1387 _table
.attach(_label
, 0, 1, 0, 1,
1391 _entry
= gtk
.Entry()
1392 _entry
.set_text(globals.prefs
['DIM_PRIMARY_PREFIX'])
1393 _size_group
.add_widget(_entry
)
1394 if not prefstate
.hasWidgetKey('DIM_PRIMARY_PREFIX'):
1395 prefstate
.setWidget('DIM_PRIMARY_PREFIX', _entry
)
1396 _table
.attach(_entry
, 1, 2, 0, 1,
1397 gtk
.FILL | gtk
.EXPAND
,
1398 gtk
.FILL | gtk
.EXPAND
,
1400 _label
= gtk
.Label(_('Default suffix:'))
1401 _table
.attach(_label
, 0, 1, 1, 2,
1405 _entry
= gtk
.Entry()
1406 _entry
.set_text(globals.prefs
['DIM_PRIMARY_SUFFIX'])
1407 _size_group
.add_widget(_entry
)
1408 if not prefstate
.hasWidgetKey('DIM_PRIMARY_SUFFIX'):
1409 prefstate
.setWidget('DIM_PRIMARY_SUFFIX', _entry
)
1410 _table
.attach(_entry
, 1, 2, 1, 2,
1411 gtk
.FILL | gtk
.EXPAND
,
1412 gtk
.FILL | gtk
.EXPAND
,
1414 _vbox
.pack_start(_frame
, False, False, 5)
1416 _frame
= gtk
.Frame(_('Secondary Dimension Text Options'))
1417 _table
= gtk
.Table(2, 2, False)
1418 _table
.set_border_width(5)
1419 _table
.set_row_spacings(5)
1420 _table
.set_col_spacings(5)
1422 if not prefstate
.hasWidgetKey('LINEAR_SECONDARY_FRAME'):
1423 prefstate
.setWidget('LINEAR_SECONDARY_FRAME', _frame
)
1424 _label
= gtk
.Label(_('Default prefix:'))
1425 _table
.attach(_label
, 0, 1, 0, 1,
1429 _entry
= gtk
.Entry()
1430 _entry
.set_text(globals.prefs
['DIM_SECONDARY_PREFIX'])
1431 _size_group
.add_widget(_entry
)
1432 if not prefstate
.hasWidgetKey('DIM_SECONDARY_PREFIX'):
1433 prefstate
.setWidget('DIM_SECONDARY_PREFIX', _entry
)
1434 _table
.attach(_entry
, 1, 2, 0, 1,
1435 gtk
.FILL | gtk
.EXPAND
,
1436 gtk
.FILL | gtk
.EXPAND
,
1438 _label
= gtk
.Label(_('Default suffix:'))
1439 _table
.attach(_label
, 0, 1, 1, 2,
1443 _entry
= gtk
.Entry()
1444 _entry
.set_text(globals.prefs
['DIM_SECONDARY_SUFFIX'])
1445 _size_group
.add_widget(_entry
)
1446 if not prefstate
.hasWidgetKey('DIM_SECONDARY_SUFFIX'):
1447 prefstate
.setWidget('DIM_SECONDARY_SUFFIX', _entry
)
1448 _table
.attach(_entry
, 1, 2, 1, 2,
1449 gtk
.FILL | gtk
.EXPAND
,
1450 gtk
.FILL | gtk
.EXPAND
,
1452 _vbox
.pack_start(_frame
, False, False, 5)
1455 def _make_radial_opts(prefstate
):
1456 _vbox
= gtk
.VBox(False, 5)
1458 _frame
= gtk
.Frame()
1459 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1461 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Radial Dimension Options')
1462 _label
= gtk
.Label(_text
)
1463 _label
.set_use_markup(True)
1465 _vbox
.pack_start(_frame
, False, False, 5)
1467 _size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1469 _frame
= gtk
.Frame(_('Primary Dimension Text Options'))
1470 _table
= gtk
.Table(2, 2, False)
1471 _table
.set_border_width(5)
1472 _table
.set_row_spacings(5)
1473 _table
.set_col_spacings(5)
1475 _label
= gtk
.Label(_('Default prefix:'))
1476 _table
.attach(_label
, 0, 1, 0, 1,
1480 _entry
= gtk
.Entry()
1481 _entry
.set_text(globals.prefs
['RADIAL_DIM_PRIMARY_PREFIX'])
1482 _size_group
.add_widget(_entry
)
1483 if not prefstate
.hasWidgetKey('RADIAL_DIM_PRIMARY_PREFIX'):
1484 prefstate
.setWidget('RADIAL_DIM_PRIMARY_PREFIX', _entry
)
1485 _table
.attach(_entry
, 1, 2, 0, 1,
1486 gtk
.FILL | gtk
.EXPAND
,
1487 gtk
.FILL | gtk
.EXPAND
,
1489 _label
= gtk
.Label(_('Default suffix:'))
1490 _table
.attach(_label
, 0, 1, 1, 2,
1494 _entry
= gtk
.Entry()
1495 _entry
.set_text(globals.prefs
['RADIAL_DIM_PRIMARY_SUFFIX'])
1496 _size_group
.add_widget(_entry
)
1497 if not prefstate
.hasWidgetKey('RADIAL_DIM_PRIMARY_SUFFIX'):
1498 prefstate
.setWidget('RADIAL_DIM_PRIMARY_SUFFIX', _entry
)
1499 _table
.attach(_entry
, 1, 2, 1, 2,
1500 gtk
.FILL | gtk
.EXPAND
,
1501 gtk
.FILL | gtk
.EXPAND
,
1503 _vbox
.pack_start(_frame
, False, False, 5)
1505 _frame
= gtk
.Frame(_('Secondary Dimension Text Options'))
1506 _table
= gtk
.Table(2, 2, False)
1507 _table
.set_border_width(5)
1508 _table
.set_row_spacings(5)
1509 _table
.set_col_spacings(5)
1511 if not prefstate
.hasWidgetKey('RADIAL_SECONDARY_FRAME'):
1512 prefstate
.setWidget('RADIAL_SECONDARY_FRAME', _frame
)
1513 _label
= gtk
.Label(_('Default prefix:'))
1514 _table
.attach(_label
, 0, 1, 0, 1,
1518 _entry
= gtk
.Entry()
1519 _entry
.set_text(globals.prefs
['RADIAL_DIM_SECONDARY_PREFIX'])
1520 _size_group
.add_widget(_entry
)
1521 if not prefstate
.hasWidgetKey('RADIAL_DIM_SECONDARY_PREFIX'):
1522 prefstate
.setWidget('RADIAL_DIM_SECONDARY_PREFIX', _entry
)
1523 _table
.attach(_entry
, 1, 2, 0, 1,
1524 gtk
.FILL | gtk
.EXPAND
,
1525 gtk
.FILL | gtk
.EXPAND
,
1527 _label
= gtk
.Label(_('Default suffix:'))
1528 _table
.attach(_label
, 0, 1, 1, 2,
1532 _entry
= gtk
.Entry()
1533 _entry
.set_text(globals.prefs
['RADIAL_DIM_SECONDARY_SUFFIX'])
1534 _size_group
.add_widget(_entry
)
1535 if not prefstate
.hasWidgetKey('RADIAL_DIM_SECONDARY_SUFFIX'):
1536 prefstate
.setWidget('RADIAL_DIM_SECONDARY_SUFFIX', _entry
)
1537 _table
.attach(_entry
, 1, 2, 1, 2,
1538 gtk
.FILL | gtk
.EXPAND
,
1539 gtk
.FILL | gtk
.EXPAND
,
1541 _vbox
.pack_start(_frame
, False, False, 5)
1543 _cb
= gtk
.CheckButton(_('Show diametrical dimension value'))
1544 _state
= globals.prefs
['RADIAL_DIM_DIA_MODE']
1545 _cb
.set_active(_state
)
1546 if not prefstate
.hasWidgetKey('RADIAL_DIM_DIA_MODE'):
1547 prefstate
.setWidget('RADIAL_DIM_DIA_MODE', _cb
)
1548 _vbox
.pack_start(_cb
, False, False, 5)
1551 def _make_angular_opts(prefstate
):
1552 _vbox
= gtk
.VBox(False, 5)
1554 _frame
= gtk
.Frame()
1555 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1557 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Angular Dimension Options')
1558 _label
= gtk
.Label(_text
)
1559 _label
.set_use_markup(True)
1561 _vbox
.pack_start(_frame
, False, False, 5)
1563 _size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1565 _frame
= gtk
.Frame(_('Primary Dimension Text Options'))
1566 _table
= gtk
.Table(2, 2, False)
1567 _table
.set_border_width(5)
1568 _table
.set_row_spacings(5)
1569 _table
.set_col_spacings(5)
1571 _label
= gtk
.Label(_('Default prefix:'))
1572 _table
.attach(_label
, 0, 1, 0, 1,
1576 _entry
= gtk
.Entry()
1577 _entry
.set_text(globals.prefs
['ANGULAR_DIM_PRIMARY_PREFIX'])
1578 _size_group
.add_widget(_entry
)
1579 if not prefstate
.hasWidgetKey('ANGULAR_DIM_PRIMARY_PREFIX'):
1580 prefstate
.setWidget('ANGULAR_DIM_PRIMARY_PREFIX', _entry
)
1581 _table
.attach(_entry
, 1, 2, 0, 1,
1582 gtk
.FILL | gtk
.EXPAND
,
1583 gtk
.FILL | gtk
.EXPAND
,
1585 _label
= gtk
.Label(_('Default suffix:'))
1586 _table
.attach(_label
, 0, 1, 1, 2,
1590 _entry
= gtk
.Entry()
1591 _entry
.set_text(globals.prefs
['ANGULAR_DIM_PRIMARY_SUFFIX'])
1592 _size_group
.add_widget(_entry
)
1593 if not prefstate
.hasWidgetKey('ANGULAR_DIM_PRIMARY_SUFFIX'):
1594 prefstate
.setWidget('ANGULAR_DIM_PRIMARY_SUFFIX', _entry
)
1595 _table
.attach(_entry
, 1, 2, 1, 2,
1596 gtk
.FILL | gtk
.EXPAND
,
1597 gtk
.FILL | gtk
.EXPAND
,
1599 _vbox
.pack_start(_frame
, False, False, 5)
1601 _frame
= gtk
.Frame(_('Secondary Dimension Text Options'))
1602 _table
= gtk
.Table(2, 2, False)
1603 _table
.set_border_width(5)
1604 _table
.set_row_spacings(5)
1605 _table
.set_col_spacings(5)
1607 if not prefstate
.hasWidgetKey('ANGULAR_SECONDARY_FRAME'):
1608 prefstate
.setWidget('ANGULAR_SECONDARY_FRAME', _frame
)
1609 _label
= gtk
.Label(_('Default prefix:'))
1610 _table
.attach(_label
, 0, 1, 0, 1,
1614 _entry
= gtk
.Entry()
1615 _entry
.set_text(globals.prefs
['ANGULAR_DIM_SECONDARY_PREFIX'])
1616 _size_group
.add_widget(_entry
)
1617 if not prefstate
.hasWidgetKey('ANGULAR_DIM_SECONDARY_PREFIX'):
1618 prefstate
.setWidget('ANGULAR_DIM_SECONDARY_PREFIX', _entry
)
1619 _table
.attach(_entry
, 1, 2, 0, 1,
1620 gtk
.FILL | gtk
.EXPAND
,
1621 gtk
.FILL | gtk
.EXPAND
,
1623 _label
= gtk
.Label(_('Default suffix:'))
1624 _table
.attach(_label
, 0, 1, 1, 2,
1628 _entry
= gtk
.Entry()
1629 _entry
.set_text(globals.prefs
['ANGULAR_DIM_SECONDARY_SUFFIX'])
1630 _size_group
.add_widget(_entry
)
1631 if not prefstate
.hasWidgetKey('ANGULAR_DIM_SECONDARY_SUFFIX'):
1632 prefstate
.setWidget('ANGULAR_DIM_SECONDARY_SUFFIX', _entry
)
1633 _table
.attach(_entry
, 1, 2, 1, 2,
1634 gtk
.FILL | gtk
.EXPAND
,
1635 gtk
.FILL | gtk
.EXPAND
,
1637 _vbox
.pack_start(_frame
, False, False, 5)
1640 def _make_basic_opts(prefstate
):
1641 _vbox
= gtk
.VBox(False, 5)
1643 _frame
= gtk
.Frame()
1644 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1646 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Basic Options')
1647 _label
= gtk
.Label(_text
)
1648 _label
.set_use_markup(True)
1650 _vbox
.pack_start(_frame
, False, False, 5)
1652 _frame
= gtk
.Frame(_('Units'))
1653 _fhbox
= gtk
.HBox(False, 5)
1654 _fhbox
.set_border_width(5)
1656 _label
= gtk
.Label(_('Drawing units:'))
1657 _fhbox
.pack_start(_label
, False, False, 5)
1658 _unit_list
= units
.get_all_units()
1659 _cur_unit
= globals.prefs
['UNITS']
1661 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1662 _widget
= gtk
.combo_box_new_text()
1663 for _i
in range(len(_unit_list
)):
1666 _widget
.append_text(_unit_list
[_i
])
1667 _widget
.set_active(_idx
)
1670 for _i
in range(len(_unit_list
)):
1673 _item
= gtk
.MenuItem(_unit_list
[_i
])
1675 _widget
= gtk
.OptionMenu()
1676 _widget
.set_menu(_menu
)
1677 _widget
.set_history(_idx
)
1678 if not prefstate
.hasWidgetKey('DRAWING_UNITS'):
1679 prefstate
.setWidget('DRAWING_UNITS', _widget
)
1680 _fhbox
.pack_start(_widget
, False, False, 5)
1681 _vbox
.pack_start(_frame
, False, False, 5)
1683 _frame
= gtk
.Frame(_('Highlight Points'))
1684 _fhbox
= gtk
.HBox(False, 5)
1685 _fhbox
.set_border_width(5)
1687 _cb
= gtk
.CheckButton(_('Boxes are drawn around Point objects'))
1688 _state
= globals.prefs
['HIGHLIGHT_POINTS']
1689 _cb
.set_active(_state
)
1690 if not prefstate
.hasWidgetKey('HIGHLIGHT_POINTS'):
1691 prefstate
.setWidget('HIGHLIGHT_POINTS', _cb
)
1692 _fhbox
.pack_start(_cb
, False, False, 5)
1693 _vbox
.pack_start(_frame
, False, False, 5)
1695 _frame
= gtk
.Frame(_('Autosplitting'))
1696 _fhbox
= gtk
.HBox(False, 5)
1697 _fhbox
.set_border_width(5)
1699 _cb
= gtk
.CheckButton(_('New Points split existing entities'))
1700 _state
= globals.prefs
['AUTOSPLIT']
1701 _cb
.set_active(_state
)
1702 if not prefstate
.hasWidgetKey('AUTOSPLIT'):
1703 prefstate
.setWidget('AUTOSPLIT', _cb
)
1704 _fhbox
.pack_start(_cb
, False, False, 5)
1705 _vbox
.pack_start(_frame
, False, False, 5)
1707 _frame
= gtk
.Frame(_('Colors'))
1708 _table
= gtk
.Table(4, 2, False)
1709 _table
.set_border_width(5)
1710 _table
.set_row_spacings(5)
1711 _table
.set_col_spacings(5)
1713 _label
= gtk
.Label(_('Drawing area color:'))
1714 _table
.attach(_label
, 0, 1, 0, 1,
1718 _color
= globals.prefs
['BACKGROUND_COLOR']
1719 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1720 if hasattr(gtk
, 'ColorButton'):
1721 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1722 _button
.set_title(_('Select Background Color'))
1723 if not prefstate
.hasWidgetKey('BACKGROUND_COLOR'):
1724 prefstate
.setWidget('BACKGROUND_COLOR', _button
)
1726 _button
= gtk
.Button()
1727 _bframe
= gtk
.Frame()
1728 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1729 _bframe
.set_border_width(5)
1730 _button
.add(_bframe
)
1731 _da
= gtk
.DrawingArea()
1732 _da
.set_size_request(20, 10)
1733 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1734 if not prefstate
.hasWidgetKey('BACKGROUND_COLOR'):
1735 prefstate
.setWidget('BACKGROUND_COLOR', _da
)
1737 _button
.connect("clicked", _select_background_color
)
1738 _table
.attach(_button
, 1, 2, 0, 1,
1743 _label
= gtk
.Label(_('Inactive layer color:'))
1744 _table
.attach(_label
, 0, 1, 1, 2,
1748 _color
= globals.prefs
['INACTIVE_LAYER_COLOR']
1749 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1750 if hasattr(gtk
, 'ColorButton'):
1751 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1752 _button
.set_title(_('Select Inactive Layer Color'))
1753 if not prefstate
.hasWidgetKey('INACTIVE_LAYER_COLOR'):
1754 prefstate
.setWidget('INACTIVE_LAYER_COLOR', _button
)
1756 _button
= gtk
.Button()
1757 _bframe
= gtk
.Frame()
1758 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1759 _bframe
.set_border_width(5)
1760 _button
.add(_bframe
)
1761 _da
= gtk
.DrawingArea()
1762 _da
.set_size_request(20, 10)
1763 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1764 if not prefstate
.hasWidgetKey('INACTIVE_LAYER_COLOR'):
1765 prefstate
.setWidget('INACTIVE_LAYER_COLOR', _da
)
1767 _button
.connect("clicked", _select_background_color
)
1768 _table
.attach(_button
, 1, 2, 1, 2,
1773 _label
= gtk
.Label(_('Single point color:'))
1774 _table
.attach(_label
, 0, 1, 2, 3,
1778 _color
= globals.prefs
['SINGLE_POINT_COLOR']
1779 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1780 if hasattr(gtk
, 'ColorButton'):
1781 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1782 _button
.set_title(_('Select Single Use Point Outline Color'))
1783 if not prefstate
.hasWidgetKey('SINGLE_POINT_COLOR'):
1784 prefstate
.setWidget('SINGLE_POINT_COLOR', _button
)
1786 _button
= gtk
.Button()
1787 _bframe
= gtk
.Frame()
1788 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1789 _bframe
.set_border_width(5)
1790 _button
.add(_bframe
)
1791 _da
= gtk
.DrawingArea()
1792 _da
.set_size_request(20, 10)
1793 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1794 if not prefstate
.hasWidgetKey('SINGLE_POINT_COLOR'):
1795 prefstate
.setWidget('SINGLE_POINT_COLOR', _da
)
1797 _button
.connect("clicked", _select_background_color
)
1798 _table
.attach(_button
, 1, 2, 2, 3,
1803 _label
= gtk
.Label(_('Multi point color:'))
1804 _table
.attach(_label
, 0, 1, 3, 4,
1808 _color
= globals.prefs
['MULTI_POINT_COLOR']
1809 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
1810 if hasattr(gtk
, 'ColorButton'):
1811 _button
= gtk
.ColorButton(color
=_gtkcolor
)
1812 _button
.set_title(_('Select Multi-Use Point Outline Color'))
1813 if not prefstate
.hasWidgetKey('MULTI_POINT_COLOR'):
1814 prefstate
.setWidget('MULTI_POINT_COLOR', _button
)
1816 _button
= gtk
.Button()
1817 _bframe
= gtk
.Frame()
1818 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
1819 _bframe
.set_border_width(5)
1820 _button
.add(_bframe
)
1821 _da
= gtk
.DrawingArea()
1822 _da
.set_size_request(20, 10)
1823 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
1824 if not prefstate
.hasWidgetKey('MULTI_POINT_COLOR'):
1825 prefstate
.setWidget('MULTI_POINT_COLOR', _da
)
1827 _button
.connect("clicked", _select_background_color
)
1828 _table
.attach(_button
, 1, 2, 3, 4,
1833 _vbox
.pack_start(_frame
, False, False, 5)
1834 _size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1836 _frame
= gtk
.Frame(_('Line Thickness'))
1837 _fhbox
= gtk
.HBox(False, 5)
1838 _fhbox
.set_border_width(5)
1840 _label
= gtk
.Label(_('Thickness:'))
1841 _fhbox
.pack_start(_label
, False, False, 5)
1842 _entry
= gtk
.Entry()
1843 _thickness
= "%f" % globals.prefs
['LINE_THICKNESS']
1844 _entry
.set_text(_thickness
)
1845 if not prefstate
.hasWidgetKey('LINE_THICKNESS'):
1846 prefstate
.setWidget('LINE_THICKNESS', _entry
)
1847 _entry
.connect("activate", entry_activate
)
1848 _entry
.connect("focus-out-event", _thickness_entry_focus_out
, prefstate
)
1849 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
1850 _entry
.set_data('handlerid', _handlerid
)
1851 _size_group
.add_widget(_entry
)
1852 _fhbox
.pack_start(_entry
, False, False, 5)
1853 _vbox
.pack_start(_frame
, False, False, 5)
1856 def _make_size_opts(prefstate
):
1857 _vbox
= gtk
.VBox(False, 5)
1859 _frame
= gtk
.Frame()
1860 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1862 _label_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1863 _entry_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1865 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Size Options')
1866 _label
= gtk
.Label(_text
)
1867 _label
.set_use_markup(True)
1869 _vbox
.pack_start(_frame
, False, False, 5)
1871 # leader line arrow size
1873 _frame
= gtk
.Frame(_('Leader Arrow Size'))
1874 _fhbox
= gtk
.HBox(False, 5)
1875 _fhbox
.set_border_width(5)
1877 _label
= gtk
.Label(_('Size:'))
1878 _label_size_group
.add_widget(_label
)
1879 _fhbox
.pack_start(_label
, False, False, 5)
1880 _entry
= gtk
.Entry()
1881 _arrowsize
= "%f" % globals.prefs
['LEADER_ARROW_SIZE']
1882 _entry
.set_text(_arrowsize
)
1883 if not prefstate
.hasWidgetKey('LEADER_ARROW_SIZE'):
1884 prefstate
.setWidget('LEADER_ARROW_SIZE', _entry
)
1885 _entry
.connect("activate", entry_activate
)
1886 _entry
.connect("focus-out-event", _leader_entry_focus_out
, prefstate
)
1887 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
1888 _entry
.set_data('handlerid', _handlerid
)
1889 _entry_size_group
.add_widget(_entry
)
1890 _fhbox
.pack_start(_entry
, False, False, 5)
1891 _vbox
.pack_start(_frame
, False, False, 5)
1895 _frame
= gtk
.Frame(_('Chamfer Length'))
1896 _fhbox
= gtk
.HBox(False, 5)
1897 _fhbox
.set_border_width(5)
1900 _label
= gtk
.Label(_('Length:'))
1901 _label_size_group
.add_widget(_label
)
1902 _fhbox
.pack_start(_label
, False, False, 5)
1903 _entry
= gtk
.Entry()
1904 _length
= "%f" % globals.prefs
['CHAMFER_LENGTH']
1905 _entry
.set_text(_length
)
1906 if not prefstate
.hasWidgetKey('CHAMFER_LENGTH'):
1907 prefstate
.setWidget('CHAMFER_LENGTH', _entry
)
1908 _entry
.connect("activate", entry_activate
)
1909 _entry
.connect("focus-out-event", _chamfer_entry_focus_out
, prefstate
)
1910 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
1911 _entry
.set_data('handlerid', _handlerid
)
1912 _entry_size_group
.add_widget(_entry
)
1913 _fhbox
.pack_start(_entry
, False, False, 5)
1914 _vbox
.pack_start(_frame
, False, False, 5)
1918 _frame
= gtk
.Frame(_('Fillet Radius'))
1919 _fhbox
= gtk
.HBox(False, 5)
1920 _fhbox
.set_border_width(5)
1923 _label
= gtk
.Label(_('Radius:'))
1924 _label_size_group
.add_widget(_label
)
1925 _fhbox
.pack_start(_label
, False, False, 5)
1926 _entry
= gtk
.Entry()
1927 _radius
= "%f" % globals.prefs
['FILLET_RADIUS']
1928 _entry
.set_text(_radius
)
1929 if not prefstate
.hasWidgetKey('FILLET_RADIUS'):
1930 prefstate
.setWidget('FILLET_RADIUS', _entry
)
1931 _entry
.connect("activate", entry_activate
)
1932 _entry
.connect("focus-out-event", _fillet_entry_focus_out
, prefstate
)
1933 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
1934 _entry
.set_data('handlerid', _handlerid
)
1935 _entry_size_group
.add_widget(_entry
)
1936 _fhbox
.pack_start(_entry
, False, False, 5)
1937 _vbox
.pack_start(_frame
, False, False, 5)
1940 def _make_text_opts(prefstate
):
1941 _vbox
= gtk
.VBox(False, 5)
1943 _frame
= gtk
.Frame()
1944 _frame
.set_shadow_type(gtk
.SHADOW_IN
)
1946 _text
= "<span weight='bold' size='16000'>%s</span>" % _('Text Options')
1947 _label
= gtk
.Label(_text
)
1948 _label
.set_use_markup(True)
1950 _vbox
.pack_start(_frame
, False, False, 5)
1952 _label_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1953 _menu_size_group
= gtk
.SizeGroup(gtk
.SIZE_GROUP_HORIZONTAL
)
1955 _frame
= gtk
.Frame(_('Font Properties'))
1956 _frame
.set_border_width(5)
1957 _fvbox
= gtk
.VBox(False, 5)
1960 _fhbox
= gtk
.HBox(False, 5)
1961 _fhbox
.set_border_width(5)
1962 _fvbox
.pack_start(_fhbox
, False, False, 5)
1963 _label
= gtk
.Label(_('Family:'))
1964 _label_size_group
.add_widget(_label
)
1965 _fhbox
.pack_start(_label
, False, False, 5)
1966 _families
= prefstate
.getFamilies()
1967 if _families
is None:
1969 _window
= prefstate
.getWindow()
1970 for _family
in _window
.get_pango_context().list_families():
1971 _families
.append(_family
.get_name())
1973 prefstate
.setFamilies(_families
)
1975 _family
= globals.prefs
['FONT_FAMILY']
1976 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
1977 _widget
= gtk
.combo_box_new_text()
1978 for _i
in range(len(_families
)):
1982 _widget
.append_text(_f
)
1983 _widget
.set_active(_idx
)
1986 for _i
in range(len(_families
)):
1990 _item
= gtk
.MenuItem(_f
)
1992 _widget
= gtk
.OptionMenu()
1993 _widget
.set_menu(_menu
)
1994 _widget
.set_history(_idx
)
1995 if not prefstate
.hasWidgetKey('FONT_FAMILY'):
1996 prefstate
.setWidget('FONT_FAMILY', _widget
)
1997 _menu_size_group
.add_widget(_widget
)
1998 _fhbox
.pack_start(_widget
, False, False, 5)
2000 _fhbox
= gtk
.HBox(False, 5)
2001 _fhbox
.set_border_width(5)
2002 _fvbox
.pack_start(_fhbox
, False, False, 5)
2003 _label
= gtk
.Label(_('Style:'))
2004 _label_size_group
.add_widget(_label
)
2005 _fhbox
.pack_start(_label
, False, False, 5)
2007 _style
= globals.prefs
['FONT_STYLE']
2008 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
2009 _widget
= gtk
.combo_box_new_text()
2010 for _i
in range(len(_font_styles
)):
2011 _name
= _font_styles
[_i
]
2012 if _style
== TextStyle
.getStyleFromString(_name
):
2014 _widget
.append_text(_name
)
2015 _widget
.set_active(_idx
)
2018 for _i
in range(len(_font_styles
)):
2019 _name
= _font_styles
[_i
]
2020 if _style
== TextStyle
.getStyleFromString(_name
):
2022 _item
= gtk
.MenuItem(_name
)
2024 _widget
= gtk
.OptionMenu()
2025 _widget
.set_menu(_menu
)
2026 _widget
.set_history(_idx
)
2027 if not prefstate
.hasWidgetKey('FONT_STYLE'):
2028 prefstate
.setWidget('FONT_STYLE', _widget
)
2029 _menu_size_group
.add_widget(_widget
)
2030 _fhbox
.pack_start(_widget
, False, False, 5)
2032 _fhbox
= gtk
.HBox(False, 5)
2033 _fhbox
.set_border_width(5)
2034 _fvbox
.pack_start(_fhbox
, False, False, 5)
2035 _label
= gtk
.Label(_('Weight:'))
2036 _label_size_group
.add_widget(_label
)
2037 _fhbox
.pack_start(_label
, False, False, 5)
2039 _weight
= globals.prefs
['FONT_WEIGHT']
2040 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
2041 _widget
= gtk
.combo_box_new_text()
2042 for _i
in range(len(_font_weights
)):
2043 _name
= _font_weights
[_i
]
2044 if _weight
== TextStyle
.getWeightFromString(_name
):
2046 _widget
.append_text(_name
)
2047 _widget
.set_active(_idx
)
2050 for _i
in range(len(_font_weights
)):
2051 _name
= _font_weights
[_i
]
2052 if _weight
== TextStyle
.getWeightFromString(_name
):
2054 _item
= gtk
.MenuItem(_name
)
2056 _widget
= gtk
.OptionMenu()
2057 _widget
.set_menu(_menu
)
2058 _widget
.set_history(_idx
)
2059 if not prefstate
.hasWidgetKey('FONT_WEIGHT'):
2060 prefstate
.setWidget('FONT_WEIGHT', _widget
)
2061 _menu_size_group
.add_widget(_widget
)
2062 _fhbox
.pack_start(_widget
, False, False, 5)
2064 _fhbox
= gtk
.HBox(False, 5)
2065 _fhbox
.set_border_width(5)
2066 _fvbox
.pack_start(_fhbox
, False, False, 5)
2067 _label
= gtk
.Label(_('Alignment:'))
2068 _label_size_group
.add_widget(_label
)
2069 _fhbox
.pack_start(_label
, False, False, 5)
2071 _align
= globals.prefs
['TEXT_ALIGNMENT']
2072 if hasattr(gtk
, 'ComboBox'): # PyGTK 2.4
2073 _widget
= gtk
.combo_box_new_text()
2074 for _i
in range(len(_text_align
)):
2075 _name
= _text_align
[_i
]
2076 if _align
== TextStyle
.getAlignmentFromString(_name
):
2078 _widget
.append_text(_name
)
2079 _widget
.set_active(_idx
)
2082 for _i
in range(len(_text_align
)):
2083 _name
= _text_align
[_i
]
2084 if _align
== TextStyle
.getAlignmentFromString(_name
):
2086 _item
= gtk
.MenuItem(_name
)
2088 _widget
= gtk
.OptionMenu()
2089 _widget
.set_menu(_menu
)
2090 _widget
.set_history(_idx
)
2091 if not prefstate
.hasWidgetKey('TEXT_ALIGNMENT'):
2092 prefstate
.setWidget('TEXT_ALIGNMENT', _widget
)
2093 _menu_size_group
.add_widget(_widget
)
2094 _fhbox
.pack_start(_widget
, False, False, 5)
2096 _fhbox
= gtk
.HBox(False, 5)
2097 _fhbox
.set_border_width(2)
2098 _fvbox
.pack_start(_fhbox
, False, False, 5)
2099 _label
= gtk
.Label(_('Color:'))
2100 _fhbox
.pack_start(_label
, False, False, 5)
2101 _color
= globals.prefs
['FONT_COLOR']
2102 _gtkcolor
= gtk
.gdk
.color_parse(str(_color
))
2103 if hasattr(gtk
, 'ColorButton'):
2104 _button
= gtk
.ColorButton(color
=_gtkcolor
)
2105 _button
.set_title(_('Select Font Color'))
2106 if not prefstate
.hasWidgetKey('FONT_COLOR'):
2107 prefstate
.setWidget('FONT_COLOR', _button
)
2109 _button
= gtk
.Button()
2110 _bframe
= gtk
.Frame()
2111 _bframe
.set_shadow_type(gtk
.SHADOW_ETCHED_OUT
)
2112 _bframe
.set_border_width(5)
2113 _button
.add(_bframe
)
2114 _da
= gtk
.DrawingArea()
2115 _da
.set_size_request(20, 10)
2116 _da
.modify_bg(gtk
.STATE_NORMAL
, _gtkcolor
)
2117 if not prefstate
.hasWidgetKey('FONT_COLOR'):
2118 prefstate
.setWidget('FONT_COLOR', _da
)
2119 _button
.connect("clicked", _select_font_color
)
2121 _fhbox
.pack_start(_button
, False, False, 5)
2123 _fhbox
= gtk
.HBox(False, 5)
2124 _fhbox
.set_border_width(5)
2125 _fvbox
.pack_start(_fhbox
, False, False, 5)
2126 _label
= gtk
.Label(_('Size:'))
2127 _label_size_group
.add_widget(_label
)
2128 _fhbox
.pack_start(_label
, False, False, 5)
2129 _entry
= gtk
.Entry()
2130 _size
= "%f" % globals.prefs
['TEXT_SIZE']
2131 _entry
.set_text(_size
)
2132 if not prefstate
.hasWidgetKey('TEXT_SIZE'):
2133 prefstate
.setWidget('TEXT_SIZE', _entry
)
2134 _entry
.connect("activate", entry_activate
)
2135 _entry
.connect("focus-out-event", _textsize_entry_focus_out
, prefstate
)
2136 _handlerid
= _entry
.connect("insert-text", entry_insert_text
)
2137 _entry
.set_data('handlerid', _handlerid
)
2138 # _entry_size_group.add_widget(_entry)
2139 _fhbox
.pack_start(_entry
, False, False, 5)
2140 _vbox
.pack_start(_frame
, False, False, 5)
2143 def _make_pref_tree(hbox
, prefstate
):
2144 _sw
= gtk
.ScrolledWindow()
2145 _sw
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
2146 _sw
.set_size_request(120, 300)
2147 _tree_store
= gtk
.TreeStore(gobject
.TYPE_STRING
,
2148 gobject
.TYPE_STRING
)
2149 _iter1
= _tree_store
.append(None)
2150 _tree_store
.set(_iter1
, 0, _('Basic'))
2151 _tree_store
.set(_iter1
, 1, 'basic')
2152 _iter1
= _tree_store
.append(None)
2153 _tree_store
.set(_iter1
, 0, _('Sized Objects'))
2154 _tree_store
.set(_iter1
, 1, 'sizes')
2155 _iter1
= _tree_store
.append(None)
2156 _tree_store
.set(_iter1
, 0, _('Text'))
2157 _tree_store
.set(_iter1
, 1, 'text')
2158 _tree_view
= gtk
.TreeView(_tree_store
)
2159 _iter1
= _tree_store
.append(None)
2160 _tree_store
.set(_iter1
, 0, _('Dimensions'))
2161 _tree_store
.set(_iter1
, 1, 'dimensions')
2162 _iter2
= _tree_store
.append(_iter1
)
2163 _tree_store
.set(_iter2
, 0, _('Primary'))
2164 _tree_store
.set(_iter2
, 1, 'primary')
2165 _iter2
= _tree_store
.append(_iter1
)
2166 _tree_store
.set(_iter2
, 0, _('Secondary'))
2167 _tree_store
.set(_iter2
, 1, 'secondary')
2168 _iter2
= _tree_store
.append(_iter1
)
2169 _tree_store
.set(_iter2
, 0, _('Linear'))
2170 _tree_store
.set(_iter2
, 1, 'linear')
2171 _iter2
= _tree_store
.append(_iter1
)
2172 _tree_store
.set(_iter2
, 0, _('Radial'))
2173 _tree_store
.set(_iter2
, 1, 'radial')
2174 _iter2
= _tree_store
.append(_iter1
)
2175 _tree_store
.set(_iter2
, 0, _('Angular'))
2176 _tree_store
.set(_iter2
, 1, 'angular')
2177 _tree_view
.set_reorderable(False) # no drag-and-drop
2178 _select
= _tree_view
.get_selection()
2179 _select
.set_mode(gtk
.SELECTION_SINGLE
)
2180 _select
.connect("changed", tree_select_cb
, prefstate
)
2181 _renderer
= gtk
.CellRendererText()
2182 _column
= gtk
.TreeViewColumn(_("Options"), _renderer
, text
=0)
2183 _tree_view
.append_column(_column
)
2185 hbox
.pack_start(_sw
, False, False, 5)
2189 def _set_dim_offset(prefstate
):
2190 _text
= prefstate
.getWidget('DIM_OFFSET').get_text()
2191 if len(_text
) and _text
!= '+':
2192 globals.prefs
['DIM_OFFSET'] = float(_text
)
2194 def _set_dim_extension(prefstate
):
2195 _text
= prefstate
.getWidget('DIM_EXTENSION').get_text()
2196 if len(_text
) and _text
!= '+':
2197 globals.prefs
['DIM_EXTENSION'] = float(_text
)
2199 def _set_dim_color(prefstate
):
2200 _widget
= prefstate
.getWidget('DIM_COLOR')
2201 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2202 _color
= _widget
.get_color()
2203 elif isinstance(_widget
, gtk
.DrawingArea
):
2204 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2206 raise TypeError, "Unexpected widget for DIM_COLOR: " + `
type(_widget
)`
2207 _r
, _g
, _b
= _get_rgb_values(_color
)
2208 globals.prefs
['DIM_COLOR'] = get_color(_r
, _g
, _b
)
2210 def _set_background_color(prefstate
):
2211 _widget
= prefstate
.getWidget('BACKGROUND_COLOR')
2212 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2213 _color
= _widget
.get_color()
2214 elif isinstance(_widget
, gtk
.DrawingArea
):
2215 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2217 raise TypeError, "Unexpected widget for BACKGROUND_COLOR: " + `
type(_widget
)`
2218 _r
, _g
, _b
= _get_rgb_values(_color
)
2219 globals.prefs
['BACKGROUND_COLOR'] = get_color(_r
, _g
, _b
)
2221 def _set_inactive_layer_color(prefstate
):
2222 _widget
= prefstate
.getWidget('INACTIVE_LAYER_COLOR')
2223 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2224 _color
= _widget
.get_color()
2225 elif isinstance(_widget
, gtk
.DrawingArea
):
2226 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2228 raise TypeError, "Unexpected widget for INACTIVE_LAYER_COLOR: " + `
type(_widget
)`
2229 _r
, _g
, _b
= _get_rgb_values(_color
)
2230 globals.prefs
['INACTIVE_LAYER_COLOR'] = get_color(_r
, _g
, _b
)
2232 def _set_single_point_color(prefstate
):
2233 _widget
= prefstate
.getWidget('SINGLE_POINT_COLOR')
2234 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2235 _color
= _widget
.get_color()
2236 elif isinstance(_widget
, gtk
.DrawingArea
):
2237 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2239 raise TypeError, "Unexpected widget for SINGLE_POINT_COLOR: " + `
type(_widget
)`
2240 _r
, _g
, _b
= _get_rgb_values(_color
)
2241 globals.prefs
['SINGLE_POINT_COLOR'] = get_color(_r
, _g
, _b
)
2243 def _set_multi_point_color(prefstate
):
2244 _widget
= prefstate
.getWidget('MULTI_POINT_COLOR')
2245 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2246 _color
= _widget
.get_color()
2247 elif isinstance(_widget
, gtk
.DrawingArea
):
2248 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2250 raise TypeError, "Unexpected widget for MULTI_POINT_COLOR: " + `
type(_widget
)`
2251 _r
, _g
, _b
= _get_rgb_values(_color
)
2252 globals.prefs
['MULTI_POINT_COLOR'] = get_color(_r
, _g
, _b
)
2254 def _set_font_color(prefstate
):
2255 _widget
= prefstate
.getWidget('FONT_COLOR')
2256 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2257 _color
= _widget
.get_color()
2258 elif isinstance(_widget
, gtk
.DrawingArea
):
2259 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2261 raise TypeError, "Unexpected widget for FONT_COLOR: " + `
type(_widget
)`
2262 _r
, _g
, _b
= _get_rgb_values(_color
)
2263 globals.prefs
['FONT_COLOR'] = get_color(_r
, _g
, _b
)
2265 def _set_dim_primary_font_color(prefstate
):
2266 _widget
= prefstate
.getWidget('DIM_PRIMARY_FONT_COLOR')
2267 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2268 _color
= _widget
.get_color()
2269 elif isinstance(_widget
, gtk
.DrawingArea
):
2270 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2272 raise TypeError, "Unexpected widget for DIM_PRIMARY_FONT_COLOR: " + `
type(_widget
)`
2273 _r
, _g
, _b
= _get_rgb_values(_color
)
2274 globals.prefs
['DIM_PRIMARY_FONT_COLOR'] = get_color(_r
, _g
, _b
)
2276 def _set_dim_secondary_font_color(prefstate
):
2277 _widget
= prefstate
.getWidget('DIM_SECONDARY_FONT_COLOR')
2278 if hasattr(gtk
, 'ColorButton') and isinstance(_widget
, gtk
.ColorButton
):
2279 _color
= _widget
.get_color()
2280 elif isinstance(_widget
, gtk
.DrawingArea
):
2281 _color
= _widget
.get_style().bg
[gtk
.STATE_NORMAL
]
2283 raise TypeError, "Unexpected widget for DIM_SECONDARY_FONT_COLOR: " + `
type(_widget
)`
2284 _r
, _g
, _b
= _get_rgb_values(_color
)
2285 globals.prefs
['DIM_SECONDARY_FONT_COLOR'] = get_color(_r
, _g
, _b
)
2287 def _set_line_thickness(prefstate
):
2288 _text
= prefstate
.getWidget('LINE_THICKNESS').get_text()
2289 if len(_text
) and _text
!= '+':
2290 globals.prefs
['LINE_THICKNESS'] = float(_text
)
2292 def _set_leader_arrow_size(prefstate
):
2293 _text
= prefstate
.getWidget('LEADER_ARROW_SIZE').get_text()
2294 if len(_text
) and _text
!= '+':
2295 globals.prefs
['LEADER_ARROW_SIZE'] = float(_text
)
2297 def _set_chamfer_length(prefstate
):
2298 _text
= prefstate
.getWidget('CHAMFER_LENGTH').get_text()
2299 if len(_text
) and _text
!= '+':
2300 globals.prefs
['CHAMFER_LENGTH'] = float(_text
)
2302 def _set_fillet_radius(prefstate
):
2303 _text
= prefstate
.getWidget('FILLET_RADIUS').get_text()
2304 if len(_text
) and _text
!= '+':
2305 globals.prefs
['FILLET_RADIUS'] = float(_text
)
2307 def _set_dim_endpoint_size(prefstate
):
2308 _text
= prefstate
.getWidget('DIM_ENDPOINT_SIZE').get_text()
2309 if len(_text
) and _text
!= '+':
2310 globals.prefs
['DIM_ENDPOINT_SIZE'] = float(_text
)
2312 def _set_text_size(prefstate
):
2313 _text
= prefstate
.getWidget('TEXT_SIZE').get_text()
2314 if len(_text
) and _text
!= '+':
2315 globals.prefs
['TEXT_SIZE'] = float(_text
)
2317 def _set_dim_primary_text_size(prefstate
):
2318 _text
= prefstate
.getWidget('DIM_PRIMARY_TEXT_SIZE').get_text()
2319 if len(_text
) and _text
!= '+':
2320 globals.prefs
['DIM_PRIMARY_TEXT_SIZE'] = float(_text
)
2322 def _set_dim_secondary_text_size(prefstate
):
2323 _text
= prefstate
.getWidget('DIM_SECONDARY_TEXT_SIZE').get_text()
2324 if len(_text
) and _text
!= '+':
2325 globals.prefs
['DIM_SECONDARY_TEXT_SIZE'] = float(_text
)
2327 def _set_dim_position_offset(prefstate
):
2328 _text
= prefstate
.getWidget('DIM_POSITION_OFFSET').get_text()
2329 if len(_text
) and _text
!= '+':
2330 globals.prefs
['DIM_POSITION_OFFSET'] = float(_text
)
2332 def _set_dim_dual_mode_offset(prefstate
):
2333 _text
= prefstate
.getWidget('DIM_DUAL_MODE_OFFSET').get_text()
2334 if len(_text
) and _text
!= '+':
2335 globals.prefs
['DIM_DUAL_MODE_OFFSET'] = float(_text
)
2337 def _set_dim_dual_mode(prefstate
):
2338 _cb
= prefstate
.getWidget('DIM_DUAL_MODE')
2339 globals.prefs
['DIM_DUAL_MODE'] = _cb
.get_active()
2341 def _set_highlight_points(prefstate
):
2342 _cb
= prefstate
.getWidget('HIGHLIGHT_POINTS')
2343 globals.prefs
['HIGHLIGHT_POINTS'] = _cb
.get_active()
2345 def _set_autosplit(prefstate
):
2346 _cb
= prefstate
.getWidget('AUTOSPLIT')
2347 globals.prefs
['AUTOSPLIT'] = _cb
.get_active()
2349 def _set_dim_primary_leading_zero(prefstate
):
2350 _cb
= prefstate
.getWidget('DIM_PRIMARY_LEADING_ZERO')
2351 globals.prefs
['DIM_PRIMARY_LEADING_ZERO'] = _cb
.get_active()
2353 def _set_dim_primary_trailing_decimal(prefstate
):
2354 _cb
= prefstate
.getWidget('DIM_PRIMARY_TRAILING_DECIMAL')
2355 globals.prefs
['DIM_PRIMARY_TRAILING_DECIMAL'] = _cb
.get_active()
2357 def _set_dim_primary_precision(prefstate
):
2358 _sb
= prefstate
.getWidget('DIM_PRIMARY_PRECISION')
2359 globals.prefs
['DIM_PRIMARY_PRECISION'] = _sb
.get_value_as_int()
2361 def _set_dim_secondary_leading_zero(prefstate
):
2362 _cb
= prefstate
.getWidget('DIM_SECONDARY_LEADING_ZERO')
2363 globals.prefs
['DIM_SECONDARY_LEADING_ZERO'] = _cb
.get_active()
2365 def _set_dim_secondary_trailing_decimal(prefstate
):
2366 _cb
= prefstate
.getWidget('DIM_SECONDARY_TRAILING_DECIMAL')
2367 globals.prefs
['DIM_SECONDARY_TRAILING_DECIMAL'] = _cb
.get_active()
2369 def _set_dim_secondary_precision(prefstate
):
2370 _sb
= prefstate
.getWidget('DIM_SECONDARY_PRECISION')
2371 globals.prefs
['DIM_SECONDARY_PRECISION'] = _sb
.get_value_as_int()
2373 def _set_dim_primary_prefix(prefstate
):
2374 _text
= prefstate
.getWidget('DIM_PRIMARY_PREFIX').get_text()
2375 globals.prefs
['DIM_PRIMARY_PREFIX'] = unicode(_text
)
2377 def _set_dim_primary_suffix(prefstate
):
2378 _text
= prefstate
.getWidget('DIM_PRIMARY_SUFFIX').get_text()
2379 globals.prefs
['DIM_PRIMARY_SUFFIX'] = unicode(_text
)
2381 def _set_dim_secondary_prefix(prefstate
):
2382 _text
= prefstate
.getWidget('DIM_SECONDARY_PREFIX').get_text()
2383 globals.prefs
['DIM_SECONDARY_PREFIX' ] = unicode(_text
)
2385 def _set_dim_secondary_suffix(prefstate
):
2386 _text
= prefstate
.getWidget('DIM_SECONDARY_SUFFIX').get_text()
2387 globals.prefs
['DIM_SECONDARY_SUFFIX'] = unicode(_text
)
2389 def _set_radial_dim_primary_prefix(prefstate
):
2390 _text
= prefstate
.getWidget('RADIAL_DIM_PRIMARY_PREFIX').get_text()
2391 globals.prefs
['RADIAL_DIM_PRIMARY_PREFIX'] = unicode(_text
)
2393 def _set_radial_dim_primary_suffix(prefstate
):
2394 _text
= prefstate
.getWidget('RADIAL_DIM_PRIMARY_SUFFIX').get_text()
2395 globals.prefs
['RADIAL_DIM_PRIMARY_SUFFIX'] = unicode(_text
)
2397 def _set_radial_dim_secondary_prefix(prefstate
):
2398 _text
= prefstate
.getWidget('RADIAL_DIM_SECONDARY_PREFIX').get_text()
2399 globals.prefs
['RADIAL_DIM_SECONDARY_PREFIX'] = unicode(_text
)
2401 def _set_radial_dim_secondary_suffix(prefstate
):
2402 _text
= prefstate
.getWidget('RADIAL_DIM_SECONDARY_SUFFIX').get_text()
2403 globals.prefs
['RADIAL_DIM_SECONDARY_SUFFIX'] = unicode(_text
)
2405 def _set_radial_dim_dia_mode(prefstate
):
2406 _cb
= prefstate
.getWidget('RADIAL_DIM_DIA_MODE')
2407 globals.prefs
['RADIAL_DIM_DIA_MODE'] = _cb
.get_active()
2409 def _set_angular_dim_primary_prefix(prefstate
):
2410 _text
= prefstate
.getWidget('ANGULAR_DIM_PRIMARY_PREFIX').get_text()
2411 globals.prefs
['ANGULAR_DIM_PRIMARY_PREFIX'] = unicode(_text
)
2413 def _set_angular_dim_primary_suffix(prefstate
):
2414 _text
= prefstate
.getWidget('ANGULAR_DIM_PRIMARY_SUFFIX').get_text()
2415 globals.prefs
['ANGULAR_DIM_PRIMARY_SUFFIX'] = unicode(_text
)
2417 def _set_angular_dim_secondary_prefix(prefstate
):
2418 _text
= prefstate
.getWidget('ANGULAR_DIM_SECONDARY_PREFIX').get_text()
2419 globals.prefs
['ANGULAR_DIM_SECONDARY_PREFIX'] = unicode(_text
)
2421 def _set_angular_dim_secondary_suffix(prefstate
):
2422 _text
= prefstate
.getWidget('ANGULAR_DIM_SECONDARY_SUFFIX').get_text()
2423 globals.prefs
['ANGULAR_DIM_SECONDARY_SUFFIX'] = unicode(_text
)
2425 def _set_drawing_units(prefstate
):
2426 _widget
= prefstate
.getWidget('DRAWING_UNITS')
2427 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2428 _unit
= _widget
.get_active()
2429 elif isinstance(_widget
, gtk
.OptionMenu
):
2430 _unit
= _widget
.get_history()
2432 raise TypeError, "Unexpected DRAWING_UNITS widget: " + `
type(_widget
)`
2433 globals.prefs
['UNITS'] = _unit
2435 def _set_dim_primary_units(prefstate
):
2436 _widget
= prefstate
.getWidget('DIM_PRIMARY_UNITS')
2437 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2438 _unit
= _widget
.get_active()
2439 elif isinstance(_widget
, gtk
.OptionMenu
):
2440 _unit
= _widget
.get_history()
2442 raise TypeError, "Unexpected DIM_PRIMARY_UNITS widget: " + `
type(_widget
)`
2443 globals.prefs
['DIM_PRIMARY_UNITS'] = _unit
2445 def _set_dim_secondary_units(prefstate
):
2446 _widget
= prefstate
.getWidget('DIM_SECONDARY_UNITS')
2447 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2448 _unit
= _widget
.get_active()
2449 elif isinstance(_widget
, gtk
.OptionMenu
):
2450 _unit
= _widget
.get_history()
2452 raise TypeError, "Unexpected DIM_SECONDARY_UNITS widget: " + `
type(_widget
)`
2453 globals.prefs
['DIM_SECONDARY_UNITS'] = _unit
2455 def _set_dim_endpoint(prefstate
):
2456 _widget
= prefstate
.getWidget('DIM_ENDPOINT')
2457 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2458 _idx
= _widget
.get_active()
2459 elif isinstance(_widget
, gtk
.OptionMenu
):
2460 _idx
= _widget
.get_history()
2462 raise TypeError, "Unexpected DIM_ENDPOINT widget: " + `
type(_widget
)`
2463 _endpoint
= Dimension
.getEndpointTypeFromString(_dim_endpoints
[_idx
])
2464 globals.prefs
['DIM_ENDPOINT'] = _endpoint
2466 def _set_dim_position(prefstate
):
2467 _widget
= prefstate
.getWidget('DIM_POSITION')
2468 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2469 _idx
= _widget
.get_active()
2470 elif isinstance(_widget
, gtk
.OptionMenu
):
2471 _idx
= _widget
.get_history()
2473 raise TypeError, "Unexpected DIM_POSITION widget: " + `
type(_widget
)`
2474 _pos
= Dimension
.getPositionFromString(_dim_positions
[_idx
])
2475 globals.prefs
['DIM_POSITION'] = _pos
2477 def _set_font_family(prefstate
):
2478 _widget
= prefstate
.getWidget('FONT_FAMILY')
2479 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2480 _idx
= _widget
.get_active()
2481 elif isinstance(_widget
, gtk
.OptionMenu
):
2482 _idx
= _widget
.get_history()
2484 raise TypeError, "Unexpected FONT_FAMILY widget: " + `
type(_widget
)`
2485 _families
= prefstate
.getFamilies()
2486 globals.prefs
['FONT_FAMILY'] = _families
[_idx
]
2488 def _set_font_style(prefstate
):
2489 _widget
= prefstate
.getWidget('FONT_STYLE')
2490 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2491 _idx
= _widget
.get_active()
2492 elif isinstance(_widget
, gtk
.OptionMenu
):
2493 _idx
= _widget
.get_history()
2495 raise TypeError, "Unexpected FONT_STYLE widget: " + `
type(_widget
)`
2496 _style
= TextStyle
.getStyleFromString(_font_styles
[_idx
])
2497 globals.prefs
['FONT_STYLE']= _style
2499 def _set_font_weight(prefstate
):
2500 _widget
= prefstate
.getWidget('FONT_WEIGHT')
2501 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2502 _idx
= _widget
.get_active()
2503 elif isinstance(_widget
, gtk
.OptionMenu
):
2504 _idx
= _widget
.get_history()
2506 raise TypeError, "Unexpected FONT_WEIGHT widget: " + `
type(_widget
)`
2507 _weight
= TextStyle
.getWeightFromString(_font_weights
[_idx
])
2508 globals.prefs
['FONT_WEIGHT'] = _weight
2510 def _set_text_alignment(prefstate
):
2511 _widget
= prefstate
.getWidget('TEXT_ALIGNMENT')
2512 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2513 _idx
= _widget
.get_active()
2514 elif isinstance(_widget
, gtk
.OptionMenu
):
2515 _idx
= _widget
.get_history()
2517 raise TypeError, "Unexpected TEXT_ALIGNMENT widget: " + `
type(_widget
)`
2518 _align
= TextStyle
.getAlignmentFromString(_text_align
[_idx
])
2519 globals.prefs
['TEXT_ALIGNMENT'] = _align
2521 def _set_dim_primary_font_family(prefstate
):
2522 _widget
= prefstate
.getWidget('DIM_PRIMARY_FONT_FAMILY')
2523 _families
= prefstate
.getFamilies()
2524 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2525 _idx
= _widget
.get_active()
2526 elif isinstance(_widget
, gtk
.OptionMenu
):
2527 _idx
= _widget
.get_history()
2529 raise TypeError, "Unexpected DIM_PRIMARY_FONT_FAMILY widget: " + `
type(_widget
)`
2530 globals.prefs
['DIM_PRIMARY_FONT_FAMILY'] = _families
[_idx
]
2532 def _set_dim_primary_font_style(prefstate
):
2533 _widget
= prefstate
.getWidget('DIM_PRIMARY_FONT_STYLE')
2534 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2535 _idx
= _widget
.get_active()
2536 elif isinstance(_widget
, gtk
.OptionMenu
):
2537 _idx
= _widget
.get_history()
2539 raise TypeError, "Unexpected DIM_PRIMARY_FONT_STYLE widget: " + `
type(_widget
)`
2540 _style
= TextStyle
.getStyleFromString(_font_styles
[_idx
])
2541 globals.prefs
['DIM_PRIMARY_FONT_STYLE'] = _style
2543 def _set_dim_primary_font_weight(prefstate
):
2544 _widget
= prefstate
.getWidget('DIM_PRIMARY_FONT_WEIGHT')
2545 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2546 _idx
= _widget
.get_active()
2547 elif isinstance(_widget
, gtk
.OptionMenu
):
2548 _idx
= _widget
.get_history()
2550 raise TypeError, "Unexpected DIM_PRIMARY_FONT_WEIGHT widget: " + `
type(_widget
)`
2551 _weight
= TextStyle
.getWeightFromString(_font_weights
[_idx
])
2552 globals.prefs
['DIM_PRIMARY_FONT_WEIGHT'] = _weight
2554 def _set_dim_primary_text_alignment(prefstate
):
2555 _widget
= prefstate
.getWidget('DIM_PRIMARY_TEXT_ALIGNMENT')
2556 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2557 _idx
= _widget
.get_active()
2558 elif isinstance(_widget
, gtk
.OptionMenu
):
2559 _idx
= _widget
.get_history()
2561 raise TypeError, "Unexpected DIM_PRIMARY_TEXT_ALIGNMENT widget: " + `
type(_widget
)`
2562 _align
= TextStyle
.getAlignmentFromString(_text_align
[_idx
])
2563 globals.prefs
['DIM_PRIMARY_TEXT_ALIGNMENT'] = _align
2565 def _set_dim_primary_font(prefstate
):
2566 _fontsel
= prefstate
.getWidget('DIM_PRIMARY_FONT')
2567 _font
= _fontsel
.get_font_name()
2568 _family
, _style
, _weight
, _stretch
, _size
= (None, None, None, None, None)
2569 globals.prefs
['DIM_PRIMARY_FONT_FAMILY'] = _family
2570 globals.prefs
['DIM_PRIMARY_TEXT_SIZE'] = float(_size
) # fixme
2571 globals.prefs
['DIM_PRIMARY_FONT_STYLE'] = _style
2572 globals.prefs
['DIM_PRIMARY_FONT_WEIGHT'] = _weight
2574 def _set_dim_secondary_font_family(prefstate
):
2575 _widget
= prefstate
.getWidget('DIM_SECONDARY_FONT_FAMILY')
2576 _families
= prefstate
.getFamilies()
2577 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2578 _idx
= _widget
.get_active()
2579 elif isinstance(_widget
, gtk
.OptionMenu
):
2580 _idx
= _widget
.get_history()
2582 raise TypeError, "Unexpected DIM_SECONDARY_FONT_FAMILY widget: " + `
type(_widget
)`
2583 globals.prefs
['DIM_SECONDARY_FONT_FAMILY'] = _families
[_idx
]
2585 def _set_dim_secondary_font_style(prefstate
):
2586 _widget
= prefstate
.getWidget('DIM_SECONDARY_FONT_STYLE')
2587 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2588 _idx
= _widget
.get_active()
2589 elif isinstance(_widget
, gtk
.OptionMenu
):
2590 _idx
= _widget
.get_history()
2592 raise TypeError, "Unexpected DIM_SECONDARY_FONT_STYLE widget: " + `
type(_widget
)`
2593 _style
= TextStyle
.getStyleFromString(_font_styles
[_idx
])
2594 globals.prefs
['DIM_SECONDARY_FONT_STYLE'] = _style
2596 def _set_dim_secondary_font_weight(prefstate
):
2597 _widget
= prefstate
.getWidget('DIM_SECONDARY_FONT_WEIGHT')
2598 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2599 _idx
= _widget
.get_active()
2600 elif isinstance(_widget
, gtk
.OptionMenu
):
2601 _idx
= _widget
.get_history()
2603 raise TypeError, "Unexpected DIM_SECONDARY_FONT_WEIGHT widget: " + `
type(_widget
)`
2604 _weight
= TextStyle
.getWeightFromString(_font_weights
[_idx
])
2605 globals.prefs
['DIM_SECONDARY_FONT_WEIGHT'] = _weight
2607 def _set_dim_secondary_text_alignment(prefstate
):
2608 _widget
= prefstate
.getWidget('DIM_SECONDARY_TEXT_ALIGNMENT')
2609 if hasattr(gtk
, 'ComboBox') and isinstance(_widget
, gtk
.ComboBox
):
2610 _idx
= _widget
.get_active()
2611 elif isinstance(_widget
, gtk
.OptionMenu
):
2612 _idx
= _widget
.get_history()
2614 raise TypeError, "Unexpected DIM_SECONDARY_TEXT_ALIGNMENT widget: " + `
type(_widget
)`
2615 _align
= TextStyle
.getAlignmentFromString(_text_align
[_idx
])
2616 globals.prefs
['DIM_SECONDARY_TEXT_ALIGNMENT'] = _align
2618 def _set_dim_secondary_font(prefstate
):
2619 _fontsel
= prefstate
.getWidget('DIM_SECONDARY_FONT')
2620 _font
= _fontsel
.get_font_name()
2621 _family
, _style
, _weight
, _stretch
, _size
= (None, None, None, None, None)
2622 globals.prefs
['DIM_SECONDARY_FONT_FAMILY'] = _family
2623 globals.prefs
['DIM_SECONDARY_TEXT_SIZE'] = float(_size
) # fixme
2624 globals.prefs
['DIM_SECONDARY_FONT_STYLE'] = _style
2625 globals.prefs
['DIM_SECONDARY_FONT_WEIGHT'] = _weight
2628 'DIM_OFFSET' : _set_dim_offset
,
2629 'DIM_EXTENSION' : _set_dim_extension
,
2630 'DIM_COLOR' : _set_dim_color
,
2631 'BACKGROUND_COLOR' : _set_background_color
,
2632 'INACTIVE_LAYER_COLOR' : _set_inactive_layer_color
,
2633 'SINGLE_POINT_COLOR' : _set_single_point_color
,
2634 'MULTI_POINT_COLOR' : _set_multi_point_color
,
2635 'FONT_COLOR' : _set_font_color
,
2636 'DIM_PRIMARY_FONT_COLOR' : _set_dim_primary_font_color
,
2637 'DIM_SECONDARY_FONT_COLOR' : _set_dim_secondary_font_color
,
2638 'LINE_THICKNESS' : _set_line_thickness
,
2639 'LEADER_ARROW_SIZE' : _set_leader_arrow_size
,
2640 'CHAMFER_LENGTH' : _set_chamfer_length
,
2641 'FILLET_RADIUS' : _set_fillet_radius
,
2642 'HIGHLIGHT_POINTS' : _set_highlight_points
,
2643 'AUTOSPLIT' : _set_autosplit
,
2644 'DIM_PRIMARY_FONT_FAMILY' : _set_dim_primary_font_family
,
2645 'DIM_PRIMARY_FONT_STYLE' : _set_dim_primary_font_style
,
2646 'DIM_PRIMARY_FONT_WEIGHT' : _set_dim_primary_font_weight
,
2647 'DIM_PRIMARY_TEXT_SIZE' : _set_dim_primary_text_size
,
2648 'DIM_PRIMARY_TEXT_ALIGNMENT' : _set_dim_primary_text_alignment
,
2649 'DIM_PRIMARY_PRECISION' : _set_dim_primary_precision
,
2650 'DIM_PRIMARY_LEADING_ZERO' : _set_dim_primary_leading_zero
,
2651 'DIM_PRIMARY_TRAILING_DECIMAL' : _set_dim_primary_trailing_decimal
,
2652 'DIM_SECONDARY_FONT_FAMILY' : _set_dim_secondary_font_family
,
2653 'DIM_SECONDARY_FONT_STYLE' : _set_dim_secondary_font_style
,
2654 'DIM_SECONDARY_FONT_WEIGHT' : _set_dim_secondary_font_weight
,
2655 'DIM_SECONDARY_TEXT_SIZE' : _set_dim_secondary_text_size
,
2656 'DIM_SECONDARY_TEXT_ALIGNMENT' : _set_dim_secondary_text_alignment
,
2657 'DIM_SECONDARY_PRECISION' : _set_dim_secondary_precision
,
2658 'DIM_SECONDARY_LEADING_ZERO' : _set_dim_secondary_leading_zero
,
2659 'DIM_SECONDARY_TRAILING_DECIMAL' : _set_dim_secondary_trailing_decimal
,
2660 'DIM_PRIMARY_PREFIX' : _set_dim_primary_prefix
,
2661 'DIM_PRIMARY_SUFFIX' : _set_dim_primary_suffix
,
2662 'DIM_SECONDARY_PREFIX' : _set_dim_secondary_prefix
,
2663 'DIM_SECONDARY_SUFFIX' : _set_dim_secondary_suffix
,
2664 'RADIAL_DIM_PRIMARY_PREFIX' : _set_radial_dim_primary_prefix
,
2665 'RADIAL_DIM_PRIMARY_SUFFIX' : _set_radial_dim_primary_suffix
,
2666 'RADIAL_DIM_SECONDARY_PREFIX' : _set_radial_dim_secondary_prefix
,
2667 'RADIAL_DIM_SECONDARY_SUFFIX' : _set_radial_dim_secondary_suffix
,
2668 'RADIAL_DIM_DIA_MODE' : _set_radial_dim_dia_mode
,
2669 'ANGULAR_DIM_PRIMARY_PREFIX' : _set_angular_dim_primary_prefix
,
2670 'ANGULAR_DIM_PRIMARY_SUFFIX' : _set_angular_dim_primary_suffix
,
2671 'ANGULAR_DIM_SECONDARY_PREFIX' : _set_angular_dim_secondary_prefix
,
2672 'ANGULAR_DIM_SECONDARY_SUFFIX' : _set_angular_dim_secondary_suffix
,
2673 'DRAWING_UNITS' : _set_drawing_units
,
2674 'DIM_PRIMARY_UNITS' : _set_dim_primary_units
,
2675 'DIM_SECONDARY_UNITS' : _set_dim_secondary_units
,
2676 'FONT_FAMILY' : _set_font_family
,
2677 'FONT_STYLE' : _set_font_style
,
2678 'FONT_WEIGHT' : _set_font_weight
,
2679 'TEXT_SIZE' : _set_text_size
,
2680 'TEXT_ALIGNMENT' : _set_text_alignment
,
2681 'DIM_PRIMARY_FONT' : _set_dim_primary_font
,
2682 'DIM_SECONDARY_FONT' : _set_dim_secondary_font
,
2683 'DIM_ENDPOINT' : _set_dim_endpoint
,
2684 'DIM_ENDPOINT_SIZE' : _set_dim_endpoint_size
,
2685 'DIM_DUAL_MODE' : _set_dim_dual_mode
,
2686 'DIM_POSITION' : _set_dim_position
,
2687 'DIM_DUAL_MODE_OFFSET' : _set_dim_dual_mode_offset
,
2688 'DIM_POSITION_OFFSET' : _set_dim_position_offset
,
2691 def apply_prefs(prefstate
):
2692 for _key
in prefstate
.getWidgetKeys():
2693 # print "widget key: " + _key
2695 _optfunc
= _keymap
[_key
]
2698 # print "no function for " + _key
2700 def prefs_dialog(gtkimage
):
2701 _window
= gtkimage
.getWindow()
2702 _prefstate
= Prefstate()
2703 _prefstate
.setImage(gtkimage
.image
)
2704 _prefstate
.setWindow(_window
)
2705 _dialog
= gtk
.Dialog(_('Set Preferences'), _window
,
2706 gtk
.DIALOG_MODAL | gtk
.DIALOG_DESTROY_WITH_PARENT
,
2707 (gtk
.STOCK_OK
, gtk
.RESPONSE_OK
,
2708 gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
))
2709 _hbox
= gtk
.HBox(False, 5)
2710 _prefstate
.setHBox(_hbox
)
2711 _hbox
.set_border_width(5)
2712 _dialog
.vbox
.pack_start(_hbox
, True, True)
2713 _tree_view
= _make_pref_tree(_hbox
, _prefstate
)
2715 _response
= _dialog
.run()
2716 if _response
== gtk
.RESPONSE_OK
:
2717 apply_prefs(_prefstate
)
2718 preferences
.save_user_prefs()