Class: TK::SubmitAlbumDialog

Inherits:
BaseDialog show all
Defined in:
lib/wiki_lyrics/gui/gui-tk.rb

Instance Attribute Summary

Attributes inherited from BaseDialog

#accepted, #values

Instance Method Summary collapse

Methods inherited from BaseDialog

#destroy, #exec, #get_position, get_screen_size, #get_size, #set_position, #set_size

Constructor Details

#initialize(values) ⇒ SubmitAlbumDialog

Returns a new instance of SubmitAlbumDialog.



773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 773

def initialize( values )
	super( values )

	set_size( 600, 400 )

	@shell.title( I18n.get( "gui.submitalbum.title", 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, "columnspan"=>5, "sticky"=>"ew" )

	album_label = Label.new( @shell, I18n.get( "gui.common.album" ) )
	album_label.grid( "row"=>2, "column"=>1, "sticky"=>"ew" )
	@album_lineedit = TextEdit.new( @shell, values["album"] )
	@album_lineedit.grid( "row"=>2, "column"=>2, "columnspan"=>5, "sticky"=>"ew" )

	label = Label.new( @shell, I18n.get( "gui.common.year" ) )
	label.grid( "row"=>3, "column"=>1, "sticky"=>"ew" )
	@year_spinbox = SpinBox.new( @shell, values["year"].to_i() )
	@year_spinbox.set_range( 1900, Date.today().year )
	@year_spinbox.grid( "row"=>3, "column"=>2, "sticky"=>"ew" )

	label = Label.new( @shell, I18n.get( "gui.common.month" ) )
	label.grid( "row"=>3, "column"=>3, "sticky"=>"ew" )
	@month_spinbox = SpinBox.new( @shell, values["month"].to_i() )
	@month_spinbox.set_range( 0, 12 )
	@month_spinbox.grid( "row"=>3, "column"=>4, "sticky"=>"ew" )

	label = Label.new( @shell, I18n.get( "gui.common.day" ) )
	label.grid( "row"=>3, "column"=>5, "sticky"=>"ew" )
	@day_spinbox = SpinBox.new( @shell, values["day"].to_i() )
	@day_spinbox.set_range( 0, 31 )
	@day_spinbox.grid( "row"=>3, "column"=>6, "sticky"=>"ew" )

	image_label = Label.new( @shell, I18n.get( "gui.common.image" ) )
	image_label.grid( "row"=>4, "column"=>1, "sticky"=>"ew" )

	image_frame = TkFrame.new( @shell )
	image_frame.grid( "row"=>4, "column"=>2, "columnspan"=>5, "sticky"=>"ew" )

	@image_path_lineedit = TextEdit.new( image_frame, @values.include?( "image_path" ) ? @values["image_path"] : I18n.get( "gui.submitalbum.coverfound" ) )
	@image_path_lineedit.set_enabled( @values.include?( "image_path" ) )
	@image_path_lineedit.pack( "side"=>"left", "fill"=>"both", "expand"=>true )

	if values.include?( "image_path" )
		@image_button = Button.new( image_frame, "..." )
		@image_button.command( proc { browse_image() } )
		@image_button.pack( "side"=>"right" )
	end

	tracks_frame = TkFrame.new( @shell )
	tracks_frame.grid( "row"=>5, "column"=>1, "columnspan"=>6, "sticky"=>"nesw" )
	bar = TkScrollbar.new( tracks_frame, "orient"=>"ver" )
	bar.pack( "side"=>"right", "fill"=>"y" )
	@tracks_text = TextArea.new( tracks_frame ) { yscrollcommand { |first, last| bar.set( first, last ) } }
	@tracks_text.set_text( values["tracks"] )
	@tracks_text.pack( "side"=>"left", "fill"=>"both", "expand"=>true )
	bar.command( proc { |*args| @tracks_text.yview( *args ) } )

	@reviewed_checkbox = CheckBox.new( @shell, I18n.get( "gui.common.reviewed" ) )
	@reviewed_checkbox.set_checked( false )
	@reviewed_checkbox.grid( "row"=>6, "column"=>1, "columnspan"=>6, "sticky"=>"w" );

	buttons = create_action_buttons( "split", I18n.get( "gui.common.submit" ) )
	buttons.grid( "row"=>7, "column"=>1, "columnspan"=>6, "sticky"=>"ew" )

	@shell.grid_rowconfigure( 5, "weight"=>1 )
	6.times { |idx| @shell.grid_columnconfigure( idx+1, "weight"=>1 ) }
end

Instance Method Details

#acceptObject



859
860
861
862
863
864
865
866
867
868
869
870
871
872
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 859

def accept()
	aux = {
		"artist"	=> @artist_lineedit.text(),
		"album"		=> @album_lineedit.text(),
		"year"		=> @year_spinbox.value(),
		"month"		=> @month_spinbox.value(),
		"day"		=> @day_spinbox.value(),
		"tracks"	=> @tracks_text.text(),
		"reviewed"	=> @reviewed_checkbox.is_checked()
	}
	aux["image_path"] = @image_path_lineedit.text() if @values.include?( "image_path" )
	@values = aux
	super()
end

#browse_imageObject



844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 844

def browse_image()
	dirname = @image_path_lineedit.text().strip()
	dirname = TK.empty_string?( dirname ) ? (ENV["HOME"] ? ENV["HOME"] : ".") : File.dirname( dirname )
	image_path = Tk.getOpenFile( {
		"parent" => @shell,
		"title" => I18n.get( "gui.uploadcover.browseimage.title" ),
		"initialdir" => dirname,
		"filetypes" =>  [
			[I18n.get( "gui.uploadcover.browseimage.images" ), ".jpg .JPG .png .PNG .bmp .BMP"],
			[I18n.get( "gui.uploadcover.browseimage.allfiles" ), "*"]
		]
	} )
	@image_path_lineedit.set_value( image_path.strip() ) if ! TK.empty_string?( image_path )
end