Module: GerminalHeaderBar
- Defined in:
- lib/headerbar.rb
Overview
Copyright 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/>.
Class Method Summary collapse
- .gen_icon_button(icon_name, tooltip) ⇒ Object
- .generate_color_sel_button(window) ⇒ Object
- .generate_current_label(window) ⇒ Object
- .generate_current_label_signals(label, window) ⇒ Object
- .generate_current_label_tooltips(label) ⇒ Object
- .generate_current_tab ⇒ Object
- .generate_font_sel_button(window) ⇒ Object
- .generate_header_bar(window) ⇒ Object
- .generate_new_tab_button(window) ⇒ Object
- .generate_next_button(window) ⇒ Object
- .generate_open_menu_button(window) ⇒ Object
- .generate_prev_button(window) ⇒ Object
- .generate_term_overv_button(window) ⇒ Object
Class Method Details
.gen_icon_button(icon_name, tooltip) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/headerbar.rb', line 115 def self.(icon_name, tooltip) = Gtk::Button.new image = Gtk::Image.new(:icon_name => icon_name, :size => :button) .add(image) .tooltip_text = tooltip if block_given? .signal_connect "clicked" do || yield() end end end |
.generate_color_sel_button(window) ⇒ Object
103 104 105 106 107 |
# File 'lib/headerbar.rb', line 103 def self.(window) ("color-select-symbolic", "Set colors") do window.show_color_selector end end |
.generate_current_label(window) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/headerbar.rb', line 51 def self.generate_current_label(window) label = Gtk::Entry.new label.has_frame = false label.width_chars = 35 label.set_icon_from_icon_name(:secondary, "edit-clear") generate_current_label_tooltips(label) generate_current_label_signals(label, window) label end |
.generate_current_label_signals(label, window) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/headerbar.rb', line 38 def self.generate_current_label_signals(label, window) label.signal_connect "activate" do |entry| window.notebook.current.tab_label = entry.text end label.signal_connect "icon-release" do |entry, position| if position == :secondary window.notebook.current.tab_label = nil entry.text = window.notebook.current.window_title end end end |
.generate_current_label_tooltips(label) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/headerbar.rb', line 27 def self.generate_current_label_tooltips(label) label.tooltip_text = "Change the name of the tab and hit\nenter in order to validate\n" label.set_icon_tooltip_text(:secondary, "Reset your changes and use the\ndefault label for the current tab\n") end |
.generate_current_tab ⇒ Object
68 69 70 |
# File 'lib/headerbar.rb', line 68 def self.generate_current_tab Gtk::Label.new("1/1") end |
.generate_font_sel_button(window) ⇒ Object
97 98 99 100 101 |
# File 'lib/headerbar.rb', line 97 def self.(window) ("font-select-symbolic", "Set font") do window.show_font_selector end end |
.generate_header_bar(window) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/headerbar.rb', line 18 def self.(window) = Gtk::HeaderBar.new .title = "Germinal" .has_subtitle = false . = true window.() end |
.generate_new_tab_button(window) ⇒ Object
78 79 80 81 82 |
# File 'lib/headerbar.rb', line 78 def self.(window) ("tab-new-symbolic", "New terminal") do window.add_terminal end end |
.generate_next_button(window) ⇒ Object
72 73 74 75 76 |
# File 'lib/headerbar.rb', line 72 def self.(window) ("pan-end-symbolic", "next") do window.show_next_tab end end |
.generate_open_menu_button(window) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/headerbar.rb', line 84 def self.(window) ("open-menu-symbolic", "Main Menu") do || builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/window-menu.ui") = Gtk::Menu.new(builder["winmenu"]) .() .children[0].signal_connect("activate") { window.show_css_editor } .show_all event = Gtk.current_event .popup(nil, nil, event., event.time) end end |
.generate_prev_button(window) ⇒ Object
62 63 64 65 66 |
# File 'lib/headerbar.rb', line 62 def self.(window) ("pan-start-symbolic", "prev") do window.show_prev_tab end end |
.generate_term_overv_button(window) ⇒ Object
109 110 111 112 113 |
# File 'lib/headerbar.rb', line 109 def self.(window) ("emblem-photos-symbolic", "Terminals overview") do window.show_terminal_chooser end end |