Class: GerminalApplication
- Inherits:
-
Gtk::Application
- Object
- Gtk::Application
- GerminalApplication
- Defined in:
- lib/application.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/>.
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
-
#initialize ⇒ GerminalApplication
constructor
A new instance of GerminalApplication.
- #update_css(new_props = nil) ⇒ Object
Constructor Details
#initialize ⇒ GerminalApplication
Returns a new instance of GerminalApplication.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/application.rb', line 19 def initialize super("com.github.cedlemo.germinal", :non_unique) signal_connect "startup" do |application| load_css_config display = Gdk::Display.default screen = display.default_screen Gtk::StyleContext.add_provider_for_screen(screen, @provider, Gtk::StyleProvider::PRIORITY_USER) action = Gio::SimpleAction.new("preferences") action.signal_connect("activate") do |_action, _parameter| puts "TODO" end application.add_action(action) action = Gio::SimpleAction.new("about") action.signal_connect("activate") do |_action, _parameter| application.windows[0].display_about end application.add_action(action) action = Gio::SimpleAction.new("quit") action.signal_connect("activate") do |_action, _parameter| application.quit end application.add_action(action) action = Gio::SimpleAction.new("term_copy") action.signal_connect("activate") do |_action, _parameter| application.windows[0].notebook.current.copy_clipboard end application.add_action(action) action = Gio::SimpleAction.new("term_paste") action.signal_connect("activate") do |_action, _parameter| application.windows[0].notebook.current.paste_clipboard end application.add_action(action) builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/app-menu.ui") = builder.get_object("appmenu") application.() end signal_connect "activate" do |application| window = GerminalWindow.new(application) window.present window.add_terminal window.notebook.current.grab_focus end end |
Instance Attribute Details
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
18 19 20 |
# File 'lib/application.rb', line 18 def provider @provider end |
Instance Method Details
#update_css(new_props = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/application.rb', line 71 def update_css(new_props = nil) css_properties @props.merge!(new_props) if new_props css = update_css_properties merged_css = Sass::Engine.new(css, :syntax => :scss).render if File.exist?(USR_CSS) FileUtils.mv(USR_CSS, "#{USR_CSS}_#{Time.new.strftime('%Y-%m-%d-%H-%M-%S')}.backup") File.open(USR_CSS, "w") do |file| file.puts merged_css end else File.open(USR_CSS, "w") do |file| file.puts merged_css end end end |