• R/O
  • HTTP
  • SSH
  • HTTPS

ruby-gtk3: Commit

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revision094156953aed2b7e5811c31485bbe04ba88ea393 (tree)
Time2019-01-06 17:01:05
AuthorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

introduce Gtk::Application

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
11 Sun January 6 2019 Shyouzou Sugitani <shy@users.osdn.me>
2+ * Gtk::Applicationを使用するようにした.
23 * AYA, AYA5互換モジュールにおいてFixnum(deprecated)を
34 使用しないよう修正した.
45 * ウインドウ形状算出処理の負荷対策を実装した.
--- a/lib/ninix_main.rb
+++ b/lib/ninix_main.rb
@@ -82,58 +82,6 @@ module Ninix_Main
8282 fail SystemExit
8383 end
8484
85- def self.main(option)
86- # parse command line arguments
87- Logging::Logging.add_logger(Logger.new(option[:logfile])) unless option[:logfile].nil?
88- # TCP 7743:伺か(未使用)(IANA Registered Port for SSTP)
89- # UDP 7743:伺か(未使用)(IANA Registered Port for SSTP)
90- # TCP 9801:伺か (IANA Registered Port for SSTP)
91- # UDP 9801:伺か(未使用)(IANA Registered Port for SSTP)
92- # TCP 9821:SSP
93- # TCP 11000:伺か(廃止) (IANA Registered Port for IRISA)
94- sstp_port = [9801]
95- # parse command line arguments
96- unless option[:sstp_port].nil?
97- if option[:sstp_port].to_i < 1024
98- Logging::Logging.warning("Invalid --sstp-port number (ignored)")
99- else
100- sstp_port << option[:sstp_port].to_i
101- end
102- end
103- Logging::Logging.set_level(Logger::DEBUG) unless option[:debug].nil?
104- home_dir = Home.get_ninix_home()
105- unless File.exists?(home_dir)
106- begin
107- FileUtils.mkdir_p(home_dir)
108- rescue
109- raise SystemExit("Cannot create Home directory (abort)\n")
110- end
111- end
112- lockfile_path = File.join(Home.get_ninix_home(), ".lock")
113- if File.exists?(lockfile_path)
114- f = open(lockfile_path, 'r')
115- abend = f.gets
116- else
117- abend = nil
118- end
119- # aquire Inter Process Mutex (not Global Mutex)
120- f = open(lockfile_path, 'w')
121- begin
122- Lock.lockfile(f)
123- rescue
124- raise SystemExit("ninix-aya is already running")
125- end
126- # start
127- app = Application.new(f, :sstp_port => sstp_port)
128- app.run(abend)
129- f.truncate(0)
130- begin
131- Lock.unlockfile(f)
132- rescue
133- #pass
134- end
135- end
136-
13785 class SSTPControler < MetaMagic::Holon
13886
13987 def initialize(sstp_port)
@@ -1690,15 +1638,68 @@ end
16901638
16911639 Logging::Logging.set_level(Logger::INFO)
16921640
1693-opt = OptionParser.new
1694-option = {}
1695-opt.on('--sstp-port sstp_port', 'additional port for listening SSTP requests') {|v| option[:sstp_port] = v}
1696-opt.on('--debug', 'debug') {|v| option[:debug] = v}
1697-opt.on('--logfile logfile_name', 'logfile name') {|v| option[:logfile] = v}
1698-opt.parse!(ARGV)
1641+gtk_app = Gtk::Application.new('net.osdn.ninix-aya', :flags_none)
1642+
1643+gtk_app.signal_connect 'activate' do |application|
1644+ # parse command line arguments
1645+ opt = OptionParser.new
1646+ option = {}
1647+ opt.on('--sstp-port sstp_port', 'additional port for listening SSTP requests') {|v| option[:sstp_port] = v}
1648+ opt.on('--debug', 'debug') {|v| option[:debug] = v}
1649+ opt.on('--logfile logfile_name', 'logfile name') {|v| option[:logfile] = v}
1650+ opt.parse!(ARGV)
1651+ Logging::Logging.add_logger(Logger.new(option[:logfile])) unless option[:logfile].nil?
1652+ # TCP 7743:伺か(未使用)(IANA Registered Port for SSTP)
1653+ # UDP 7743:伺か(未使用)(IANA Registered Port for SSTP)
1654+ # TCP 9801:伺か (IANA Registered Port for SSTP)
1655+ # UDP 9801:伺か(未使用)(IANA Registered Port for SSTP)
1656+ # TCP 9821:SSP
1657+ # TCP 11000:伺か(廃止) (IANA Registered Port for IRISA)
1658+ sstp_port = [9801]
1659+ # parse command line arguments
1660+ unless option[:sstp_port].nil?
1661+ if option[:sstp_port].to_i < 1024
1662+ Logging::Logging.warning("Invalid --sstp-port number (ignored)")
1663+ else
1664+ sstp_port << option[:sstp_port].to_i
1665+ end
1666+ end
1667+ Logging::Logging.set_level(Logger::DEBUG) unless option[:debug].nil?
1668+ home_dir = Home.get_ninix_home()
1669+ unless File.exists?(home_dir)
1670+ begin
1671+ FileUtils.mkdir_p(home_dir)
1672+ rescue
1673+ raise SystemExit("Cannot create Home directory (abort)\n")
1674+ end
1675+ end
1676+ lockfile_path = File.join(Home.get_ninix_home(), ".lock")
1677+ if File.exists?(lockfile_path)
1678+ f = open(lockfile_path, 'r')
1679+ abend = f.gets
1680+ else
1681+ abend = nil
1682+ end
1683+ # aquire Inter Process Mutex (not Global Mutex)
1684+ f = open(lockfile_path, 'w')
1685+ begin
1686+ Lock.lockfile(f)
1687+ rescue
1688+ raise SystemExit("ninix-aya is already running")
1689+ end
1690+ # start
1691+ app = Ninix_Main::Application.new(f, :sstp_port => sstp_port)
1692+ app.run(abend)
1693+ f.truncate(0)
1694+ begin
1695+ Lock.unlockfile(f)
1696+ rescue
1697+ #pass
1698+ end
1699+end
16991700
17001701 begin
1701- Ninix_Main.main(option)
1702+ gtk_app.run
17021703 rescue => e # should never rescue Exception
17031704 Ninix_Main.handleException(e)
17041705 end
Show on old repository browser