I was a bit bummed to find that there is an Ink Color Button, but there doesn't seem to be a similar control for a toolbar. So I just made a button that pops up the color dialog.
It would be sweet if there was a popup menu connected to a toolbar, so you could kind of pull down and set your color instead of popping the dialog. Perhaps there is a related quidget in the future. Speaking of quidgets, I similarly used a popup to get the integer value from the user for the ink width. It was nice to be able to just pop up the prompt with a one liner and move on. So Quidgets ftw!
I used goocanvases to show the current color and line width on the buttons:
path_str = "M 5 20 L 25 20"
self.__ink_width = 5
ink_button_gc = goocanvas.Canvas()
ink_button_gc.set_bounds(0,0,40,40)
ink_button_gc.show()
bttn_root = ink_button_gc.get_root_item()
self.__ink_width_path = goocanvas.Path(data=path_str,
parent=bttn_root, line_width=self.__ink_width,
stroke_color=self.__ink_color)
self.builder.get_object("toolbutton_ink_width").set_icon_widget(ink_button_gc)
It seems to work, but every time the code makes the change, I get a gtk warning:
bin/photobomb:304: Warning: invalid cast from `GooCanvas' to `GtkMisc'
gtk.main()
bin/photobomb:304: GtkWarning: gtk_misc_set_alignment: assertion `GTK_IS_MISC (misc)' failed
gtk.main()
I suppose I'll need to either:
- log a bug and hope this gets fixed in gtk
- figure out if the bug is in my code and fix it there
- use a more tradition gtk way of doing this kind of thing
No comments:
Post a Comment