Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fa23bb24f1
Fetching contributors…

Cannot retrieve contributors at this time

213 lines (182 sloc) 5.851 kb
#!/usr/bin/ruby
require 'ldap'
LDAP.config['hostname'] = 'localhost'
LDAP.config['port'] = 3389
LDAP.config['base'] = 'dc=eighthbit,dc=net'
require 'gtk2'
require 'listbox'
#~ Gtk.init
#~ @main_window = Gtk::Window.new
#~ @main_window.set_default_size 500,300
#~ lb_left = ListBox.new
#~ lb_left.header = 'Ad Groups'
#~ lb_left.append('ulkomaanpuhelut')
#~ lb_left.append('kaukopuhelut')
#~ lb_left.append('suuntanumerot')
#~ lb_right = ListBox.new
#~ lb_right.header = 'State Nicknames'
#~ lb_right.fill(['Empire','Golden','Silver','Sooner','Hoosier','Razorback','Buckeye','Lone Star'])
#~ box = Gtk::HBox.new
#~ @main_window.add(box)
#~ box.pack_start(lb_left,true)
#~ box.pack_start(lb_right,true)
#~ @main_window.show_all
#~ @main_window.signal_connect("destroy") { Gtk.main_quit }
#~ lb_left.signal_connect('button_release_event') do |widget,event|
#~ puts lb_left.button_release(widget,event)
#~ end
#~ lb_left.signal_connect('key-release-event') do |widget,event|
#~ selection = lb_left.key_release(widget,event)
#~ puts "#{selection}" if selection.class == String
#~ end
#~ # Note that no signal_connect code has been written for lb_right, so a selection cannot be made.
#~ Gtk.main
class RubyApp < Gtk::Window
def initialize
super
set_title "BitUI"
signal_connect "destroy" do
Gtk.main_quit
end
init_ui
set_default_size 300, 250
#set_window_position Gtk::Window::POS_CENTER
show_all
end
def init_ui
set_border_width 15
table = Gtk::Table.new 8, 4, false
table.set_column_spacings 3
title = Gtk::Label.new "Windows"
halign = Gtk::Alignment.new 0, 0, 0, 0
halign.add title
table.attach(halign, 0, 1, 0, 1, Gtk::FILL,
Gtk::FILL, 0, 0)
lb_left = ListBox.new
lb_left.header = 'Nodes'
table.attach(lb_left, 0, 2, 1, 3, Gtk::FILL | Gtk::EXPAND,
Gtk::FILL | Gtk::EXPAND, 1, 1)
dn = LDAP.config['base']
entries = LDAP.ldap.search :base => dn, :filter => Net::LDAP::Filter.eq('objectclass', 'x-bit-ircUser')
entries.each do |entry|
lb_left.append entry[:uid].first
end
lb_left.signal_connect('button-release-event') do |widget,event|
next unless event.button == 1
puts lb_left.button_release(widget, event)
end
lb_left.signal_connect('key-release-event') do |widget, event|
p event
selection = lb_left.key_release(widget,event)
puts selection if selection.class == String
end
activate = Gtk::Button.new "Activate"
activate.set_size_request 50, 30
table.attach(activate, 3, 4, 1, 2, Gtk::FILL,
Gtk::SHRINK, 1, 1)
valign = Gtk::Alignment.new 0, 0, 0, 0
close = Gtk::Button.new "Close"
close.set_size_request 70, 30
valign.add close
table.set_row_spacing 1, 3
table.attach(valign, 3, 4, 2, 3, Gtk::FILL,
Gtk::FILL | Gtk::EXPAND, 1, 1)
halign2 = Gtk::Alignment.new 0, 1, 0, 0
help = Gtk::Button.new "Help"
help.set_size_request 70, 30
halign2.add help
table.set_row_spacing 3, 6
table.attach(halign2, 0, 1, 4, 5, Gtk::FILL,
Gtk::FILL, 0, 0)
ok = Gtk::Button.new "OK"
ok.set_size_request 70, 30
table.attach(ok, 3, 4, 4, 5, Gtk::FILL,
Gtk::FILL, 0, 0)
add table
end
end
Gtk.init
window = RubyApp.new
Gtk.main
#~ #!/usr/bin/ruby
#~
#~ # ZetCode Ruby GTK tutorial
#~ #
#~ # This example shows a menu with
#~ # images, accelerators and a separator
#~ #
#~ # author: jan bodnar
#~ # website: www.zetcode.com
#~ # last modified: June 2009
#~
#~ require 'gtk2'
#~
#~
#~ class RubyApp < Gtk::Window
#~
#~ def initialize
#~ super
#~
#~ set_title "Github GUI"
#~ signal_connect "destroy" do
#~ Gtk.main_quit
#~ end
#~
#~ init_ui
#~
#~ set_default_size 250, 200
#~ set_window_position Gtk::Window::POS_CENTER
#~
#~ show_all
#~ end
#~
#~ def init_ui
#~
#~ modify_bg Gtk::STATE_NORMAL, Gdk::Color.new(6400, 6400, 6440)
#~
#~ mb = Gtk::MenuBar.new
#~
#~ filemenu = Gtk::Menu.new
#~ filem = Gtk::MenuItem.new "User"
#~ filem.set_submenu filemenu
#~
#~ agr = Gtk::AccelGroup.new
#~ add_accel_group agr
#~
#~ newi = Gtk::ImageMenuItem.new Gtk::Stock::NEW, agr
#~ key, mod = Gtk::Accelerator.parse "N"
#~ newi.add_accelerator("activate", agr, key,
#~ mod, Gtk::ACCEL_VISIBLE)
#~ filemenu.append newi
#~
#~ openm = Gtk::ImageMenuItem.new Gtk::Stock::OPEN, agr
#~ key, mod = Gtk::Accelerator.parse "O"
#~ openm.add_accelerator("activate", agr, key,
#~ mod, Gtk::ACCEL_VISIBLE)
#~ filemenu.append openm
#~
#~ sep = Gtk::SeparatorMenuItem.new
#~ filemenu.append sep
#~
#~ exit = Gtk::ImageMenuItem.new Gtk::Stock::QUIT, agr
#~ key, mod = Gtk::Accelerator.parse "Q"
#~ exit.add_accelerator("activate", agr, key,
#~ mod, Gtk::ACCEL_VISIBLE)
#~
#~ exit.signal_connect "activate" do
#~ Gtk.main_quit
#~ end
#~ filemenu.append exit
#~
#~ mb.append filem
#~
#~ vbox = Gtk::VBox.new false, 2
#~ vbox.pack_start mb, false, false, 0
#~
#~ add vbox
#~ end
#~ end
#~
#~ Gtk.init
#~ window = RubyApp.new
#~ Gtk.main
Jump to Line
Something went wrong with that request. Please try again.