Desktop multi-plataform ruby app

L

Leslie Viljoen

This all sounds very interesting, and I want to investigate it, but I dread
having to deal with the java monster. I've been there before. Forty-five+
versions, all with 26 letter names, and documentation that requires a
masters in CS to decypher. I simply cannot know everything, and I'm pretty
committed in a couple of other fields. Still, I have programming to get
done, and drag and drop GUI that doesn't require yet another book to read
would be a blessing.

So, onward, again. I try to install Netbeans 6 for Linux. Says it want a JDK
(the dread starts now). I'm on Kubuntu, so I go to Adept, find sun-jave6-jdk
- nothing else looks more likely - and install it. Now Netbeans says it
can't find it and I need to point the way. Huh? Don't have a clue.

Looking at the helpful (?) installed files list under the tab of the same
name in I see a long file list. Nothing seems clearly the answer to Netbeans
problems, so I throw a number of possibilities at it. Nothing works. Sigh.

Could someone who knows more please give me a clue here? I'm be most
grateful.

I understand your dread - I have the same dread, and the same problems getting
Java + XYZ to work. I actually currently have a Netbeans install that
I have tried
to use the built-in plugin installer to install Ruby support - after
incomprehensible
errors it knows nothing of Ruby. Busy re-downloading. I tried monkeybars and the
tutorials for a few hours and failed completely. Perhaps it is very
good, but it is
surely also very complicated.

After failing there I have been having quite a nice time with
Glade/Gtk. I am working on
a tutorial but in the meantime, below is a message I sent a friend as an intro.

Look at my previous post to this list for "glader" which should
convert your .glade
file to a program directly so get you started fast.

Also, be aware that the Glade form builder uses a bit of a different
form building philosophy if you
come from a VB/C#/VS environment. If you get stuck with it, mail me
and I'll help out. You just need to understand a few of the ideas and
you can build good-looking forms really quickly and easily in Glade.


--snip--

Glade as a GUI builder works quite well on both Windows and Linux and had a fair
selection of ok looking Widgets.

Installing it on Linux is also quite easy - apt-get libglade2-ruby1.8
and glade-3 to pull in
most of what you need. Certain widgets have their own packages, so you may need
one of these, depending on which your Ruby program uses:

libgtk-mozembed-ruby - ruby binding of GtkMozEmbed, gecko renderer
libgtk-mozembed-ruby1.8 - ruby binding of GtkMozEmbed, gecko renderer
libgtkglext1-ruby - GTK+ GL extension bindings for the Ruby language
libgtkglext1-ruby1.8 - GTK+ GL extension bindings for the Ruby language
libgtkhtml2-ruby - GtkHTML bindings for the Ruby language
libgtkhtml2-ruby1.8 - GtkHTML bindings for the Ruby language
libgtksourceview1-ruby - GtkSourceView bindings for the Ruby language
libgtksourceview1-ruby1.8 - GtkSourceView bindings for the Ruby language

ie. apt-cache search libgtk|grep ruby

After that you build forms using glade-3 and run a little script
(ruby-glade-create-template) to
convert your XML glade files to Ruby programs. Well, almost. The
script creates a bit of
an example for you and doesn't actually SHOW the form as you may
expect. To show the
form, you need to access the GladeXML object that is created in the
form's initializer and
call something like @glade["window1"].show, where "window1" is the id
of the form you
want to show.

I am going to improve the script so that it makes things much more
seamless, for now
it's just a basic example-form-with-events creator. (see glader in prev post)

In Windows you need to download a few things:
Ruby-gnome:
http://downloads.sourceforge.net/ru...6-mswin32.exe?modtime=1171279190&big_mirror=0

Glade and Gtk:
http://downloads.sourceforge.net/gladewin32/glade-3.4.3-win32-1.tar.bz2
http://downloads.sourceforge.net/gladewin32/gtk-2.12.9-win32-2.exe

There's a bit of a guide (minus glade) here:
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Install+Guide+for+Windows


Good luck!
Les
 
