[PythonCAD] a simplifying patch?
Russ Nelson
nelson at crynwr.com
Tue Jun 6 03:34:05 CEST 2006
Is it appropriate to send patches to the list? This one's fairly
short, so I'll take the chance. This code is much simpler to read and
understand.
diff -ur orig/PythonCAD/Interface/Gtk/gtkmenus.py ./PythonCAD/Interface/Gtk/gtkmenus.py
--- orig/PythonCAD/Interface/Gtk/gtkmenus.py 2006-05-11 16:50:23.000000000 -0400
+++ ./PythonCAD/Interface/Gtk/gtkmenus.py 2006-06-05 21:05:48.000000000 -0400
@@ -350,66 +350,34 @@
#------------------------------------------------------------
def _select_all_cb(menuitem, gtkimage):
+ _selects = [('SelectAllPoints', 'point'),
+ ('SelectAllSegments','segment'),
+ ('SelectAllCircles','circle'),
+ ('SelectAllArcs','arc'),
+ ('SelectAllLeaders','leader'),
+ ('SelectAllPolylines','polyline'),
+ ('SelectAllChamfers','chamfer'),
+ ('SelectAllFillets','fillet'),
+ ('SelectAllHCLines','hcline'),
+ ('SelectAllVCLines','vcline'),
+ ('SelectAllACLines','acline'),
+ ('SelectAllCLines','cline'),
+ ('SelectAllCCircles','ccircle'),
+ ('SelectAllTextBlocks','textblock'),
+ ('SelectAllLDims','linear_dimension'),
+ ('SelectAllHDims','horizontal_dimension'),
+ ('SelectAllVDims','vertical_dimension'),
+ ('SelectAllRDims','radial_dimension'),
+ ('SelectAllADims','angular_dimension'),
+ ]
+
_group = gtkimage.getGroup('Edit')
if _group is not None:
_layer = gtkimage.getActiveLayer()
- _act = _group.get_action('SelectAllPoints')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('point') > 0)
- _act = _group.get_action('SelectAllSegments')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('segment') > 0)
- _act = _group.get_action('SelectAllCircles')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('circle') > 0)
- _act = _group.get_action('SelectAllArcs')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('arc') > 0)
- _act = _group.get_action('SelectAllLeaders')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('leader') > 0)
- _act = _group.get_action('SelectAllPolylines')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('polyline') > 0)
- _act = _group.get_action('SelectAllChamfers')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('chamfer') > 0)
- _act = _group.get_action('SelectAllFillets')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('fillet') > 0)
- _act = _group.get_action('SelectAllHCLines')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('hcline') > 0)
- _act = _group.get_action('SelectAllVCLines')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('vcline') > 0)
- _act = _group.get_action('SelectAllACLines')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('acline') > 0)
- _act = _group.get_action('SelectAllCLines')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('cline') > 0)
- _act = _group.get_action('SelectAllCCircles')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('ccircle') > 0)
- _act = _group.get_action('SelectAllTextBlocks')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('textblock') > 0)
- _act = _group.get_action('SelectAllLDims')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('linear_dimension') > 0)
- _act = _group.get_action('SelectAllHDims')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('horizontal_dimension') > 0)
- _act = _group.get_action('SelectAllVDims')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('vertical_dimension') > 0)
- _act = _group.get_action('SelectAllRDims')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('radial_dimension') > 0)
- _act = _group.get_action('SelectAllADims')
- if _act is not None:
- _act.set_property('sensitive', _layer.getEntityCount('angular_dimension') > 0)
+ for action, entity in _selects:
+ _act = _group.get_action(action)
+ if _act is not None:
+ _act.set_property('sensitive', _layer.getEntityCount(entity) > 0)
#------------------------------------------------------------
def edit_undo_cb(menuitem, gtkimage):
--
--my blog is at http://blog.russnelson.com | When immigration is
Crynwr sells support for free software | PGPok | outlawed, only criminals
521 Pleasant Valley Rd. | +1 315-323-1241 | will immigrate. Illegal
Potsdam, NY 13676-3213 | Sheepdog | immigration causes crime.
More information about the PythonCAD
mailing list