Blob Blame History Raw
From ffe9fec4c2cd83c08cd90b4139bc562c2558e44a Mon Sep 17 00:00:00 2001
From: Kouhei Sutou <kou@clear-code.com>
Date: Mon, 12 Oct 2015 16:56:51 +0900
Subject: [PATCH 13/14] gio2: support Gio::Application.new(:arguments => [...])

GitHub: fix #519

Reported by Mamoru TASAKA. Thanks!!!
---
 gio2/lib/gio2/application-command-line.rb  | 12 ++++++++++++
 gio2/test/test-application-command-line.rb |  6 ++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gio2/lib/gio2/application-command-line.rb b/gio2/lib/gio2/application-command-line.rb
index 97fbb30..c739064 100644
--- a/gio2/lib/gio2/application-command-line.rb
+++ b/gio2/lib/gio2/application-command-line.rb
@@ -16,6 +16,18 @@
 
 module Gio
   class ApplicationCommandLine
+    def initialize(properties=nil)
+      if properties
+        arguments = properties[:arguments]
+        if arguments and !arguments.is_a?(GLib::Variant)
+          arguments = GLib::Variant.new(arguments,
+                                        GLib::VariantType::BYTESTRING_ARRAY)
+          properties = properties.merge(:arguments => arguments)
+        end
+      end
+      super(properties)
+    end
+
     alias_method :arguments_raw, :arguments
     def arguments
       arguments_raw[0]
diff --git a/gio2/test/test-application-command-line.rb b/gio2/test/test-application-command-line.rb
index 441bb81..d699551 100644
--- a/gio2/test/test-application-command-line.rb
+++ b/gio2/test/test-application-command-line.rb
@@ -16,12 +16,10 @@
 
 class TestApplicationCommandLine < Test::Unit::TestCase
   include GioTestUtils::Omissions
-  def setup
-    @command_line = Gio::ApplicationCommandLine.new
-  end
 
   test "#arguments" do
     omit_on_travis_ci
-    assert_equal([], @command_line.arguments)
+    command_line = Gio::ApplicationCommandLine.new(:arguments => ["hello"])
+    assert_equal(["hello"], command_line.arguments)
   end
 end
-- 
2.5.0