T

Tom Cloyd

Israel said:
I would recommend the same.

There is also the command whereis:

whereis java

I can't remember, but i think it shows only where the binary is. Anyway you
could try that.
Thanks Hassan, and Israel, for you help. The matter resolved itself when
I restarted the Netbeans installation. Since I installed the JDK right
after NB complained about not finding it, and DIDN'T start the install
from scratch, but merely backed up a couple of windows and came forward
again, it still couldn't find the JDK, post install. With a fresh start,
this time, it did.

I'm in business.

I agree at least in part with your comment about package installers.
Something they're quicker though.

t.


--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog)
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
D

David Masover

:preface => I hate *nix package managers :)

The main reason I still use *nix is because of package managers.
I think you'd be better off downloading a JDK from Sun and installing
it the normal way, so you /know/ where it's located.

Huh?

$ which java
/usr/bin/java
$ dpkg -L sun-java6-jdk
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/sun-java6-jdk
/usr/share/doc/sun-java6-jdk/README.html
/usr/share/doc/sun-java6-jdk/README.alternatives
/usr/share/doc/sun-java6-jdk/copyright
/usr/share/doc/sun-java6-jdk/changelog.Debian.gz
/usr/share/applications
/usr/share/applications/sun-java6-jconsole.desktop
(LONG output snipped -- run it yourself)

Maybe it could be easier, but I can, in fact, get a list of every single file
a package has installed -- or every single file it will installed, before I
do. Usually I use packages.ubuntu.com, but that seems to be down right now...
 
D

David Masover

Since no one seemed to mention it...

I want to develop a desktop app that runs in either linux or windows.
I have many doubts about which GUI i should use. What's the best option?

I can't speak for the "best", but there are many. Why's Shoes looks the most
interesting (to me, anyway), and you could also use Qt or GTK+ bindings.
I would prefer something that has a graphical app that can help me creating
the visual part.

Well, GTK+ has Glade, and Qt has qt-designer.

I'm a Rails developer by day, so when I want to create a UI beyond a
commandline, I usually build a web interface unless I have a good reason not
to. Haven't had a good reason not to, yet.
 
J

James Britt

Tom said:
This all sounds very interesting, and I want to investigate it, but I
dread having to deal with the java monster. I've been there before.

So have I. And David created Monkeybars to avoid all that.

Seriously, you can write desktop apps that use Swing and run under JRuby
and never look at a line of Java. That's basically the whole point.

We wanted whatever was good we could glom from Java, while avoiding
having to write any actual Java ourselves.

Forty-five+ versions, all with 26 letter names, and documentation that
requires a masters in CS to decypher. I simply cannot know everything,
and I'm pretty committed in a couple of other fields. Still, I have
programming to get done, and drag and drop GUI that doesn't require yet
another book to read would be a blessing.

Monkeybars. It uses reflection and naming conventions to interact with
the UI components so that you stick to Ruby.

So, onward, again. I try to install Netbeans 6 for Linux. Says it want a
JDK (the dread starts now). I'm on Kubuntu, so I go to Adept, find
sun-jave6-jdk - nothing else looks more likely - and install it. Now
Netbeans says it can't find it and I need to point the way. Huh? Don't
have a clue.

Better off grabbing the JDB+NetBeans bundle from netbeans.org, then once
installed telling NetBeans to install the Ruby plugins.

There is a screencast on monkeybars.org that goes through the
installation of NetBeans:

http://monkeybars.rubyforge.org/tutorials/netbeans.html
 
J

James Britt

Leslie said:
I understand your dread - I have the same dread, and the same problems getting
Java + XYZ to work. I actually currently have a Netbeans install that
I have tried
to use the built-in plugin installer to install Ruby support - after
incomprehensible
errors it knows nothing of Ruby. Busy re-downloading. I tried monkeybars and the
tutorials for a few hours and failed completely. Perhaps it is very
good, but it is
surely also very complicated.

