# Screen splash

**URL:** <https://www.ruby-forum.com/t/screen-splash/135341>\
**Category:** Ruby-Gnome 2\
**Created:** [April 21, 2008, 11:08am UTC](https://www.ruby-forum.com/t/screen-splash/135341 "2008-04-21T11:08:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 11:08am UTC](https://www.ruby-forum.com/t/screen-splash/135341/1 "2008-04-21T11:08:10Z")

</div>

Hi:

how can i make an screen splash to see before application was open??

ItÂ´s important for me beacuse i need put a company logo. ItÂ´s something  
like institutional, nor functional.

pd: I am using libglade.

Regards.

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/2 "2008-04-21T12:43:59Z")

</div>

> how can i make an screen splash to see before application was open??
> 
> ItÂ´s important for me beacuse i need put a company logo. ItÂ´s something  
> like institutional, nor functional.
> 
> pd: I am using libglade.

Hi,

Please define “before”. Until ruby & gtk is loaded, you cannot do such  
thing. But then it’s just a window with an image.

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 12:47pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/3 "2008-04-21T12:47:31Z")

</div>

Hi:

I have found a PHP GTK sample here:

> **[Splash screens with PHP-GTK](http://phpexperts.blogspot.com/2007/05/splash-screens-with-php-gtk.html)**
>
> Splash screen is a term used to describe an image that appears while a computer program is loading. Splash screens often don't cover the ent...

this is my ruby version.

It works fine but the callback doesntÂ´s work. Any help?  
Someone know like conect a signal inside a class:

class One  
def initialize(callback)  
callback  
end

end

class Main  
def initialize  
One.new(“talk\_with\_me”)  
end

def talk\_with\_me  
puts “i am here”  
end

end

GTK version by now:

* * *

require ‘gtk2’

class SplashScreen \< Gtk::Window

def initialize(img\_dir,callback)  
super(Gtk:🪟:POPUP)  
self.window\_position=Gtk:🪟:POS\_CENTER  
vbox=Gtk::VBox.new  
img=Gtk::Image.new(img\_dir)  
vbox.pack\_start(img,false,false)  
self.add(vbox)  
self.show\_all  
Gtk.timeout\_add(100) {  
callback  
}  
end

def hide  
self.hide  
end  
end

class Application

def initialize  
@splash=SplashScreen.new(“screen.png”,“end\_splash”)

end

def end\_splash  
@splash.hide  
puts “i am not here!!!”  
end  
end

Application.new

Gtk.main

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 12:54pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/4 "2008-04-21T12:54:21Z")

</div>

Hi:

> Hi,
> 
> Please define “before”. Until ruby & gtk is loaded, you cannot do such  
> thing. But then it’s just a window with an image.

I know, i donÂ´t need create a screen splash professional and real. The  
most important is the company logo, because the software is a fake 😃 .  
itÂ´s only for publicity.

thanks.

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 1:13pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/5 "2008-04-21T13:13:09Z")

</div>

thanks joaz:

this is my final version of the fake:  
I have added a timeout remove because create infinite windows, and i  
have added a time parameter to be configurable.

require ‘gtk2’

class SplashScreen \< Gtk::Window

def initialize(img\_dir,time,&callback)  
super(Gtk::Window::POPUP)  
self.window\_position=Gtk::Window::POS\_CENTER  
vbox=Gtk::VBox.new  
img=Gtk::Image.new(img\_dir)  
vbox.pack\_start(img,false,false)  
self.add(vbox)  
self.show\_all  
@id\_timeout=Gtk.timeout\_add(time) {  
callback.call  
}  
end

def hide\_splash  
self.hide  
Gtk.timeout\_remove(@id\_timeout)

end  
end

class Application

def initialize  
@splash=SplashScreen.new(“screen.png”,1000){  
end\_splash  
}

end

def end\_splash  
@splash.hide\_splash  
@window=Gtk::Window.new  
@window.signal\_connect(“destroy”) { Gtk.main\_quit }  
@window.window\_position=Gtk::Window::POS\_CENTER  
@window.show\_all  
end  
end

Application.new

Gtk.main

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 12:55pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/6 "2008-04-21T12:55:25Z")

</div>

> It works fine but the callback doesntÂ´s work. Any help?  
> Someone know like conect a signal inside a class:  
> Sure it doesn’t work like. You’re giving a string parameter to the  
> Splashscreen class. You can’t expect a String to call a function 🙂

Try using blocks:

def initialize(img\_dir,&callback)  
[…]  
Gtk.timeout\_add(100) {  
callback.call  
}  
end

And then  
@splash=SplashScreen.new(“screen.png”){  
end\_splash  
}

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 5:12pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/7 "2008-04-21T17:12:32Z")

</div>

> Application.new
> 
> Gtk.main

this part is probably dangerous. your Application object is normally  
reclaimable by the garbage collector, as you hold no references on it  
when you trigger Gtk.main.

–  
Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/8 "2008-04-21T17:55:19Z")

</div>

Guillaume C. wrote:

> > Application.new
> > 
> > Gtk.main
> 
> this part is probably dangerous. your Application object is normally  
> reclaimable by the garbage collector, as you hold no references on it  
> when you trigger Gtk.main.
> 
> –  
> Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)

Thanks Guillaume. I donÂ´t know the garbage collector system in ruby.

What is it a better solution then??

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 22, 2008, 11:15am UTC](https://www.ruby-forum.com/t/screen-splash/135341/9 "2008-04-22T11:15:42Z")

</div>

On Mon, Apr 21, 2008 at 5:55 PM, Martin V.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > –  
> > Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)
> 
> Thanks Guillaume. I don´t know the garbage collector system in ruby.
> 
> What is it a better solution then??

You just need to retain a reference on your object. As the application  
is global to the program, I find the use of global variables logical,  
so I can do like:

$app = Application.new

–  
Guillaume C. - [NVC Communication Obstacles Game](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 6:48pm UTC](https://www.ruby-forum.com/t/screen-splash/135341/10 "2008-04-21T18:48:10Z")

</div>

Am Montag, den 21.04.2008, 12:47 +0200 schrieb Martin V.:

> ```
> super(Gtk::Window::POPUP)
> 
> ```

Popups are only intended for things like menus or tooltips.

Better use

your\_window.decorated = false

Cheers, detlef
