# Gtk2/rbgtkwidget.c change

**URL:** <https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495>\
**Category:** Ruby-Gnome 2\
**Created:** [June 11, 2012, 8:11pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495 "2012-06-11T20:11:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 11, 2012, 8:11pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/1 "2012-06-11T20:11:23Z")

</div>

I’m now just getting into porting another application to the “latest and  
greatest” ruby-gnome2 release. I’m getting one undefined method.

In rbgtkwidget.c I see on Sep 9, 2011 there was a commit that removed  
“methods implementing properties in gtk2”

So one of these methods, “window” I was using to get at the window and  
call  
set\_cursor() on it.

So basically, I have a Gtk::Dialog, that used to have a method  
“window()”  
and now it doesn’t. How do I get at that object now? I’m sure I’m just  
overlooking something, just still new to this.

Thanks

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 11, 2012, 9:58pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/2 "2012-06-11T21:58:56Z")

</div>

I’m now just getting into porting another application to the "latest and

> overlooking something, just still new to this.

I just noticed that two of the sample programs in gtk2 have this same  
problem. I’d be happy to update them once I figure out how to make this  
work, the two sample programs are  
…/gtk2/sample/misc/cursor.rb  
…/gtk2/sample/misc/xbm\_cursor.rb

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 12, 2012, 2:31pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/3 "2012-06-12T14:31:11Z")

</div>

Hi,

In [CAC6rHio=removed\_email\_address@domain.invalid](mailto:CAC6rHio=removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change” on Mon, 11 Jun 2012  
12:10:59 -0600,  
grant schoep [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So basically, I have a Gtk::Dialog, that used to have a method “window()” and  
> now it doesn’t. How do I get at that object now? I’m sure I’m just overlooking  
> something, just still new to this.

Could you show a script that reproduces your problem?

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 14, 2012, 5:58pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/4 "2012-06-14T17:58:27Z")

</div>

Sorry if this comes as a double post, not sure if my posts were getting  
through. Trying directly from ruby-forum website

Yes, luckily there are two examles in the current ruby-gnome2 distro!  
Both in the gtk2 package.

/gtk2/sample/misc/cursor.rb  
/gtk2/sample/misc/xbm\_cursor.rb

The code from cursor.rb is at the end of this post.  
The error message is:

cursor.rb:25:in `block in <main>': undefined method`window’ for  
#\<Gtk::Window:0xa791f44 ptr=0xa7ad800\> Line 25 is the  
window.window.set\_cursor(Gdk::Cursor.new(cursor)) line

Reviewing the git repo, the window method was removed from rbgtkwidget.c  
on a commit on Sep 9, 2011

–Heres the example from cursor.rb—  
–the window.window.set\_cursor reports the undefined method ‘window’----

require ‘gtk2’

window = Gtk::Window.new(“Gdk::Cursor sample”)  
window.realize

button = Gtk::Button.new(“Click!”)  
button.use\_underline = false

cursors = Gdk::Cursor::Type.values - [Gdk::Cursor::CURSOR\_IS\_PIXMAP]

cnt = 0  
button.signal\_connect(‘clicked’) do  
cursor = cursors[cnt]  
p cursor.inspect  
button.set\_label(cursor.inspect)  
window.window.set\_cursor(Gdk::Cursor.new(cursor))  
cnt += 1  
cnt = 0 if cnt == cursors.size  
end  
window.add(button)  
window.set\_default\_size(400,100).show\_all

Gtk.main

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 14, 2012, 11:20pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/5 "2012-06-14T23:20:48Z")

</div>

Yes, luckily there is two in the current ruby-gnome2 distro! Both in  
the gtk2 package

/gtk2/sample/misc/cursor.rb  
/gtk2/sample/misc/xbm\_cursor.rb

Here is what is in cursor.rb. The error message is.

cursor.rb:25:in `block in <main>': undefined method`window’ for  
#\<Gtk::Window:0xa791f44 ptr=0xa7ad800\>  
Line 25 is the window.window.set\_cursor(Gdk::Cursor.new(cursor)) line

Reviewing the git repo, the window method was removed from rbgtkwidget.c  
on a commit on Sep 9, 2011.

* * *

require ‘gtk2’

window = Gtk::Window.new(“Gdk::Cursor sample”)  
window.realize

button = Gtk::Button.new(“Click!”)  
button.use\_underline = false

cursors = Gdk::Cursor::Type.values - [Gdk::Cursor::CURSOR\_IS\_PIXMAP]

