Thursday, January 7, 2010

Tonight's Photobomb Feature: Ink Properties

Tonight I added ink width and ink color. This means that you can kinda sorta do a lolz with photobomb.

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:
  1. log a bug and hope this gets fixed in gtk
  2. figure out if the bug is in my code and fix it there
  3. use a more tradition gtk way of doing this kind of thing

2 comments:

  1. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung
    http://www.jual-jaring.blogspot.com/
    http://www.agen-jaring.blogspot.com/
    http://www.pancasamudera-safetynet.blogspot.com/
    http://www.toko-jaring.blogspot.com/
    http://www.pusat-jaring.blogspot.com/
    http://jualjaringpengaman.blogspot.com/
    https://pancasamudera.wordpress.com/
    https://pasangjaringfutsal.wordpress.com/
    https://jualtambangmurah.wordpress.com/
    https://tokojaring.wordpress.com/
    https://jualjaringfutsal.wordpress.com/
    https://jaringfutsal.wordpress.com/

    ReplyDelete