Rollovers in NM applet menu

This commit is contained in:
Dan Williams 2006-11-01 14:25:47 -05:00
parent a8fda48c72
commit 9ef18ffe99

View File

@ -288,6 +288,14 @@ nm_bubble_wireless = {
'padding' : style.space_unit * 1.5 'padding' : style.space_unit * 1.5
} }
nm_bubble_wireless_hi = {
'fill-color' : 0x979797FF,
'stroke-color' : 0x979797FF,
'progress-color': 0x666666FF,
'spacing' : style.space_unit,
'padding' : style.space_unit * 1.5
}
nm_bubble_wired = { nm_bubble_wired = {
'fill-color' : 0x000000FF, 'fill-color' : 0x000000FF,
'stroke-color' : 0x000000FF, 'stroke-color' : 0x000000FF,
@ -296,6 +304,14 @@ nm_bubble_wired = {
'padding' : style.space_unit * 1.5 'padding' : style.space_unit * 1.5
} }
nm_bubble_wired_hi = {
'fill-color' : 0x333333FF,
'stroke-color' : 0x3333333FF,
'progress-color': 0x000000FF,
'spacing' : style.space_unit,
'padding' : style.space_unit * 1.5
}
nm_menu_item_title = { nm_menu_item_title = {
'xalign': hippo.ALIGNMENT_START, 'xalign': hippo.ALIGNMENT_START,
'padding-left': 5, 'padding-left': 5,
@ -305,18 +321,36 @@ nm_menu_item_title = {
style.register_stylesheet("nm.Bubble.Wireless", nm_bubble_wireless) style.register_stylesheet("nm.Bubble.Wireless", nm_bubble_wireless)
style.register_stylesheet("nm.Bubble.Wireless.Hi", nm_bubble_wireless_hi)
style.register_stylesheet("nm.Bubble.Wired", nm_bubble_wired) style.register_stylesheet("nm.Bubble.Wired", nm_bubble_wired)
style.register_stylesheet("nm.Bubble.Wired.Hi", nm_bubble_wired_hi)
style.register_stylesheet("nm.MenuItem.Title", nm_menu_item_title) style.register_stylesheet("nm.MenuItem.Title", nm_menu_item_title)
class NetworkMenuItem(Bubble): class NetworkMenuItem(Bubble):
def __init__(self, text, percent=0, stylesheet="nm.Bubble.Wireless"): def __init__(self, text, percent=0, stylesheet="nm.Bubble.Wireless", hi_stylesheet="nm.Bubble.Wireless.Hi"):
Bubble.__init__(self, percent=percent) Bubble.__init__(self, percent=percent)
self._hover = False
self._default_stylesheet = stylesheet
self._hi_stylesheet = hi_stylesheet
style.apply_stylesheet(self, stylesheet) style.apply_stylesheet(self, stylesheet)
text_item = hippo.CanvasText(text=text) text_item = hippo.CanvasText(text=text)
style.apply_stylesheet(text_item, 'nm.MenuItem.Title') style.apply_stylesheet(text_item, 'nm.MenuItem.Title')
self.append(text_item) self.append(text_item)
self.connect('motion-notify-event', self._motion_notify_event_cb)
def _motion_notify_event_cb(self, widget, event, handled=False):
if event.detail == hippo.MOTION_DETAIL_ENTER:
if not self._hover:
self._hover = True
style.apply_stylesheet(self, self._hi_stylesheet)
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
if self._hover:
self._hover = False
style.apply_stylesheet(self, self._default_stylesheet)
class NetworkMenu(gtk.Window): class NetworkMenu(gtk.Window):
__gsignals__ = { __gsignals__ = {
'action': (gobject.SIGNAL_RUN_FIRST, 'action': (gobject.SIGNAL_RUN_FIRST,