Suspend the mesh view when it's not active so that
we don't keep blinking the icon in the background.
This commit is contained in:
parent
6c9eb64de3
commit
87f1e9bcc9
@ -9,7 +9,7 @@
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
@ -24,10 +24,15 @@ from view.home.MeshBox import MeshBox
|
||||
from view.home.HomeBox import HomeBox
|
||||
from view.home.FriendsBox import FriendsBox
|
||||
|
||||
_HOME_PAGE = 0
|
||||
_FRIENDS_PAGE = 1
|
||||
_MESH_PAGE = 2
|
||||
|
||||
class HomeWindow(gtk.Window):
|
||||
def __init__(self, shell):
|
||||
gtk.Window.__init__(self)
|
||||
self._shell = shell
|
||||
self._active = False
|
||||
|
||||
self.set_default_size(gtk.gdk.screen_width(),
|
||||
gtk.gdk.screen_height())
|
||||
@ -35,6 +40,8 @@ class HomeWindow(gtk.Window):
|
||||
self.realize()
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
|
||||
self.connect("key-release-event", self._key_release_cb)
|
||||
self.connect('focus-in-event', self._focus_in_cb)
|
||||
self.connect('focus-out-event', self._focus_out_cb)
|
||||
|
||||
self._nb = gtk.Notebook()
|
||||
self._nb.set_show_border(False)
|
||||
@ -56,8 +63,8 @@ class HomeWindow(gtk.Window):
|
||||
canvas.show()
|
||||
|
||||
canvas = hippo.Canvas()
|
||||
box = MeshBox(shell, MenuShell(canvas))
|
||||
canvas.set_root(box)
|
||||
self._mesh_box = MeshBox(shell, MenuShell(canvas))
|
||||
canvas.set_root(self._mesh_box)
|
||||
self._nb.append_page(canvas)
|
||||
canvas.show()
|
||||
|
||||
@ -66,13 +73,29 @@ class HomeWindow(gtk.Window):
|
||||
if keyname == "Alt_L":
|
||||
self._home_box.release()
|
||||
|
||||
def _update_mesh_state(self):
|
||||
if self._active and self._nb.get_current_page() == _MESH_PAGE:
|
||||
self._mesh_box.resume()
|
||||
else:
|
||||
self._mesh_box.suspend()
|
||||
|
||||
def _focus_in_cb(self, widget, event):
|
||||
self._active = True
|
||||
self._update_mesh_state()
|
||||
|
||||
def _focus_out_cb(self, widget, event):
|
||||
self._active = False
|
||||
self._update_mesh_state()
|
||||
|
||||
def set_zoom_level(self, level):
|
||||
if level == sugar.ZOOM_HOME:
|
||||
self._nb.set_current_page(0)
|
||||
self._nb.set_current_page(_HOME_PAGE)
|
||||
elif level == sugar.ZOOM_FRIENDS:
|
||||
self._nb.set_current_page(1)
|
||||
self._nb.set_current_page(_FRIENDS_PAGE)
|
||||
elif level == sugar.ZOOM_MESH:
|
||||
self._nb.set_current_page(2)
|
||||
self._nb.set_current_page(_MESH_PAGE)
|
||||
|
||||
self._update_mesh_state()
|
||||
|
||||
def get_home_box(self):
|
||||
return self._home_box
|
||||
|
@ -204,6 +204,7 @@ class MeshBox(SpreadBox):
|
||||
self._access_points = {}
|
||||
self._mesh = None
|
||||
self._buddy_to_activity = {}
|
||||
self._suspended = True
|
||||
|
||||
for buddy_model in self._model.get_buddies():
|
||||
self._add_alone_buddy(buddy_model)
|
||||
@ -329,3 +330,15 @@ class MeshBox(SpreadBox):
|
||||
icon = self._access_points[ap_model.get_id()]
|
||||
self.remove_item(icon)
|
||||
del self._access_points[ap_model.get_id()]
|
||||
|
||||
def suspend(self):
|
||||
if not self._suspended:
|
||||
self._suspended = True
|
||||
for ap in self._access_points.values():
|
||||
ap.props.paused = True
|
||||
|
||||
def resume(self):
|
||||
if self._suspended:
|
||||
self._suspended = False
|
||||
for ap in self._access_points.values():
|
||||
ap.props.paused = False
|
||||
|
@ -20,6 +20,8 @@ from sugar.graphics.canvasicon import CanvasIcon
|
||||
|
||||
class PulsingIcon(CanvasIcon):
|
||||
__gproperties__ = {
|
||||
'paused' : (bool, None, None, False,
|
||||
gobject.PARAM_READWRITE),
|
||||
'colors' : (object, None, None,
|
||||
gobject.PARAM_READWRITE),
|
||||
'pulse-time' : (float, None, None,
|
||||
@ -28,6 +30,7 @@ class PulsingIcon(CanvasIcon):
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self._paused = False
|
||||
self._pulse_time = 0.0
|
||||
self._colors = None
|
||||
self._pulse_sid = 0
|
||||
@ -41,12 +44,18 @@ class PulsingIcon(CanvasIcon):
|
||||
if pspec.name == 'pulse-time':
|
||||
self._pulse_time = value
|
||||
self._stop()
|
||||
if self._pulse_time > 0.0:
|
||||
if not self._paused and self._pulse_time > 0.0:
|
||||
self._start()
|
||||
elif pspec.name == 'colors':
|
||||
self._colors = value
|
||||
self._pos = 0
|
||||
self._update_colors()
|
||||
elif pspec.name == 'paused':
|
||||
self._paused = value
|
||||
if not self._paused and self._pulse_time > 0.0:
|
||||
self._start()
|
||||
else:
|
||||
self._stop()
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
CanvasIcon.do_get_property(self, pspec)
|
||||
|
@ -1,6 +1,6 @@
|
||||
VERSION=0.63
|
||||
DATE=`date +%Y%m%d`
|
||||
RELEASE=2.65
|
||||
RELEASE=2.67
|
||||
TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2
|
||||
|
||||
rm sugar-$VERSION.tar.bz2
|
||||
|
Loading…
Reference in New Issue
Block a user