Merge branch 'master' of git://dev.laptop.org/sugar
This commit is contained in:
commit
a6503b8bd8
@ -103,6 +103,7 @@ class Bubble(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
cr.set_line_width(line_width)
|
cr.set_line_width(line_width)
|
||||||
cr.stroke();
|
cr.stroke();
|
||||||
|
|
||||||
|
if self._percent > 0:
|
||||||
self._paint_progress_bar(cr, x, y, width, height, line_width)
|
self._paint_progress_bar(cr, x, y, width, height, line_width)
|
||||||
|
|
||||||
def _paint_progress_bar(self, cr, x, y, width, height, line_width):
|
def _paint_progress_bar(self, cr, x, y, width, height, line_width):
|
||||||
|
@ -111,13 +111,14 @@ class Network(gobject.GObject):
|
|||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return self._valid
|
return self._valid
|
||||||
|
|
||||||
def add_to_menu(self, menu):
|
def add_to_menu(self, menu, callback, dev):
|
||||||
strength = self._strength
|
strength = self._strength
|
||||||
if strength > 100:
|
if strength > 100:
|
||||||
strength = 100
|
strength = 100
|
||||||
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('button-press-event', callback, (dev, self))
|
||||||
menu.add_item(item)
|
menu.add_item(item)
|
||||||
|
|
||||||
|
|
||||||
@ -188,18 +189,21 @@ class Device(gobject.GObject):
|
|||||||
self._active_net = None
|
self._active_net = None
|
||||||
del self._networks[net_op]
|
del self._networks[net_op]
|
||||||
|
|
||||||
def _add_to_menu_wired(self, menu):
|
def _add_to_menu_wired(self, menu, callback):
|
||||||
item = NetworkMenuItem(_("Wired Network"), stylesheet="nm.Bubble.Wired")
|
item = NetworkMenuItem(_("Wired Network"), stylesheet="nm.Bubble.Wired",
|
||||||
|
hi_stylesheet="nm.Bubble.Wired.Hi",
|
||||||
|
act_stylesheet="nm.Bubble.Wired.Activated")
|
||||||
|
item.connect('button-press-event', callback, (self, None))
|
||||||
menu.add_item(item)
|
menu.add_item(item)
|
||||||
|
|
||||||
def _add_to_menu_wireless(self, menu, active_only):
|
def _add_to_menu_wireless(self, menu, callback, active_only):
|
||||||
act_net = None
|
act_net = None
|
||||||
if self._active_net and self._networks.has_key(self._active_net):
|
if self._active_net and self._networks.has_key(self._active_net):
|
||||||
act_net = self._networks[self._active_net]
|
act_net = self._networks[self._active_net]
|
||||||
|
|
||||||
# Only add the active network if active_only == True
|
# Only add the active network if active_only == True
|
||||||
if active_only and act_net:
|
if active_only and act_net:
|
||||||
act_net.add_to_menu(menu)
|
act_net.add_to_menu(menu, callback, self)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Otherwise, add all networks _except_ the active one
|
# Otherwise, add all networks _except_ the active one
|
||||||
@ -208,13 +212,13 @@ class Device(gobject.GObject):
|
|||||||
continue
|
continue
|
||||||
if act_net == net:
|
if act_net == net:
|
||||||
continue
|
continue
|
||||||
net.add_to_menu(menu)
|
net.add_to_menu(menu, callback, self)
|
||||||
|
|
||||||
def add_to_menu(self, menu, active_only=False):
|
def add_to_menu(self, menu, callback, active_only=False):
|
||||||
if self._type == DEVICE_TYPE_802_3_ETHERNET:
|
if self._type == DEVICE_TYPE_802_3_ETHERNET:
|
||||||
self._add_to_menu_wired(menu)
|
self._add_to_menu_wired(menu, callback)
|
||||||
elif self._type == DEVICE_TYPE_802_11_WIRELESS:
|
elif self._type == DEVICE_TYPE_802_11_WIRELESS:
|
||||||
self._add_to_menu_wireless(menu, active_only)
|
self._add_to_menu_wireless(menu, callback, active_only)
|
||||||
|
|
||||||
def get_op(self):
|
def get_op(self):
|
||||||
return self._op
|
return self._op
|
||||||
@ -288,6 +292,22 @@ 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_wireless_activated = {
|
||||||
|
'fill-color' : 0xA7A7A7FF,
|
||||||
|
'stroke-color' : 0xA7A7A7FF,
|
||||||
|
'progress-color': 0x777777FF,
|
||||||
|
'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 +316,22 @@ nm_bubble_wired = {
|
|||||||
'padding' : style.space_unit * 1.5
|
'padding' : style.space_unit * 1.5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_bubble_wired_hi = {
|
||||||
|
'fill-color' : 0x333333FF,
|
||||||
|
'stroke-color' : 0x333333FF,
|
||||||
|
'progress-color': 0x000000FF,
|
||||||
|
'spacing' : style.space_unit,
|
||||||
|
'padding' : style.space_unit * 1.5
|
||||||
|
}
|
||||||
|
|
||||||
|
nm_bubble_wired_activated = {
|
||||||
|
'fill-color' : 0x444444FF,
|
||||||
|
'stroke-color' : 0x444444FF,
|
||||||
|
'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 +341,47 @@ 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.Wireless.Activated", nm_bubble_wireless_activated)
|
||||||
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.Bubble.Wired.Activated", nm_bubble_wired_activated)
|
||||||
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",
|
||||||
|
act_stylesheet="nm.Bubble.Wireless.Activated"):
|
||||||
Bubble.__init__(self, percent=percent)
|
Bubble.__init__(self, percent=percent)
|
||||||
|
self._hover = False
|
||||||
|
self._default_stylesheet = stylesheet
|
||||||
|
self._hi_stylesheet = hi_stylesheet
|
||||||
|
self._act_stylesheet = act_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)
|
||||||
|
# Disable active hilight for now...
|
||||||
|
#self.connect('button-press-event', self._button_press_event_cb)
|
||||||
|
|
||||||
|
def _motion_notify_event_cb(self, widget, event):
|
||||||
|
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)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _button_press_event_cb(self, widget, event):
|
||||||
|
style.apply_stylesheet(self, self._act_stylesheet)
|
||||||
|
return False
|
||||||
|
|
||||||
class NetworkMenu(gtk.Window):
|
class NetworkMenu(gtk.Window):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'action': (gobject.SIGNAL_RUN_FIRST,
|
'action': (gobject.SIGNAL_RUN_FIRST,
|
||||||
@ -523,7 +588,7 @@ class NMClientApp:
|
|||||||
act_dev = self._devices[self._active_device]
|
act_dev = self._devices[self._active_device]
|
||||||
|
|
||||||
if act_dev:
|
if act_dev:
|
||||||
act_dev.add_to_menu(menu, active_only=True)
|
act_dev.add_to_menu(menu, self._menu_item_clicked_cb, active_only=True)
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
|
|
||||||
# Wired devices first, if they don't support carrier detect
|
# Wired devices first, if they don't support carrier detect
|
||||||
@ -536,7 +601,7 @@ class NMClientApp:
|
|||||||
continue
|
continue
|
||||||
if dev == act_dev:
|
if dev == act_dev:
|
||||||
continue
|
continue
|
||||||
dev.add_to_menu(menu)
|
dev.add_to_menu(menu, self._menu_item_clicked_cb)
|
||||||
|
|
||||||
# Wireless devices second
|
# Wireless devices second
|
||||||
for dev in self._devices.values():
|
for dev in self._devices.values():
|
||||||
@ -544,7 +609,7 @@ class NMClientApp:
|
|||||||
continue
|
continue
|
||||||
if dev.get_type() != DEVICE_TYPE_802_11_WIRELESS:
|
if dev.get_type() != DEVICE_TYPE_802_11_WIRELESS:
|
||||||
continue
|
continue
|
||||||
dev.add_to_menu(menu)
|
dev.add_to_menu(menu, self._menu_item_clicked_cb)
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
@ -687,6 +752,13 @@ 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, event, dev_data):
|
||||||
|
(device, network) = dev_data
|
||||||
|
net_op = ""
|
||||||
|
if network:
|
||||||
|
net_op = network.get_op()
|
||||||
|
logging.debug("clicked dev %s, net %s" % (device.get_op(), net_op))
|
||||||
|
|
||||||
def device_activation_stage_sig_handler(self, device, stage):
|
def device_activation_stage_sig_handler(self, device, stage):
|
||||||
print 'Network Manager Device Stage "%s" for device %s'%(NM_DEVICE_STAGE_STRINGS[stage], device)
|
print 'Network Manager Device Stage "%s" for device %s'%(NM_DEVICE_STAGE_STRINGS[stage], device)
|
||||||
|
|
||||||
|
@ -76,5 +76,9 @@ for i in range(1, len(sys.argv)):
|
|||||||
emulator = Emulator(fullscreen)
|
emulator = Emulator(fullscreen)
|
||||||
emulator.start()
|
emulator.start()
|
||||||
|
|
||||||
|
# FIXME temporary until dbus support services in home dir
|
||||||
|
if not os.path.isdir('/tmp/sugar-services'):
|
||||||
|
os.mkdir('/tmp/sugar-services')
|
||||||
|
|
||||||
os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session',
|
os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session',
|
||||||
'--config-file=%s' % env.get_dbus_config(), program)
|
'--config-file=%s' % env.get_dbus_config(), program)
|
||||||
|
@ -12,6 +12,7 @@ class Bundle:
|
|||||||
self._show_launcher = False
|
self._show_launcher = False
|
||||||
self._valid = True
|
self._valid = True
|
||||||
self._path = path
|
self._path = path
|
||||||
|
self._activity_version = 0
|
||||||
|
|
||||||
info_path = os.path.join(path, 'activity', 'activity.info')
|
info_path = os.path.join(path, 'activity', 'activity.info')
|
||||||
if os.path.isfile(info_path):
|
if os.path.isfile(info_path):
|
||||||
@ -50,6 +51,9 @@ class Bundle:
|
|||||||
if cp.has_option(section, 'icon'):
|
if cp.has_option(section, 'icon'):
|
||||||
self._icon = cp.get(section, 'icon')
|
self._icon = cp.get(section, 'icon')
|
||||||
|
|
||||||
|
if cp.has_option(section, 'activity_version'):
|
||||||
|
self._activity_version = int(cp.get(section, 'activity_version'))
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return self._valid
|
return self._valid
|
||||||
|
|
||||||
@ -69,6 +73,10 @@ class Bundle:
|
|||||||
"""Get the activity icon name"""
|
"""Get the activity icon name"""
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
||||||
|
def get_activity_version(self):
|
||||||
|
"""Get the activity version"""
|
||||||
|
return self._activity_version
|
||||||
|
|
||||||
def get_exec(self):
|
def get_exec(self):
|
||||||
"""Get the command to execute to launch the activity factory"""
|
"""Get the command to execute to launch the activity factory"""
|
||||||
return self._exec
|
return self._exec
|
||||||
|
Loading…
Reference in New Issue
Block a user