Work around non-bound HippoCanvas 'clickable' property by using button-press-event instead

This commit is contained in:
Dan Williams 2006-11-01 16:55:24 -05:00
parent a6ff123ffe
commit 823f1cf6f7

View File

@ -118,7 +118,7 @@ class Network(gobject.GObject):
elif strength < 0: elif strength < 0:
strength = 0 strength = 0
item = NetworkMenuItem(text=self._ssid, percent=strength) item = NetworkMenuItem(text=self._ssid, percent=strength)
item.connect('activated', callback, dev, self) item.connect('button-press-event', callback, (dev, self))
menu.add_item(item) menu.add_item(item)
@ -193,7 +193,7 @@ class Device(gobject.GObject):
item = NetworkMenuItem(_("Wired Network"), stylesheet="nm.Bubble.Wired", item = NetworkMenuItem(_("Wired Network"), stylesheet="nm.Bubble.Wired",
hi_stylesheet="nm.Bubble.Wired.Hi", hi_stylesheet="nm.Bubble.Wired.Hi",
act_stylesheet="nm.Bubble.Wired.Activated") act_stylesheet="nm.Bubble.Wired.Activated")
item.connect('activated', callback, self) item.connect('button-press-event', callback, (self, None))
menu.add_item(item) menu.add_item(item)
def _add_to_menu_wireless(self, menu, callback, active_only): def _add_to_menu_wireless(self, menu, callback, active_only):
@ -364,8 +364,8 @@ class NetworkMenuItem(Bubble):
self.append(text_item) self.append(text_item)
self.connect('motion-notify-event', self._motion_notify_event_cb) self.connect('motion-notify-event', self._motion_notify_event_cb)
self.connect('button-press-event', self._button_press_event_cb) # Disable active hilight for now...
self.connect('activated', self._activated_cb) #self.connect('button-press-event', self._button_press_event_cb)
def _motion_notify_event_cb(self, widget, event): def _motion_notify_event_cb(self, widget, event):
if event.detail == hippo.MOTION_DETAIL_ENTER: if event.detail == hippo.MOTION_DETAIL_ENTER:
@ -379,18 +379,9 @@ class NetworkMenuItem(Bubble):
return True return True
def _button_press_event_cb(self, widget, event): def _button_press_event_cb(self, widget, event):
logging.debug("button press")
style.apply_stylesheet(self, self._act_stylesheet) style.apply_stylesheet(self, self._act_stylesheet)
return False return False
def _activated_cb(self, widget):
logging.debug("activated: %s" % self._hover)
if self._hover:
style.apply_stylesheet(self, self._act_stylesheet)
else:
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,
@ -761,7 +752,8 @@ class NMClientApp:
for arg in args: for arg in args:
logging.debug(' ' + str(arg)) logging.debug(' ' + str(arg))
def _menu_item_clicked_cb(self, widget, device, network=None): def _menu_item_clicked_cb(self, widget, event, dev_data):
(device, network) = dev_data
net_op = "" net_op = ""
if network: if network:
net_op = network.get_op() net_op = network.get_op()