Commit 0a06ca01 authored by sumpfralle's avatar sumpfralle

fixed GTK 2.16+ code (2.12 is our target)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@206 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 6236538f
Version 0.2.1 - UNRELEASED Version 0.2.1 - UNRELEASED
* * fixed code that depended on GTK 2.16 (instead of 2.12)
Version 0.2 - 2010-03-04 Version 0.2 - 2010-03-04
* added an alternative GTK interface with additional features: * added an alternative GTK interface with additional features:
......
...@@ -43,6 +43,9 @@ COLORS = { ...@@ -43,6 +43,9 @@ COLORS = {
"color_toolpath_return": (0.5, 1.0, 0.5), "color_toolpath_return": (0.5, 1.0, 0.5),
} }
# floating point color values are only available since gtk 2.16
GTK_COLOR_MAX = 65535
def show_error_dialog(window, message): def show_error_dialog(window, message):
warn_window = gtk.MessageDialog(window, type=gtk.MESSAGE_ERROR, warn_window = gtk.MessageDialog(window, type=gtk.MESSAGE_ERROR,
...@@ -420,11 +423,12 @@ class ProjectGui: ...@@ -420,11 +423,12 @@ class ProjectGui:
def get_color_wrapper(obj): def get_color_wrapper(obj):
def gtk_color_to_float(): def gtk_color_to_float():
gtk_color = obj.get_color() gtk_color = obj.get_color()
return (gtk_color.red_float, gtk_color.green_float, gtk_color.blue_float) return (gtk_color.red / GTK_COLOR_MAX, gtk_color.green / GTK_COLOR_MAX, gtk_color.blue / GTK_COLOR_MAX)
return gtk_color_to_float return gtk_color_to_float
def set_color_wrapper(obj): def set_color_wrapper(obj):
def set_gtk_color_by_float((red, green, blue)): def set_gtk_color_by_float((red, green, blue)):
obj.set_color(gtk.gdk.Color(red, green, blue)) obj.set_color(gtk.gdk.Color(int(red * GTK_COLOR_MAX),
int(green * GTK_COLOR_MAX), int(blue * GTK_COLOR_MAX)))
return set_gtk_color_by_float return set_gtk_color_by_float
for name, objname in (("color_background", "ColorBackground"), for name, objname in (("color_background", "ColorBackground"),
("color_model", "ColorModel"), ("color_model", "ColorModel"),
...@@ -534,7 +538,8 @@ class ProjectGui: ...@@ -534,7 +538,8 @@ class ProjectGui:
actiongroup = gtk.ActionGroup("menubar") actiongroup = gtk.ActionGroup("menubar")
for action in [action for action in self.gui.get_objects() if isinstance(action, gtk.Action)]: for action in [action for action in self.gui.get_objects() if isinstance(action, gtk.Action)]:
actiongroup.add_action(action) actiongroup.add_action(action)
uimanager.insert_action_group(actiongroup) # the "pos" parameter is optional since 2.12 - we can remove it later
uimanager.insert_action_group(actiongroup, pos=-1)
# load the menubar and connect functions to its items # load the menubar and connect functions to its items
self.menubar = uimanager.get_widget("/MenuBar") self.menubar = uimanager.get_widget("/MenuBar")
window_box = self.gui.get_object("WindowBox") window_box = self.gui.get_object("WindowBox")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment