Class: MyFileChooserButton
- Inherits:
-
Gtk::FileChooserWidget
- Object
- Gtk::FileChooserWidget
- MyFileChooserButton
- Includes:
- Conf, ManqodCommon
- Defined in:
- lib/FormHolder/Form/InputHolder/FileChooser.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])
Constant Summary
Constants included from ManqodCommon
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included from Eprint
Instance Attribute Summary collapse
-
#ftp ⇒ Object
Returns the value of attribute ftp.
-
#pc ⇒ Object
Returns the value of attribute pc.
-
#progress ⇒ Object
Returns the value of attribute progress.
Instance Method Summary collapse
- #ftp_get ⇒ Object
- #ftp_store ⇒ Object
-
#initialize(pc) ⇒ MyFileChooserButton
constructor
A new instance of MyFileChooserButton.
- #item ⇒ Object
- #load ⇒ Object
- #loadPixbuf ⇒ Object
- #save(content) ⇒ Object
- #text ⇒ Object
- #update(nfilename = item['default']) ⇒ Object
Methods included from Conf
#get_conf, #load_conf, #save_conf, #set_conf
Methods included from ManqodCommon
#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick
Methods included from Eprint
#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception
Constructor Details
#initialize(pc) ⇒ MyFileChooserButton
Returns a new instance of MyFileChooserButton.
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 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 8 def initialize(pc) @pc=pc action=case item['action'] when 'load' then Gtk::FileChooser::Action::OPEN when 'save' then Gtk::FileChooser::Action::SAVE end super(action) # set_select_multiple(false) path=get_conf(0,item['id'],"path") set_current_folder(path) if !path.nil? preview=Gtk::Image.new (preview) signal_connect("update-preview") { filename = preview_filename begin have_pixbuf=true pixbuf = Gdk::Pixbuf.new(filename, 128, 128) rescue have_pixbuf=false end .set_pixbuf(pixbuf) (have_pixbuf) } begin @ftp=eval(pc.gtk_attribute("ftp-access").to_s) rescue =>err ewarn(err) end pack_start(@progress=Gtk::ProgressBar.new,false,true,1) if @ftp.class==Array end |
Instance Attribute Details
#ftp ⇒ Object
Returns the value of attribute ftp.
39 40 41 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 39 def ftp @ftp end |
#pc ⇒ Object
Returns the value of attribute pc.
39 40 41 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 39 def pc @pc end |
#progress ⇒ Object
Returns the value of attribute progress.
39 40 41 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 39 def progress @progress end |
Instance Method Details
#ftp_get ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 100 def ftp_get unless @ftp.class==Array warn("no ftp access defined") return false end set_conf(0,item['id'],"path",current_folder) ftp=Net::FTP.new(@ftp[0],@ftp[1],@ftp[2]) @ftp[3].each("/"){|s| einfo("changing ftp dir: #{s}","form") ftp.chdir(s) } if @ftp[3] perc=0 einfo(item["initial"],"form") ftp.getbinaryfile(item["initial"],filename,ftp.size(item["initial"])/100){ progress.set_fraction(perc/100.0) Gtk.show_thread_changes perc+=1 } ftp.close end |
#ftp_store ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 74 def ftp_store unless @ftp.class==Array warn("no ftp access defined") return false end set_conf(0,item['id'],"path",current_folder) ftp=Net::FTP.new(@ftp[0],@ftp[1],@ftp[2]) @ftp[3].each("/"){|s| begin einfo("changing ftp dir: #{s}","form") ftp.chdir(s) rescue =>err einfo("creating ftp dir: #{s}","form") ftp.mkdir(s) retry end } if @ftp[3] perc=0 ftp.putbinaryfile(filename,text,File.size(filename)/100){ progress.set_fraction(perc/100.0) Gtk.show_thread_changes perc+=1 } ftp.close end |
#item ⇒ Object
41 42 43 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 41 def item @pc.item end |
#load ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 56 def load ret=String.new file = File.new(filename, "rb") ret=file.read file.close edebug("loaded","list-filechooser","debug") set_conf(0,item['id'],"path",current_folder) ret end |
#loadPixbuf ⇒ Object
122 123 124 125 126 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 122 def loadPixbuf set_conf(0,item['id'],"path",current_folder) pixdata=Gdk::Pixdata.from_pixbuf(Gdk::Pixbuf.new(filename),true) pixdata.serialize.pack("c*") end |
#save(content) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 66 def save(content) file = File.new(filename, "wb+") file.write(content) file.close edebug("saved","list-filechooser","debug") set_conf(0,item['id'],"path",current_folder) end |
#text ⇒ Object
52 53 54 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 52 def text filename[current_folder.length() +1 .. filename.length()] end |
#update(nfilename = item['default']) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/FormHolder/Form/InputHolder/FileChooser.rb', line 45 def update(nfilename=item['default']) run_events(item['id'],'info_item-BeforeUpdate') edebug("filename to set: |#{nfilename}|","list-filechooser","debug") set_current_name(nfilename) if nfilename run_events(item['id'],'info_item-AfterUpdate') end |