Module: MyExec

Included in:
MyRendererButton, MyRendererCalendarButton
Defined in:
lib/Common/MyExec.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Instance Method Summary collapse

Instance Method Details

#myexec(filename, filedata) ⇒ Object



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
# File 'lib/Common/MyExec.rb', line 7

def myexec(filename,filedata)
  ext=if last=filename.rindex(".");then filename[last+1 .. filename.length];else "";end
  gettmp=true
  while gettmp
	if tmp=get_conf(0,0,"dir_tmp")
	  if !tmpok=FileTest.directory?(tmp)
		begin
		  Dir.mkdir(tmp)
		  rescue SystemCallError => err
		end
		tmpok=FileTest.directory?(tmp)
	  end
	end
	if !tmpok
	  asker=Gtk::Dialog.new()
	  asker.set_title("tmp?")
	  op=Gtk::Entry.new
	  asker.vbox.add(op)
	  okebutton=asker.add_button('',0).set_image(Gtk::Image.new(Gtk::Stock::OK,Gtk::IconSize::BUTTON)).set_label('ok').set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked') do |c| asker.response(1) end
	  cancelbutton=asker.add_button('',0).set_image(Gtk::Image.new(Gtk::Stock::CANCEL,Gtk::IconSize::BUTTON)).set_label('megsem').set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked') do |c| asker.response(-1) end
	  #warner.realize;warner.window.set_functions(Gdk::Window::WMFunction::ALL | Gdk::Window::WMFunction::CLOSE)
	  asker.show_all
	  if asker.run ==1
		set_conf(0,0,"dir_tmp",op.text)
		gettmp=true
		else
		gettmp=false
	  end
	  asker.destroy
	  else
	  gettmp=false
	end
  end
  return false if !tmpok
  filepath=tmp+filename
  file = File.new(filepath, "wb+")
  file.write(filedata)
  file.close
  tryit=true
  while tryit
	if prog=get_conf(0,0,"file_#{ext}")
	  ret=system prog, filepath 
	end
	if prog.nil? or !ret
	  asker=Gtk::Dialog.new()
	  asker.set_title("Program?")
	  op=Gtk::Entry.new
	  asker.vbox.add(op)
	  okebutton=asker.add_button('',0).set_image(Gtk::Image.new(Gtk::Stock::OK,Gtk::IconSize::BUTTON)).set_label('ok').set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked') do |c|
		asker.response(1)
	  end
	  cancelbutton=asker.add_button('',0).set_image(Gtk::Image.new(Gtk::Stock::CANCEL,Gtk::IconSize::BUTTON)).set_label('megsem').set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked') do |c|
		asker.response(-1)
	  end
	  #warner.realize;warner.window.set_functions(Gdk::Window::WMFunction::ALL | Gdk::Window::WMFunction::CLOSE)
	  asker.show_all
	  if asker.run ==1
		set_conf(0,0,"file_#{ext}",op.text)
		tryit=true
		else
		tryit=false
	  end
	  asker.destroy
	  else
	  tryit=false
	end
  end
  File.delete(filepath)
end