lib/rabbit/command/rabbit.rb in rabbit-2.1.6 vs lib/rabbit/command/rabbit.rb in rabbit-2.1.7
- old
+ new
@@ -46,14 +46,16 @@
@options, @logger = parse_command_line_arguments(arguments)
require "rabbit/canvas"
GC.enable
- succeeded = __send__("do_#{@options.action}")
-
- ::Rabbit.cleanup
-
+ application = ::Rabbit.application
+ succeeded = false
+ application.signal_connect("activate") do
+ succeeded = __send__("do_#{@options.action}")
+ end
+ application.run
succeeded
end
private
def parse_command_line_arguments(arguments)
@@ -508,18 +510,10 @@
_("Specify XML-RPC port as [PORT]."),
"(#{options.xmlrpc_port})") do |port|
options.xmlrpc_port = port
end
- parser.category _("Server")
-
- parser.on("--server",
- _("Specify whether to run as server."),
- "(#{options.server})") do
- options.action = :server
- end
-
parser.category _("Public level")
levels = Front::PublicLevel.constants.sort_by do |const|
Front::PublicLevel.const_get(const)
end.collect do |const|
@@ -816,15 +810,12 @@
@logger.error($!.message)
false
end
def do_save_as_image
- Renderer::Pixmap.init
- ::Rabbit.gui_init
-
source = make_source
- canvas = make_canvas(Renderer::Pixmap)
+ canvas = make_canvas(Renderer::Pixmap::Cairo)
setup_size(canvas)
setup_image_info(canvas)
setup_print_info(canvas)
setup_paper_size(canvas)
setup_3d_info(canvas)
@@ -841,11 +832,10 @@
display_init_options = {}
if @options.use_gl
display_init_options[:preferred_class_name] = "ClutterEmbed"
end
Renderer::Display.init(display_init_options)
- ::Rabbit.gui_init
source = make_source
canvas = make_canvas(Renderer::Display)
frame = Frame.new(@logger, canvas)
frame.geometry = @options.geometry
@@ -868,54 +858,9 @@
front = make_front(canvas)
setup_druby(front) if @options.use_druby
setup_soap(front) if @options.use_soap
setup_xmlrpc(front) if @options.use_xmlrpc
-
- Gtk.main
-
- true
- end
-
- def do_server
- ::Rabbit.gui_init
-
- # GLib::Log.cancel_handler
- # GLib::Log.set_handler(nil, GLib::Log::LEVEL_ERROR)
-
- source = make_source
- canvas = make_canvas(Renderer::Pixmap)
- setup_size(canvas)
- setup_paper_size(canvas)
- setup_image_info(canvas)
- setup_print_info(canvas)
- setup_3d_info(canvas)
- apply_theme_if_need(canvas)
- parse(canvas, source)
-
- soap_server_thread = nil
- xmlrpc_server_thread = nil
-
- front = make_front(canvas)
- setup_druby(front) if @options.use_druby
- if @options.use_soap
- soap_server_thread = setup_soap(front)
- end
- if @options.use_xmlrpc
- xmlrpc_server_thread = setup_xmlrpc(front)
- end
-
- soap_server_thread.join if soap_server_thread
- xmlrpc_server_thread.join if xmlrpc_server_thread
- if @options.use_druby
- prev = trap(:INT) do
- @logger.info(_("going to shutdown..."))
- DRb.thread.exit
- @logger.info(_("DRb.thread done."))
- trap(:INT, prev)
- end
- DRb.thread.join
- end
true
end
def do_check_syntax