zik 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/ChangeLog +222 -0
- data/INSTALL +34 -0
- data/Makefile.in +199 -0
- data/README +53 -0
- data/ZiK.desktop +11 -0
- data/ZiK.rb +377 -0
- data/configure +269 -0
- data/dependencies +142 -0
- data/doc/COPYING +340 -0
- data/doc/ChangeLog +222 -0
- data/doc/html/fr/index.html +128 -0
- data/doc/html/index.html +126 -0
- data/doc/html/pix/ZiK3.png +0 -0
- data/doc/html/pix/capture.png +0 -0
- data/doc/html/pix/capture_cd.png +0 -0
- data/doc/html/pix/capture_compact.png +0 -0
- data/doc/html/pix/capture_radio.png +0 -0
- data/doc/html/pix/icon.png +0 -0
- data/doc/html/pix/logo.png +0 -0
- data/doc/html/styles/main.css +47 -0
- data/doc/man/manpage.1 +43 -0
- data/gui/assistant.rb +133 -0
- data/gui/cdgui.rb +54 -0
- data/gui/common.rb +56 -0
- data/gui/config.rb +120 -0
- data/gui/edit.rb +413 -0
- data/gui/error.rb +124 -0
- data/gui/gui.rb +1383 -0
- data/gui/mod.rb +239 -0
- data/gui/preference.rb +496 -0
- data/gui/progress.rb +50 -0
- data/gui/radiogui.rb +404 -0
- data/gui/search.rb +249 -0
- data/gui/socket.rb +107 -0
- data/mod/brainz.rb +76 -0
- data/mod/brainz/dialogs.rb +132 -0
- data/mod/brainz/functions.rb +55 -0
- data/mod/brainz/ofa.rb +76 -0
- data/mod/brainz/song.rb +139 -0
- data/mod/brainz/widget.rb +34 -0
- data/mod/cover.rb +90 -0
- data/mod/cover/application-x-cd-image.svg +666 -0
- data/mod/cover/config.rb +79 -0
- data/mod/cover/configwidget.rb +35 -0
- data/mod/cover/widget.rb +147 -0
- data/mod/hotkeys.rb +137 -0
- data/mod/hotkeys/config.rb +84 -0
- data/mod/hotkeys/configwidget.rb +93 -0
- data/mod/interact.rb +131 -0
- data/mod/interact/configwidget.rb +107 -0
- data/mod/interact/interaction.rb +79 -0
- data/mod/notify.rb +128 -0
- data/mod/notify/config.rb +96 -0
- data/mod/notify/configwidget.rb +76 -0
- data/mod/notify/window.rb +56 -0
- data/mod/trayicon.rb +83 -0
- data/mod/trayicon/config.rb +79 -0
- data/mod/trayicon/configwidget.rb +35 -0
- data/mod/trayicon/icon.rb +99 -0
- data/pix/ZiK.svg +78 -0
- data/pix/ZiK3.png +0 -0
- data/pix/assistant/capture.png +0 -0
- data/pix/gtk-directory.svg +287 -0
- data/pix/media-cdrom.svg +292 -0
- data/pix/network-wireless.svg +429 -0
- data/pix/player_play.svg +286 -0
- data/pix/sound.svg +244 -0
- data/pix/sound_directory.svg +464 -0
- data/player/cdplayer.rb +108 -0
- data/player/player.rb +132 -0
- data/player/radioplayer.rb +124 -0
- data/playlist/cdlist.rb +140 -0
- data/playlist/common.rb +343 -0
- data/playlist/editlist.rb +50 -0
- data/playlist/export.rb +108 -0
- data/playlist/playlist.rb +143 -0
- data/playlist/radiolist.rb +148 -0
- data/playlist/song.rb +122 -0
- data/po/ZiK.pot +622 -0
- data/po/fr/ZiK.po +658 -0
- data/zik +2 -0
- metadata +265 -0
- metadata.gz.sig +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,47 @@
|
|
1
|
+
div#header{
|
2
|
+
height:auto;
|
3
|
+
font-size:x-large;
|
4
|
+
background:#E3E3FF;
|
5
|
+
}
|
6
|
+
div#footer{
|
7
|
+
height:auto;
|
8
|
+
clear:both;
|
9
|
+
background:#E3E3FF;
|
10
|
+
text-align:right;
|
11
|
+
}
|
12
|
+
div#side{
|
13
|
+
float:left;
|
14
|
+
width:15%;
|
15
|
+
height:100%;
|
16
|
+
margin-top:5%;
|
17
|
+
}
|
18
|
+
div#side ul{
|
19
|
+
padding:5%;
|
20
|
+
border:2px solid;
|
21
|
+
background:#E3E3FF;/*#E4E4E4;*/
|
22
|
+
}
|
23
|
+
div#side li{
|
24
|
+
list-style-type:none;
|
25
|
+
padding:5%;
|
26
|
+
}
|
27
|
+
div#main{
|
28
|
+
float:left;
|
29
|
+
width:85%;
|
30
|
+
height:100%;
|
31
|
+
}
|
32
|
+
div#main p,div#main h1,div#main h2,div#main h3,div#main img{
|
33
|
+
margin-left:2%;
|
34
|
+
}
|
35
|
+
|
36
|
+
h1{
|
37
|
+
text-align: center;
|
38
|
+
}
|
39
|
+
.code{
|
40
|
+
border: thin solid black;
|
41
|
+
width: 50%;
|
42
|
+
padding-left: 5%;
|
43
|
+
background-color:#B9B9B9;
|
44
|
+
}
|
45
|
+
.index{
|
46
|
+
font-size:small;
|
47
|
+
}
|
data/doc/man/manpage.1
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
\" Copyright 2007-2010 Vincent Carmona
|
2
|
+
\"
|
3
|
+
\" This file is part of ZiK.
|
4
|
+
\"
|
5
|
+
\" ZiK is free software; you can redistribute it and/or modify
|
6
|
+
\" it under the terms of the GNU General Public License as published by
|
7
|
+
\" the Free Software Foundation; either version 2 of the License, or
|
8
|
+
\" (at your option) any later version.
|
9
|
+
\"
|
10
|
+
\" ZiK is distributed in the hope that it will be useful,
|
11
|
+
\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
\" GNU General Public License for more details.
|
14
|
+
\"
|
15
|
+
\" You should have received a copy of the GNU General Public License
|
16
|
+
\" along with ZiK; if not, write to the Free Software
|
17
|
+
\" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
\"
|
19
|
+
.TH ZIK 1 "August 20, 2010"
|
20
|
+
.\" Please adjust this date whenever revising the manpage.
|
21
|
+
.SH NAME
|
22
|
+
zik \- ZiK is an audio player.
|
23
|
+
.SH SYNOPSIS
|
24
|
+
.B zik
|
25
|
+
.RI [ options ] " files" ...
|
26
|
+
.SH DESCRIPTION
|
27
|
+
.B ZiK
|
28
|
+
is simple and powerfull.
|
29
|
+
Audio files are shown the way you have sorted it to be added to your playlist. There is no library audio.
|
30
|
+
It can play all formats supported by gstreamer, CDs and radios.
|
31
|
+
.SH OPTIONS
|
32
|
+
.TP
|
33
|
+
.B \-h, \-\-help
|
34
|
+
Show summary of options.
|
35
|
+
.TP
|
36
|
+
.B \-v, \-\-version
|
37
|
+
Show version of program and exit.
|
38
|
+
.SH SEE ALSO
|
39
|
+
gstreamer documentation (http://gstreamer.freedesktop.org)
|
40
|
+
.P
|
41
|
+
http://zik.rubyforge.org/
|
42
|
+
.SH AUTHOR
|
43
|
+
zik was written by Vincent Carmona.
|
data/gui/assistant.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
|
5
|
+
This file is part of ZiK.
|
6
|
+
|
7
|
+
ZiK is free software; you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation; either version 2 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
ZiK is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with ZiK; if not, write to the Free Software
|
19
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
=end
|
21
|
+
|
22
|
+
class Assistant < Gtk::Assistant
|
23
|
+
def initialize(config, zik=nil)
|
24
|
+
@config=config; @zik=zik
|
25
|
+
super()
|
26
|
+
signal_connect('delete_event'){quit}
|
27
|
+
signal_connect('cancel'){quit}
|
28
|
+
signal_connect('close'){close}
|
29
|
+
|
30
|
+
#*********************Page 0******************************
|
31
|
+
lintro=Gtk::Label.new(_(
|
32
|
+
"Welcome to ZiK.\nThis assistant will briefly helps you to use and configure ZiK."))
|
33
|
+
lintro.wrap=true
|
34
|
+
append_page(lintro)
|
35
|
+
set_page_header_image(lintro, Gdk::Pixbuf.new(File.join(Pix_dir, 'ZiK3.png'), 128, 64))
|
36
|
+
set_page_title(lintro, _("Introduction (1/6)"))
|
37
|
+
set_page_type(lintro, Gtk::Assistant::PAGE_INTRO)
|
38
|
+
set_page_complete(lintro, true)
|
39
|
+
|
40
|
+
#*********************Page 1******************************
|
41
|
+
label1=Gtk::Label.new(_(
|
42
|
+
"ZiK uses the path of your audio files instead of a music library.\n"+
|
43
|
+
"The browser (1) shows your audio files.\n"+
|
44
|
+
"Your playlist is shown on (3).\n"+
|
45
|
+
"You can use buttons (2) to add/remove files to/from your playlist.\n"+
|
46
|
+
"The button (4) is used to hide/show the different part of the window."+" "+
|
47
|
+
"It is also used to display the radio and the CDs player."))
|
48
|
+
label1.wrap=true
|
49
|
+
icapture=Gtk::Image.new(File.join(Doc_dir, 'html', 'pix', 'capture.png'))
|
50
|
+
#Box
|
51
|
+
vbox1=Gtk::VBox.new
|
52
|
+
vbox1.spacing=$border
|
53
|
+
vbox1.border_width=$border
|
54
|
+
vbox1.pack_start(label1)
|
55
|
+
vbox1.pack_start(icapture, false)
|
56
|
+
append_page(vbox1)
|
57
|
+
set_page_header_image(vbox1, Gdk::Pixbuf.new(File.join(Pix_dir, 'ZiK3.png'), 128, 64))
|
58
|
+
set_page_title(vbox1, _("Main window (2/6)"))
|
59
|
+
set_page_type(vbox1, Gtk::Assistant::PAGE_CONTENT)
|
60
|
+
set_page_complete(vbox1, true)
|
61
|
+
|
62
|
+
#*********************Page 2******************************
|
63
|
+
#Directories
|
64
|
+
@dirbox=DirBox.new(self)
|
65
|
+
@dirbox.ilabel=_(
|
66
|
+
'The browser displays only the selected directories.'+' '+'
|
67
|
+
Please select at least one Diretory.')
|
68
|
+
#Extensions
|
69
|
+
@extbox=ExtBox.new(config)
|
70
|
+
@extbox.ilabel=_(
|
71
|
+
'Only files with the given extension are displayed in the browser view.'+' '+
|
72
|
+
'Extensions must be separate by a comma (,).')
|
73
|
+
#Box
|
74
|
+
label2=Gtk::Label.new(_("Later you can change your setting in the Browser/Preferences menu."))
|
75
|
+
vbox2=Gtk::VBox.new
|
76
|
+
vbox2.spacing=$border
|
77
|
+
vbox2.border_width=$border
|
78
|
+
vbox2.pack_start(@dirbox, false)
|
79
|
+
vbox2.pack_start(@extbox, false)
|
80
|
+
vbox2.pack_start(label2, false)
|
81
|
+
append_page(vbox2)
|
82
|
+
set_page_header_image(vbox2, Gdk::Pixbuf.new(File.join(Pix_dir, 'ZiK3.png'), 128, 64))
|
83
|
+
set_page_title(vbox2, _("Configuration (3/6)"))
|
84
|
+
set_page_type(vbox2, Gtk::Assistant::PAGE_CONTENT)
|
85
|
+
set_page_complete(vbox2, true)
|
86
|
+
|
87
|
+
#*********************Page 3******************************
|
88
|
+
label3=Gtk::Label.new(_(
|
89
|
+
"ZiK uses GStreamer to play audio files. GStreamer supports a lot of formats."+" "+
|
90
|
+
"The number of supported formats depends on which gstreamer plug-ins are installed"+" "+
|
91
|
+
"If you cannot play a file you should check which plug-ins are not installed."+" "+
|
92
|
+
"More informations on http://zik.rubyforge.org/wiki/wiki.pl?Supported_Formats"))
|
93
|
+
label3.wrap=true
|
94
|
+
append_page(label3)
|
95
|
+
set_page_header_image(label3, Gdk::Pixbuf.new(File.join(Pix_dir, 'ZiK3.png'), 128, 64))
|
96
|
+
set_page_title(label3, _("GStreamer (4/5)"))
|
97
|
+
set_page_type(label3, Gtk::Assistant::PAGE_CONTENT)
|
98
|
+
set_page_complete(label3, true)
|
99
|
+
|
100
|
+
#*********************Page 4******************************
|
101
|
+
label4=Gtk::Label.new(_(
|
102
|
+
"ZiK configuration is done. You can find more options on the preferences window."+" "+
|
103
|
+
"You can find help or rerun this assistant on the help menu."))
|
104
|
+
label4.wrap=true
|
105
|
+
append_page(label4)
|
106
|
+
set_page_header_image(label4, Gdk::Pixbuf.new(File.join(Pix_dir, 'ZiK3.png'), 128, 64))
|
107
|
+
set_page_title(label4, _("Conclusion (5/5)"))
|
108
|
+
set_page_type(label4, Gtk::Assistant::PAGE_CONFIRM)
|
109
|
+
set_page_complete(label4, true)
|
110
|
+
|
111
|
+
@config['directory'].split(',').each{|dir| @dirbox.add_directory(dir)}
|
112
|
+
config['extension'].split(',').each{|ext| @extbox.add_ext(ext)}
|
113
|
+
show_all
|
114
|
+
end
|
115
|
+
|
116
|
+
def close
|
117
|
+
ext=@config['extension']; dir=@config['directory']
|
118
|
+
@config['directory']=@dirbox.sdirectory
|
119
|
+
@config['extension']=@extbox.sext
|
120
|
+
if @zik
|
121
|
+
if @config['directory']==dir
|
122
|
+
@zik.refresh_treestore(@config['directory'], @config['extension']) unless @config['extension']==ext
|
123
|
+
else
|
124
|
+
@zik.refresh_treestore(@config['directory'], @config['extension'])
|
125
|
+
end
|
126
|
+
end
|
127
|
+
quit
|
128
|
+
end
|
129
|
+
|
130
|
+
def quit
|
131
|
+
destroy
|
132
|
+
end
|
133
|
+
end
|
data/gui/cdgui.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
|
23
|
+
module Cd
|
24
|
+
class Window < Gtk::ScrolledWindow
|
25
|
+
attr_reader :store, :view, :renderer
|
26
|
+
|
27
|
+
def initialize(config, list)
|
28
|
+
@config=config
|
29
|
+
@list=list
|
30
|
+
|
31
|
+
@store=Gtk::ListStore.new(String,TrueClass)
|
32
|
+
refresh_store
|
33
|
+
|
34
|
+
@renderer=Gtk::CellRendererText.new
|
35
|
+
@renderer.background=@config['playing_color']
|
36
|
+
@col=Gtk::TreeViewColumn.new(_("Cd"), @renderer, :text => 0, :background_set => 1)
|
37
|
+
@view=Gtk::TreeView.new(@store)
|
38
|
+
@view.append_column(@col)
|
39
|
+
|
40
|
+
super()
|
41
|
+
self.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
|
42
|
+
self.add(@view)
|
43
|
+
end
|
44
|
+
|
45
|
+
def refresh_store
|
46
|
+
@store.clear
|
47
|
+
@list.songs.each{|song|
|
48
|
+
child=@store.append
|
49
|
+
child[0]=song.name
|
50
|
+
child[1]=false
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/gui/common.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
|
23
|
+
#GDK_KEY_name are defined since gtk 2.22 and ruby-gnome2 ?.?
|
24
|
+
#GDK_name will be dropped
|
25
|
+
begin
|
26
|
+
Gdk::Keyval::GDK_KEY_p
|
27
|
+
rescue NameError
|
28
|
+
module Gdk
|
29
|
+
module Keyval
|
30
|
+
def self.compat(key)
|
31
|
+
eval("GDK_KEY_"+key+"=GDK_"+key)
|
32
|
+
end
|
33
|
+
%w(p s b n Down Up f d F1 Delete).each{|el| self.compat(el)}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Pack
|
39
|
+
private
|
40
|
+
def hpack(array)
|
41
|
+
hbox=Gtk::HBox.new
|
42
|
+
hbox.border_width=$border
|
43
|
+
hbox.spacing=$border
|
44
|
+
array.each{|el|
|
45
|
+
el.is_a?(Gtk::Entry) ? expand=true : expand=false
|
46
|
+
hbox.pack_start(el, expand)}
|
47
|
+
hbox
|
48
|
+
end
|
49
|
+
def vpack(array)
|
50
|
+
vbox=Gtk::VBox.new
|
51
|
+
vbox.border_width=$border
|
52
|
+
vbox.spacing=$border
|
53
|
+
array.each{|el| vbox.pack_start(el, false)}
|
54
|
+
vbox
|
55
|
+
end
|
56
|
+
end
|
data/gui/config.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
|
23
|
+
class Configuration < Hash
|
24
|
+
|
25
|
+
attr_reader :default
|
26
|
+
|
27
|
+
def initialize(file)
|
28
|
+
#Colors are list in /etc/X11/rgb.txt.
|
29
|
+
@default={'name_format'=>'Artist - Title - None - None',
|
30
|
+
'play_on_start'=>false, 'current_song'=>0, 'volume'=>1.0, 'shuffle'=>false, 'repeat'=>false,
|
31
|
+
'sort_by_track'=>false,
|
32
|
+
'x'=>0, 'y'=>0, 'width'=>500, 'height'=>500, 'view'=>'all', 'paned_position'=>250,
|
33
|
+
'playing_color'=>'Pink', 'compact'=>false,
|
34
|
+
'directory'=>',', 'extension'=>'wav,flac,ogg,mp3,wma,xspf,m3u,pls',
|
35
|
+
'sort_directories_first'=>true, 'sort_case_sensitive'=>true, 'refresh_on_start'=>true,
|
36
|
+
'search_in_path'=>true, 'search_in_title'=>false, 'search_in_artist'=>false,
|
37
|
+
'search_in_album'=>false, 'search_in_genre'=>false,
|
38
|
+
'relative_playlist'=>false,
|
39
|
+
'cd_device'=>'/dev/cdrom', 'cd_web'=>false,
|
40
|
+
'remaining_time'=>false,
|
41
|
+
'socket'=>false,
|
42
|
+
'module'=>','}
|
43
|
+
@file=file
|
44
|
+
|
45
|
+
super
|
46
|
+
self.merge!(@default)
|
47
|
+
|
48
|
+
if File.exist?(@file)
|
49
|
+
read
|
50
|
+
else
|
51
|
+
ErrorWarning.new("Configuration file not found. Loading default configuration.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def read
|
56
|
+
begin
|
57
|
+
f=File.open(@file,'r')
|
58
|
+
array=f.readlines
|
59
|
+
array.reject!{|a| a =~ /^#/}
|
60
|
+
array.reject!{|a| a =~ /^\n/}
|
61
|
+
array.each{|a| a.chomp!}
|
62
|
+
array.each{|a|
|
63
|
+
l=a.split('=', 2)
|
64
|
+
self[l[0]]=l[1]
|
65
|
+
}
|
66
|
+
ErrorInfo.new("#{@file} read.")
|
67
|
+
rescue
|
68
|
+
ErrorError.new('Error while reading configuration file. Use default configuration.')
|
69
|
+
ensure
|
70
|
+
str2value
|
71
|
+
f.close unless f.nil?
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def write
|
76
|
+
begin
|
77
|
+
f=File.open(@file,'w')
|
78
|
+
f.puts '##Configuration file for ZiK player.'
|
79
|
+
f.puts '##All lines begining with # are ignored.'
|
80
|
+
f.puts '###'
|
81
|
+
self.each{|key,value| f.puts "#{key}=#{value}"}
|
82
|
+
ErrorInfo.new("Configuration saved.")
|
83
|
+
rescue
|
84
|
+
ErrorError.new(_('Saving configuration.'), true)
|
85
|
+
ensure
|
86
|
+
f.close unless f.nil?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def str2value
|
93
|
+
#Playlist
|
94
|
+
self['sort_by_track']=="true" ? self['sort_by_track']=true : self['sort_by_track']=false
|
95
|
+
#Player
|
96
|
+
self['play_on_start']=="true" ? self['play_on_start']=true : self['play_on_start']=false
|
97
|
+
self['current_song']=self['current_song'].to_i
|
98
|
+
self['volume']=self['volume'].gsub(/,/,'.').to_f#Volume is written with a comma to seperate decimals. Is it a bug?
|
99
|
+
self['shuffle']=="true" ? self['shuffle']=true : self['shuffle']=false
|
100
|
+
self['repeat']=="true" ? self['repeat']=true : self['repeat']=false
|
101
|
+
#cd
|
102
|
+
self['cd_web']=="true" ? self['cd_web']=true : self['cd_web']=false
|
103
|
+
#Gui
|
104
|
+
self['x']=self['x'].to_i;self['y']=self['y'].to_i;
|
105
|
+
self['width']=self['width'].to_i;self['height']=self['height'].to_i
|
106
|
+
self['paned_position']=self['paned_position'].to_i
|
107
|
+
self['refresh_on_start']=="false" ? self['refresh_on_start']=false : self['refresh_on_start']=true
|
108
|
+
self['sort_directories_first']=="false" ? self['sort_directories_first']=false : self['sort_directories_first']=true
|
109
|
+
self['sort_case_sensitive']=="false" ? self['sort_case_sensitive']=false : self['sort_case_sensitive']=true
|
110
|
+
self['search_in_path']=="false" ? self['search_in_path']=false : self['search_in_path']=true
|
111
|
+
self['search_in_title']=="true" ? self['search_in_title']=true : self['search_in_title']=false
|
112
|
+
self['search_in_artist']=="true" ? self['search_in_artist']=true : self['search_in_artist']=false
|
113
|
+
self['search_in_album']=="true" ? self['search_in_album']=true : self['search_in_album']=false
|
114
|
+
self['search_in_genre']=="true" ? self['search_in_genre']=true : self['search_in_genre']=false
|
115
|
+
self['relative_playlist']=="true" ? self['relative_playlist']=true : self['relative_playlist']=false
|
116
|
+
self['compact']=="true" ? self['compact']=true : self['compact']=false
|
117
|
+
self['remaining_time']=="true" ? self['remaining_time']=true : self['remaining_time']=false
|
118
|
+
self['socket']=="true" ? self['socket']=true : self['socket']=false
|
119
|
+
end
|
120
|
+
end
|