Class: KeepYourHead::DialogEditFlashcardLatex
- Inherits:
-
Object
- Object
- KeepYourHead::DialogEditFlashcardLatex
- Defined in:
- lib/Keepyourhead/gui/DialogEditLatex.rb
Constant Summary collapse
- Widgets =
[ "notebook_output", "textview_output", "image_preview", "hscalePage", "hscaleBox", "viewport_edit", ]
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(flashcard, type) ⇒ DialogEditFlashcardLatex
constructor
ImageWidth = (Gdk::Screen.default.width * 0.6).to_i.
- #makePreview ⇒ Object
- #run ⇒ Object
- #text ⇒ Object
- #text=(t) ⇒ Object
Constructor Details
#initialize(flashcard, type) ⇒ DialogEditFlashcardLatex
ImageWidth = (Gdk::Screen.default.width * 0.6).to_i
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 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 28 def initialize( flashcard, type ) @compilation = nil @glade = GladeXML.new(Resources::system("glade/DialogEditLatex.glade")) { |handler| method(handler) } @window = @glade.("dialog_edit_latex") @flashcard, @type = flashcard, type Widgets.each { |name| = @glade.(name) assert eval("@#{name} = widget") } @flashcardViewController = FlashcardViewController.new @image_preview, @hscalePage, @hscaleBox @window.title = "editieren" # @notebook_output.width_request = (ImageWidth * 1.1).to_i language = Gtk::SourceLanguagesManager.new.get_language("text/x-tex") @edit_buffer = Gtk::SourceBuffer.new language @edit_buffer.set_property( "check-brackets", true ) @edit_buffer.set_property( "highlight", true ) # @edit_buffer.set_property( "max-undo-levels", 20 ) @textview_latex = Gtk::SourceView.new @edit_buffer @textview_latex.set_property( "auto-indent", true) @textview_latex.set_property( "insert-spaces-instead-of-tabs", false) # @textview_latex.set_property( "margin", 10) @textview_latex.set_property( "show-line-markers", true) @textview_latex.set_property( "show-line-numbers", true) @textview_latex.set_property( "show-margin", true) @textview_latex.set_property( "smart-home-end", true) @textview_latex.set_property( "tabs-width", 4) @viewport_edit.add @textview_latex @textview_latex.show @button_preview = @window. "Vorschau", RESPONSE_PREVIEW @button_edit = @window. "editieren", RESPONSE_EDIT @window. Gtk::Stock::APPLY, Gtk::Dialog::RESPONSE_APPLY @window. Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL end |
Instance Method Details
#destroy ⇒ Object
127 128 129 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 127 def destroy @window.destroy end |
#makePreview ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 82 def makePreview style = @flashcard.file.style("latex") @compilation.remove if @compilation @compilation = @flashcard.compileImage(@type, :previewCode => @textview_latex.buffer.text ) @flashcardViewController.filenames = Images.fromCompilation @type, @compilation if @compilation.success and @compilation.filenames.length > 0 then @notebook_output.page = 2 else @notebook_output.page = 1 end @textview_output.buffer.text = @compilation.output end |
#run ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 100 def run @window.show ret = nil while ret == nil do response = @window.run case response when Gtk::Dialog::RESPONSE_APPLY ret = true when Gtk::Dialog::RESPONSE_CANCEL ret = false when RESPONSE_PREVIEW makePreview when RESPONSE_EDIT @notebook_output.page = 0 else # puts response end end @compilation.remove if @compilation ret end |
#text ⇒ Object
74 75 76 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 74 def text @edit_buffer.text end |
#text=(t) ⇒ Object
78 79 80 |
# File 'lib/Keepyourhead/gui/DialogEditLatex.rb', line 78 def text=(t) @edit_buffer.text = t end |