#!/usr/bin/env ruby
# Copyright 2015-2018 Cedric LE MOIGNE, cedlemo@gmx.com
# This file is part of Topinambour.
#
# Topinambour 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.
#
# Topinambour 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 Topinambour.  If not, see <http://www.gnu.org/licenses/>.
#
# Topinambour is a terminal emulator written with the ruby gtk3 and
# vte 3 bindings.
# Author:: Cedlemo (mailto:cedlemo@gmx.com)

require 'vte3'
require 'fileutils'

err_msg = "\tTopinambour processus pid = #{Process.pid} has been "

Signal.trap('INT') do
  STDERR.puts err_msg + 'interrupted with Ctrl-C'
  exit
end

Signal.trap('TERM') do
  STDERR.puts err_msg + 'has been killed'
  exit
end

CURRENT_PATH = __dir__
LIB_PATH = "#{CURRENT_PATH}/../lib".freeze
DATA_PATH = "#{CURRENT_PATH}/../data".freeze
CONFIG_DIR = File.expand_path("#{ENV['HOME']}/.config/topinambour")
DATA_HOME_DIR = File.expand_path("#{ENV['HOME']}/.local/share/topinambour")
USR_CSS = "#{CONFIG_DIR}/topinambour.css".freeze
USR_LIB_PATH  = "#{CONFIG_DIR}/lib".freeze
gresource_bin = "#{DATA_PATH}/topinambour.gresource"
resource = Gio::Resource.load(gresource_bin)
Gio::Resources.register(resource)

# Load default libraries !!WARNING!! loading order matters
%w[version about actions application rgb_names_regexes
   terminal_regex terminal color_selector font_selector
   shortcuts window preferences].each do |l|
  require "#{LIB_PATH}/#{l}.rb"
end

topinambour = TopinambourApplication.new

exit(topinambour.run([$PROGRAM_NAME] + ARGV))
