class ManqodHelp
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
admin[R]
browser[R]
filter[R]
index[R]
toolbar[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/ManqodHelp.rb, line 7 def initialize @admin=false super() set_title("Manqod Help") add(vb=Gtk::VBox.new) vb.pack_start(@toolbar=HelpToolbar.new(self),false,false). pack_start(hp=Gtk::HPaned.new) toolbar.append(@back_button=Gtk::ToolButton.new(Gtk::Stock::GO_BACK)) toolbar.append toolbar.append(Gtk::Label.new("Search:")) toolbar.append(@filter=Gtk::Entry.new) toolbar.append(filter_button=Gtk::ToolButton.new(Gtk::Stock::FIND)) toolbar.append(clear=Gtk::ToolButton.new(Gtk::Stock::CLEAR)) toolbar.append toolbar.append(@formats_button=Gtk::ToolButton.new(Gtk::Stock::BOLD).set_no_show_all(true)) toolbar.append(@new_item_button=Gtk::ToolButton.new(Gtk::Stock::NEW).set_no_show_all(true)) toolbar.append(@edit_item_button=Gtk::ToolButton.new(Gtk::Stock::EDIT).set_no_show_all(true)) toolbar.append(@delete_item_button=Gtk::ToolButton.new(Gtk::Stock::DELETE).set_no_show_all(true)) toolbar.append(hidden=Gtk::EventBox.new.add(Gtk::Label.new)).set_expand(true) toolbar.append toolbar.append(@close=Gtk::ToolButton.new(Gtk::Stock::CLOSE)) hp.add1(@index=HelpIndex.new(self)). add2(@browser=HelpBrowser.new(self)). set_position(150). set_position_set(true) filter.signal_connect('activate',filter_button){|me,filter_button| filter_button.clicked } filter_button.signal_connect('clicked'){|me| @index.refilter } clear.signal_connect('clicked'){|me| filter.text="" @index.refilter } @back_button.signal_connect('clicked'){|me| @index.go_back } @close.signal_connect('clicked'){|me| destroy } hidden.signal_connect('event'){|me,ev| if ev.event_type == Gdk::Event::BUTTON3_PRESS @admin=!@admin @formats_button.set_visible(@admin) @new_item_button.set_visible(@admin) @edit_item_button.set_visible(@admin) @delete_item_button.set_visible(@admin) end } @formats_button.signal_connect('clicked'){|me| FormatsEditor.new(self).run } @new_item_button.signal_connect('clicked'){|me| w=Gtk::Dialog.new("New item index",self,Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,[Gtk::Stock::NEW,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]).set_default_response(Gtk::Dialog::RESPONSE_ACCEPT) w.vbox.pack_start(Gtk::Label.new("Item Index(only use indexes that you want to be links):"),false,false).pack_start(e=Gtk::Entry.new,false,false) w.show_all.run{|response| if response == Gtk::Dialog::RESPONSE_ACCEPT browser.add_item(e.text) index.populate.set_cursor(e.text) browser.save_current_item end w.destroy } } @edit_item_button.signal_connect('clicked'){|me| if browser.item w=Gtk::Dialog.new("Editing item",self,Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,[Gtk::Stock::CLOSE,Gtk::Dialog::RESPONSE_ACCEPT]).set_default_response(Gtk::Dialog::RESPONSE_ACCEPT) w.vbox.pack_start(Gtk::ScrolledWindow.new.add(e=Gtk::TextView.new).set_size_request(400,200).set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC),false,false) e.buffer.set_text(browser.items[browser.item]) e.buffer.signal_connect('changed'){|me| browser.update_current_item(me.get_text)} w.show_all.run{|response| browser.save_current_item w.destroy } end } @delete_item_button.signal_connect('clicked'){|me| if browser.item w=Gtk::Dialog.new("Removing item",self,Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,[Gtk::Stock::DELETE,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]).set_default_response(Gtk::Dialog::RESPONSE_REJECT) w.vbox.pack_start(Gtk::Label.new("Are you sure about removing the selected item?"),false,false) w.show_all.run{|response| browser.remove_current_item if response == Gtk::Dialog::RESPONSE_ACCEPT w.destroy } end } update_back_button end
Public Instance Methods
populate()
click to toggle source
# File lib/ManqodHelp.rb, line 103 def populate browser.clear_items browser.buffer.tag_table.clear i=ManqodDB.instance.cache.get("help_items") i.each_pair{|key,descr| browser.add_item(key,descr)} index.populate i=ManqodDB.instance.cache.get("help_formats") i.each_pair{|key,format| browser.buffer.tag_table.add(format)} # buffer.tag_table.add({"name"=>"_header","code"=>Regexp.escape("[h1]"),"font"=>"Sans Bold 20"}) self end