cnt = 0  
button.signal\_connect(‘clicked’) do  
cursor = cursors[cnt]  
p cursor.inspect  
button.set\_label(cursor.inspect)  
window.window.set\_cursor(Gdk::Cursor.new(cursor))  
cnt += 1  
cnt = 0 if cnt == cursors.size  
end  
window.add(button)  
window.set\_default\_size(400,100).show\_all

## Gtk.main

* * *

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 15, 2012, 12:06am UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/6 "2012-06-15T00:06:23Z")

</div>

> > So basically, I have a Gtk::Dialog, that used to have a method  
> > “window()” and  
> > now it doesn’t. How do I get at that object now? I’m sure I’m just  
> > overlooking  
> > something, just still new to this.
> 
> Could you show a script that reproduces your problem?

Yes, luckily there are two in the current ruby-gnome2 distro! Both in  
the  
gtk2 package

/gtk2/sample/misc/cursor.rb

/gtk2/sample/misc/xbm\_cursor.rb

Here is what is in cursor.rb(see end of email for cut and paste of it).  
The  
error message is.

cursor.rb:25:in `block in <main>': undefined method `window’ for  
#\<Gtk:🪟0xa791f44 ptr=0xa7ad800\> Line 25 is the  
window.window.set\_cursor(Gdk::Cursor.new(cursor)) line  
Reviewing the git repo, the window method was removed from rbgtkwidget.c  
on  
a commit on Sep 9, 2011.

–begin cursor.rb–

require ‘gtk2’

window = Gtk::Window.new(“Gdk::Cursor sample”)  
window.realize

button = Gtk::Button.new(“Click!”)  
button.use\_underline = false

cursors = Gdk::Cursor::Type.values - [Gdk::Cursor::CURSOR\_IS\_PIXMAP]

cnt = 0  
button.signal\_connect(‘clicked’) do  
cursor = cursors[cnt]  
p cursor.inspect  
button.set\_label(cursor.inspect)  
window.window.set\_cursor(Gdk::Cursor.new(cursor))  
cnt += 1  
cnt = 0 if cnt == cursors.size  
end  
window.add(button)  
window.set\_default\_size(400,100).show\_all

Gtk.main

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 18, 2012, 7:08am UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/7 "2012-06-18T07:08:22Z")

</div>

Marc H. wrote in post #1064915:

> Your last mail seems to have arrived three times in total. 🙂

Yeah, sorry about that. I had posted one waited over a day, didn’t see  
anything. Posted it again, still didn’t see anything, though I only  
waited 3-4 hours. Finally I posted would directly via ruby-forum, and  
was instantly there. Then a short time later all my other posts showed  
up.

Sorry for the over-postage. I haven’t gotten back to the problem to see  
a way to get at what that old window() method gave. Just been busy with  
bunches of other problems elsewhere

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 17, 2012, 8:42pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/8 "2012-06-17T20:42:34Z")

</div>

Your last mail seems to have arrived three times in total. 🙂

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 19, 2012, 9:08pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/9 "2012-06-19T21:08:13Z")

</div>

> Thanks!  
> But I can’t reproduce your problem with it… :\<
> 
> Could you show your Ruby, Ruby/GTK2 and GTK+ versions?  
> Here are mine of them:
> 
> % ruby -v  
> ruby 1.9.3p194 (2012-04-20 revision 35410) [x86\_64-linux]  
> % ruby -r gtk2 -e ‘p Gtk::BINDING\_VERSION’  
> [1, 1, 3]  
> % ruby -r gtk2 -e ‘p Gtk::VERSION’  
> [2, 24, 10]

Here’s mine

% ruby --version  
ruby 1.9.2p320 (2012-04-20 revision 35421) [i686-linux]  
% ruby -r gtk2 -e ‘p Gtk::BINDING\_VERSION’  
[1, 1, 3]  
% ruby -r gtk2 -e ‘p Gtk::VERSION’  
[2, 10, 4]

So I am stuck on 2.10.4 of gtk, for sometime, so that could be the  
issue. I see the method “window()” was removed in ruby-gnome2 from the  
rbgtkwidget.c file. Is this one that was reimplemented somewhere else  
that doesn’t get picked up for 2.10.4? I’m stuck with 2.10.4( RHEL 5.x)  
for sometime.

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 19, 2012, 2:43pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/10 "2012-06-19T14:43:41Z")

</div>

Hi,