If you honestly believe that then we (the Monkeybars crew) have failed
someplace, perhaps in the docs or the screencasts, because the last
thing we want is anything complicated.

Now, granted, I'm biased (I'm a Monkeybars contributer and have been
building production apps with it for almost a year), but if you can
tell me (off-list, perhaps) what you thought was complicated, I will see
what I can do to help you out.
 
L

Leslie Viljoen

If you honestly believe that then we (the Monkeybars crew) have failed
someplace, perhaps in the docs or the screencasts, because the last thing we
want is anything complicated.

Now, granted, I'm biased (I'm a Monkeybars contributer and have been
building production apps with it for almost a year), but if you can tell me
(off-list, perhaps) what you thought was complicated, I will see what I can
do to help you out.

I don't think you failed, and it's not that the process is complex,
it's that the whole setup is
complex. I think Matisse is a fantastic GUI builder and have been
eagerly waiting for it to
support Ruby for ages now (even spoke to the developer for a while) so
I am glad there's
finally a solution for wiring it into Ruby. It's just that Ruby + Java
+ Packages + Netbeans + dependencies + MVC framework + updating + etc.
is a very slow 50 step process with a
huge number of dependencies.

I have just now finished that process for the second time and I still
don't have anything to see.
I must have missed something. I watched all the videos and followed
all the tutorials here:
http://monkeybars.rubyforge.org/tutorials.html

The last page seems to be here:
http://monkeybars.rubyforge.org/tutorials/netbeans.html .. which talks
about RAWR. Rawr install just seems to have added to my Rakefile, and
I don't know what to do now. Do I start making forms? Do I run one of
the RAWR tasks? The link at the bottom of that page points back to
"using the generator" which I have already done. The link after that
is an overview page which is rather long and sounds good but still
doesn't get me to just plain connect a form to my app!

When I got to this point before I started looking at the view,
thinking that it would be somehow related to a form I might build with
Matisse. I tried putting things into the quotes after set_java_class.

If I click "run" now I get to choose something to do with RAWR from a
combo box and then I get:

init:
deps-jar:
Created dir: /home/lesliev/dev/ruby-gui/demo/build/classes
Compiling 1 source file to /home/lesliev/dev/ruby-gui/demo/build/classes
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:11:
package org.jruby does not exist
import org.jruby.Ruby;
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:12:
package org.jruby.javasupport does not exist
import org.jruby.javasupport.JavaEmbedUtils;
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:19:
cannot find symbol
symbol : class Ruby
location: class org.rubyforge.rawr.Main
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0));
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:19:
cannot find symbol
symbol : variable JavaEmbedUtils
location: class org.rubyforge.rawr.Main
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0));
4 errors
BUILD FAILED (total time: 2 seconds)


So you see, it's complicated.

Les
 
I

Israel Guerra

[Note: parts of this message were removed to make it a legal post.]

One thing i have really liked about monkeybars is the mvc thing. If i choose
another GUI option, would i have another option that would give me the mvc
abstraction like that?

Another option, like someone said, would be to use rails and forget a non
web interface.
 
J

James Britt

Israel said:
One thing i have really liked about monkeybars is the mvc thing. If i choose
another GUI option, would i have another option that would give me the mvc
abstraction like that?

I don't know if other GUI tools encourages any particular way to
organize your code. I believe most are simply bindings to widgets.

Another option, like someone said, would be to use rails and forget a non
web interface.

If so, you should give a look at Ramaze, Merb, and some of the other
dozen+ Ruby Web frameworks. Find something that suits how you want to
work and build.
 
T

Tom Cloyd

James said:
So have I. And David created Monkeybars to avoid all that.

Seriously, you can write desktop apps that use Swing and run under
JRuby and never look at a line of Java. That's basically the whole
point.

We wanted whatever was good we could glom from Java, while avoiding
having to write any actual Java ourselves.



Monkeybars. It uses reflection and naming conventions to interact
with the UI components so that you stick to Ruby.



Better off grabbing the JDB+NetBeans bundle from netbeans.org, then
once installed telling NetBeans to install the Ruby plugins.

