librelist archives

« back to archive

Rambling thoughts about the next shoes

Rambling thoughts about the next shoes

From:
Cecil Coupe
Date:
2010-09-09 @ 04:55
I was poking around in the C source code for gtk to see how hard it
would be to add and user requested button.text and button.text = method
as requested long ago. Probably not too hard once I learn all the macros
and a bit of gtk, but if I have to live in the C/C++ world why not learn
to use Qt from C/C++? If there was one more platform/file 'qt.c' in the
shoes/native/ directory then we wouldn't have make the button.text=
changes for two other platforms. Still have to test on all three but you
don't have know cocoa/objective-c or the windows API or the less than
obvious gtk macros.

I know everyone wants to do shoes in ruby and not have to deal with C/C
++. But, gtk.c is only 34KB to convert to the code to write and it is
not THAT difficult and obvious in intent. There are many benefits to
writing the next Shoes by adding an optional C/C++ qt platform layer. It
doesn't fork the project. The magic that _why dusted in the C code for
scope and blocks and whatever would still exist and not have to be
re-invented (some of that magic may not be possible if you try to make
Shoes a gem.  A GUI feature request would only have to be implemented
once (assuming qt can do it).

Getting the rakefiles correct is probably more time consuming than
putting qt native widgets on par with mac/win/nix platforms. This scheme
would also work with wx (groan) or tk (gasp), but would it not prevent
them or other platforms from being added. It's not a new Shoes or a
fork, It's just another GUI toolkit/uber-platform called by the C
internals of Shoes. 

>From the developer POV,  you need a drawing surface for Cairo, some font
handling code and the native widgets. Granted, we all have to learn
enough C/C++ to write/debug the qt layer but I'm guessing that is easier
than rewriting Shoes in pure ruby using rubyqt/rcairo and one could
still distribute Shoes binaries (yet another rakefile solvable groaner
problem), assuming that binary packaging is something worthwhile to the
community.

Your thoughts please?

P.S. Yes I know, the rakefile could explode in complexity.

Re: [shoes] Rambling thoughts about the next shoes

From:
ashbb
Date:
2010-09-10 @ 13:45
Hi Cecil,

If we write qt.c, can we compile the same source code (i.e. qt.c) on all
three platforms?

But if so, why can't we compile gtk.c on all platforms? I think GTK+ has
cross platform compatibility. I'm not sure what the real meaning of
compatibility, though. :-P

ashbb

Re: [shoes] Rambling thoughts about the next shoes

From:
Cecil Coupe
Date:
2010-09-10 @ 23:00
On Fri, 2010-09-10 at 22:45 +0900, ashbb wrote:
> Hi Cecil,
> 
> If we write qt.c, can we compile the same source code (i.e. qt.c) on
> all three platforms?
You still need rakefiles for all three platforms (and the qt libraries)
so nothing is gained there. But, we would have have to fix bugs and
extend the Shoes->Qt widgets instead of three platforms widgets. That
could be a nice win. Neither you nor I can add button.text methods to
the shoes-cocoa code. 
> 
> But if so, why can't we compile gtk.c on all platforms? I think GTK+
> has cross platform compatibility. I'm not sure what the real meaning
> of compatibility, though. :-P

I did little looking around and the state of GTK+ Quartz/Mac project is
not something I'm comfortable with, but I could be wrong. It's also C++
which is a complication Shoes does not need (IMO)
> 
> ashbb
> 

Re: [shoes] Rambling thoughts about the next shoes

From:
ashbb
Date:
2010-09-11 @ 00:14
Thank you for the explanation!

> You still need rakefiles for all three platforms (and the qt libraries)
> so nothing is gained there. But, we would have have to fix bugs and
> extend the Shoes->Qt widgets instead of three platforms widgets.
> That could be a nice win.
Yeah, that's true. I understand now.
Okay, two more questions. ;-)

1st:
We are useing cairo and pango apis directly in ruby.c or other shoes/***.c
files. Do you think that we still can use the same code when we replace
gtk.c/windows.c/cocoa.m to qt.c?

2nd:
If we could write qt.c, can we also write qt.rb?
The qt.c means writing the code in C with QT C apis.
The qt.rb means writing the code in Ruby with Ruby/QT apis.

ashbb

Re: [shoes] Rambling thoughts about the next shoes

From:
Cecil Coupe
Date:
2010-09-11 @ 00:49
On Sat, 2010-09-11 at 09:14 +0900, ashbb wrote:

> 1st: 
> We are useing cairo and pango apis directly in ruby.c or other
> shoes/***.c files. Do you think that we still can use the same code
> when we replace gtk.c/windows.c/cocoa.m to qt.c?
That is what has to be learned. I think it is possible but I have much
to learn about qt - its a large animal that does things it's way. There
are benefits because qt has more widgets that we can expose in shoes

> 2nd:
> If we could write qt.c, can we also write qt.rb?
Yes, we can of course, but they are fundamentally different:
qt.c would attempt to replace the gui portion of shoes with qt. It keeps
all the ugly C code no one wants to look at (actually it's very good C
code)

qt.rb is a ground up rewrite of Shoes in Ruby using as little developer
visible C as possible. There will come a time when it needs to figure
out how shoes internals works (in the C) and replace it with Ruby, if
possible.
> The qt.c means writing the code in C with QT C apis.
> The qt.rb means writing the code in Ruby with Ruby/QT apis.
> 
> ashbb
> 

Re: [shoes] Rambling thoughts about the next shoes

From:
Steve Klabnik
Date:
2010-09-11 @ 01:04
> qt.rb is a ground up rewrite of Shoes in Ruby using as little developer
> visible C as possible. There will come a time when it needs to figure
> out how shoes internals works (in the C) and replace it with Ruby, if
> possible.

Which is sort of what I was doing with my branch, which I haven't had
tons of time to work on as of late.

But the QT ruby wrapper is quite nice, I think if we go with QT we
should just do all Ruby, and if we went gtk then I have no informed
opinion.

Re: [shoes] Rambling thoughts about the next shoes

From:
Cecil Coupe
Date:
2010-09-11 @ 01:39
On Fri, 2010-09-10 at 21:04 -0400, Steve Klabnik wrote:
> > qt.rb is a ground up rewrite of Shoes in Ruby using as little developer
> > visible C as possible. There will come a time when it needs to figure
> > out how shoes internals works (in the C) and replace it with Ruby, if
> > possible.
> 
> Which is sort of what I was doing with my branch, which I haven't had
> tons of time to work on as of late.
> 
> But the QT ruby wrapper is quite nice, I think if we go with QT we
> should just do all Ruby, and if we went gtk then I have no informed
> opinion.

I just learned qt is C++, that is an issue in my scheme. 

I think I should spend some time documenting at the C/Ruby developer
level about what Shoes does during startup - if you learn initialization
then you know what needs to be re-invented (using qt or pure ruby),
along with what all the pieces-parts purpose are and where they live in
the source tree.