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
data/gui/search.rb
ADDED
@@ -0,0 +1,249 @@
|
|
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 ListSearchWidget < Gtk::HBox
|
24
|
+
#Code herited from old ListSearchWindow class
|
25
|
+
#I should rewrite it.
|
26
|
+
def initialize(songs, selection, view)
|
27
|
+
@songs=songs
|
28
|
+
@selection=selection
|
29
|
+
@view=view
|
30
|
+
@result=[]; @pos=0
|
31
|
+
refresh_names
|
32
|
+
|
33
|
+
#**************************Find zone*****************************************
|
34
|
+
@entry=Gtk::Entry.new
|
35
|
+
@entry.signal_connect("activate"){
|
36
|
+
begin
|
37
|
+
i=0; @result=[]
|
38
|
+
pattern=Regexp.new(@entry.text,true)#equivalent to: /text/i
|
39
|
+
@names.each{|name|
|
40
|
+
@result.push(i) unless (name=~ pattern).nil?
|
41
|
+
i+=1
|
42
|
+
}
|
43
|
+
@selection.unselect_all
|
44
|
+
unless @result.empty?
|
45
|
+
path=Gtk::TreePath.new(@result[@pos].to_s)
|
46
|
+
@selection.select_path(path)
|
47
|
+
@view.scroll_to_cell(path, nil, true, 0.5, 0)
|
48
|
+
end
|
49
|
+
rescue
|
50
|
+
ErrorError.new(_("Searching (ListSearchWidget)."), true)
|
51
|
+
end
|
52
|
+
}
|
53
|
+
|
54
|
+
@bprev=Gtk::Button.new
|
55
|
+
@bprev.image=Gtk::Image.new(Gtk::Stock::GO_UP, Gtk::IconSize::BUTTON)
|
56
|
+
@bprev.signal_connect('clicked'){
|
57
|
+
@pos-=1
|
58
|
+
@pos=@result.length-1 if @pos<0
|
59
|
+
@selection.unselect_all
|
60
|
+
unless @result.empty?
|
61
|
+
path=Gtk::TreePath.new(@result[@pos].to_s)
|
62
|
+
@selection.select_path(path)
|
63
|
+
@view.scroll_to_cell(path, nil, true, 0.5, 0)
|
64
|
+
end
|
65
|
+
}
|
66
|
+
@bnext=Gtk::Button.new
|
67
|
+
@bnext.image=Gtk::Image.new(Gtk::Stock::GO_DOWN, Gtk::IconSize::BUTTON)
|
68
|
+
@bnext.signal_connect('clicked'){
|
69
|
+
@pos+=1
|
70
|
+
@pos=0 if @pos>=@result.length
|
71
|
+
@selection.unselect_all
|
72
|
+
unless @result.empty?
|
73
|
+
path=Gtk::TreePath.new(@result[@pos].to_s)
|
74
|
+
@selection.select_path(path)
|
75
|
+
@view.scroll_to_cell(path, nil, true, 0.5, 0)
|
76
|
+
end
|
77
|
+
}
|
78
|
+
@bclose=Gtk::Button.new
|
79
|
+
@bclose.image=Gtk::Image.new(Gtk::Stock::CLOSE, Gtk::IconSize::BUTTON)
|
80
|
+
@bclose.signal_connect('clicked'){self.destroy}
|
81
|
+
|
82
|
+
super()
|
83
|
+
self.pack_start(@entry)
|
84
|
+
self.pack_start(@bprev, false)
|
85
|
+
self.pack_start(@bnext, false)
|
86
|
+
self.pack_start(@bclose, false)
|
87
|
+
self.show_all
|
88
|
+
end
|
89
|
+
|
90
|
+
def focus
|
91
|
+
@entry.grab_focus
|
92
|
+
end
|
93
|
+
|
94
|
+
def refresh_names
|
95
|
+
@names=[]
|
96
|
+
@songs.each{|song| @names.push(song.name)}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class BrowseSearchWindow < Gtk::Window
|
101
|
+
@@exist=false
|
102
|
+
@@refresh=false
|
103
|
+
|
104
|
+
def BrowseSearchWindow.refresh
|
105
|
+
@@refresh=true
|
106
|
+
end
|
107
|
+
|
108
|
+
def BrowseSearchWindow.show(parent,config)
|
109
|
+
if @@exist
|
110
|
+
@@window.refresh_data if @@refresh
|
111
|
+
@@window.hide;@@window.show
|
112
|
+
else
|
113
|
+
@@window=BrowseSearchWindow.new(parent,config)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def initialize(parent,config)
|
118
|
+
@config=config
|
119
|
+
refresh_data
|
120
|
+
|
121
|
+
#**************************Entry zone******************************************
|
122
|
+
@entry=Gtk::Entry.new
|
123
|
+
@entry.signal_connect("activate"){
|
124
|
+
begin
|
125
|
+
@results=[]
|
126
|
+
pattern=Regexp.new(@entry.text,true)#equivalent to: /text/i
|
127
|
+
|
128
|
+
if @config['search_in_title'] || @config['search_in_artist'] || @config['search_in_album'] || @config['search_in_genre']
|
129
|
+
refresh_data if @titles.empty?
|
130
|
+
[@paths, @titles, @artists, @albums, @genres].transpose.each{|path, title, artist, album, genre|
|
131
|
+
temp=''
|
132
|
+
temp+=path if @config['search_in_path'];temp+=';;;;'
|
133
|
+
temp+=title if @config['search_in_title'];temp+=';;;;'
|
134
|
+
temp+=artist if @config['search_in_artist'];temp+=';;;;'
|
135
|
+
temp+=album if @config['search_in_album'];temp+=';;;;'
|
136
|
+
temp+=genre if @config['search_in_genre']
|
137
|
+
@results.push(path) unless (temp=~ pattern).nil?
|
138
|
+
}
|
139
|
+
else
|
140
|
+
if @config['search_in_path']
|
141
|
+
@paths.each{|path|
|
142
|
+
@results.push(path) unless (path=~ pattern).nil?
|
143
|
+
}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
refresh_store
|
148
|
+
rescue
|
149
|
+
ErrorError.new(_("Searching (BrowseSearchWindow)"), true)
|
150
|
+
end
|
151
|
+
}
|
152
|
+
|
153
|
+
#**************************Results zone****************************************
|
154
|
+
@result_store=Gtk::ListStore.new(String,String)
|
155
|
+
|
156
|
+
@renderer=Gtk::CellRendererText.new
|
157
|
+
@col=Gtk::TreeViewColumn.new(_("Results"), @renderer, :text => 0)
|
158
|
+
@result_view=Gtk::TreeView.new(@result_store)
|
159
|
+
@result_view.append_column(@col)
|
160
|
+
|
161
|
+
@result_selection=@result_view.selection
|
162
|
+
@result_selection.mode=Gtk::SELECTION_MULTIPLE
|
163
|
+
|
164
|
+
@wresult=Gtk::ScrolledWindow.new
|
165
|
+
@wresult.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
|
166
|
+
@wresult.add(@result_view)
|
167
|
+
|
168
|
+
#**************************Button zone*****************************************
|
169
|
+
@badd=Gtk::Button.new
|
170
|
+
@badd.image=Gtk::Image.new(Gtk::Stock::ADD,Gtk::IconSize::BUTTON)
|
171
|
+
@badd.signal_connect('clicked') {parent.list_add(@result_selection,@config['extension'])}
|
172
|
+
|
173
|
+
@hbox=Gtk::HBox.new
|
174
|
+
@hbox.pack_end(@badd,false)
|
175
|
+
|
176
|
+
#**************************Main window*****************************************
|
177
|
+
@vbox=Gtk::VBox.new
|
178
|
+
@vbox.pack_start(@entry,false)
|
179
|
+
@vbox.pack_start(@wresult)
|
180
|
+
@vbox.pack_start(@hbox, false)
|
181
|
+
|
182
|
+
super(Gtk::Window::TOPLEVEL)
|
183
|
+
self.transient_for=parent
|
184
|
+
self.skip_taskbar_hint=true
|
185
|
+
self.skip_pager_hint=true
|
186
|
+
self.title=_('Search')
|
187
|
+
self.icon=Gdk::Pixbuf.new(File.join(Pix_dir,'ZiK.svg'))
|
188
|
+
s=parent.size; self.set_default_size((0.8*s[0]).to_i,(0.8*s[1]).to_i)
|
189
|
+
self.add(@vbox)
|
190
|
+
|
191
|
+
self.show_all
|
192
|
+
|
193
|
+
self.signal_connect("delete_event"){self.hide}
|
194
|
+
|
195
|
+
@@exist=true
|
196
|
+
end
|
197
|
+
|
198
|
+
private
|
199
|
+
|
200
|
+
def refresh_data
|
201
|
+
@paths=[]
|
202
|
+
@titles=[]
|
203
|
+
@artists=[]
|
204
|
+
@albums=[]
|
205
|
+
@genres=[]
|
206
|
+
rexp=Regexp.new('.*\.('+@config['extension'].gsub(',','|')+')$', Regexp::IGNORECASE)
|
207
|
+
|
208
|
+
@config['directory'].split(',').each{|directory| Find.find(directory){|f| @paths.push(f) if f=~rexp}}
|
209
|
+
@paths.sort!
|
210
|
+
|
211
|
+
if @config['search_in_title'] || @config['search_in_artist'] || @config['search_in_album'] || @config['search_in_genre']
|
212
|
+
@paths.each{|path|
|
213
|
+
begin
|
214
|
+
tag=TagLib::File.new(path)
|
215
|
+
@titles.push(tag.title)
|
216
|
+
@artists.push(tag.artist)
|
217
|
+
@albums.push(tag.album)
|
218
|
+
@genres.push(tag.genre)
|
219
|
+
rescue TagLib::BadFile
|
220
|
+
ErrorError.new("Cannot read #{path}\'s tag.")
|
221
|
+
@titles.push('')
|
222
|
+
@artists.push('')
|
223
|
+
@albums.push('')
|
224
|
+
@genres.push('')
|
225
|
+
rescue TagLib::BadTag
|
226
|
+
ErrorError.new("Cannot read #{path}\'s tag.")
|
227
|
+
@titles.push('')
|
228
|
+
@artists.push('')
|
229
|
+
@albums.push('')
|
230
|
+
@genres.push('')
|
231
|
+
ensure
|
232
|
+
tag.close unless tag.nil?
|
233
|
+
end
|
234
|
+
}
|
235
|
+
end
|
236
|
+
|
237
|
+
@@refresh=false
|
238
|
+
end
|
239
|
+
|
240
|
+
def refresh_store
|
241
|
+
@result_store.clear
|
242
|
+
@results.each{|path|
|
243
|
+
child=@result_store.append
|
244
|
+
child[0]=path#Show the full path or just a relative one.
|
245
|
+
child[1]=path
|
246
|
+
}
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
data/gui/socket.rb
ADDED
@@ -0,0 +1,107 @@
|
|
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
|
+
module ZiKSocket
|
23
|
+
#Address and clean function are defined in ZiK.rb
|
24
|
+
Welcome_message="Hi! This is #{$name} through unix socket."
|
25
|
+
|
26
|
+
module Error
|
27
|
+
class NoServer < Exception; end
|
28
|
+
class ServerExists < Exception; end
|
29
|
+
end
|
30
|
+
module Event
|
31
|
+
class CloseClient < Exception; end
|
32
|
+
class CloseServer < Exception; end
|
33
|
+
end
|
34
|
+
|
35
|
+
def ZiKSocket.start_server(gui, config, playlist)
|
36
|
+
Thread.new{ZiKSocket::Server.new(gui, config, playlist)}
|
37
|
+
end
|
38
|
+
|
39
|
+
class Server
|
40
|
+
def initialize(gui, config, playlist)
|
41
|
+
raise Error::ServerExists.new if File.exists?(ZiKSocket::Address)
|
42
|
+
UNIXServer.open(ZiKSocket::Address){|server|
|
43
|
+
begin
|
44
|
+
client=server.accept
|
45
|
+
client.puts Welcome_message
|
46
|
+
loop{
|
47
|
+
case command=client.gets.chomp
|
48
|
+
#when /^list_commands/i
|
49
|
+
when /^version$/i
|
50
|
+
client.puts Version
|
51
|
+
when /^show$/i
|
52
|
+
gui.hide if gui.visible?
|
53
|
+
gui.show
|
54
|
+
client.puts "Shown."
|
55
|
+
when /^add\ /
|
56
|
+
arg=command.split(' ', 2)[1]
|
57
|
+
playlist.add(arg, config['extension'])
|
58
|
+
gui.refresh_liststore
|
59
|
+
client.puts "#{arg} added."
|
60
|
+
when /^bye$/i, /^quit$/i, /^close$/i
|
61
|
+
client.puts "Bye."
|
62
|
+
raise Event::CloseClient.new
|
63
|
+
when /^close_server$/i
|
64
|
+
client.puts "Shuting down server."
|
65
|
+
raise Event::CloseServer
|
66
|
+
else
|
67
|
+
client.puts "ERROR: Unknown command."
|
68
|
+
end
|
69
|
+
}
|
70
|
+
rescue Event::CloseClient, Errno::EPIPE
|
71
|
+
client.close
|
72
|
+
retry
|
73
|
+
rescue Event::CloseServer
|
74
|
+
client.close
|
75
|
+
end
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Client
|
81
|
+
def initialize
|
82
|
+
raise Error::NoServer.new unless File.socket?(ZiKSocket::Address)
|
83
|
+
@socket=UNIXSocket.new(ZiKSocket::Address)
|
84
|
+
unless @socket.gets.chomp==Welcome_message
|
85
|
+
@socket.close
|
86
|
+
raise Error::NoServer.new
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def command(str)
|
91
|
+
@socket.puts str
|
92
|
+
@socket.gets.chomp
|
93
|
+
end
|
94
|
+
|
95
|
+
#list_commads
|
96
|
+
|
97
|
+
def close
|
98
|
+
command("close")
|
99
|
+
@socket.close
|
100
|
+
end
|
101
|
+
|
102
|
+
def close_server
|
103
|
+
command("close_serveur")
|
104
|
+
@socket.close
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/mod/brainz.rb
ADDED
@@ -0,0 +1,76 @@
|
|
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 Brainz
|
24
|
+
def Brainz.mod
|
25
|
+
@m||=Mod.new('brainz', "Brainz", _("Retrieve track infos from the web."),
|
26
|
+
'Vincent Carmona <vinc4mai@gmail.com>', 'GPL-2')
|
27
|
+
end
|
28
|
+
|
29
|
+
Brainz.mod
|
30
|
+
def @m.init(input)
|
31
|
+
@dir=input[:mod_dir]
|
32
|
+
end
|
33
|
+
|
34
|
+
def @m.load
|
35
|
+
unless loaded?
|
36
|
+
require 'net/http'
|
37
|
+
begin
|
38
|
+
require File.join(@dir, 'brainz', 'functions')
|
39
|
+
require File.join(@dir, 'brainz', 'ofa')
|
40
|
+
require File.join(@dir, 'brainz', 'song')
|
41
|
+
require File.join(@dir, 'brainz', 'dialogs')
|
42
|
+
require File.join(@dir, 'brainz', 'widget')
|
43
|
+
@widget=Widget.new(zik)
|
44
|
+
pack(@widget, true, false)
|
45
|
+
it=Gtk::MenuItem.new("Brainz")
|
46
|
+
it.signal_connect('activate'){
|
47
|
+
s=zik.list_selection.selected_rows
|
48
|
+
unless s.empty?
|
49
|
+
i=s[-1].to_s.to_i
|
50
|
+
Brainz.tag(zik, zik.playlist.songs[i])
|
51
|
+
end
|
52
|
+
}
|
53
|
+
list_cmenu_add(it); it.show
|
54
|
+
ModErrorInfo.new(self, "module loaded.")
|
55
|
+
@loaded=true
|
56
|
+
rescue OfaNotFound
|
57
|
+
ModErrorLoadError.new(self,
|
58
|
+
_("Cannot find ofa element. Please install ofa Gstreamer plugins."))
|
59
|
+
@loaded=false
|
60
|
+
end
|
61
|
+
else
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def @m.unload
|
67
|
+
if loaded?
|
68
|
+
@widget.destroy
|
69
|
+
ModErrorInfo.new(self, "module unloaded.")
|
70
|
+
@loaded=false
|
71
|
+
true
|
72
|
+
else
|
73
|
+
false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright 2007-2011 Vincent Carmona
|
3
|
+
vinc4mai@gmail.com
|
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
|
+
module Brainz
|
23
|
+
class TagDialog < Gtk::Window
|
24
|
+
def initialize(parent, song)
|
25
|
+
@id=nil; @song=song
|
26
|
+
#*********************Select**************************
|
27
|
+
@bprev=Gtk::Button.new(Gtk::Stock::GO_BACK)
|
28
|
+
@bprev.signal_connect('clicked'){refresh_tag(@id-1)}
|
29
|
+
@lid=Gtk::Label.new
|
30
|
+
@bnext=Gtk::Button.new(Gtk::Stock::GO_FORWARD)
|
31
|
+
@bnext.signal_connect('clicked'){refresh_tag(@id+1)}
|
32
|
+
|
33
|
+
@bselect=Gtk::HBox.new
|
34
|
+
@bselect.pack_start(@bprev, false)
|
35
|
+
@bselect.pack_start(@lid)
|
36
|
+
@bselect.pack_start(@bnext, false)
|
37
|
+
|
38
|
+
#*********************Tag*****************************
|
39
|
+
@ftitle=Gtk::Frame.new(_("Title"))
|
40
|
+
@ftitle.border_width=$border
|
41
|
+
@ctitle=Gtk::ComboBoxEntry.new
|
42
|
+
@ftitle.add(@ctitle)
|
43
|
+
@fartist=Gtk::Frame.new(_("Artist"))
|
44
|
+
@fartist.border_width=$border
|
45
|
+
@cartist=Gtk::ComboBoxEntry.new
|
46
|
+
@fartist.add(@cartist)
|
47
|
+
@falbum=Gtk::Frame.new(_("Album"))
|
48
|
+
@falbum.border_width=$border
|
49
|
+
@calbum=Gtk::ComboBoxEntry.new
|
50
|
+
@falbum.add(@calbum)
|
51
|
+
@ftrack=Gtk::Frame.new(_("Track"))
|
52
|
+
@ftrack.border_width=$border
|
53
|
+
@ctrack=Gtk::ComboBoxEntry.new
|
54
|
+
@ftrack.add(@ctrack)
|
55
|
+
|
56
|
+
refresh_tag(1)
|
57
|
+
#*********************Buttons*************************
|
58
|
+
@blabel=Gtk::Label.new(_("Click Ok to save tags in #{song.file} file."))
|
59
|
+
@bok=Gtk::Button.new(Gtk::Stock::OK)
|
60
|
+
@bok.signal_connect('clicked'){
|
61
|
+
begin
|
62
|
+
track=@ctrack.active_text.to_i
|
63
|
+
song.update_zik(parent.config['name_format'], @ctitle.active_text, @cartist.active_text,
|
64
|
+
@calbum.active_text, track)
|
65
|
+
rescue
|
66
|
+
ModErrorError.new(Brainz.mod, "Track is not an integer.")
|
67
|
+
song.update_zik(parent.config['name_format'], @ctitle.active_text, @cartist.active_text,
|
68
|
+
@calbum.active_text)
|
69
|
+
end
|
70
|
+
parent.refresh_liststore
|
71
|
+
quit
|
72
|
+
}
|
73
|
+
@bcancel=Gtk::Button.new(Gtk::Stock::CANCEL)
|
74
|
+
@bcancel.signal_connect('clicked'){quit}
|
75
|
+
@bbox=Gtk::HBox.new
|
76
|
+
[@bcancel, @bok].reverse!.each{|button| @bbox.pack_end(button,false)}
|
77
|
+
|
78
|
+
#*********************Main window***********************
|
79
|
+
@vbox=Gtk::VBox.new
|
80
|
+
@vbox.pack_start(@bselect,false)
|
81
|
+
[@ftitle, @fartist, @falbum, @ftrack].each{|w| @vbox.pack_start(w)}
|
82
|
+
@vbox.pack_start(@blabel)
|
83
|
+
@vbox.pack_start(@bbox,false)
|
84
|
+
|
85
|
+
super(Gtk::Window::TOPLEVEL)
|
86
|
+
self.transient_for=parent
|
87
|
+
self.skip_taskbar_hint=true
|
88
|
+
self.skip_pager_hint=true
|
89
|
+
self.title='Brainz'
|
90
|
+
self.icon=Gdk::Pixbuf.new(File.join(Pix_dir,'ZiK.svg'))
|
91
|
+
self.signal_connect("delete_event") {quit;true}
|
92
|
+
self.add(@vbox)
|
93
|
+
self.show_all
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
def quit
|
98
|
+
self.destroy
|
99
|
+
end
|
100
|
+
|
101
|
+
def refresh_tag(id)
|
102
|
+
unless @id.nil?
|
103
|
+
@n_titles.times{@ctitle.remove_text(0)}
|
104
|
+
@n_artists.times{@cartist.remove_text(0)}
|
105
|
+
@n_albums.times{@calbum.remove_text(0)}
|
106
|
+
@n_tracks.times{@ctrack.remove_text(0)}
|
107
|
+
end
|
108
|
+
|
109
|
+
@id=id
|
110
|
+
if @id==0
|
111
|
+
@lid.text=(_("Id (Original tags)"))
|
112
|
+
@bprev.sensitive=false
|
113
|
+
else
|
114
|
+
@lid.text=(_("Id (#{@id}/#{@song.puids.length})"))
|
115
|
+
@bprev.sensitive=true
|
116
|
+
end
|
117
|
+
if @id>=@song.tags.length-1
|
118
|
+
@bnext.sensitive=false
|
119
|
+
else
|
120
|
+
@bnext.sensitive=true
|
121
|
+
end
|
122
|
+
@n_titles=@song.tags[@id][:titles].each{|title| @ctitle.append_text(title)}.length
|
123
|
+
@ctitle.active=0
|
124
|
+
@n_artists=@song.tags[@id][:artists].each{|artist| @cartist.append_text(artist)}.length
|
125
|
+
@cartist.active=0
|
126
|
+
@n_albums=@song.tags[@id][:albums].each{|album| @calbum.append_text(album)}.length
|
127
|
+
@calbum.active=0
|
128
|
+
@n_tracks=@song.tags[@id][:tracks].each{|track| @ctrack.append_text(track.to_s)}.length
|
129
|
+
@ctrack.active=0
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|