There is a screencast on monkeybars.org that goes through the
installation of NetBeans:

http://monkeybars.rubyforge.org/tutorials/netbeans.html
Yeah, I'm sold. Did a brief scan of the website and immediately liked
what I saw. Monkeybars looks slick. Heck, *I* might even be able to
understand it! Hope springs eternal, yessir. So, I'm all installed and
ready to have a swing at it, as soon as I find a free moment.

All the dependencies, etc., DOES look (in the mind) a bit scary, but
I've found that if one give the Big Boys a few months, they generally
get things wired together so they Just Work. And beyond that, there's
the marvelous Ruby community. Rare has been the time that I haven't
gotten an answer back to whatever problem I've posted about - in under
an hour. Phenomenal, actually. The rest of life should be so good!

t.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC
Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website & psychotherapy weblog)
<< sleightmind.wordpress.com >> (mental health issues weblog)
<< directpathdesign.com >> (web site design & consultation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
C

Charles Oliver Nutter

mdiam said:
(but jruby is still a litle slower than ruby at startup time, because
of the JVM)

In 1.1.2 we have hopefully improved that...for me, startup time went
from 1.5s to about .6s, which is a great improvement. Others have
reported similar boost, maybe not as great. Work continues.

- Charlie
 
C

Charles Oliver Nutter

Israel said:
I hardly believe that an interpreter made in java running on a jvm will be
as fast as a C interpreter.

1 thing could cause that and would be a very bad work made on the CRuby and
i don't believe that's the case.

The truth is that the convenience of the JRuby is ok for most end uses.

Try JRuby yourself and see. If it's not faster, file it as a bug. We are
working very hard to make JRuby as fast as possible.

- Charlie
 
C

Charles Oliver Nutter

Victor said:
Can JRuby coexist with C-Ruby?

Yes, and you can have any number of entirely separate JRuby installs or
a single one you use. It's up to you. The JRuby install process is
essentially "1. unpack, 2. run" provided you have a compliant JVM
installed (almost all OSes have free and Free compliant JVMs available now).
Does anyone have any performance numbers of Ruby vs JRuby?

Should be as good, but let us know if not.
Would any JRuby appl with GUI run on any *NIX server that supports Java?

Java is Java wherever you go, so the same GUI will basically work as-is
on any *NIX. For a non-GUI example, we have people running Rails + weird
database access on systems like AS/400 and HP/UX.
Is there a drag and drop widgets creation GUI design under JRuby with Swing?

Matisse does the drag-and-drop and MonkeyBars makes it all Ruby-nice.
Currently I am running Ruby 1.8.7 and on some servers I am playing 1.9. What
is the equivalent version of JRuby to the latest level of Ruby?

Almost nobody is asking for 1.9 features, so we've only taken a marginal
interest. If people want those features, it wouldn't take more than a
couple dedicated weeks to get them in.
How far behind is JRuby from Ruby (C-Ruby)?

Not far behind at all...most normal pure-Ruby code should "just work".
The places we find bugs these days are in our Java integration layer (up
for a rewrite this summer) or where you interact with system-level
resources (IO and process control are especially twitchy). But if you're
not doing anything that wouldn't have portability challenges under
normal Ruby, it will probably work great in JRuby too.

- Charlie
 
A

Axel Etzold

Dear Monkeybars developers,

how did you produce the videos ?

Thanks.

Best regards,

Axel
 
L

Leslie Viljoen

When I got to this point before I started looking at the view,
thinking that it would be somehow related to a form I might build with
Matisse. I tried putting things into the quotes after set_java_class.

If I click "run" now I get to choose something to do with RAWR from a
combo box and then I get:

init:
deps-jar:
Created dir: /home/lesliev/dev/ruby-gui/demo/build/classes
Compiling 1 source file to /home/lesliev/dev/ruby-gui/demo/build/classes
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:11:
package org.jruby does not exist
import org.jruby.Ruby;
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:12:
package org.jruby.javasupport does not exist
import org.jruby.javasupport.JavaEmbedUtils;
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:19:
cannot find symbol
symbol : class Ruby
location: class org.rubyforge.rawr.Main
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0));
/home/lesliev/dev/ruby-gui/demo/src/org/rubyforge/rawr/Main.java:19:
cannot find symbol
symbol : variable JavaEmbedUtils
location: class org.rubyforge.rawr.Main
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0));
4 errors
BUILD FAILED (total time: 2 seconds)

