Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'gtk2'
- module NNTPManager
- class MainWindow
- def initialize
- window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
- window.set_title "NNTP-manager main"
- window.signal_connect("delete_event") { Gtk.main_quit }
- new_post_button = Gtk::Button.new("New Post")
- view_posts_button = Gtk::Button.new("View Posts")
- preferences_button = Gtk::Button.new("Preferences")
- new_post_button.signal_connect("clicked") {
- NewPostForm.new
- }
- view_posts_button.signal_connect("clicked") {
- ViewPostsWindow.new
- }
- preferences_button.signal_connect("clicked") {
- PreferencesFormWindow.new
- }
- buttonbox = Gtk::HBox.new
- buttonbox.pack_start(new_post_button, false, false, 0)
- buttonbox.pack_start(view_posts_button, false, false, 0)
- buttonbox.pack_start(preferences_button, false, false, 0)
- window.add(buttonbox)
- window.signal_connect("destroy") { Gtk.main_quit }
- window.show_all
- Gtk.main
- end
- end
- class PreferencesFormWindow
- attr_accessor :host, :port, :user, :password
- def initialize
- window = Gtk::Window.new
- window.set_title "NNTP server host info"
- window.border_width = 20
- window.signal_connect("delete_event") { Gtk.main_quit }
- host_label = Gtk::Label.new("Host: ")
- port_label = Gtk::Label.new("Port: ")
- user_label = Gtk::Label.new("User: ")
- password_label = Gtk::Label.new("Password: ")
- host = Gtk::Entry.new
- port = Gtk::Entry.new
- user = Gtk::Entry.new
- password = Gtk::Entry.new
- password.visibility = false
- submit_button = Gtk::Button.new("Save")
- submit_button.signal_connect("clicked") {
- @host = host.text
- @port = port.text.to_i
- @user = user.text
- @password = password.text
- puts "loading following information into library file: "
- puts "host: #{@host}"
- puts "port: #{@port}"
- puts "user: #{@user}"
- puts "password: #{@password}"
- # write_lib_file({ :info => { :host => @host,
- # :port => @port,
- # :user => @user,
- # :password => @password
- # }
- # })
- }
- host_field = Gtk::HBox.new(false, 0)
- host_field.pack_start(host_label, true, true, 0)
- host_field.pack_start(host, true, true, 0)
- port_field = Gtk::HBox.new(false, 0)
- port_field.pack_start(port_label, true, true, 0)
- port_field.pack_start(port, true, true, 0)
- user_field = Gtk::HBox.new(false, 0)
- user_field.pack_start(user_label, true, true, 0)
- user_field.pack_start(user, true, true, 0)
- password_field = Gtk::HBox.new(false, 0)
- password_field.pack_start(password_label, true, true, 0)
- password_field.pack_start(password, true, true, 0)
- form = Gtk::VBox.new(false, 0)
- form.add(host_field)
- form.add(port_field)
- form.add(user_field)
- form.add(password_field)
- form.pack_start(submit_button, true, true, 0)
- window.add(form)
- window.show_all
- Gtk.main
- end
- # def write_lib_file(hash)
- # hash.each do |key, value|
- end
- class ViewPostsWindow
- def initialize
- end
- mainapp = MainWindow.new
Add Comment
Please, Sign In to add comment