# Busy application and mouse cursor

**URL:** <https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743>\
**Category:** Ruby-Gnome 2\
**Created:** [December 2, 2009, 11:56pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743 "2009-12-02T23:56:21Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 2, 2009, 11:56pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/1 "2009-12-02T23:56:21Z")

</div>

Hi everyone.

I use a Gtk::Window for my application and I would like to change the  
cursor during loading (the graphical interface is showed, the program is  
running but resources are used to intialize the program). Usually in gtk  
during initialization, the cursor is set to a rotating image instead of  
an arrow to show that program is busy. How can I achieve this?

I take a look at Gdk::Cursor but I did not saw a simple method to do it.

Vincent C.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 3, 2009, 8:24am UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/2 "2009-12-03T08:24:42Z")

</div>

this is how i do it:  
mainwindow.window.set\_cursor(Gdk::Cursor.new(Gdk::Cursor::WATCH))

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 3, 2009, 11:48am UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/3 "2009-12-03T11:48:21Z")

</div>

I also wondered a long time before I found.

I got it when I realized a cursor is attached to a GDK::Window, not a  
GTK.  
And that GDK::Window is just a rectangular area on the screen.

So, the flow is :

1. Get the area where you want to change the cursor (GTK::Widget#window)
2. Change the cursor in this area (GDK::Window#cursor=)

Hope it helps.

Simon

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 4, 2009, 8:50pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/4 "2009-12-04T20:50:47Z")

</div>

Thanks for your replies. I was looking for a way to get the GDK::Window  
and for the Gdk::Cursor::WATCH constant. I did not see this constant on  
the hiki.  
I will implement this feature on my apllication.

P.S. : I am currently writting an audio player based on ruby/gtk2 and  
ruby/gst. I have just change the status to beta. Can I ask for  
beta-tester on this list?

Simon A. wrote:

> I also wondered a long time before I found.
> 
> I got it when I realized a cursor is attached to a GDK::Window, not a  
> GTK.  
> And that GDK::Window is just a rectangular area on the screen.
> 
> So, the flow is :
> 
> 1. Get the area where you want to change the cursor (GTK::Widget#window)
> 2. Change the cursor in this area (GDK::Window#cursor=)
> 
> Hope it helps.
> 
> Simon

Dobai-Pataky BÃ¡lint wrote:

> this is how i do it:  
> mainwindow.window.set\_cursor(Gdk::Cursor.new(Gdk::Cursor::WATCH))

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 5, 2009, 9:22pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/5 "2009-12-05T21:22:13Z")

</div>

i’ll give it a hit if you send us the download address.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 6, 2009, 6:20pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/6 "2009-12-06T18:20:44Z")

</div>

ZiK is an audio player based on ruby/gtk2 and ruby/gst.  
The official website can be found at [http://zik.rubyforge.org/](http://zik.rubyforge.org/). The  
project is hosted by rubyforge : [http://rubyforge.org/projects/zik/](http://rubyforge.org/projects/zik/).

Dobai-Pataky BÃ¡lint wrote:

> i’ll give it a hit if you send us the download address.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 6, 2009, 9:03pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/7 "2009-12-06T21:03:45Z")

</div>

hi  
i like it.  
just reported some stug on rubyforge.

thanks

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 8, 2009, 11:57am UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/8 "2009-12-08T11:57:53Z")

</div>

Hi

2009/12/7 Vincent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Thanks for your interesd on ZiK. I have answered to ypur reports on  
> rubyforge. Can you explain this two points :  
> scroll event handling on the trayicon,

I think he means :  
Do something when I scroll the mouse wheel, while the mouse is over the  
tray  
icon.  
Maybe next/prev song, or play faster/slower.

I tried very fast.  
I crash when I try to access the preferences, but I think it’s because I  
did  
not install it. I just cloned and ruby main.rb. It seems you are loading  
libs with a path configured somewhere, which is bad, imo.

Also, I don’t know why, but taglib is taglib2 if installed through gems.  
Maybe contact the author to fix this.

Good work otherwise, even if I’m not looking for a new music player. I’m  
happy to know there will be something to look at if I ever need GST in  
ruby  
:).

cheers

Simon

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 7, 2009, 9:49am UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/9 "2009-12-07T09:49:23Z")

</div>

Thanks for your interesd on ZiK. I have answered to ypur reports on  
rubyforge. Can you explain this two points :  
scroll event handling on the trayicon,  
padding of widgets in the preferences window/browser,playlist.

As I am not fluent in english I am nnot I understand wht you mean.

Dobai-Pataky BÃ¡lint wrote:

> hi  
> i like it.  
> just reported some stug on rubyforge.
> 
> thanks

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 8, 2009, 4:42pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/10 "2009-12-08T16:42:20Z")

</div>

2009/12/8 Vincent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> (widget)’ failed  
> Gtk-CRITICAL \*\*:gtk\_container\_add: assertion `GTK_IS_WIDGET (widget)' failed Gtk-CRITICAL **:gtk_widget_thaw_child_notify: assertion `GTK\_IS\_WIDGET  
> (widget)’ failed

I really don’t know how to do it :). I was just clarifying.

Latest gtk has a signal for that, dunno if it is in ruby-gnome2.