I'd seriously like to know how to continue here. Either I missed a tutorial page
somewhere or the tutorials stop short of actually building a form and connecting
it to the Ruby program. Did I miss something?

Les
 
I

Israel Guerra

[Note: parts of this message were removed to make it a legal post.]

Great man!
I will really try it.

To be fair with monkeybars, i think it's the easier way to have a mvc + gui
"drag and drop" designer.

Thanks everyone for help. :)

I hardly believe that an interpreter made in java running on a jvm will be
as fast as a C interpreter.

1 thing could cause that and would be a very bad work made on the CRuby
and
i don't believe that's the case.

The truth is that the convenience of the JRuby is ok for most end uses.

Try JRuby yourself and see. If it's not faster, file it as a bug. We are
working very hard to make JRuby as fast as possible.

- Charlie
[/QUOTE]
 
V

Victor Reyes

[Note: parts of this message were removed to make it a legal post.]

On Sat, 2008-06-07 at 05:57 +0900, James Britt wrote:

If you have questions, jump on #monkeybars on irc; the Monkeybars squad is usually about and very happy to answer questions.


Which network? Freenode? The #monkeybars channel there has no topic and
one person idling in it. :)

--
*Michael T. Richter* <[email protected]> (*GoogleTalk:*
(e-mail address removed))
*Never, ever, ever let systems-level engineers do human interaction design
unless they have displayed a proven secondary talent in that area. Their
opinion of what represents good human-computer interaction tends to be a bit
off-track. (Bruce Tognazzini)*
Team,

*Tristin*: I already tried the suggestion of FxRuby plus other GUIs. The
documentation for FxRuby was so so. I am the type that learn by example.
*Hassan*: I'll give it a try without un-installing "regular" Ruby.
*Tom*: I am also terrified of the Java T-Rex. So many packages, so many ways
to configure it, so many .....
I went to
http://www.netbeans.org/community/releases/61/install.html#requiredsoftwareand
found the soft requirements. I proceeded to Sun site and downloaded a
ton of software: JDK, JRE, NetBeans, Etc. My installation went fine. The
problem is when I try something as simple as jruby -v (I do ruby -v for
regular ruby, so I assume the same is valid for jruby only with the prefix
j). I got the msg:

Set JAV_HOME to point to your JDK/JRE directory.
I am using MS Windows XP and I set the variable. So now it works as long as
I am inside the *C:\jruby-1.1.2\bin* dir. I tried setting the PATH but
nothing.
*C:\jruby-1.1.2\bin>jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]

*I set the PATH but nothing. Perhaps I am not setting the PATH correctly. So
this is my new show-stopper. I will continue playing until I either get it
or get tired. Although I am already getting tired. This is not supposed to
be this difficult. But dealing with Java nothing is ever simple.
*Leslie*: Does Glade provides a drag/drop widget creation feature? I went to
*glade.gnome.org* but could not find anything about it.
*Charles*: That's a good feature I see useful. "Java is Java and so the same
GUI will basically work as-is on any *NIX". One thing that worries me
though, the JRuby site states that JRuby supports "almost" all the Ruby
classes. I have Ruby 1.8.6 running in well over 100 production AIX Servers.
If I convert to JRuby and need to ensure that current scripts will still
work under it. Is there any docs stating what's not support in JRuby which
is in Ruby?

Well, I am about to reboot my desktop and see if that will fix my problems.
I did not rebooted after the NetBeans installation.

Thanks everyone!

Victor
 
L

Leslie Viljoen

