zik 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/edit.rb
ADDED
@@ -0,0 +1,413 @@
|
|
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 EditSongWindow < Gtk::Window
|
24
|
+
|
25
|
+
def initialize(song, wmain, name_format, editListWindow=nil)
|
26
|
+
@song=song
|
27
|
+
@elw=editListWindow
|
28
|
+
@old={:title=> @song.title, :artist=>@song.artist, :album=>@song.album, :genre=>@song.genre, :track=>@song.track}
|
29
|
+
|
30
|
+
#*********************Tag zone*******************************
|
31
|
+
@title_entry=Gtk::Entry.new
|
32
|
+
@title_entry.text=@song.title
|
33
|
+
@title_frame=Gtk::Frame.new(_('Title'))
|
34
|
+
@title_frame.add(@title_entry)
|
35
|
+
|
36
|
+
@artist_entry=Gtk::Entry.new
|
37
|
+
@artist_entry.text=@song.artist
|
38
|
+
@artist_frame=Gtk::Frame.new(_('Artist'))
|
39
|
+
@artist_frame.add(@artist_entry)
|
40
|
+
|
41
|
+
@album_entry=Gtk::Entry.new
|
42
|
+
@album_entry.text=@song.album
|
43
|
+
@album_frame=Gtk::Frame.new(_('Album'))
|
44
|
+
@album_frame.add(@album_entry)
|
45
|
+
|
46
|
+
@genre_entry=Gtk::Entry.new
|
47
|
+
@genre_entry.text=@song.genre
|
48
|
+
@genre_frame=Gtk::Frame.new(_('Genre'))
|
49
|
+
@genre_frame.add(@genre_entry)
|
50
|
+
|
51
|
+
@track_entry=Gtk::Entry.new
|
52
|
+
@track_entry.text=@song.track.to_s
|
53
|
+
@track_frame=Gtk::Frame.new(_('Track'))
|
54
|
+
@track_frame.add(@track_entry)
|
55
|
+
|
56
|
+
@path_frame=Gtk::Frame.new(_('Path'))
|
57
|
+
@path_frame.add(Gtk::Label.new(@song.path))
|
58
|
+
|
59
|
+
if @song.duration==-1
|
60
|
+
str=_('Unknown')
|
61
|
+
else
|
62
|
+
if @song.duration<3600
|
63
|
+
str=Time.at(@song.duration).strftime("%M min %S s")
|
64
|
+
else
|
65
|
+
str=(@song.duration.to_i/3600).to_s+" h "+Time.at(@song.duration).strftime("%M min %S s")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@duration_frame=Gtk::Frame.new(_('Duration'))
|
69
|
+
@duration_frame.add(Gtk::Label.new(str))
|
70
|
+
|
71
|
+
@song.bitrate==-1 ? str=_('Unknown') : str=@song.bitrate.to_s
|
72
|
+
@bitrate_frame=Gtk::Frame.new(_('Bitrate'))
|
73
|
+
@bitrate_frame.add(Gtk::Label.new(str))
|
74
|
+
|
75
|
+
@song.samplerate==-1 ? str=_('Unknown') : str=@song.samplerate.to_s
|
76
|
+
@samplerate_frame=Gtk::Frame.new(_('Samplerate'))
|
77
|
+
@samplerate_frame.add(Gtk::Label.new(str))
|
78
|
+
|
79
|
+
@song.channels==-1 ? str=_('Unknown') : str=@song.channels.to_s
|
80
|
+
@channels_frame=Gtk::Frame.new(_('Channels'))
|
81
|
+
@channels_frame.add(Gtk::Label.new(str))
|
82
|
+
|
83
|
+
@song_box=Gtk::VBox.new
|
84
|
+
[@title_frame, @artist_frame, @album_frame, @genre_frame, @track_frame, @path_frame, @duration_frame,
|
85
|
+
@bitrate_frame, @samplerate_frame, @channels_frame].each{|widget|
|
86
|
+
@song_box.pack_start(widget, true, true, 5)
|
87
|
+
}
|
88
|
+
@song_frame=Gtk::Frame.new
|
89
|
+
@song_frame.label_widget=Gtk::Label.new.set_markup("<b>#{song.name}</b>")
|
90
|
+
@song_frame.add(@song_box)
|
91
|
+
|
92
|
+
#*********************Main window*******************************
|
93
|
+
@warning_label=Gtk::Label.new.set_markup(_("<b>Song\'s tag will be overwrite by clicking Ok.</b>"))
|
94
|
+
|
95
|
+
@bcancel=Gtk::Button.new(Gtk::Stock::CANCEL)
|
96
|
+
@bcancel.signal_connect('clicked'){quit}
|
97
|
+
@bok=Gtk::Button.new(Gtk::Stock::OK)
|
98
|
+
@bok.signal_connect('clicked'){
|
99
|
+
title=@title_entry.text; artist=@artist_entry.text; album=@album_entry.text; genre=@genre_entry.text
|
100
|
+
begin
|
101
|
+
track=@track_entry.text.to_i
|
102
|
+
rescue
|
103
|
+
track=@old[:track]
|
104
|
+
ErrorError.new("Track must be a integer. Use old value.", true)
|
105
|
+
end
|
106
|
+
unless @old=={:title=> title, :artist=> artist, :album=>album, :genre=>genre, :track=>track}
|
107
|
+
song.title=title; song.artist=artist; song.album=album; song.genre=genre; song.track=track
|
108
|
+
song.refresh_name(name_format)
|
109
|
+
song.write_tag(@song.path)
|
110
|
+
if @elw.nil?
|
111
|
+
wmain.refresh_liststore
|
112
|
+
else
|
113
|
+
@elw.refresh_liststore
|
114
|
+
@elw.force_refresh_parent=true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
quit
|
118
|
+
}
|
119
|
+
@hbox=Gtk::HBox.new
|
120
|
+
[@bcancel, @bok].reverse.each{|button| @hbox.pack_end(button,false)}
|
121
|
+
|
122
|
+
@vbox=Gtk::VBox.new
|
123
|
+
@vbox.pack_start(@song_frame, true, true, 5)
|
124
|
+
@vbox.pack_start(@warning_label)
|
125
|
+
@vbox.pack_start(@hbox,false)
|
126
|
+
|
127
|
+
super(Gtk::Window::TOPLEVEL)
|
128
|
+
self.transient_for=wmain
|
129
|
+
self.modal=true
|
130
|
+
self.skip_taskbar_hint=true
|
131
|
+
self.skip_pager_hint=true
|
132
|
+
self.title=_('Edit tag')
|
133
|
+
self.icon=Gdk::Pixbuf.new(File.join(Pix_dir,'ZiK.svg'))
|
134
|
+
#s=wmain.size; self.set_default_size((0.8*s[0]).to_i,(0.8*s[1]).to_i)
|
135
|
+
self.add(@vbox)
|
136
|
+
self.signal_connect("delete_event") {quit;true}
|
137
|
+
|
138
|
+
self.show_all
|
139
|
+
end
|
140
|
+
|
141
|
+
def quit
|
142
|
+
self.destroy
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
class EditListWrapper
|
148
|
+
#Code herited from old EditListWindow class.
|
149
|
+
#I should rewrite it.
|
150
|
+
attr_reader :table, :list, :badd, :bsave
|
151
|
+
attr_accessor :force_refresh_parent
|
152
|
+
|
153
|
+
def initialize(wmain, list, config)
|
154
|
+
@wmain=wmain
|
155
|
+
@list=list
|
156
|
+
@extension=config['extension']
|
157
|
+
@name_format=config['name_format']
|
158
|
+
@force_refresh_parent=false
|
159
|
+
|
160
|
+
#*********************Playlist zone****************************
|
161
|
+
@list_store=Gtk::ListStore.new(String, Song)
|
162
|
+
refresh_liststore
|
163
|
+
|
164
|
+
@renderer=Gtk::CellRendererText.new
|
165
|
+
@col=Gtk::TreeViewColumn.new(_('Song name'), @renderer, :text => 0)
|
166
|
+
@list_view=Gtk::TreeView.new(@list_store)
|
167
|
+
@list_view.headers_visible=false
|
168
|
+
@list_view.reorderable=true
|
169
|
+
@list_view.append_column(@col)
|
170
|
+
@list_view.signal_connect("row-activated"){|view, path, column|
|
171
|
+
i=path.to_s.to_i
|
172
|
+
EditSongWindow.new(@list.songs[i], @wmain, @name_format, self)
|
173
|
+
}
|
174
|
+
|
175
|
+
@list_selection=@list_view.selection
|
176
|
+
@list_selection.mode=Gtk::SELECTION_MULTIPLE
|
177
|
+
|
178
|
+
@wlist=Gtk::ScrolledWindow.new
|
179
|
+
@wlist.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
|
180
|
+
@wlist.add(@list_view)
|
181
|
+
|
182
|
+
#*********************Right buttons zone************************
|
183
|
+
@btop=Gtk::Button.new
|
184
|
+
@btop.image=Gtk::Image.new(Gtk::Stock::GOTO_TOP,Gtk::IconSize::BUTTON)
|
185
|
+
@btop.tooltip_text=_('Move to the top')
|
186
|
+
@btop.signal_connect('clicked'){top}
|
187
|
+
|
188
|
+
@bup=Gtk::Button.new
|
189
|
+
@bup.image=Gtk::Image.new(Gtk::Stock::GO_UP,Gtk::IconSize::BUTTON)
|
190
|
+
@bup.tooltip_text=_('Move up')
|
191
|
+
@bup.signal_connect('clicked'){up}
|
192
|
+
|
193
|
+
@bedit=Gtk::Button.new
|
194
|
+
@bedit.image=Gtk::Image.new(Gtk::Stock::EDIT,Gtk::IconSize::BUTTON)
|
195
|
+
@bedit.tooltip_text=_('Edit tag')
|
196
|
+
@bedit.signal_connect('clicked'){
|
197
|
+
s=@list_selection.selected_rows
|
198
|
+
unless s.empty?
|
199
|
+
i=s[-1].to_s.to_i
|
200
|
+
EditSongWindow.new(@list.songs[i], @wmain, @name_format, self)
|
201
|
+
end
|
202
|
+
}
|
203
|
+
|
204
|
+
@bdown=Gtk::Button.new
|
205
|
+
@bdown.image=Gtk::Image.new(Gtk::Stock::GO_DOWN,Gtk::IconSize::BUTTON)
|
206
|
+
@bdown.tooltip_text=_('Move down')
|
207
|
+
@bdown.signal_connect('clicked'){down}
|
208
|
+
|
209
|
+
@bbottom=Gtk::Button.new
|
210
|
+
@bbottom.image=Gtk::Image.new(Gtk::Stock::GOTO_BOTTOM,Gtk::IconSize::BUTTON)
|
211
|
+
@bbottom.tooltip_text=_('Move to the bottom')
|
212
|
+
@bbottom.signal_connect('clicked'){bottom}
|
213
|
+
|
214
|
+
#*********************Bottom buttons zone***********************
|
215
|
+
@badd=Gtk::Button.new
|
216
|
+
@badd.image=Gtk::Image.new(Gtk::Stock::ADD,Gtk::IconSize::BUTTON)
|
217
|
+
@badd.tooltip_text=_('Add a file')
|
218
|
+
@badd.signal_connect('clicked'){add_file}
|
219
|
+
|
220
|
+
@bsave=Gtk::Button.new
|
221
|
+
@bsave.image=Gtk::Image.new(Gtk::Stock::SAVE,Gtk::IconSize::BUTTON)
|
222
|
+
@bsave.tooltip_text=_('Save playlist')
|
223
|
+
@bsave.signal_connect('clicked'){save}
|
224
|
+
|
225
|
+
#*********************Main window*******************************
|
226
|
+
@table=Gtk::Table.new(7, 2)
|
227
|
+
@table.row_spacings=$border
|
228
|
+
@table.column_spacings=$border
|
229
|
+
@table.attach(@wlist, 0, 1, 0, 7)
|
230
|
+
@table.attach(@btop, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK)
|
231
|
+
@table.attach(@bup, 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK)
|
232
|
+
@table.attach(@bedit, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK)
|
233
|
+
@table.attach(@bdown, 1, 2, 4, 5, Gtk::SHRINK, Gtk::SHRINK)
|
234
|
+
@table.attach(@bbottom, 1, 2, 5, 6, Gtk::SHRINK, Gtk::SHRINK)
|
235
|
+
|
236
|
+
@table.show_all
|
237
|
+
@badd.show
|
238
|
+
@bsave.show
|
239
|
+
end
|
240
|
+
|
241
|
+
def destroy
|
242
|
+
#to be sure that another EditListWrapper#table can attach to the Gui#table
|
243
|
+
#Others objects are destroyed by GC. (?)
|
244
|
+
@table.destroy
|
245
|
+
@badd.destroy
|
246
|
+
@bsave.destroy
|
247
|
+
end
|
248
|
+
|
249
|
+
def has_focus?
|
250
|
+
@list_view.destroyed? ? false : @list_view.has_focus?
|
251
|
+
end
|
252
|
+
|
253
|
+
def refresh_liststore
|
254
|
+
@list_store.clear
|
255
|
+
@list.songs.each{|song|
|
256
|
+
child=@list_store.append
|
257
|
+
child[0]=song.name
|
258
|
+
child[1]=song
|
259
|
+
}
|
260
|
+
end
|
261
|
+
|
262
|
+
def refresh_list
|
263
|
+
@list.songs.clear
|
264
|
+
iter=@list_store.iter_first
|
265
|
+
if iter
|
266
|
+
@list.songs.push(iter[1])
|
267
|
+
while iter.next!
|
268
|
+
@list.songs.push(iter[1])
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def add_song(path)
|
274
|
+
refresh_list
|
275
|
+
@list.add(path, @extension)
|
276
|
+
refresh_liststore
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_songs(selection)
|
280
|
+
refresh_list
|
281
|
+
selection.selected_each{|model, path, iter| @list.add(iter[1], @extension)}
|
282
|
+
refresh_liststore
|
283
|
+
end
|
284
|
+
|
285
|
+
def rm_song
|
286
|
+
refresh_list
|
287
|
+
s=@list_selection.selected_rows
|
288
|
+
unless s.empty?
|
289
|
+
s.reverse! #Treepath must be in order
|
290
|
+
s.each{|p| @list.songs.delete_at(p.to_s.to_i)}
|
291
|
+
refresh_liststore
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def clear
|
296
|
+
@list.clear
|
297
|
+
@list_store.clear
|
298
|
+
end
|
299
|
+
|
300
|
+
def search
|
301
|
+
refresh_list
|
302
|
+
@wmain.search(@list.songs, @list_selection, @list_view)
|
303
|
+
end
|
304
|
+
|
305
|
+
private
|
306
|
+
|
307
|
+
def add_file
|
308
|
+
#TODO : merge with Gui#import_list
|
309
|
+
dialog=Gtk::FileChooserDialog.new(_("Add a File"), @wmain,
|
310
|
+
Gtk::FileChooser::ACTION_OPEN, nil,
|
311
|
+
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
|
312
|
+
dialog.select_multiple=true
|
313
|
+
#dialog.filter=Gtk::FileFilter.new.add_pattern('*.{'+@extension+'}')#Do not work!
|
314
|
+
dialog.show_hidden=false
|
315
|
+
if dialog.run==Gtk::Dialog::RESPONSE_ACCEPT
|
316
|
+
refresh_list
|
317
|
+
dialog.filenames.each{|file| @list.add(file, @extension)}
|
318
|
+
refresh_liststore
|
319
|
+
end
|
320
|
+
dialog.destroy
|
321
|
+
end
|
322
|
+
|
323
|
+
def save
|
324
|
+
#TODO : merge with Gui#list_save
|
325
|
+
dialog=Gtk::FileChooserDialog.new(_("Save list"), @wmain,
|
326
|
+
Gtk::FileChooser::ACTION_SAVE, nil,
|
327
|
+
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
|
328
|
+
dialog.do_overwrite_confirmation=true
|
329
|
+
dialog.filter=Gtk::FileFilter.new.add_pattern('*.m3u')
|
330
|
+
dialog.show_hidden=false
|
331
|
+
if dialog.run==Gtk::Dialog::RESPONSE_ACCEPT
|
332
|
+
f=dialog.filename
|
333
|
+
f=f+'.m3u' unless f=~/.*\.m3u$/i
|
334
|
+
refresh_list
|
335
|
+
@list.save_m3u(f)
|
336
|
+
end
|
337
|
+
dialog.destroy
|
338
|
+
end
|
339
|
+
|
340
|
+
def top
|
341
|
+
refresh_list
|
342
|
+
s=@list_selection.selected_rows
|
343
|
+
unless s.empty?
|
344
|
+
index=[]
|
345
|
+
s.each{|p| index.push(p.to_s.to_i)}
|
346
|
+
index.reverse! #Treepath must be in order
|
347
|
+
tmp=[]
|
348
|
+
index.each{|i| tmp.push(@list.songs.delete_at(i))}#Dirty to manipulate @list.songs! Write a method to reorder songs within EditList class.
|
349
|
+
@list.songs.unshift(tmp.reverse!).flatten!
|
350
|
+
refresh_liststore
|
351
|
+
@list_selection.select_range(Gtk::TreePath.new('0'), Gtk::TreePath.new((tmp.length-1).to_s))
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
def up
|
356
|
+
refresh_list
|
357
|
+
s=@list_selection.selected_rows
|
358
|
+
unless s.empty?
|
359
|
+
index=[]
|
360
|
+
s.each{|p| index.push(p.to_s.to_i)}
|
361
|
+
n=0#Is it not more easy to delete the firsts rows if they are selected?
|
362
|
+
index.each{|i|
|
363
|
+
@list.songs[i-1], @list.songs[i]= @list.songs[i], @list.songs[i-1] unless i==n
|
364
|
+
n+=1
|
365
|
+
}
|
366
|
+
refresh_liststore
|
367
|
+
n=0
|
368
|
+
index.each{|i|
|
369
|
+
i==n ? p=i.to_s : p=(i-1).to_s
|
370
|
+
@list_selection.select_path(Gtk::TreePath.new(p))
|
371
|
+
n+=1
|
372
|
+
}
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
def down
|
377
|
+
refresh_list
|
378
|
+
s=@list_selection.selected_rows
|
379
|
+
unless s.empty?
|
380
|
+
index=[]
|
381
|
+
s.each{|p| index.push(p.to_s.to_i)}
|
382
|
+
n=@list.songs.length-1
|
383
|
+
index.reverse!.each{|i|
|
384
|
+
@list.songs[i+1], @list.songs[i]= @list.songs[i], @list.songs[i+1] unless i==n
|
385
|
+
n-=1
|
386
|
+
}
|
387
|
+
refresh_liststore
|
388
|
+
n=@list.songs.length-1
|
389
|
+
index.each{|i|
|
390
|
+
i==n ? p=i.to_s : p=(i+1).to_s
|
391
|
+
@list_selection.select_path(Gtk::TreePath.new(p))
|
392
|
+
n-=1
|
393
|
+
}
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
def bottom
|
398
|
+
refresh_list
|
399
|
+
s=@list_selection.selected_rows
|
400
|
+
unless s.empty?
|
401
|
+
index=[]
|
402
|
+
s.each{|p| index.push(p.to_s.to_i)}
|
403
|
+
index.reverse! #Treepath must be in order
|
404
|
+
tmp=[]
|
405
|
+
index.each{|i| tmp.push(@list.songs.delete_at(i))}
|
406
|
+
b=@list.songs.length.to_s
|
407
|
+
@list.songs.concat(tmp.reverse!)
|
408
|
+
refresh_liststore
|
409
|
+
e=(@list.songs.length-1).to_s
|
410
|
+
@list_selection.select_range(Gtk::TreePath.new(b), Gtk::TreePath.new(e))
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
data/gui/error.rb
ADDED
@@ -0,0 +1,124 @@
|
|
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
|
+
|
23
|
+
ErrorINFO=0
|
24
|
+
ErrorWARNING=10
|
25
|
+
ErrorERROR=20
|
26
|
+
ModErrorINFO=1
|
27
|
+
ModErrorWARNING=11
|
28
|
+
ModErrorERROR=21
|
29
|
+
ModErrorLOAD_ERROR=22
|
30
|
+
|
31
|
+
class Error
|
32
|
+
#Error superclass not to be directly used.
|
33
|
+
def Error.gui=(gui)
|
34
|
+
@@zik=gui
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_reader :message, :type, :long_message
|
38
|
+
|
39
|
+
def initialize(type, message, user, description)
|
40
|
+
@type=type; @message=message; @long_message=description||message
|
41
|
+
case type
|
42
|
+
when ErrorINFO, ModErrorINFO
|
43
|
+
puts message
|
44
|
+
if $show_errors&&user
|
45
|
+
dialog=Gtk::MessageDialog.new(@@zik, Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,
|
46
|
+
Gtk::MessageDialog::INFO, Gtk::MessageDialog::BUTTONS_CLOSE, @long_message)
|
47
|
+
dialog.run; dialog.destroy
|
48
|
+
end
|
49
|
+
when ErrorWARNING, ModErrorWARNING
|
50
|
+
$stderr.puts "WARNING. "+message
|
51
|
+
if $show_errors&&user
|
52
|
+
dialog=Gtk::MessageDialog.new(@@zik, Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,
|
53
|
+
Gtk::MessageDialog::WARNING, Gtk::MessageDialog::BUTTONS_CLOSE, @long_message)
|
54
|
+
dialog.run; dialog.destroy
|
55
|
+
end
|
56
|
+
when ErrorERROR, ModErrorERROR
|
57
|
+
$stderr.puts "ERROR. "+message
|
58
|
+
if $show_errors&&user
|
59
|
+
dialog=Gtk::MessageDialog.new(@@zik, Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,
|
60
|
+
Gtk::MessageDialog::ERROR, Gtk::MessageDialog::BUTTONS_CLOSE, @long_message)
|
61
|
+
dialog.run; dialog.destroy
|
62
|
+
end
|
63
|
+
when ModErrorLOAD_ERROR
|
64
|
+
puts "LoAD ERROR. "+message
|
65
|
+
else
|
66
|
+
$stderr.puts "ERROR. Unknown Error type."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class ErrorInfo < Error
|
72
|
+
def initialize(message, user=false, description=nil)
|
73
|
+
super(ErrorINFO, message, user, description)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class ErrorWarning < Error
|
78
|
+
def initialize(message, user=false, description=nil)
|
79
|
+
super(ErrorWARNING, message, user, description)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class ErrorError < Error
|
84
|
+
def initialize(message, user=false, description=nil)
|
85
|
+
super(ErrorERROR, message, user, description)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class ErrorsStock
|
90
|
+
#Class to display many errors at once
|
91
|
+
def ErrorsStock.gui=(gui)
|
92
|
+
@@zik=gui
|
93
|
+
end
|
94
|
+
|
95
|
+
def initialize
|
96
|
+
@stock=[]
|
97
|
+
end
|
98
|
+
|
99
|
+
def nb
|
100
|
+
@stock.length
|
101
|
+
end
|
102
|
+
|
103
|
+
def add(type, message, description=nil)
|
104
|
+
@stock.push(Error.new(type, message, false, description))
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
def show_all(message="")
|
109
|
+
if $show_errors
|
110
|
+
unless @stock.empty?
|
111
|
+
tmp=[]
|
112
|
+
@stock.each{|error| message+="\n#{error.long_message}"; tmp.push(error.type)}
|
113
|
+
case tmp.max
|
114
|
+
when ErrorINFO; type=Gtk::MessageDialog::INFO
|
115
|
+
when ErrorWARNING; type=Gtk::MessageDialog::WARNING
|
116
|
+
else; type=Gtk::MessageDialog::ERROR
|
117
|
+
end
|
118
|
+
dialog=Gtk::MessageDialog.new(@@zik, Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,
|
119
|
+
type, Gtk::MessageDialog::BUTTONS_CLOSE, message)
|
120
|
+
dialog.run; dialog.destroy
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|