Class: MyRendererButton

Inherits:
Gtk::Button
  • Object
show all
Includes:
Conf, ManqodCommon, MyExec
Defined in:
lib/FormHolder/Form/InputHolder/Button.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

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MyExec

#myexec

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) ⇒ MyRendererButton

Returns a new instance of MyRendererButton.



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
76
77
78
79
80
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 9

def initialize(pc)
@pc=pc
super(item['description'])
set_relief(Gtk::ReliefStyle::NONE)
set_image_position(Gtk::PositionType::RIGHT)
set_use_underline(true)
signal_connect('clicked'){|me|
  edebug("#{item['default']} clicked","gtk_button","debug")
  run_events(item['id'],'form_item-Action')
  unless target == "-1" || target == "0"
    if modname=='form'
      @form=Myform::MyFormHolder.new("dialog",self,@pc.target_runmode,target)
      @form.set_parentM(parentM)
      ret=@form.run(text.to_i)
      update(ret) if ret and ret>0
      notify_changes
    else
    mr=MainRouter.new(w=Gtk::Dialog.new)
    w.vbox.
      pack_start(Gtk::HBox.new.
        pack_start(back_button=Gtk::Button.new(Gtk::Stock::GO_BACK),false,false).
        pack_start(clear_button=Gtk::Button.new(Gtk::Stock::CLEAR),false,false),
        false,false).
      pack_start(mr)
    back_button.signal_connect("clicked"){|me,ev|
      update(mr.child.list.get_cursor_id.to_s)
      w.destroy
      notify_changes
    }
    clear_button.signal_connect("clicked"){|me,ev|
      update("-1")
      w.destroy
      notify_changes
    }
    if sw=get_conf(target,0,"width") and sh=get_conf(target,0,"height")
      w.resize(sw.to_i,sh.to_i)# if sw.to_i * sh.to_i >0
      else
      w.resize(600,400)
    end
    sx=get_conf(target,0,"x") || 50
    sy=get_conf(target,0,"y") || 60
    w.move(sx.to_i,sy.to_i)

    w.maximize if get_conf(target,0,"maximized") == "true"
    w.iconify if get_conf(target,0,"iconified") == "true"
    w.fullscreen if get_conf(target,0,"fullscreen") == "true"

    w.set_resizable(true).set_transient_for(@pc.caller.get_ancestor(Gtk::Window)).set_modal(true).show_all
    w.signal_connect("configure-event"){|me,event|
      if nick
        set_conf(target,0,"width",event.width.to_s)
        set_conf(target,0,"height",event.height.to_s)
        set_conf(target,0,"x",event.x.to_s)
        set_conf(target,0,"y",event.y.to_s)
      end
      false
    }
    w.signal_connect("window-state-event"){|me,event|
      if nick
        set_conf(target,0,"maximized",(event.new_window_state &  Gdk::EventWindowState::MAXIMIZED == Gdk::EventWindowState::MAXIMIZED).to_s)
        set_conf(target,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::ICONIFIED == Gdk::EventWindowState::ICONIFIED).to_s)
        set_conf(target,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::FULLSCREEN == Gdk::EventWindowState::FULLSCREEN).to_s)
      end
      false
    }

    mr.update(self)
    mr.child.list.set_cursor_id(text.to_i)
    end
  end
}
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



81
82
83
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 81

def pc
  @pc
end

Instance Method Details

#inspectObject



120
121
122
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 120

def inspect
  "Button(#{item['description']})"
end

#itemObject



117
118
119
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 117

def item
pc.item
end

#modnameObject



83
84
85
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 83

def modname
  @pc.target_module
end

#notify_changesObject



127
128
129
130
131
132
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 127

def notify_changes
  edebug("'#{item['data']}' changed","form")
  pc.changed
  pc.notify_observers(self)
  edebug("'#{item['data']}' emiting 'changed' to observers","form")
end

#parentMObject



110
111
112
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 110

def parentM
pc.parentM
end

#targetObject



114
115
116
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 114

def target
item['to_call']
end

#textObject



106
107
108
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 106

def text
item['default'].to_s
end

#to_sObject



123
124
125
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 123

def to_s
  inspect
end

#update(new_value = item['default']) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/FormHolder/Form/InputHolder/Button.rb', line 86

def update(new_value=item['default'])
item['default']=new_value
run_events(item['id'],'form_item-BeforeUpdate')
pc.run_query
if @pc.type_def.size == 0
  set_label(item['default'])
  else
  s=""
  @pc.type_def.each_pair{|key,value| 
    s="#{s}\n" if s.size>0
    s="#{s}#{@pc.query_result[key]}" if @pc.query_result.has_key?(key)
  }
  set_label(s)
  set_image(Gtk::Image.new((parentM.runmode=='info' ? Gtk::Stock::INFO : (text=="-1" || text=="0" ? Gtk::Stock::ADD : Gtk::Stock::EDIT )),Gtk::IconSize.from_name(get_conf(0,0,"button-size"))))
  notify_changes
end
edebug("#{text} updated","gtk_button","info")
run_events(item['id'],'form_item-AfterUpdate')
end