On Sat, 2008-06-07 at 05:57 +0900, James Britt wrote:

If you have questions, jump on #monkeybars on irc; the Monkeybars squad is usually about and very happy to answer questions.


Which network? Freenode? The #monkeybars channel there has no topic and
one person idling in it. :)

--
*Michael T. Richter* <[email protected]> (*GoogleTalk:*
(e-mail address removed))
*Never, ever, ever let systems-level engineers do human interaction design
unless they have displayed a proven secondary talent in that area. Their
opinion of what represents good human-computer interaction tends to be a bit
off-track. (Bruce Tognazzini)*
Team,

*Tristin*: I already tried the suggestion of FxRuby plus other GUIs. The
documentation for FxRuby was so so. I am the type that learn by example.
*Hassan*: I'll give it a try without un-installing "regular" Ruby.
*Tom*: I am also terrified of the Java T-Rex. So many packages, so many ways
to configure it, so many .....
I went to
http://www.netbeans.org/community/releases/61/install.html#requiredsoftwareand
found the soft requirements. I proceeded to Sun site and downloaded a
ton of software: JDK, JRE, NetBeans, Etc. My installation went fine. The
problem is when I try something as simple as jruby -v (I do ruby -v for
regular ruby, so I assume the same is valid for jruby only with the prefix
j). I got the msg:

Set JAV_HOME to point to your JDK/JRE directory.
I am using MS Windows XP and I set the variable. So now it works as long as
I am inside the *C:\jruby-1.1.2\bin* dir. I tried setting the PATH but
nothing.
*C:\jruby-1.1.2\bin>jruby -v
ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2]

*I set the PATH but nothing. Perhaps I am not setting the PATH correctly. So
this is my new show-stopper. I will continue playing until I either get it
or get tired. Although I am already getting tired. This is not supposed to
be this difficult. But dealing with Java nothing is ever simple.
*Leslie*: Does Glade provides a drag/drop widget creation feature? I went to
*glade.gnome.org* but could not find anything about it.


Glade is a form builder, it allows you to drop containers onto forms
and Gtk widgets
into those containers. This is not the same as with Netbeans or Visual Studio,
but you can get the same results and in some ways the system is better
- it takes better care of how forms change when text is translated or
fonts changed.

You may find it has a learning curve in the beginning, but only until
you understand
how things work, after that it's quick and easy.

I'm putting together a 5-minute tutorial but I'll include the text
portion below
to get you started. The tutorial uses the "glader" script which I'll
include at the bottom.

Warning: I haven't tried glader in Windows yet!


Starting out with Glade and Ruby
------------------------------------------

Open glade.

1. Add a new window, common -> border width: 10
2. Add a vbox to the window (2 items), general -> spacing: 10
3. Add a hbox to the bottom area, general -> spacing: 10
4. Right-click hbox in tree, add parent, alignment
5. Put a button in each of the two bottom blocks
6. On the alignment container, horizonal scale: 0, vertical scale: 0,
horizontal alignment: 1
7. On the alignment container, expand: no, fill: no

If expand is no, the area does not take on more space when the parent grows.
If expand is yes, the area will grow with its parent, and 'fill'
controls how it grows.
If 'fill' is yes, extra space is added around the widgets, otherwise
the extra space
goes inside the widget and the widget itself grows.

8. Add a table in the top space
9. table, packing -> expand: no, general -> row spacing: 10, column spacing: 10

Before saving, click on window1, signals -> gtkobject -> destroy and select
"on_window1_destroy" from the combo.

Now save as "designation" and run "./glader designation.glade" from
the command line.
After generation, run "ruby designation.rb"

Note that when you resize, everything still looks good except the
three labels, which
shouldn't grow horizontally like that.
Also, since you added the on_window1_destroy signal, you can close the
window and your
Ruby program will exit nicely (glader wrote a handler for that).

Return to Glade.

1. label1, packing -> fill: deselect expand
2. Do the same for the other two labels
3. Save

