Class: GerminalNotebook
- Inherits:
-
Gtk::Notebook
- Object
- Gtk::Notebook
- GerminalNotebook
- Defined in:
- lib/notebook.rb
Overview
Copyright 2015-2016 Cédric LE MOIGNE, [email protected] This file is part of Germinal.
Germinal is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
Germinal is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Germinal. If not, see <www.gnu.org/licenses/>.
Instance Attribute Summary collapse
-
#gen_preview ⇒ Object
Returns the value of attribute gen_preview.
-
#visible ⇒ Object
readonly
Returns the value of attribute visible.
Instance Method Summary collapse
- #current ⇒ Object
- #cycle_next_page ⇒ Object
- #cycle_prev_page ⇒ Object
-
#initialize ⇒ GerminalNotebook
constructor
A new instance of GerminalNotebook.
- #remove_all_pages ⇒ Object
- #remove_current_page ⇒ Object
- #toggle_visibility ⇒ Object
Constructor Details
#initialize ⇒ GerminalNotebook
Returns a new instance of GerminalNotebook.
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 |
# File 'lib/notebook.rb', line 19 def initialize super() @gen_preview = true signal_connect "hide" do @visible = false end signal_connect "show" do @visible = true end signal_connect "switch-page" do |, next_page, next_page_num| toplevel.current_label.text = next_page.tab_label || get_tab_label(next_page).text toplevel.current_tab.text = "#{next_page_num + 1}/#{n_pages}" if page >= 0 && @gen_preview current.queue_draw _x, _y, w, h = current.allocation.to_a pix = current.window.to_pixbuf(0, 0, w, h) current.preview = pix if pix elsif !@gen_preview @gen_preview = true end end signal_connect "page-reordered" do toplevel.current_tab.text = "#{page + 1}/#{n_pages}" end signal_connect "page-removed" do toplevel.current_tab.text = "#{page + 1}/#{n_pages}" if toplevel.class == GerminalWindow end set_show_tabs(false) end |
Instance Attribute Details
#gen_preview ⇒ Object
Returns the value of attribute gen_preview.
18 19 20 |
# File 'lib/notebook.rb', line 18 def gen_preview @gen_preview end |
#visible ⇒ Object (readonly)
Returns the value of attribute visible.
17 18 19 |
# File 'lib/notebook.rb', line 17 def visible @visible end |
Instance Method Details
#current ⇒ Object
69 70 71 |
# File 'lib/notebook.rb', line 69 def current get_nth_page(page) end |
#cycle_next_page ⇒ Object
61 62 63 |
# File 'lib/notebook.rb', line 61 def cycle_next_page page < (n_pages - 1) ? next_page : set_page(0) end |
#cycle_prev_page ⇒ Object
65 66 67 |
# File 'lib/notebook.rb', line 65 def cycle_prev_page page > 0 ? prev_page : set_page(n_pages - 1) end |
#remove_all_pages ⇒ Object
54 55 56 57 58 59 |
# File 'lib/notebook.rb', line 54 def remove_all_pages each do || index = page_num() remove_page(index) end end |
#remove_current_page ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/notebook.rb', line 73 def remove_current_page if n_pages == 1 toplevel.quit_gracefully else remove(current) current.grab_focus end end |
#toggle_visibility ⇒ Object
82 83 84 |
# File 'lib/notebook.rb', line 82 def toggle_visibility @visible ? hide : show end |