Gtk2/rbgtkwidget.c change

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

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

Hi,

In [email protected]
“[ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change” on Mon, 11 Jun 2012
12:10:59 -0600,
grant schoep [email protected] 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

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 methodwindow’ 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

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 methodwindow’ 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


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 methodwindow’ 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.

–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

Marc H. wrote in post #1064915:

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

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

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

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.

Hi,

In 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 [email protected] 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

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

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

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.

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change” on Wed, 20 Jun
2012 07:24:53 +0200,
Grant S. [email protected] wrote:

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

Could you send them by “pull request”?
About pull requests - GitHub Docs

Then I’ll merge them.

I have a comment about your change for it:
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. :slight_smile:

Thanks,

kou