Module: VR::Dialog

Defined in:
lib/Dialog.rb

Class Method Summary collapse

Class Method Details

.folder_box(builder) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/Dialog.rb', line 73

def Dialog.folder_box(builder)
  dialog = Gtk::FileChooserDialog.new("Select Folder...",
                 builder['window1'],
                 Gtk::FileChooser::ACTION_SELECT_FOLDER,
                 nil,
                 [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
                 [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
  
  #		if pattern != nil
  #			filter = Gtk::FileFilter.new
  #			filter.add_pattern(pattern)
  #			filter.name = "VR Project Folders" 	
  #			dialog.add_filter(filter)
  #		end
  if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
    ret =  dialog.current_folder
else
	ret = false
  end 
  dialog.destroy
return ret
end

.input_box(message, default = "", title = "Visual Ruby") ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/Dialog.rb', line 37

def Dialog.input_box(message, default="", title = "Visual Ruby")
     dialog = Gtk::MessageDialog.new(
       nil,
       Gtk::Dialog::MODAL,
       Gtk::MessageDialog::QUESTION,
       Gtk::MessageDialog::BUTTONS_OK_CANCEL,
       message)
		dialog.title = title
		input = Gtk::Entry.new
		dialog.vbox.add(input)
		dialog.show_all
		ret = ""
     dialog.run do |response|
			if response == Gtk::Dialog::RESPONSE_OK
				ret = input.buffer.text
			else
				ret = false
			end
		end
    	dialog.destroy
		return ret
end

.listbox(message, list, title = "Visual Ruby", icon = Gtk::Stock::DIALOG_QUESTION) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/Dialog.rb', line 132

def Dialog.listbox(message,list,title="Visual Ruby",icon=Gtk::Stock::DIALOG_QUESTION)
  dialog = Gtk::Dialog.new(
    title,
    nil,
    Gtk::Dialog::MODAL,
    [Gtk::Stock::YES, Gtk::Dialog::RESPONSE_ACCEPT],
    [Gtk::Stock::NO,Gtk::Dialog::RESPONSE_REJECT])
  hbox = Gtk::HBox.new
  hbox.add(Gtk::Image.new(icon,Gtk::IconSize::DIALOG))
  hbox.add(Gtk::Label.new(message))
  dialog.vbox.add(hbox)
  vrlist = VR::ListView.new({:item=>String})
  list.each do |entry|
    vrlist.add_row(:item => entry)
  end
  vrlist.headers_visible = false
  holder = Gtk::ScrolledWindow.new
  holder.add(vrlist)
  dialog.vbox.add(holder)
  dialog.vbox.show_all
  ret = (dialog.run == Gtk::Dialog::RESPONSE_ACCEPT)
  dialog.destroy
  return ret
end

.message_box(message, title = "Visual Ruby") ⇒ Object

def Dialog.calendar(datetime)

dialog = Gtk::Dialog.new(
  "Select Date", nil,
  Gtk::Dialog::MODAL,
  [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
  [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT])

c = Gtk::Calendar.new c.select_month(datetime.month, datetime.year) c.select_day(datetime.day) c.mark_day(datetime.day) dialog.vbox.add© dialog.show_all

      ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? DateTime.new(*c.date) : nil
     	dialog.destroy
			return ret

end



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Dialog.rb', line 24

def Dialog.message_box(message, title = "Visual Ruby")
 	dialog = Gtk::MessageDialog.new(
     nil,
     Gtk::Dialog::MODAL,
     Gtk::MessageDialog::INFO,
     Gtk::MessageDialog::BUTTONS_OK,
     message)
	dialog.title = title
	dialog.show_all
	dialog.run
	dialog.destroy
end

.ok_box(message, title = "Visual Ruby") ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/Dialog.rb', line 60

def Dialog.ok_box(message, title = "Visual Ruby")
     dialog = Gtk::MessageDialog.new(
       nil,
       Gtk::Dialog::MODAL,
       Gtk::MessageDialog::QUESTION,
       Gtk::MessageDialog::BUTTONS_OK_CANCEL,
       message)
		dialog.title = title
     ret = (dialog.run == Gtk::Dialog::RESPONSE_OK)
    	dialog.destroy
		return ret
end

.userpass(message, title = "Visual Ruby") ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/Dialog.rb', line 110

def Dialog.userpass(message, title = "Visual Ruby")
  dialog = Gtk::Dialog.new(
    title,
    nil,
    Gtk::Dialog::MODAL,
    [Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],
    [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT])
  dialog.vbox.add(Gtk::Label.new(message))
  hbox = Gtk::HBox.new
  hbox.add(Gtk::Label.new("Username:"))
  hbox.add(user = Gtk::Entry.new)
  dialog.vbox.add(hbox)
  hbox = Gtk::HBox.new
  hbox.add(Gtk::Label.new("Password:"))
  hbox.add(pass = Gtk::Entry.new)
  dialog.vbox.add(hbox)
  pass.visibility = false
  ret = (dialog.run == Gtk::Dialog::RESPONSE_ACCEPT) ? {:user => user.text, :pass => pass.text } : nil
  dialog.destroy
  return ret
end

.yesno(message, title = "Visual Ruby") ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/Dialog.rb', line 97

def Dialog.yesno(message, title = "Visual Ruby")
  dialog = Gtk::MessageDialog.new(
    nil,
    Gtk::Dialog::MODAL,
    Gtk::MessageDialog::QUESTION,
    Gtk::MessageDialog::BUTTONS_YES_NO,
    message)
  dialog.title = title
  ret = (dialog.run == Gtk::Dialog::RESPONSE_YES)
  dialog.destroy
  return ret
end