class RunnerManager
class RunnerManager
< TkFloatTitledFrame
Constants
- ROW_GAP
Attributes
cmd_width[R]
ext_width[R]
name_width[R]
title_width[R]
Public Class Methods
new(_parent)
click to toggle source
Calls superclass method
HinnerSplittedDialogTitled::new
# File lib/a-core.rb, line 1986 def initialize(_parent) super("Runners manager") @addb = @titled_frame.add_fixed_button('[Add Runner]',proc{do_add}) @saveb = @titled_frame.add_fixed_button('[Save]',proc{do_save}) @items = Hash.new @content = Hash.new @content_root = Tk::ScrollFrame.new(self.hinner_frame).place('x'=>0, 'y'=>0, 'relheight'=>1, 'relwidth'=>1) @content_root_frame = @content_root.baseframe #screen_width = TkWinfo.vrootwidth(self.hinner_frame) - 140 #char_width = 8 font_metrics = TkFont.new(Arcadia.conf('edit.font')).metrics screen_width = TkWinfo.vrootwidth(self.hinner_frame) - 140 font_metrics_hash = {} font_metrics.each{|a| font_metrics_hash[a[0]] = a[1] } char_width = font_metrics_hash["ascent"] - font_metrics_hash["descent"] - 1 screen_width_in_chars = screen_width.to_f/char_width #proporzioni ext_part = 1 name_part = 3 title_part = 4 cmd_part = 8 tot_part = ext_part+name_part+title_part+cmd_part one_part = screen_width_in_chars/tot_part @ext_width = (one_part*ext_part).round @name_width = (one_part*name_part).round @title_width = (one_part*title_part).round @cmd_width = (one_part*cmd_part).round end
Public Instance Methods
add_gap()
click to toggle source
# File lib/a-core.rb, line 2051 def add_gap #p @content_root.y_scrolled? root_height = Arcadia.instance.root_height if self.height < root_height/2 self.height(self.height + ROW_GAP) @content_root.vscroll(true) if !@content_root.y_scrolled? end end
clear_items()
click to toggle source
# File lib/a-core.rb, line 2112 def clear_items @items.each_value{|i| i.each_value{|j| j.destroy } i.clear } #@items.clear end
del_gap()
click to toggle source
# File lib/a-core.rb, line 2060 def del_gap self.height(self.height - ROW_GAP) end
do_add(_runner_from=nil)
click to toggle source
# File lib/a-core.rb, line 2035 def do_add(_runner_from=nil) if _runner_from runner_hash = _runner_from.hash_value runner_hash[:name]="copy of #{runner_hash[:name]}" else runner_hash = {} end @items[:config]["item#{@items[:config].count}"]=RunnerMangerItem.new(self, @content[:config], runner_hash, @items[:config].count+1) # @content[:config].pack # root_height = Arcadia.instance.root_height # # self.height(self.height + ROW_GAP) if self.height < root_height add_gap @content_root.yview_moveto('1.0') end
do_close()
click to toggle source
Calls superclass method
HinnerSplittedDialogTitled#do_close
# File lib/a-core.rb, line 2022 def do_close if something_has_changed? if Arcadia.dialog(self, 'type'=>'yes_no', 'msg'=> Arcadia.text("main.d.confirm_exit_runners_manager.msg"), 'title' => Arcadia.text("main.d.confirm_exit_runners_manager.title"), 'level' => 'question')!='yes' return end end super() end
do_delete_item(_item, _tyme=:config)
click to toggle source
# File lib/a-core.rb, line 2064 def do_delete_item(_item, _tyme=:config) @items[:config].delete_if{|k,v| v == _item} del_gap #self.height(self.height - ROW_GAP) end
do_save()
click to toggle source
# File lib/a-core.rb, line 2082 def do_save items_saved = [] @items.each_value{|i| i.each_value{|j| if !j.readonly && j.change? jhash = j.hash_value name = jhash[:name].gsub(" ", "_") Arcadia.conf("runners.#{name}", jhash.to_s) j.reset_change items_saved << name end } } Arcadia.instance.update_local_config Arcadia.instance.reload_runners if items_saved.count >0 Arcadia.dialog(self, 'type'=>'ok', 'title' => "Save info", 'msg'=>"Saved #{items_saved.to_s}!", 'level'=>'info') else Arcadia.dialog(self, 'type'=>'ok', 'title' => "Save info", 'msg'=>"Nothing done!", 'level'=>'info') end end
load_items(_kind = :runtime)
click to toggle source
# File lib/a-core.rb, line 2172 def load_items(_kind = :runtime) items = @items[_kind] if items.nil? items = @items[_kind] = Hash.new end if _kind == :runtime runs_pers=Arcadia.pers_group('runners', true) runs = {} runs_pers.each{|k, v| runs[k]="#{v}|||runtime" } elsif _kind == :config runs_with_local=Arcadia.conf_group('runners', true) runs_without_local = Arcadia.conf_group_without_local('runners', false) runs = {} # loading extensions runners Arcadia.extensions.each{|ext| ext_runs = Arcadia.conf_group("#{ext}.runners", true) if ext_runs && !ext_runs.empty? ext_runs_enanched = {} ext_runs.each{|k, v| ext_runs_enanched[k]="#{v}|||#{ext}" } runs.update(ext_runs_enanched) end } # loading main runners runs_with_local.each{|k,v| if runs_without_local.include?(k) runs[k]="#{v}|||main" else runs[k]=v end } end @content[_kind] = Arcadia.wf.frame(@content_root_frame){padding "3 3 12 12"} @content[_kind].pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes') #@content.extend(TkScrollableWidget).show # ICON TkGrid.columnconfigure(@content[_kind], 0, :weight => 0 , :uniform => 'a') # NAME TkGrid.columnconfigure(@content[_kind], 1, :weight => 1 ) # TITLE TkGrid.columnconfigure(@content[_kind], 2, :weight => 2 ) # CMD TkGrid.columnconfigure(@content[_kind], 3, :weight => 3 ) # FILE EXTS TkGrid.columnconfigure(@content[_kind], 4, :weight => 1 ) # COPY BUTTON TkGrid.columnconfigure(@content[_kind], 5, :weight => 0, :uniform => 'a' ) # DELETE BUTTON TkGrid.columnconfigure(@content[_kind], 6, :weight => 0, :uniform => 'a' ) TkGrid.propagate(@content[_kind], true) load_titles(@content[_kind]) runs.keys.reverse.each{|name| hash_string = runs[name] hash_string, origin = hash_string.split("|||") item_hash = eval hash_string item_hash[:name]=name if item_hash[:runner] && Arcadia.runner(item_hash[:runner]) item_hash = Hash.new.update(Arcadia.runner(item_hash[:runner])).update(item_hash) end if origin item_hash[:origin] = origin state_array = [] << :disabled end items[name]=RunnerMangerItem.new(self, @content[_kind], item_hash, items.count+1, state_array) #self.height(self.height + ROW_GAP) add_gap } end
load_tips()
click to toggle source
# File lib/a-core.rb, line 2120 def load_tips # Runners keywords related the current file => <<FILE>>, <<DIR>>, <<FILE_BASENAME>>, <<FILE_BASENAME_WITHOUT_EXT>>, <<INPUT>>, <<INPUT_FILE>> # INPUT is required to user text = Arcadia.wf.text(@content_root_frame, "height" => 2, "bg" => '#009999' ) text.pack('side' =>'top','anchor'=>'nw','fill'=>'x','padx'=>5, 'pady'=>5) text.insert("end", "Keywords => <<RUBY>>, <<FILE>>, <<DIR>>, <<FILE_BASENAME>>, <<FILE_BASENAME_WITHOUT_EXT>>, <<INPUT_FILE>>, <<INPUT_DIR>>, <<INPUT_STRING>>") add_gap #self.height(self.height + ROW_GAP) end
load_titles(_content)
click to toggle source
# File lib/a-core.rb, line 2133 def load_titles(_content) bg = Arcadia.conf("titlelabel.background") fg = Arcadia.conf("titlelabel.foreground") # # ICON # Arcadia.wf.label(_content, # 'text'=> "" , # 'background'=> bg, # 'relief'=>'flat').grid(:column => 0, :row => 0, :sticky => "WE", :padx=>1, :pady=>1) # NAME Arcadia.wf.label(_content, 'text'=> "Name", 'background'=> bg, 'foreground'=> fg, 'relief'=>'flat').grid(:column => 1, :row => 0, :sticky => "WE", :padx=>1, :pady=>1) # TITLE Arcadia.wf.label(_content, 'text'=> "Title" , 'background'=> bg, 'foreground'=> fg, 'relief'=>'flat').grid(:column => 2, :row => 0, :sticky => "WE", :padx=>1, :pady=>1) # CMD Arcadia.wf.label(_content, 'text'=> "CMD" , 'background'=> bg, 'foreground'=> fg, 'relief'=>'flat').grid(:column => 3, :row => 0, :sticky => "WE", :padx=>1, :pady=>1) # FILE EXTS Arcadia.wf.label(_content, 'text'=> "Exts" , 'background'=> bg, 'foreground'=> fg, 'relief'=>'flat').grid(:column => 4, :row => 0, :sticky => "WE", :padx=>1, :pady=>1) end
something_has_changed?()
click to toggle source
# File lib/a-core.rb, line 2070 def something_has_changed? ret = false @items.each_value{|i| i.each_value{|j| ret = ret || (!j.readonly && j.change?) break if ret } break if ret } ret end