> **[Learn GNOME](https://help.gnome.org)**

> libs are loaded by :  
> require ‘lib’  
> but ZiK files (other than ZiK.rb/main.rb) are loaded by adding Data\_dir  
> to $:.  
> In main.rb Data\_dir is defined by File.dirname( **FILE** ). Maybe there is  
> something to do here.  
> In installed ZiK, Data\_dir was redefined by installation.  
> Is there a better way (a more rubysh one) of doing things?  
> I use ./main.rb (instead ofruby main.rb) and everything works smooth.

You might want to look at :  
[http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices](http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices)

> I do not use gems. I install all package from my distributions. I will  
> have to learn how to use gems before checking this and create a gem  
> release of ZiK.  
> The library used by ZiK can be found at  
> [Ruby-taglib](http://www.hakubi.us/ruby-taglib/).

I know where to find it :).  
I was just saying that it is shipped as ‘taglib’ on my distribution  
(Debian  
sid), et as ‘taglib2’ through gems. Both are the same lib, I don’t know  
why  
the gem is shipped as ‘taglib2’. The author has not been working on it  
since  
2006 it seems, so he may not be working on it anymore.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 8, 2009, 5:09pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/11 "2009-12-08T17:09:21Z")

</div>

The crash with preferences dialog was a bug! Thanks for the report. It  
should be fix in the last commit.

Simon A. wrote:

> I really don’t know how to do it :). I was just clarifying.
> 
> Latest gtk has a signal for that, dunno if it is in ruby-gnome2.  
> [Learn GNOME](http://library.gnome.org/devel/gtk/stable/GtkStatusIcon.html)

Thanks for the clarification. This signal is not implemented ruby/gtk  
0.17. I will try 0.19 later.

> You might want to look at :  
> [http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices](http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices)

Thanks for the link. I will try to change my practises.

> I know where to find it :).  
> I was just saying that it is shipped as ‘taglib’ on my distribution  
> (Debian  
> sid), et as ‘taglib2’ through gems. Both are the same lib, I don’t know  
> why  
> the gem is shipped as ‘taglib2’. The author has not been working on it  
> since  
> 2006 it seems, so he may not be working on it anymore.

I add the link just to be sure we were talking about the same lib. Can  
you mail me the address of the gem packager? You can find mine in  
main.rb.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 8, 2009, 3:46pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/12 "2009-12-08T15:46:41Z")

</div>

Hi.

Simon A. wrote:

> I think he means :  
> Do something when I scroll the mouse wheel, while the mouse is over the  
> tray  
> icon.  
> Maybe next/prev song, or play faster/slower.

Next/prev song on scroll event seems nice but I do not no how to deal  
with events and Gtk::StatusIcon. It seems you cannot add a  
Gtk::StatusIcon to a Gtk::EventBox.

require ‘gtk2’  
si=Gtk::StatusIcon.new  
eb=Gtk::EventBox.new  
eb.add(si)  
GLib-GObject-WARNING \*\*:invalid cast from `GtkStatusIcon' to `GtkWidget’  
Gtk-CRITICAL \*\*:gtk\_widget\_freeze\_child\_notify: assertion `GTK_IS_WIDGET (widget)' failed Gtk-CRITICAL **:gtk_container_add: assertion `GTK\_IS\_WIDGET (widget)’  
failed  
Gtk-CRITICAL \*\*:gtk\_widget\_thaw\_child\_notify: assertion `GTK\_IS\_WIDGET  
(widget)’ failed

> I tried very fast.  
> I crash when I try to access the preferences, but I think it’s because I  
> did  
> not install it. I just cloned and ruby main.rb. It seems you are loading  
> libs with a path configured somewhere, which is bad, imo.

libs are loaded by :  
require ‘lib’  
but ZiK files (other than ZiK.rb/main.rb) are loaded by adding Data\_dir  
to $:.  
In main.rb Data\_dir is defined by File.dirname( **FILE** ). Maybe there is  
something to do here.  
In installed ZiK, Data\_dir was redefined by installation.  
Is there a better way (a more rubysh one) of doing things?  
I use ./main.rb (instead ofruby main.rb) and everything works smooth.

> Also, I don’t know why, but taglib is taglib2 if installed through gems.  
> Maybe contact the author to fix this.

I do not use gems. I install all package from my distributions. I will  
have to learn how to use gems before checking this and create a gem  
release of ZiK.  
The library used by ZiK can be found at  
[Ruby-taglib](http://www.hakubi.us/ruby-taglib/).

> Good work otherwise, even if I’m not looking for a new music player. I’m  
> happy to know there will be something to look at if I ever need GST in  
> ruby  
> :).

Thanks.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 28, 2009, 4:37pm UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/13 "2009-12-28T16:37:33Z")

</div>

Dobai-Pataky BÃ¡lint wrote:

> hi  
> i like it.  
> just reported some stug on rubyforge.
> 
> thanks

Hi.

The ZiK 0.12 was released. I think it closes features request you add on  
rubyforge.  
[http://rubyforge.org/tracker/index.php?func=detail&aid=27519&group\_id=5494&atid=21259](http://rubyforge.org/tracker/index.php?func=detail&aid=27519&group_id=5494&atid=21259)  
Can you give it a try and tell me if features you missed are  
implemented?

Vincent.

---

<div class="post-metadata">

**Author:** ![coubi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@coubi](https://www.ruby-forum.com/u/coubi)\
**Post date:** [December 29, 2009, 11:09am UTC](https://www.ruby-forum.com/t/busy-application-and-mouse-cursor/179743/14 "2009-12-29T11:09:48Z")

</div>

thanks,  
i will