Now re-run designation.rb. You don't have to regenerate since the class and main
file will not change, only the form definition (glade) file. If you
resize you'll
see that the labels now stay small and only the text fields and combo
boxes grow,
which is nice.



----------------------- glader.rb
#!/usr/bin/ruby -w

# This class is a quick way of creating a runnable Ruby program from
# a single Glade form.
#
class Glader
def initialize(glade_filename)
raise ArgumentError.new("File missing: #{glade_filename}") if
!File.exist?(glade_filename)
raise ArgumentError.new("Not a .glade file: #{glade_filename}") if
glade_filename !~ /.*\.glade/

@glade_filename = glade_filename
@base_filename = File.basename(@glade_filename, ".glade")
@class_filename = @base_filename + "_glade.rb"
end

# Runs the ruby-glade-create-template script to create a file with a
# class that corresponds to the form. This can be called repeatedly
# to keep creating the class every time the .glade file changes.
#
def make_class
`/usr/bin/ruby-glade-create-template #{@glade_filename} > #{@class_filename}`
@class_filename
end

# Creates a main program that uses the glade class created with
# _make_class_ and opens the window with the form. It will do nothing
# if the main program file already exists, since the user is likely
# to add code to this file.
#
def make_main
main_filename = @base_filename + '.rb'

if(File.exist?(main_filename))
raise ArgumentError.new("#{main_filename} already exists, skipping")
else
File.open(main_filename, "w") {|f| f.write generate_main}
end
main_filename
end

private
def generate_main()
class_name = File.read(@class_filename).scan(/class (.*)/).to_s
window_id = File.read(@glade_filename).scan(/class="\w+"
id="(\w*)">$/).flatten[0]

main =<<END

require '#{@base_filename}_glade'

class #{class_name}
def form
@glade["#{window_id}"]
end

def show
form.show
end

#if this signal exists, exit nicely
#
def on_#{window_id}_destroy(widget)
Gtk.main_quit
end
end

form = #{class_name}.new("#{@glade_filename}", nil, "Application")
form.show

Gtk.main

END
end
end

if __FILE__ == $0
if ARGV.length != 1
puts
puts "This script creates a class and a main program that shows a
window using"
puts "that class from a .glade file. It can be used to quickly
generate a functional Ruby"
puts "program from a .glade file"
puts
puts "Usage: #{__FILE__} <file.glade>"
puts
exit
end

glader = Glader.new(ARGV[0])
print "Making class file (#{glader.make_class})...\n"

begin
print "Making main file (#{glader.make_main})...\n"
rescue => e
puts e.message
end
puts

end
 
C

Charles Oliver Nutter

Victor said:
*Charles*: That's a good feature I see useful. "Java is Java and so the same
GUI will basically work as-is on any *NIX". One thing that worries me
though, the JRuby site states that JRuby supports "almost" all the Ruby
classes. I have Ruby 1.8.6 running in well over 100 production AIX Servers.
If I convert to JRuby and need to ensure that current scripts will still
work under it. Is there any docs stating what's not support in JRuby which
is in Ruby?

Continuation support is the only major class intentionally missing. As
far as general features go, the other big one is that we don't support
C-based extensions, but usually there's a Java library that does just as
well. Just about everything else should be there. If it's missing, we
want to add it. If it's not working correctly, we want to fix it.

- Charlie
 
J

James Britt

Tom said:
All the dependencies, etc., DOES look (in the mind) a bit scary, but
I've found that if one give the Big Boys a few months, they generally
get things wired together so they Just Work. And beyond that, there's
the marvelous Ruby community. Rare has been the time that I haven't
gotten an answer back to whatever problem I've posted about - in under
an hour. Phenomenal, actually. The rest of life should be so good!

There are usually a few people on IRC, on #monkeybars, hanging out
willing to answer questions. (Maybe not so much on Sunday; but usually
we're on the channel.)


There's also a monkeybars mailing (see www.monkeybars.org)


--
James Britt

www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.risingtidesoftware.com - Wicked Cool Coding
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top