class MySourceView

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

Attributes

pc[RW]
tv[RW]

Public Class Methods

new(pc) click to toggle source
Calls superclass method
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 7
def initialize(pc)
        @pc=pc
        super(nil,nil)
        set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
        @tv=Gtk::SourceView.new()
        
        add(@tv)
        @tv.buffer.set_highlight_matching_brackets(true)
        @tv.set_auto_indent(true).
                set_highlight_current_line(true).
                set_indent_on_tab(true).
                set_indent_on_tab(true).
                set_indent_width(4)
        @tv.editable=item['editable']=="true"
        @tv.modify_font(Pango::FontDescription.new('Monospace 10'))
        
        @found_tag=@tv.buffer.create_tag('found',{'background' => 'yellow'})
        @search_window=Gtk::Window.new(Gtk::Window::POPUP).set_destroy_with_parent(true).set_modal(true).set_window_position(Gtk::Window::POS_CENTER_ON_PARENT).set_decorated(false)
        @search_window.add(Gtk::VBox.new.
                pack_start(Gtk::Label.new("filter: #{item['description']}")).
                pack_start(@entry=Gtk::Entry.new.set_can_focus(true).set_can_default(true))
        )

        @entry.signal_connect("key-release-event"){|me,ev|
                @tv.buffer.remove_tag(@found_tag,@tv.buffer.start_iter,@tv.buffer.end_iter)
                if ev.keyval == Gdk::Keyval::GDK_KEY_Escape
                        @search_window.hide
                        else
                        start_iter=@tv.buffer.start_iter
                        while bounds=start_iter.forward_search(me.text,Gtk::TextIter::SEARCH_TEXT_ONLY,nil)
                                @tv.buffer.apply_tag(@found_tag,bounds[0],bounds[1])
                                start_iter=bounds[1]
                        end
                end
        }
        @entry.signal_connect("activate"){|me|
                @search_window.hide
        }
end

Public Instance Methods

editable() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 53
def editable
        pc.editable
end
inspect() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 91
def inspect
        "SourceView #{item['description']}(#{pc.gtk_attribute("language")})"
end
item() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 50
def item
        @pc.item
end
parentM() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 87
def parentM
        @pc.parentM
end
parentselected() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 83
      def parentselected
              @pc.parentselected
end
test_content() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 75
def test_content
              client_query(eeval("\"#{text}\""))
end
text() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 57
def text
        @tv.buffer.text
end
to_s() click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 95
def to_s
        inspect
end
update(new_value=item['default']) click to toggle source
# File lib/FormHolder/Form/InputHolder/SourceView.rb, line 61
        def update(new_value=item['default'])
                item['default']=new_value
                run_events(item['id'],'form_item-BeforeUpdate')
                pc.run_query

                @tv.buffer.delete(*@tv.buffer.bounds)
                @tv.buffer.set_language(Gtk::SourceLanguageManager.new.get_language(pc.gtk_attribute("language") || "sql"))
                @tv.buffer.non_undoable_action {
                        @tv.buffer.insert(@tv.buffer.get_iter_at_offset(0),item['default']) if item['default']
                }
#               @tv.set_sensitive(item['editable']=="true")
                run_events(item['id'],'form_item-AfterUpdate')
  end