Module: YSupport::X
- Defined in:
- lib/y_support/x.rb
Class Method Summary collapse
-
.echo_primary_clipboard(string) ⇒ Object
Echo a string to the primary X clip with ‘xsel -b -i`.
-
.echo_secondary_clipboard(string) ⇒ Object
Echo a string to the secondary X clip with ‘xsel -b -i`.
-
.message_box(message = "Press any key to close this window!") ⇒ Object
Message box.
-
.query_box(dialog_text, prompt: '> ', title_bar: 'User input required', &block) ⇒ Object
Dialog box querying for a string.
Class Method Details
.echo_primary_clipboard(string) ⇒ Object
Echo a string to the primary X clip with ‘xsel -b -i`.
7 8 9 |
# File 'lib/y_support/x.rb', line 7 def echo_primary_clipboard( string ) system 'echo -n "' + string + '" | xsel -b -i' end |
.echo_secondary_clipboard(string) ⇒ Object
Echo a string to the secondary X clip with ‘xsel -b -i`.
13 14 15 |
# File 'lib/y_support/x.rb', line 13 def echo_secondary_clipboard( string ) system 'echo -n "' + string + '" | xsel -s -i' end |
.message_box(message = "Press any key to close this window!") ⇒ Object
Message box.
55 56 57 58 59 60 61 62 |
# File 'lib/y_support/x.rb', line 55 def ( ="Press any key to close this window!" ) w = Gtk::Window.new w.add_events Gdk::Event::KEY_PRESS w.add Gtk::Label.new( ) w.signal_connect "key-release-event" do Gtk.main_quit end w.set_default_size( 600, 120 ).show_all Gtk.main end |
.query_box(dialog_text, prompt: '> ', title_bar: 'User input required', &block) ⇒ Object
Dialog box querying for a string.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/y_support/x.rb', line 19 def query_box( dialog_text, prompt: '> ', title_bar: 'User input required', &block ) = prompt_label_text = prompt w = Gtk::Window.new( Gtk::Window::TOPLEVEL ) w.set_title( ) w.border_width = 10 w.signal_connect 'delete_event' do Gtk.main_quit end # cc = Gtk::Label.new( dialog_text ) = Gtk::Label.new( prompt_label_text ) = Gtk::Entry.new .visibility = true # cc hbox = Gtk::HBox.new(false, 5) # cc hbox.pack_start_defaults( ) # cc hbox.pack_start_defaults( ) vbox = Gtk::VBox.new(false, 5) vbox.pack_start_defaults( ) vbox.pack_start_defaults( hbox ) w.add(vbox) .signal_connect("key-release-event") do |sender, event| # cc kn = Gdk::Keyval.to_name(k = event.keyval) if kn == "Return" block.( sender.text ) Gtk.main_quit end end w.show_all # cc Gtk.main end |