4 BUTTON_HILIGHT_FILE_NAME = "/etc/hildon/theme/mediaplayer/Button.png"
6 fancy_button_highlight_pb = None
8 class FancyButton (gtk.EventBox):
11 'clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
14 def __init__ (self, image, text):
15 gtk.EventBox.__init__ (self)
21 self.label = gtk.Label (text)
23 align = gtk.Alignment (xalign=0.5, yalign=0.5)
24 align.add (self.image)
26 vbox.pack_start (align, expand=False, fill=False)
27 vbox.pack_start (self.label, expand=False, fill=False)
30 self.set_visible_window (False)
31 self.set_above_child (True)
33 self.connect ("button-press-event", self.custom_button_press_event)
34 self.connect ("button-release-event", self.custom_button_release_event)
35 self.connect ("enter-notify-event", self.custom_enter_notify_event)
36 self.connect ("leave-notify-event", self.custom_leave_notify_event)
37 self.image.connect ("expose-event", self.image_expose_event)
40 def custom_button_press_event (self, p, q):
41 self.image.set_state (gtk.STATE_ACTIVE)
45 def custom_button_release_event (self, p, q):
47 if (self.pressed and self.image.state == gtk.STATE_ACTIVE):
50 self.image.set_state (gtk.STATE_NORMAL)
53 def custom_enter_notify_event (self, p, q):
55 self.image.set_state (gtk.STATE_ACTIVE)
57 def custom_leave_notify_event (self, p, q):
58 self.image.set_state (gtk.STATE_NORMAL)
60 def image_expose_event (self, widget, event):
61 global fancy_button_highlight_pb
63 if (widget.state == gtk.STATE_ACTIVE):
64 if (fancy_button_highlight_pb):
65 widget.window.draw_pixbuf (None,
66 fancy_button_highlight_pb,
71 gtk.Style.paint_flat_box (widget.style,
84 def settings_changed (obj, spec):
85 global fancy_button_highlight_pb
87 fancy_button_highlight_pb = gtk.gdk.pixbuf_new_from_file (BUTTON_HILIGHT_FILE_NAME)
90 fancy_button_highlight_pb = None
92 if __name__ == "__main__":
96 settings = gtk.settings_get_default ()
97 settings.connect ("notify", settings_changed)
98 settings_changed (None, None)
102 frame.add (FancyButton ())
104 align = gtk.Alignment (xalign=0.5, yalign=0.5)
110 w.connect ("delete-event", gtk.main_quit)