y_support 2.0.19 → 2.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 830c2250049f13a6556ee845c9df177a028c1fe1
4
- data.tar.gz: 21967540a9ab9d1404f6dc082b81ad5ce17e655a
3
+ metadata.gz: b352e0007b5e318e5c95c58725ea49240d283a8d
4
+ data.tar.gz: e82fac18c9c94700166f7ce1858bb79f671c5c96
5
5
  SHA512:
6
- metadata.gz: eedc8bbb2c27b4aa09236f65e325709f6a4b14d3c4cc528314632140f85cd17d92b29b389847dbc969694c0eefc52d1494d939b1c176b0b07a9230136854e8fb
7
- data.tar.gz: 6d04e578d1157188194b7183e58039f4351e6252b9de4bcce3b50a6b1a162024d056469ca20c9d75323d467c6417129cd4269f744d20431d89f71e9b10a08883
6
+ metadata.gz: 6acfc2dee84cf9e609a2ee271ea67161ee70abb0a912735c8e2b3f8fe37b7c32ab1ed2bb8a8879341bb19b9fd30345cc805d9396100e14fb05e0fa64b951d90d
7
+ data.tar.gz: 69c8f221798a650bc8f33093e9f058555c1a8744d3aeb6c83823121d0fac7ecb59d63a693c6256a57efc252af46b973e0d4a7f33e703a9b62de3669c9bf3c6e1
@@ -1,3 +1,3 @@
1
1
  module YSupport
2
- VERSION = "2.0.19"
2
+ VERSION = "2.0.20"
3
3
  end
data/lib/y_support/x.rb CHANGED
@@ -1,68 +1,70 @@
1
1
  require 'y_support'
2
+ require 'gtk2'
2
3
 
3
4
  module YSupport::X
4
- class << self
5
- # Echo a string to the primary X clip with `xsel -b -i`.
6
- #
7
- def echo_primary_clipboard( string )
8
- system 'echo -n "' + string + '" | xsel -b -i'
9
- end
10
-
11
- # Echo a string to the secondary X clip with `xsel -b -i`.
12
- #
13
- def echo_secondary_clipboard( string )
14
- system 'echo -n "' + string + '" | xsel -s -i'
15
- end
16
-
17
- # Dialog box querying for a string.
18
- #
19
- def query_box( dialog_text, prompt: '> ', title_bar: 'User input required', &block )
20
- title_bar_text = title_bar
21
- prompt_label_text = prompt
22
-
23
- w = Gtk::Window.new( Gtk::Window::TOPLEVEL )
24
- w.set_title( title_bar_text )
25
- w.border_width = 10
26
- w.signal_connect 'delete_event' do Gtk.main_quit end # cc
27
-
28
- tlabel_widget = Gtk::Label.new( dialog_text )
29
- plabel_widget = Gtk::Label.new( prompt_label_text )
30
- ebox_widget = Gtk::Entry.new
31
- ebox_widget.visibility = true # cc
32
-
33
- hbox = Gtk::HBox.new(false, 5) # cc
34
- hbox.pack_start_defaults( plabel_widget ) # cc
35
- hbox.pack_start_defaults( ebox_widget )
36
- vbox = Gtk::VBox.new(false, 5)
37
- vbox.pack_start_defaults( tlabel_widget )
38
- vbox.pack_start_defaults( hbox )
39
- w.add(vbox)
5
+ # Echo a string to the primary X clip with `xsel -b -i`.
6
+ #
7
+ def echo_primary_clipboard( string )
8
+ system 'echo -n ' + string.inspect + ' | xsel -b -i'
9
+ end
40
10
 
41
- memo = ""
42
- memo_closure = -> txt { memo << txt }
11
+ # Echo a string to the secondary X clip with `xsel -b -i`.
12
+ #
13
+ def echo_secondary_clipboard( string )
14
+ system 'echo -n "' + string.inspect + '" | xsel -s -i'
15
+ end
43
16
 
