Example #1
0
 def _init_hsv_widgets(self, minimal, details):
     hsv, = find_widgets(self.color_sel, lambda w: w.get_name() == 'GtkHSV')
     hsv.unset_flags(gtk.CAN_FOCUS)
     hsv.unset_flags(gtk.CAN_DEFAULT)
     hsv.set_size_request(150, 150)
     container = hsv.parent
     if minimal:
         container.remove(hsv)
         self.add(hsv)
     else:
         container.parent.remove(container)
         # Make the packing box give extra space to the HSV widget
         container.set_child_packing(hsv, True, True, 0, gtk.PACK_START)
         container.set_spacing(0)
         if details:
             self.add_details_dialogs(container)
         self.add(container)
     # When extra space is given, grow the HSV wheel.
     # We can only control the GtkHSV's radius if PyGTK exposes it to us
     # as the undocumented gtk.HSV.
     if hasattr(hsv, "set_metrics"):
         def set_hsv_metrics(hsvwidget, alloc):
             radius = min(alloc.width, alloc.height)
             ring_width = max(12, int(radius/16))
             hsvwidget.set_metrics(radius, ring_width)
             hsvwidget.queue_draw()
         hsv.connect("size-allocate", set_hsv_metrics)
         self.hsv_widget = hsv
Example #2
0
 def add_details_dialogs(self, hsv_container):
     prev, current = find_widgets(hsv_container,
         lambda w: w.get_name() == 'GtkDrawingArea')
     def on_button_press(swatch, event):
         if event.type != gdk._2BUTTON_PRESS:
             return False
         dialogs.change_current_color_detailed(self.app)
     current.connect("button-press-event", on_button_press)
     prev.connect("button-press-event", on_button_press)