class ConfStorage

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Public Instance Methods

conf_values() click to toggle source
# File lib/Common/Conf.rb, line 26
def conf_values
@myconf
end
get_conf(i,j,k) click to toggle source
# File lib/Common/Conf.rb, line 9
def get_conf(i,j,k)
        if !@myconf.nil?
                if @myconf[i.to_s]
                        if @myconf[i.to_s][j.to_s]
                                @myconf[i.to_s][j.to_s][k.to_s]
                        end
                end
        end
end
load_conf() click to toggle source
# File lib/Common/Conf.rb, line 67
def load_conf
        @myconf=Hash.new# if @myconf.nil?
        @myinitconf=Hash.new# if @myinitconf.nil?
        sql="select * from conf where nick='#{Nick.instance.get_nick}'"
        ManqodDB.instance.manqod_db.admin.rows("select * from conf where nick='#{Nick.instance.get_nick}'").each{|row|
                        set_conf(row["moditemid"].to_s,row["itemid"].to_s,row["Variable"].to_s,row["Value"].to_s)
                        set_conf(row["moditemid"].to_s,row["itemid"].to_s,row["Variable"].to_s,row["Value"].to_s,@myinitconf)
                        if Eprint::DOMAIN.has_key?(row["Variable"].to_s)
                                Eprint::DOMAIN[row["Variable"]]=row["Value"]
                        end
        }
        set_conf(0,0,"button-size","gtk-small-toolbar") if !get_conf(0,0,"button-size")
        set_conf(0,0,"menu-type","standard") if !get_conf(0,0,"menu-type")
        set_conf(0,0,"menu-position","top") if !get_conf(0,0,"menu-position")
        set_conf(0,0,"grid","both") if !get_conf(0,0,"grid")
        set_conf(0,0,"form-grid","none") if !get_conf(0,0,"form-grid")
        set_conf(0,0,"list-tooltip","false") if !get_conf(0,0,"list-tooltip")

        set_conf(0,0,"info-frame-font","Verdana 10") if !get_conf(0,0,"info-frame-font")
        set_conf(0,0,"info-item-font","Verdana Bold 10") if !get_conf(0,0,"info-item-font")
        set_conf(0,0,"form-frame-font","Verdana Bold 10") if !get_conf(0,0,"form-frame-font")
        set_conf(0,0,"form-item-font","Verdana 10") if !get_conf(0,0,"form-item-font")

        set_conf(0,0,"list-button-font","Verdana 10") if !get_conf(0,0,"list-button-font")
        set_conf(0,0,"list-cell-font","Verdana 10") if !get_conf(0,0,"list-cell-font")

        set_conf(0,0,"bar-menu-font","Verdana 10") if !get_conf(0,0,"bar-menu-font")

        set_conf(0,0,"confirm-exit","true") if !get_conf(0,0,"confirm-exit")
        set_conf(0,0,"last-viewed-message",0) if !get_conf(0,0,"last-viewed-message")

end
print_conf(conf=@myconf) click to toggle source
save_conf() click to toggle source
# File lib/Common/Conf.rb, line 40
def save_conf
return false if Nick.instance.get_nick.nil?
edebug("saving settings for #{Nick.instance.get_nick}","config","info")
scount=0
begin
@myconf.each{|ik,iv|
                iv.each{|jk,jv|
               jv.each{|kk,kv|
                                if @myinitconf.has_key?(ik) && @myinitconf[ik].has_key?(jk) && @myinitconf[ik][jk].has_key?(kk)
                              needtosave=@myinitconf[ik][jk][kk] != @myconf[ik][jk][kk]
                                else
                              needtosave=true
                                end
                                if needtosave
                    sql="replace into conf set nick='#{Nick.instance.get_nick}', Variable='#{kk}', moditemid='#{ik}', itemid='#{jk}',  Value='#{ManqodDB.instance.manqod_db.admin.escape_string(kv)}'"
                    ManqodDB.instance.manqod_db.admin.query(sql)
                              scount=scount+1
                                end
               }
                }
}
edebug("#{scount} changed settings saved","config","normal")
rescue =>err
        edebug("can't save user configs, #{err}","config","error")
end
end
set_conf(moditem_id,item_id,variable,value,conf=@myconf) click to toggle source
# File lib/Common/Conf.rb, line 19
def set_conf(moditem_id,item_id,variable,value,conf=@myconf)
        edebug("#{moditem_id}:#{item_id}:#{variable} => #{value}","config","info")
        conf[moditem_id.to_s]=Hash.new if !conf.has_key?(moditem_id.to_s)
        conf[moditem_id.to_s][item_id.to_s]=Hash.new if !conf[moditem_id.to_s].has_key?(item_id.to_s)
        conf[moditem_id.to_s][item_id.to_s][variable.to_s]=value.to_s
end