Forum: Ruby-Gnome 2 gtk2/rbgtkwidget.c change

C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-11 20:11
(Received via mailing list)
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
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-11 21:58
(Received via mailing list)
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
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2012-06-12 14:31
(Received via mailing list)
Hi,

In <CAC6rHio=47D3fAFXMTBBtmyJG1y4NQT8VZCefPXQUTjTtb2W9A@mail.gmail.com>
  "[ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change" on Mon, 11 Jun 2012
12:10:59 -0600,
  grant schoep <matobinder@gmail.com> 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
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-14 17:58
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.

<ruby-gnome2 source>/gtk2/sample/misc/cursor.rb
<ruby-gnome2 source>/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
80ce28a496fc19f178979c80aa0c6c1e?d=identicon&s=25 Grant Schoep (Guest)
on 2012-06-14 23:20
(Received via mailing list)
Yes, luckily there is two  in the current ruby-gnome2 distro! Both in
the gtk2 package

<ruby-gnome2 source>/gtk2/sample/misc/cursor.rb
<ruby-gnome2 source>/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
------------------------------------------------------------------------
--------
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-15 00:06
(Received via mailing list)
> > 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

<ruby-gnome2 source>/gtk2/sample/misc/cursor.rb

<ruby-gnome2 source>/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::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
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2012-06-17 20:42
Your last mail seems to have arrived three times in total. :-)
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-18 07:08
Marc Heiler 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
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2012-06-19 14:43
(Received via mailing list)
Hi,

In <CAC6rHiqUzk9JQbHg1ww4sDRADT-f0PdCA=0wEp2KpxiLKcD49g@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change" on Thu, 14 Jun
2012 09:41:37 -0600,
  grant schoep <matobinder@gmail.com> wrote:

> gtk2 package
>
> <ruby-gnome2 source>/gtk2/sample/misc/cursor.rb
>
> <ruby-gnome2 source>/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
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-19 21:08
> 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.
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-20 03:56
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
C53e81f5d7c781c6dc3979c4ce888706?d=identicon&s=25 Grant Schoep (matobinder)
on 2012-06-20 07:24
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.
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2012-06-20 14:02
(Received via mailing list)
Hi,

In <1e396bfd20e50cc380881376f6e6ea96@ruby-forum.com>
  "Re: [ruby-gnome2-devel-en] gtk2/rbgtkwidget.c change" on Wed, 20 Jun
2012 07:24:53 +0200,
  Grant Schoep <ruby-forum-incoming@andreas-s.net> wrote:

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

Could you send them by "pull request"?
  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/1...

+                          (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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.