Class: TK::SubmitSongDialog
- Inherits:
-
BaseDialog
- Object
- BaseDialog
- TK::SubmitSongDialog
- Defined in:
- lib/wiki_lyrics/gui/gui-tk.rb
Instance Attribute Summary
Attributes inherited from BaseDialog
Instance Method Summary collapse
- #accept ⇒ Object
-
#initialize(values) ⇒ SubmitSongDialog
constructor
A new instance of SubmitSongDialog.
- #toggle_instrumental_checked ⇒ Object
Methods inherited from BaseDialog
#destroy, #exec, #get_position, get_screen_size, #get_size, #set_position, #set_size
Constructor Details
#initialize(values) ⇒ SubmitSongDialog
Returns a new instance of SubmitSongDialog.
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 684 def initialize( values ) super( values ) set_size( 600, 400 ) edit_mode = @values["edit_mode"].to_s() == "true" @shell.title( I18n.get( "gui.submitsong.title." + (edit_mode ? "edit" : "submit"), values["site_name"] ) ) artist_label = Label.new( @shell, I18n.get( "gui.common.artist" ) ) artist_label.grid( "row"=>1, "column"=>1, "sticky"=>"ew" ) @artist_lineedit = TextEdit.new( @shell, values["artist"] ) @artist_lineedit.grid( "row"=>1, "column"=>2, "sticky"=>"ew" ) title_label = Label.new( @shell, I18n.get( "gui.common.song" ) ) title_label.grid( "row"=>1, "column"=>3, "sticky"=>"ew" ) @title_lineedit = TextEdit.new( @shell, values["title"] ) @title_lineedit.grid( "row"=>1, "column"=>4, "sticky"=>"ew" ) credits_label = Label.new( @shell, I18n.get( "gui.common.credits" ) ) credits_label.grid( "row"=>2, "column"=>1, "sticky"=>"ew" ) @credits_lineedit = TextEdit.new( @shell, values["credits"] ) @credits_lineedit.grid( "row"=>2, "column"=>2, "sticky"=>"ew" ) lyricist_label = Label.new( @shell, I18n.get( "gui.common.lyricist" ) ) lyricist_label.grid( "row"=>2, "column"=>3, "sticky"=>"ew" ) @lyricist_lineedit = TextEdit.new( @shell, values["lyricist"] ) @lyricist_lineedit.grid( "row"=>2, "column"=>4, "sticky"=>"ew" ) year_label = Label.new( @shell, I18n.get( "gui.common.year" ) ) year_label.grid( "row"=>3, "column"=>1, "sticky"=>"ew" ) @year_spinbox = SpinBox.new( @shell, values["year"] ) @year_spinbox.set_range( 1900, Date.today().year ) @year_spinbox.grid( "row"=>3, "column"=>2, "sticky"=>"ew" ) album_label = Label.new( @shell, I18n.get( "gui.common.album" ) ) album_label.grid( "row"=>3, "column"=>3, "sticky"=>"ew" ) @album_lineedit = TextEdit.new( @shell, values["album"] ) @album_lineedit.grid( "row"=>3, "column"=>4, "sticky"=>"ew" ) @instrumental_checkbox = CheckBox.new( @shell, I18n.get( "gui.submitsong.instrumental" ) ) @instrumental_checkbox.set_checked( values["instrumental"].to_s() == "true" ) @instrumental_checkbox.command = proc { toggle_instrumental_checked() } @instrumental_checkbox.grid( "row"=>4, "column"=>1, "columnspan"=>3, "sticky"=>"w" ) lyrics_frame = TkFrame.new( @shell ) lyrics_frame.grid( "row"=>5, "column"=>1, "columnspan"=>4, "sticky"=>"nesw" ) = TkScrollbar.new( lyrics_frame, "orient"=>"ver" ) .pack( "side"=>"right", "fill"=>"y" ) @lyrics_text = TextArea.new( lyrics_frame ) { yscrollcommand { |first, last| .set( first, last ) } } @lyrics_text.set_text( values["lyrics"] ) @lyrics_text.pack( "side"=>"left", "fill"=>"both", "expand"=>true ) .command( proc { |*args| @lyrics_text.yview( *args ) } ) toggle_instrumental_checked() @reviewed_checkbox = CheckBox.new( @shell, I18n.get( "gui.common.reviewed" ) ) @reviewed_checkbox.set_checked( false ) @reviewed_checkbox.grid( "row"=>6, "column"=>1, "columnspan"=>4, "sticky"=>"w" ) = ( "split", I18n.get( "gui.common.submit" ) ) .grid( "row"=>7, "column"=>1, "columnspan"=>4, "sticky"=>"ew" ) @shell.grid_rowconfigure( 5, "weight"=>1 ) 4.times { |idx| @shell.grid_columnconfigure( idx+1, "weight"=>1 ) } end |
Instance Method Details
#accept ⇒ Object
753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 753 def accept() @values = { "artist" => @artist_lineedit.text(), "year" => @year_spinbox.value(), "album" => @album_lineedit.text(), "title" => @title_lineedit.text(), "lyrics" => @lyrics_text.text(), "instrumental" => @instrumental_checkbox.is_checked(), "lyricist" => @lyricist_lineedit.text(), "credits" => @credits_lineedit.text(), "reviewed" => @reviewed_checkbox.is_checked() } super() end |
#toggle_instrumental_checked ⇒ Object
749 750 751 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 749 def toggle_instrumental_checked() @lyrics_text.set_enabled( ! @instrumental_checkbox.is_checked() ) end |