X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=bin%2Fembrace;h=6433d0475d371624a2b3a0024daebfdf62f6fd3d;hb=6e0caa5565c83f5f5d8b451c4ad5b85ea87d8564;hp=9772596e4280c26e21eeb6148f706d9049379765;hpb=16f509dbf97d51232c282cce8c22090435ff3a66;p=embrace.git diff --git a/bin/embrace b/bin/embrace index 9772596..6433d04 100755 --- a/bin/embrace +++ b/bin/embrace @@ -134,21 +134,21 @@ module Embrace end # smart callbacks - def on_show + def smart_show @objects.each { |o| o.show } @alpha_anim ||= AlphaAnimator.new(2, @img, @label) @alpha_anim.on_finished { @alpha_anim = nil } end - def on_hide + def smart_hide @objects.each { |o| o.hide } @alpha_anim && @alpha_anim.delete @alpha_anim = nil end - def on_delete + def smart_delete @objects.each { |o| o.delete } @objects.clear @@ -157,13 +157,13 @@ module Embrace @img = @label = @alpha_anim = nil end - def on_move(x, y) + def smart_move(x, y) @objects.each { |o| o.move(x, y) } @label.center(self) end - def on_resize(w, h) + def smart_resize(w, h) @img.resize(w, h) end end @@ -177,7 +177,7 @@ module Embrace super @bg = Evas::Rectangle.new(evas) - @bg.set_color(0, 0, 0, 255) + @bg.set_color(0, 0, 0, 8) add_member(@bg) @@ -188,6 +188,14 @@ module Embrace @add_lock_count = 0 end + def can_add? + !slots_left.zero? && @add_lock_count.zero? + end + + def can_delete? + @about_to_add.zero? && @add_lock_count.zero? + end + def <<(i) Kernel.raise(ContainerFullError) if slots_left.zero? Kernel.raise(ContainerLockedError) unless @add_lock_count.zero? @@ -248,24 +256,24 @@ module Embrace end # smart callbacks - def on_show + def smart_show @bg.show end - def on_hide + def smart_hide @bg.hide end - def on_delete + def smart_delete @bg.delete @bg = nil end - def on_move(x, y) + def smart_move(x, y) @bg.move(x, y) end - def on_resize(w, h) + def smart_resize(w, h) @bg.resize(w, h) end @@ -287,6 +295,7 @@ module Embrace def initialize super + self.has_alpha = true self.title = "Embrace" self.borderless = true @@ -330,10 +339,6 @@ module Embrace end private - def add_icon(name) - @container << MailboxIcon.new(evas, name) - end - def on_timer return unless @server.nil? @@ -352,22 +357,10 @@ module Embrace found = evas.find_object(lbl) - begin - if ev.count.zero? - unless found.nil? - #puts "removing icon #{lbl}" - @container.delete(found) - else - #puts "count == 0, but icon not found (#{lbl})" - end - elsif found.nil? - #puts "adding icon #{lbl}" - add_icon(lbl) - else - #puts "count > 0, but already there (#{lbl})" - end - rescue Exception => e - puts e.message + if ev.count.zero? && !found.nil? && @container.can_delete? + @container.delete(found) + elsif !ev.count.zero? && found.nil? && @container.can_add? + @container << MailboxIcon.new(evas, lbl) end false