[gnome-clocks] Add a spotlight transition to/from the standalone clock
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Add a spotlight transition to/from the standalone clock
- Date: Mon, 27 Aug 2012 12:01:15 +0000 (UTC)
commit 781480f6de41f4308a27bebd7d033320b3b04d79
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Aug 27 13:36:01 2012 +0200
Add a spotlight transition to/from the standalone clock
gnomeclocks/app.py | 35 ++++++++++++++++++++++-------------
gnomeclocks/widgets.py | 29 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 13 deletions(-)
---
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index c4f1503..5b98740 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -51,8 +51,8 @@ class Window(Gtk.ApplicationWindow):
self.set_size_request(640, 480)
self.vbox = Gtk.VBox()
- embed = Embed(self.vbox)
- self.add(embed)
+ self.embed = Embed(self.vbox)
+ self.add(self.embed)
self.notebook = Gtk.Notebook()
self.notebook.set_show_tabs(False)
self.notebook.set_show_border(False)
@@ -64,7 +64,7 @@ class Window(Gtk.ApplicationWindow):
self.views = (self.world, self.alarm, self.stopwatch, self.timer)
- self.toolbar = ClocksToolbar(self.views, embed)
+ self.toolbar = ClocksToolbar(self.views, self.embed)
self.vbox.pack_start(self.toolbar, False, False, 0)
self.vbox.pack_start(self.toolbar.selection_toolbar, False, False, 0)
@@ -86,18 +86,27 @@ class Window(Gtk.ApplicationWindow):
self.toolbar.activate_view(view)
def _on_show_clock(self, widget, d):
- self.toolbar._set_single_toolbar()
- self.notebook.set_current_page(-1)
- for child in self.single_evbox.get_children():
- self.single_evbox.remove(child)
- self.single_evbox.add(d.get_standalone_widget())
- self.single_evbox.show_all()
- self.toolbar.city_label.set_markup("<b>" + d.id + "</b>")
+ def show_standalone_clock():
+ self.toolbar._set_single_toolbar()
+ self.toolbar.city_label.set_markup("<b>%s</b>" % (d.id))
+ self.single_evbox.add(d.get_standalone_widget())
+ self.single_evbox.show_all()
+ self.notebook.set_current_page(-1)
+
+ self.embed.spotlight(show_standalone_clock)
def _on_view_clock(self, button, view):
- view.unselect_all()
- self.notebook.set_current_page(self.views.index(view))
- self.toolbar._set_overview_toolbar()
+ def show_clock_view():
+ for child in self.single_evbox.get_children():
+ self.single_evbox.remove(child)
+ view.unselect_all()
+ self.notebook.set_current_page(self.views.index(view))
+ self.toolbar._set_overview_toolbar()
+
+ if self.single_evbox.get_children():
+ self.embed.spotlight(show_clock_view)
+ else:
+ show_clock_view()
def _on_new_activated(self, action, param):
self.toolbar.current_view.open_new_dialog()
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index c0ad680..75d509a 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -828,6 +828,35 @@ class Embed(GtkClutter.Embed):
Clutter.BinAlignment.FIXED)
self.show_all()
+ # also pack a white background to use for spotlights
+ # between window modes
+ white = Clutter.Color.get_static(Clutter.StaticColor.WHITE)
+ self._background = Clutter.Actor(background_color=white)
+ self._viewLayout.add(self._background,
+ Clutter.BinAlignment.FILL,
+ Clutter.BinAlignment.FILL)
+ self._background.lower_bottom()
+
+ def _spotlight_finished(self, actor, name, is_finished):
+ self._viewActor.set_child_below_sibling(self._background, None)
+ self._background.disconnect_by_func(self._spotlight_finished)
+
+ def spotlight(self, action):
+ self._background.save_easing_state()
+ self._background.set_easing_duration(0)
+ self._viewActor.set_child_above_sibling(self._background, None)
+ self._background.set_opacity(255)
+ self._background.restore_easing_state()
+
+ action()
+
+ self._background.save_easing_state()
+ self._background.set_easing_duration(200)
+ self._background.set_easing_mode(Clutter.AnimationMode.LINEAR)
+ self._background.set_opacity(0)
+ self._background.restore_easing_state()
+ self._background.connect('transition-stopped::opacity', self._spotlight_finished)
+
def set_show_selectionbar(self, show):
if show:
self._selectionToolbar.fade_in()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]