gtk interface (with glade) don't wanna run

M

Mathspeedy

Hi all, well I'm not really good with User interface, and I decided to
make one for this little program:

Code:
#!/usr/bin/ruby

class Programming_menu
#show a menu offering programming utilities
def show_menu()
puts "1. gedit (Text Editor...) **"
puts "2. Glade 3 (Interface designer) **"
puts "3. Terminal"
puts "4. IRB (interactive ruby)"
puts "5. Blender (3D modeler) **"
puts "6. Gimp (2D editor) **"
puts "7. GTKRadiant (Game map editor) **"
puts "8. Dia (diagram designer) **"
puts "9. Hex editor **"
puts "10. TOP (app monitor)"
puts "11. EXIT (please read the advertisement)"
puts "-=====================================-"
puts "if app return infos just press ENTER"
puts "EXITING this program will exit ** apps"
puts "-=====================================-"
end
#ask for the choice
def choice()
puts "Please enter the number of the wanted app."
choice = gets.to_i
if choice == 1
system("gedit &")
elsif choice == 2
system("glade-3 &")
elsif choice == 3
system("gnome-terminal")
elsif choice == 4
system("gnome-terminal -e irb")
elsif choice == 5
system("blender &")
elsif choice == 6
system("gimp &")
elsif choice == 7
system("/opt/gtkradiant/radiant.x86 &")
elsif choice == 8
system("dia &")
elsif choice == 9
system("ghex2 &")
elsif choice == 10
system("gnome-terminal -e top")
elsif choice == 11
break
end
end

#main process.

pc = Programming_menu.new
pc.show_menu()
pc.choice()
loop do
system("clear")
pc.show_menu()
pc.choice()
end
end

and this is the code with GUI
Code:
#!/usr/bin/ ruby
require 'libglade2'

class GpumGlade
include GetText

attr :glade

def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
bindtextdomain(domain, localedir, nil, "UTF-8")
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}

end

def on_gimp_button_clicked(widget)
puts "on_gimp_button_clicked() is not implemented yet."
end
def on_window_delete_event(widget, arg0)
Gtk.main_quit
end
def on_gedit_button_clicked(widget)
system("gedit &")
end
def on_irb_button_clicked(widget)
system("gnome-terminal -e irb &")
end
def on_term_button_clicked(widget)
system("gnome-terminal &")
end
def on_top_button_clicked(widget)
system("gnome-terminal -e top &")
end
def on_blender_button_clicked(widget)
system("blender &")
end
def on_dia_button_clicked(widget)
system("dia &")
end
def on_glade_button_clicked(widget)
system("glade-3 &")
end
def on_radiant_button_clicked(widget)
system("/opt/gtkradiant/radiant.x86 &")
end
def on_hex_button_clicked(widget)
system("ghex2 &")
end
end

# Main program
if __FILE__ == $0
# Set values as your own application.
PROG_PATH = "GPUM.glade"
PROG_NAME = "YOUR_APPLICATION_NAME"
GpumGlade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
end
Can someone could tell me why it is not working ...
 

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,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top