-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.rb
77 lines (70 loc) · 2.14 KB
/
gui.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env ruby
#
# This file is gererated by ruby-glade-create-template 1.1.4.
#
require 'libglade2'
require 'gtk2'
require "librubyocamlsearchr"
class OcamlsearchrGlade
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)}
@fileselector = @glade.get_widget("filechooser1")
@searcharea = @glade.get_widget("vbox2")
@to_find = @glade.get_widget("entry5")
@listview = @glade.get_widget("treeview1")
[_("Adress"), _("Hexadecimal"), _("Text")].each_with_index { |name, i|
column = Gtk::TreeViewColumn.new(name, Gtk::CellRendererText.new, :text => i)
@listview.append_column(column)
}
@store = Gtk::ListStore.new(String, String, String)
@listview.model = @store
end
def on_open1_activate(widget)
ret = @fileselector.run
if ret == Gtk::Dialog::RESPONSE_OK then
@file = @fileselector.filename
end
@searcharea.sensitive = true
@fileselector.hide
end
def on_quit1_activate(widget)
Gtk.main_quit
end
def gtk_main_quit(widget, arg0)
Gtk.main_quit
end
def on_startbutton_pressed(widget)
@store.clear
searcher = OcamlSearchR.new(@file,@to_find.text)
while true
begin
pos,bytes = searcher.search()
position = sprintf("%012d",pos.to_s)
hexmatch = bytes.collect{|x| sprintf("%X",x.to_s)}.join(" ")
iter = @store.append
@store.set_value(iter,0,position)
@store.set_value(iter,1,hexmatch)
@store.set_value(iter,2,bytes.to_s)
rescue Exception => exc
break
end
end
end
def on_A_propos1_activate(widget)
puts "on_A_propos1_activate() is not implemented yet."
end
def on_button5_pressed(widget)
puts "on_button5_pressed() is not implemented yet."
end
end
# Main program
if __FILE__ == $0
# Set values as your own application.
PROG_PATH = "ocamlsearchr.glade"
PROG_NAME = "YOUR_APPLICATION_NAME"
OcamlsearchrGlade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
end