In [CAC6rHiqUzk9JQbHg1ww4sDRADT-f0PdCA=removed\_email\_address@domain.invalid](mailto:CAC6rHiqUzk9JQbHg1ww4sDRADT-f0PdCA=removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change” on Thu, 14 Jun  
2012 09:41:37 -0600,  
grant schoep [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> gtk2 package
> 
> /gtk2/sample/misc/cursor.rb
> 
> /gtk2/sample/misc/xbm\_cursor.rb

Thanks!  
But I can’t reproduce your problem with it… :\<

Could you show your Ruby, Ruby/GTK2 and GTK+ versions?  
Here are mine of them:

% ruby -v  
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86\_64-linux]  
% ruby -r gtk2 -e ‘p Gtk::BINDING\_VERSION’  
[1, 1, 3]  
% ruby -r gtk2 -e ‘p Gtk::VERSION’  
[2, 24, 10]

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 20, 2012, 3:56am UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/11 "2012-06-20T03:56:43Z")

</div>

Ok I was able to get this to work, by modifying some of the source. Not  
sure if this is the best way.

But I modified rbgtkwidget.c and rbgdkwindow.c

Modified rbgtkwidget.c like this

#if GTK\_CHECK\_VERSION(2,10,0)  
RG\_DEF\_METHOD(action, 0);  
RG\_DEF\_METHOD\_P(composited, 0);  
RG\_DEF\_METHOD(window, 0); \<— added this line  
#endif  
…  
#if GTK\_CHECK\_VERSION(2,10,0)  
static VALUE  
rg\_action(VALUE self)  
{  
return GOBJ2RVAL(gtk\_widget\_get\_action(\_SELF(self)));  
}

static VALUE  
rg\_composited\_p(VALUE self)  
{  
return CBOOL2RVAL(gtk\_widget\_is\_composited(\_SELF(self)));  
}

static VALUE \<-- Added this function  
def  
rg\_window(VALUE self)  
{  
return GOBJ2RVAL(\_SELF(self)-\>window);  
}  
#endif

And did the same for set\_cursor in rbgtkwindow.c. I added  
#if GTK\_CHECK\_VERSION(2,10,0)  
static VALUE  
rg\_set\_cursor(VALUE self, VALUE cursor)  
{  
gdk\_window\_set\_cursor(\_SELF(self),  
(GdkCursor\*)(NIL\_P(cursor) ? NULL :  
RVAL2BOXED(cursor, GDK\_TYPE\_CURSOR)));  
return self;  
}  
#endif

AND

#if GTK\_CHECK\_VERSION(2,10,0)  
RG\_DEF\_METHOD(set\_cursor, 1);  
#endif

This seems to work fine for me on GTK 2,10,0. So I’d be happy to commit  
these changes. I’ve worked on code for years, but never really worked  
on a nice open source project. If I were too, whats the policy for  
making changes? Note, I always will follow the coding style of the code  
I am mucking with.

Thanks

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 20, 2012, 7:24am UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/12 "2012-06-20T07:24:53Z")

</div>

So I decided to learn something new. Had to read up on “git for cvs  
users” I’m fairly old school, been just using cvs and vi for years…

Anyways, I forked the ruby-gnome2 repo and made

[https://github.com/matobinder/ruby-gnome2](https://github.com/matobinder/ruby-gnome2)

I committed my two changes(rbgdkwindow.c and rbgdkwindow.c). I’m still  
not sure if that was the correct way to go. I’d appreciate any comments,  
I’d like to try to help out more, especially as I need to keep  
supporting ruby-gnome2 on 2.10.0 of GTK.

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [June 20, 2012, 2:02pm UTC](https://www.ruby-forum.com/t/gtk2-rbgtkwidget-c-change/220495/13 "2012-06-20T14:02:14Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change” on Wed, 20 Jun  
2012 07:24:53 +0200,  
Grant S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> supporting ruby-gnome2 on 2.10.0 of GTK.  
> Great!!!

Could you send them by “pull request”?  
[Pull requests - GitHub Docs](https://help.github.com/articles/using-pull-requests)

Then I’ll merge them.

I have a comment about your change for it:  
[https://github.com/matobinder/ruby-gnome2/commit/1b05bd625d98ff5ca047e785750987b7463d988f#L0R605](https://github.com/matobinder/ruby-gnome2/commit/1b05bd625d98ff5ca047e785750987b7463d988f#L0R605)

- 

```
                     (GdkCursor*)(NIL_P(cursor) ? NULL : 

```

RVAL2BOXED(cursor, GDK\_TYPE\_CURSOR)));

You can remove NIL check because RVAL2BOXED() checks it. So  
you can write it as

(GdkCursor \*)RVAL2BOXED(cursor, GDK\_TYPE\_CURSOR)

(I’ll merge your changes without this fix. 🙂

## Thanks,

kou
