def max_signal(w): if window_is_max(w): win.unmaximize() print "min" else: win.maximize() print "max"
def expose_max_button(widget, event, cache_pixbuf, sub_dir, max_path_prefix, unmax_path_prefix): '''Expose function to replace event box's image.''' # Get dynamic pixbuf. if window_is_max(widget): normal_dpixbuf = ui_theme.get_pixbuf("%s/%s_normal.png" % (sub_dir, unmax_path_prefix)) hover_dpixbuf = ui_theme.get_pixbuf("%s/%s_hover.png" % (sub_dir, unmax_path_prefix)) press_dpixbuf = ui_theme.get_pixbuf("%s/%s_press.png" % (sub_dir, unmax_path_prefix)) else: normal_dpixbuf = ui_theme.get_pixbuf("%s/%s_normal.png" % (sub_dir, max_path_prefix)) hover_dpixbuf = ui_theme.get_pixbuf("%s/%s_hover.png" % (sub_dir, max_path_prefix)) press_dpixbuf = ui_theme.get_pixbuf("%s/%s_press.png" % (sub_dir, max_path_prefix)) # Get pixbuf along with button's sate. if widget.state == gtk.STATE_NORMAL: image = normal_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_PRELIGHT: image = hover_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_ACTIVE: image = press_dpixbuf.get_pixbuf() # Init size. image_width = image.get_width() image_height = image.get_height() # Draw button. pixbuf = image if pixbuf.get_width() != image_width or pixbuf.get_height() != image_height: cache_pixbuf.scale(image, image_width, image_height) pixbuf = cache_pixbuf.get_cache() cr = widget.window.cairo_create() draw_pixbuf(cr, pixbuf, widget.allocation.x, widget.allocation.y) # Propagate expose to children. propagate_expose(widget, event) return True