44
- ebox_widget.signal_connect("key-release-event") do |sender, event| # cc
45
- kn = Gdk::Keyval.to_name(k = event.keyval)
46
- if kn == "Return"
47
- memo_closure.( sender.text )
48
- block.( sender.text )
49
- Gtk.main_quit
50
- end
17
+ # Dialog box querying for a string.
18
+ #
19
+ def query_box( dialog_text, prompt: '> ', title_bar: 'User input required', &block )
20
+ title_bar_text = title_bar
21
+ prompt_label_text = prompt
22
+
23
+ w = Gtk::Window.new( Gtk::Window::TOPLEVEL )
24
+ w.set_title( title_bar_text )
25
+ w.border_width = 10
26
+ w.signal_connect 'delete_event' do Gtk.main_quit end # cc
27
+
28
+ tlabel_widget = Gtk::Label.new( dialog_text )
29
+ plabel_widget = Gtk::Label.new( prompt_label_text )
30
+ ebox_widget = Gtk::Entry.new
31
+ ebox_widget.visibility = true # cc
32
+
33
+ hbox = Gtk::HBox.new(false, 5) # cc
34
+ hbox.pack_start_defaults( plabel_widget ) # cc
35
+ hbox.pack_start_defaults( ebox_widget )
36
+ vbox = Gtk::VBox.new(false, 5)
37
+ vbox.pack_start_defaults( tlabel_widget )
38
+ vbox.pack_start_defaults( hbox )
39
+ w.add(vbox)
40
+
41
+ memo = ""
42
+ memo_closure = -> txt { memo << txt }
43
+
44
+ ebox_widget.signal_connect "key-release-event" do |sender, event| # cc
45
+ kn = Gdk::Keyval.to_name( event.keyval )
46
+ if kn == "Return"
47
+ memo_closure.( sender.text )
48
+ block.( sender.text ) if block
49
+ Gtk.main_quit
51
50
  end
52
-
53
- memo.tap { w.show_all; Gtk.main }
54
51
  end
52
+
53
+ memo.tap { w.show_all; Gtk.main }
54
+ end
55
55
 
56
- # Message box.
57
- #
58
- def message_box( message="Press any key to close this window!" )
59
- w = Gtk::Window.new
60
- w.add_events Gdk::Event::KEY_PRESS
61
- w.add Gtk::Label.new( message )
62
- w.signal_connect "key-release-event" do Gtk.main_quit end
63
- w.set_default_size( 600, 120 ).show_all
64
- Gtk.main
65
- end
66
- alias popup message_box
56
+ # Message box.
57
+ #
58
+ def message_box( message="Press any key to close this window!" )
59
+ w = Gtk::Window.new
60
+ w.add_events Gdk::Event::KEY_PRESS
61
+ w.add Gtk::Label.new( message )
62
+ w.signal_connect "key-release-event" do Gtk.main_quit end
63
+ w.set_default_size( 600, 120 )
64
+ w.show_all
65
+ Gtk.main
67
66
  end
67
+ alias popup message_box
68
+
69
+ extend self
68
70
  end # module YSupport::X
data/test/x_test.rb CHANGED
@@ -8,12 +8,12 @@ require './../lib/y_support/x'
8
8
  class XTest < Test::Unit::TestCase
9
9
  context "X" do
10
10
  setup do
11
- YSupport::X.echo_primary_clipboard "hello"
12
- YSupport::X.echo_secondary_clipboard "world"
11
+ YSupport::X.echo_primary_clipboard '"foo"'
12
+ YSupport::X.echo_secondary_clipboard "bar"
13
13
  end
14
14
 
15
15
  should "have clipboard as expected" do
16
- assert_equal "hello world", [`xsel -b`, `xsel -s`].join(' ')
16
+ assert_equal '"foo" bar', [`xsel -b`, `xsel -s`].join(' ')
17
17
  end
18
18
  end # context X
19
19
  end # class XTest
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.19
4
+ version: 2.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris