class GerminalNotebook

Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com 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/>.

Attributes

gen_preview[RW]
visible[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# 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 |_widget, 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

Public Instance Methods

current() click to toggle source
# File lib/notebook.rb, line 69
def current
  get_nth_page(page)
end
cycle_next_page() click to toggle source
# File lib/notebook.rb, line 61
def cycle_next_page
  page < (n_pages - 1) ? next_page : set_page(0)
end
cycle_prev_page() click to toggle source
# File lib/notebook.rb, line 65
def cycle_prev_page
  page > 0 ? prev_page : set_page(n_pages - 1)
end
remove_all_pages() click to toggle source
# File lib/notebook.rb, line 54
def remove_all_pages
  each do |widget|
    index = page_num(widget)
    remove_page(index)
  end
end
remove_current_page() click to toggle source
# 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() click to toggle source
# File lib/notebook.rb, line 82
def toggle_visibility
  @visible ? hide : show
end