Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
e6ab812294
@ -63,6 +63,11 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
devices_model.connect('device-disappeared',
|
||||
self._device_disappeared_cb)
|
||||
|
||||
self._redraw_id = None
|
||||
|
||||
def __del__(self):
|
||||
self.suspend()
|
||||
|
||||
def _add_device(self, device):
|
||||
view = deviceview.create(device)
|
||||
self.append(view, hippo.PACK_FIXED)
|
||||
@ -103,6 +108,23 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
i += 1
|
||||
|
||||
_REDRAW_TIMEOUT = 5 * 60 * 1000 # 5 minutes
|
||||
|
||||
def resume(self):
|
||||
self._redraw_activity_ring()
|
||||
if self._redraw_id is None:
|
||||
self._redraw_id = gobject.timeout_add(self._REDRAW_TIMEOUT,
|
||||
self._redraw_activity_ring)
|
||||
|
||||
def suspend(self):
|
||||
if self._redraw_id is not None:
|
||||
gobject.source_remove(self._redraw_id)
|
||||
self._redraw_id = None
|
||||
|
||||
def _redraw_activity_ring(self):
|
||||
self._donut.emit_request_changed()
|
||||
return True
|
||||
|
||||
def has_activities(self):
|
||||
return self._donut.has_activities()
|
||||
|
||||
|
@ -64,6 +64,7 @@ class HomeWindow(gtk.Window):
|
||||
self._mesh_box = MeshBox(shell)
|
||||
self._transition_box = TransitionBox()
|
||||
|
||||
self._activate_view()
|
||||
self._canvas.set_root(self._home_box)
|
||||
|
||||
self._transition_box.connect('completed',
|
||||
@ -93,22 +94,28 @@ class HomeWindow(gtk.Window):
|
||||
if keyname == "Alt_L":
|
||||
self._home_box.release()
|
||||
|
||||
def _update_mesh_state(self):
|
||||
if self._active and self._level == ShellModel.ZOOM_MESH:
|
||||
self._mesh_box.resume()
|
||||
else:
|
||||
def _deactivate_view(self):
|
||||
if self._level == ShellModel.ZOOM_HOME:
|
||||
self._home_box.suspend()
|
||||
elif self._level == ShellModel.ZOOM_MESH:
|
||||
self._mesh_box.suspend()
|
||||
|
||||
def _activate_view(self):
|
||||
if self._level == ShellModel.ZOOM_HOME:
|
||||
self._home_box.resume()
|
||||
elif self._level == ShellModel.ZOOM_MESH:
|
||||
self._mesh_box.resume()
|
||||
|
||||
def _focus_in_cb(self, widget, event):
|
||||
self._active = True
|
||||
self._update_mesh_state()
|
||||
self._activate_view()
|
||||
|
||||
def _focus_out_cb(self, widget, event):
|
||||
self._active = False
|
||||
self._update_mesh_state()
|
||||
self._deactivate_view()
|
||||
|
||||
def set_zoom_level(self, level):
|
||||
self._deactivate_view()
|
||||
self._level = level
|
||||
self._activate_view()
|
||||
|
||||
self._canvas.set_root(self._transition_box)
|
||||
|
||||
@ -129,7 +136,5 @@ class HomeWindow(gtk.Window):
|
||||
elif self._level == ShellModel.ZOOM_MESH:
|
||||
self._canvas.set_root(self._mesh_box)
|
||||
|
||||
self._update_mesh_state()
|
||||
|
||||
def get_home_box(self):
|
||||
return self._home_box
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import colorsys
|
||||
from gettext import gettext as _
|
||||
import logging
|
||||
import math
|
||||
|
||||
import hippo
|
||||
@ -317,10 +318,12 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
||||
'expected format' % pid)
|
||||
|
||||
# Next, see how much free memory is left.
|
||||
free_memory = 0
|
||||
try:
|
||||
meminfo = open('/proc/meminfo')
|
||||
meminfo.readline()
|
||||
free_memory = int(meminfo.readline()[9:-3])
|
||||
for line in meminfo.readlines():
|
||||
if line.startswith('MemFree:') or line.startswith('SwapFree:'):
|
||||
free_memory += int(line[9:-3])
|
||||
meminfo.close()
|
||||
except IOError:
|
||||
logging.warn('ActivitiesDonut: could not read /proc/meminfo')
|
||||
|
Loading…
Reference in New Issue
Block a user