Class: TK::UploadCoverDialog
- Inherits:
-
BaseDialog
- Object
- BaseDialog
- TK::UploadCoverDialog
- Defined in:
- lib/wiki_lyrics/gui/gui-tk.rb
Instance Attribute Summary
Attributes inherited from BaseDialog
Instance Method Summary collapse
- #accept ⇒ Object
- #browse_image ⇒ Object
-
#initialize(values) ⇒ UploadCoverDialog
constructor
A new instance of UploadCoverDialog.
Methods inherited from BaseDialog
#destroy, #exec, #get_position, get_screen_size, #get_size, #set_position, #set_size
Constructor Details
#initialize(values) ⇒ UploadCoverDialog
Returns a new instance of UploadCoverDialog.
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 879 def initialize( values ) super( values ) set_size( 380, 180 ) @shell.title( I18n.get( "gui.uploadcover.title", values["site_name"] ) ) label = Label.new( @shell, I18n.get( "gui.common.album" ) ) label.grid( "row"=>1, "column"=>1, "sticky"=>"w" ) label = Label.new( @shell, I18n.get( "gui.common.artist" ) ) label.grid( "row"=>2, "column"=>1 ) @artist_lineedit = TextEdit.new( @shell, @values["artist"] ) @artist_lineedit.grid( "row"=>2, "column"=>2, "sticky"=>"ew" ) label = Label.new( @shell, I18n.get( "gui.common.album" ) ) label.grid( "row"=>3, "column"=>1 ) @album_lineedit = TextEdit.new( @shell, @values["album"] ) @album_lineedit.grid( "row"=>3, "column"=>2, "sticky"=>"ew" ) label = Label.new( @shell, I18n.get( "gui.common.year" ) ) label.grid( "row"=>4, "column"=>1 ) @year_spinbox = SpinBox.new( @shell, values["year"] ) @year_spinbox.set_range( 1900, Date.today().year ) @year_spinbox.grid( "row"=>4, "column"=>2, "sticky"=>"ew" ) label = Label.new( @shell, I18n.get( "gui.common.image" ) ) label.grid( "row"=>6, "column"=>1, "columnspan"=>2, "sticky"=>"w" ) label = Label.new( @shell, I18n.get( "gui.uploadcover.imagepath" ) ) label.grid( "row"=>7, "column"=>1, "sticky"=>"ew" ) image_frame = TkFrame.new( @shell ) image_frame.grid( "row"=>7, "column"=>2, "sticky"=>"ew" ) @image_path_lineedit = TextEdit.new( image_frame, @values["image_path"] ) @image_path_lineedit.pack( "side"=>"left", "fill"=>"both", "expand"=>true ) @image_button = Button.new( image_frame, "..." ) @image_button.command( proc { browse_image() } ) @image_button.pack( "side"=>"right" ) = () .grid( "row"=>9, "column"=>1, "columnspan"=>4, "sticky"=>"ew" ) @shell.grid_rowconfigure( 5, "weight"=>1 ) @shell.grid_rowconfigure( 8, "weight"=>1 ) @shell.grid_columnconfigure( 2, "weight"=>1 ) end |
Instance Method Details
#accept ⇒ Object
942 943 944 945 946 947 948 949 950 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 942 def accept() @values = { "artist" => @artist_lineedit.text(), "album" => @album_lineedit.text(), "year" => @year_spinbox.value(), "image_path" => @image_path_lineedit.text() } super() end |
#browse_image ⇒ Object
927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
# File 'lib/wiki_lyrics/gui/gui-tk.rb', line 927 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_text( image_path.strip() ) if ! TK.empty_string?( image_path ) end |