zik 0.17.0 → 0.17.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 +7 -0
- data/Makefile.in +1 -2
- data/ZiK.rb +3 -3
- data/dependencies +1 -1
- data/doc/ChangeLog +7 -0
- data/gui/common.rb +9 -2
- data/gui/config.rb +1 -1
- data/gui/gui.rb +12 -12
- data/playlist/export.rb +29 -3
- data/playlist/song.rb +5 -0
- data/zik +0 -399
- metadata +8 -28
- metadata.gz.sig +2 -3
- data/doc/man/zik.1.gz +0 -0
- data/mod/interact.rb +0 -131
- data/mod/interact/configwidget.rb +0 -107
- data/mod/interact/interaction.rb +0 -79
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Fix bug when ZiK is called with configuration option
|
2
|
+
|
3
|
+
###Version 0.17.1
|
4
|
+
Fix a bug in configuration reading that leads to a crash (Thank Mouine89 for the report on ubuntu-fr forum)
|
5
|
+
Fix bugs in Pack module and export functions with ruby1.9 (Thank Кຼزດ for the report on ubuntu-fr forum)
|
6
|
+
Fix a bug in dependencies script
|
7
|
+
|
1
8
|
###Version 0.17.0
|
2
9
|
Use new icons picture. Thanks J. Kaiden for the artwork.
|
3
10
|
Add choices for theme in preferences window.
|
data/Makefile.in
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
NAME=ZiK
|
2
|
-
VERSION=0.17.
|
2
|
+
VERSION=0.17.1
|
3
3
|
|
4
4
|
SHELL=/bin/sh
|
5
5
|
RUBY=/usr/bin/ruby
|
@@ -89,7 +89,6 @@ install-theme:
|
|
89
89
|
$(INSTALL_DIR) $(DESTDIR)$(THEMEDIR)
|
90
90
|
for theme in $(THEMES); do \
|
91
91
|
$(INSTALL_DIR) $(DESTDIR)$(THEMEDIR)/$$theme; \
|
92
|
-
# echo $(SRCDIR)/theme/$theme/*; \
|
93
92
|
$(INSTALL_DATA) $(SRCDIR)/theme/$$theme/* $(DESTDIR)$(THEMEDIR)/$$theme; \
|
94
93
|
done
|
95
94
|
|
data/ZiK.rb
CHANGED
@@ -119,8 +119,8 @@ $border=5
|
|
119
119
|
#Configuration
|
120
120
|
require File.join(Data_dir, 'gui/config')
|
121
121
|
if (defined? User_dir)
|
122
|
-
Cache_dir=File.join(
|
123
|
-
Runtime_dir=File.join(
|
122
|
+
Cache_dir=File.join(User_dir, 'cache')
|
123
|
+
Runtime_dir=File.join(User_dir, 'runtime')
|
124
124
|
else
|
125
125
|
User_dir= ENV['XDG_CONFIG_HOME'] ? File.join(ENV['XDG_CONFIG_HOME'], 'ZiK') :
|
126
126
|
File.join(ENV['HOME'], '.config', 'ZiK')
|
@@ -142,7 +142,7 @@ unless File.exist?(User_dir)
|
|
142
142
|
Dir.mkdir(User_dir)
|
143
143
|
config_new=true
|
144
144
|
end
|
145
|
-
Dir.mkdir(Cache_dir) unless File.exist?(Cache_dir)
|
145
|
+
Dir.mkdir(Cache_dir) unless File.exist?(Cache_dir)#TODO bug with zik -c /dev/null
|
146
146
|
Dir.mkdir(Runtime_dir, 0700) unless File.exist?(Runtime_dir)
|
147
147
|
if File.directory?(User_dir)
|
148
148
|
configuration_file=File.join(User_dir,'ZiKrc')
|
data/dependencies
CHANGED
data/doc/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Fix bug when ZiK is called with configuration option
|
2
|
+
|
3
|
+
###Version 0.17.1
|
4
|
+
Fix a bug in configuration reading that leads to a crash (Thank Mouine89 for the report on ubuntu-fr forum)
|
5
|
+
Fix bugs in Pack module and export functions with ruby1.9 (Thank Кຼزດ for the report on ubuntu-fr forum)
|
6
|
+
Fix a bug in dependencies script
|
7
|
+
|
1
8
|
###Version 0.17.0
|
2
9
|
Use new icons picture. Thanks J. Kaiden for the artwork.
|
3
10
|
Add choices for theme in preferences window.
|
data/gui/common.rb
CHANGED
@@ -20,6 +20,13 @@ This file is part of ZiK.
|
|
20
20
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
21
|
=end
|
22
22
|
|
23
|
+
#General utilities methods
|
24
|
+
def array_from_args(arg)
|
25
|
+
#To be call after "def my_method(*args)"
|
26
|
+
#in order to accept both forms: my_method([1, 2, 3]) and my_method(1, 2, 3)
|
27
|
+
arg[0].instance_of?(Array) && arg.length==1 ? arg[0] : arg
|
28
|
+
end
|
29
|
+
|
23
30
|
#GDK_KEY_name are defined since gtk 2.22 and ruby-gnome2 ?.?
|
24
31
|
#GDK_name will be dropped
|
25
32
|
begin
|
@@ -38,7 +45,7 @@ end
|
|
38
45
|
module Pack
|
39
46
|
private
|
40
47
|
def hpack(*a)#Accept both forms: hpack([1, 2, 3]) and hpack(1, 2, 3)
|
41
|
-
array
|
48
|
+
array=array_from_args(a)
|
42
49
|
hbox=Gtk::HBox.new
|
43
50
|
hbox.border_width=$border
|
44
51
|
hbox.spacing=$border
|
@@ -48,7 +55,7 @@ def hpack(*a)#Accept both forms: hpack([1, 2, 3]) and hpack(1, 2, 3)
|
|
48
55
|
hbox
|
49
56
|
end
|
50
57
|
def vpack(*a)
|
51
|
-
array
|
58
|
+
array=array_from_args(a)
|
52
59
|
vbox=Gtk::VBox.new
|
53
60
|
vbox.border_width=$border
|
54
61
|
vbox.spacing=$border
|
data/gui/config.rb
CHANGED
@@ -95,7 +95,7 @@ private
|
|
95
95
|
#Player
|
96
96
|
self['play_on_start']=="true" ? self['play_on_start']=true : self['play_on_start']=false
|
97
97
|
self['current_song']=self['current_song'].to_i
|
98
|
-
self['volume']=self['volume'].
|
98
|
+
self['volume']=self['volume'].to_f
|
99
99
|
self['shuffle']=="true" ? self['shuffle']=true : self['shuffle']=false
|
100
100
|
self['repeat']=="true" ? self['repeat']=true : self['repeat']=false
|
101
101
|
#cd
|
data/gui/gui.rb
CHANGED
@@ -510,7 +510,7 @@ class Gui < Gtk::Window
|
|
510
510
|
@bnext= Gtk::Button.new;@bnext.image=@inext
|
511
511
|
@bnext.signal_connect('clicked'){next_song}
|
512
512
|
#time
|
513
|
-
@lposition=Gtk::Label.new('--:--')
|
513
|
+
@lposition=Gtk::Label.new(' --:--')
|
514
514
|
@lposbox=Gtk::EventBox.new
|
515
515
|
@lposbox.events=Gdk::Event::BUTTON_PRESS_MASK
|
516
516
|
@lposbox.add(@lposition)
|
@@ -784,14 +784,14 @@ public
|
|
784
784
|
@song_title.text="#{song.name}"
|
785
785
|
duration=song.duration
|
786
786
|
if duration <= 0
|
787
|
-
@lduration.text='--:--'
|
787
|
+
@lduration.text='--:-- '
|
788
788
|
@sposition.set_range(0,1200)#Use 20 minutes if song's duration is not known.
|
789
789
|
GLib::Timeout.add(600){get_gst_duration(player, song)}#if taglib cannot give the track duration, let's try GStreamer
|
790
790
|
elsif duration < 3600
|
791
|
-
@lduration.text=Time.at(duration).strftime("%M:%S")
|
791
|
+
@lduration.text=Time.at(duration).strftime("%M:%S ")
|
792
792
|
@sposition.set_range(0,duration)
|
793
793
|
else
|
794
|
-
@lduration.text=(duration.to_i/3600).to_s+":"+Time.at(duration).strftime("%M:%S")
|
794
|
+
@lduration.text=(duration.to_i/3600).to_s+":"+Time.at(duration).strftime("%M:%S ")
|
795
795
|
@sposition.set_range(0,duration)
|
796
796
|
end
|
797
797
|
store.each{|model, path, iter|
|
@@ -805,25 +805,25 @@ public
|
|
805
805
|
GLib::Timeout.add(400){
|
806
806
|
position=player.position
|
807
807
|
if position <= 0
|
808
|
-
@lposition.text="--:--"
|
808
|
+
@lposition.text=" --:--"
|
809
809
|
else
|
810
810
|
duration=song.duration#get an uptodate duration
|
811
811
|
if duration <= 0
|
812
|
-
@lposition.text=Time.at(position).strftime("%M:%S")
|
812
|
+
@lposition.text=Time.at(position).strftime(" %M:%S")
|
813
813
|
elsif duration < 3600
|
814
814
|
if @config['remaining_time']
|
815
|
-
t=duration-position; format="-%M:%S"
|
815
|
+
t=duration-position; format=" -%M:%S"
|
816
816
|
else
|
817
|
-
t=position; format="%M:%S"
|
817
|
+
t=position; format=" %M:%S"
|
818
818
|
end
|
819
819
|
@lposition.text=Time.at(t).strftime(format)
|
820
820
|
else
|
821
821
|
if @config['remaining_time']
|
822
822
|
t=duration-position
|
823
|
-
format="-"
|
823
|
+
format=" -"
|
824
824
|
else
|
825
825
|
t=position
|
826
|
-
format=""
|
826
|
+
format=" "
|
827
827
|
end
|
828
828
|
@lposition.text=format+(t.to_i/3600).to_s+":"+Time.at(t).strftime("%M:%S")
|
829
829
|
end
|
@@ -848,9 +848,9 @@ private
|
|
848
848
|
if duration>0
|
849
849
|
song.duration=duration
|
850
850
|
if duration < 3600
|
851
|
-
@lduration.text=Time.at(duration).strftime("%M:%S")
|
851
|
+
@lduration.text=Time.at(duration).strftime("%M:%S ")
|
852
852
|
else
|
853
|
-
@lduration.text=(duration.to_i/3600).to_s+":"+Time.at(duration).strftime("%M:%S")
|
853
|
+
@lduration.text=(duration.to_i/3600).to_s+":"+Time.at(duration).strftime("%M:%S ")
|
854
854
|
end
|
855
855
|
@sposition.set_range(0,duration)
|
856
856
|
else
|
data/playlist/export.rb
CHANGED
@@ -20,7 +20,33 @@ This file is part of ZiK.
|
|
20
20
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
21
|
=end
|
22
22
|
|
23
|
-
|
23
|
+
begin
|
24
|
+
#ruby 1.9+
|
25
|
+
require 'fileutils'
|
26
|
+
rescue LoadError
|
27
|
+
#Emulate FileUtils needed methods
|
28
|
+
require 'ftools'
|
29
|
+
class FileUtils
|
30
|
+
def FileUtils.makedirs(dir)
|
31
|
+
File.makedirs(dir)
|
32
|
+
end
|
33
|
+
def FileUtils.copy_file(src, dest)
|
34
|
+
File.copy(src, dest)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
=begin
|
40
|
+
begin
|
41
|
+
#ruby 1.8
|
42
|
+
require 'ftools'
|
43
|
+
# def ExportList.makedirs ExportList.copy
|
44
|
+
rescue LoadError
|
45
|
+
#ruby 1.9
|
46
|
+
require 'fileutils'
|
47
|
+
# def ExportList.makedirs ExportList.copy
|
48
|
+
end
|
49
|
+
=end
|
24
50
|
|
25
51
|
class ExportSong
|
26
52
|
attr_reader :old_path, :path, :duration, :name, :bitrate, :samplerate, :channels, :type,
|
@@ -87,8 +113,8 @@ class ExportList
|
|
87
113
|
estock.add(ErrorWARNING, _("#{song.path} allready exists."))
|
88
114
|
else
|
89
115
|
dir=File.dirname(song.path)
|
90
|
-
|
91
|
-
|
116
|
+
FileUtils.makedirs(dir) unless File.exist?(dir)
|
117
|
+
FileUtils.copy_file(song.old_path, song.path)
|
92
118
|
end
|
93
119
|
rescue Errno::ENOENT#Original file (song.old) was removed
|
94
120
|
estock.add(ErrorERROR, _("Cannot access #{song.old_path}"))
|
data/playlist/song.rb
CHANGED
@@ -92,6 +92,7 @@ class Song
|
|
92
92
|
@bitrate=tag.bitrate
|
93
93
|
@samplerate=tag.samplerate
|
94
94
|
@channels=tag.channels
|
95
|
+
tag.close if tag.respond_to?(:close)
|
95
96
|
rescue TagLib::BadFile
|
96
97
|
ErrorWarning.new("Cannot read #{file}\'s tag.")
|
97
98
|
@title||=''; @artist||=''; @album||=''; @track||=-1; @genre||=''; @duration||=-1
|
@@ -103,6 +104,8 @@ class Song
|
|
103
104
|
rescue TagLib::BadAudioProperties
|
104
105
|
ErrorWarning.new("Cannot read #{file}\'s audio properties.")
|
105
106
|
@bitrate||=-1; @samplerate||=-1; @channels||=-1
|
107
|
+
ensure
|
108
|
+
tag.close if tag&&tag.respond_to?(:close)#Deprecated (ruby-taglib >= 0.1.3). Use "tag.close if tag"
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
@@ -116,6 +119,8 @@ class Song
|
|
116
119
|
ErrorWarning.new("Cannot write #{file}\'s tag.")
|
117
120
|
rescue TagLib::BadTag
|
118
121
|
ErrorWarning.new("Cannot write #{file}\'s tag.")
|
122
|
+
ensure
|
123
|
+
tag.close if tag&&tag.respond_to?(:close)#Deprecated (ruby-taglib >= 0.1.3)
|
119
124
|
end
|
120
125
|
end
|
121
126
|
|
data/zik
CHANGED
@@ -1,401 +1,2 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
|
-
|
4
|
-
=begin
|
5
|
-
Copyright 2007-2011 Vincent Carmona
|
6
|
-
vinc4mai@gmail.com
|
7
|
-
|
8
|
-
This file is part of ZiK.
|
9
|
-
|
10
|
-
ZiK is free software; you can redistribute it and/or modify
|
11
|
-
it under the terms of the GNU General Public License as published by
|
12
|
-
the Free Software Foundation; either version 2 of the License, or
|
13
|
-
(at your option) any later version.
|
14
|
-
|
15
|
-
ZiK is distributed in the hope that it will be useful,
|
16
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
-
GNU General Public License for more details.
|
19
|
-
|
20
|
-
You should have received a copy of the GNU General Public License
|
21
|
-
along with ZiK; if not, write to the Free Software
|
22
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23
|
-
=end
|
24
|
-
|
25
|
-
$name='ZiK'
|
26
|
-
Version='0.17.0+gitv0.17'
|
27
|
-
|
28
|
-
#Usage
|
29
|
-
def usage
|
30
|
-
puts "ZiK is an audio player based on gstreamer.\n\n"
|
31
|
-
puts "Options."
|
32
|
-
puts "--help -h\tPrint this help."
|
33
|
-
puts "--configuration -c <path>\tDirectory used to load and save configuration."
|
34
|
-
puts "--file -f <files>\tAdd files to playlist."
|
35
|
-
puts "--append -f <files>\tAppend files playlist."
|
36
|
-
puts "--show-all\tshow browser and playlist."
|
37
|
-
puts "--show-browser\tshow browser."
|
38
|
-
puts "--show-playlist\tshow playlist."
|
39
|
-
puts "--show-cd\tshow CD."
|
40
|
-
puts "--show-radio\tshow radios."
|
41
|
-
puts "--disable-cd\tDisable cd support"
|
42
|
-
puts "--disable-radio\tDisable webradios"
|
43
|
-
puts "--disable-module\tDisable module support"
|
44
|
-
puts "--hide-errors\tDo not show errors dialogs."
|
45
|
-
puts "--quiet -q\tDo not print on standart output."
|
46
|
-
puts "--no-save\tDo not overwrite configuration file"
|
47
|
-
puts "--title -t <name>\tRename window's title."
|
48
|
-
puts "--version\tDisplay the current version and exit."
|
49
|
-
end
|
50
|
-
|
51
|
-
#Parse options
|
52
|
-
$write_config=true
|
53
|
-
$show_errors=true
|
54
|
-
$cd=true
|
55
|
-
$radio=true
|
56
|
-
$module=true
|
57
|
-
append=false
|
58
|
-
playfiles=[]
|
59
|
-
while arg=ARGV.shift
|
60
|
-
case arg
|
61
|
-
when '--version'
|
62
|
-
puts "ZiK version #{Version}.";exit 0
|
63
|
-
when '--help', '-h'
|
64
|
-
usage;exit 0
|
65
|
-
when '--quiet', '-q'
|
66
|
-
$stderr=$stdout=File.new('/dev/null', 'w')
|
67
|
-
when '--no-save'
|
68
|
-
$write_config=false
|
69
|
-
when '--hide-errors'
|
70
|
-
$show_errors=false
|
71
|
-
when '--disable-cd'
|
72
|
-
$cd=false
|
73
|
-
when '--disable-radio'
|
74
|
-
$radio=false
|
75
|
-
when '--disable-module'
|
76
|
-
$module=false
|
77
|
-
when '--configuration', '-c'
|
78
|
-
User_dir=ARGV.shift
|
79
|
-
when '--show-all'
|
80
|
-
view='all'
|
81
|
-
when '--show-browser'
|
82
|
-
view='browser'
|
83
|
-
when '--show-playlist'
|
84
|
-
view='playlist'
|
85
|
-
when '--show-cd'
|
86
|
-
view='cd'
|
87
|
-
when '--show-radio'
|
88
|
-
view='radio'
|
89
|
-
when '--file', '-f'
|
90
|
-
append=false
|
91
|
-
when '--append', '-a'
|
92
|
-
append=true
|
93
|
-
when '--title', '-t'
|
94
|
-
$name+=' - '+ARGV.shift
|
95
|
-
when /^-/
|
96
|
-
$stderr.puts "Unknown option. Try ZiK --help.";exit 1
|
97
|
-
else
|
98
|
-
playfiles.push(arg)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
Data_dir='/usr/local/share/ZiK'
|
103
|
-
Pix_dir=File.join(Data_dir,'pix')
|
104
|
-
Theme_dir=File.join(Data_dir, 'theme')
|
105
|
-
Doc_dir='/usr/local/share/doc/ZiK'
|
106
|
-
Locale_dir='/usr/local/share/locale'
|
107
|
-
|
108
|
-
require 'gettext'
|
109
|
-
include GetText
|
110
|
-
bindtextdomain('ZiK', {:path=>Locale_dir})
|
111
|
-
require File.join(Data_dir, 'gui/error')
|
112
|
-
estock=ErrorsStock.new
|
113
|
-
|
114
|
-
ErrorInfo.new("Hi! This is #{$name} (#{Version}). Enjoy your music.")
|
115
|
-
|
116
|
-
#Global configuration
|
117
|
-
$border=5
|
118
|
-
|
119
|
-
#Configuration
|
120
|
-
require File.join(Data_dir, 'gui/config')
|
121
|
-
if (defined? User_dir)
|
122
|
-
Cache_dir=File.join('User_dir', 'cache')
|
123
|
-
Runtime_dir=File.join('User_dir', 'runtime')
|
124
|
-
else
|
125
|
-
User_dir= ENV['XDG_CONFIG_HOME'] ? File.join(ENV['XDG_CONFIG_HOME'], 'ZiK') :
|
126
|
-
File.join(ENV['HOME'], '.config', 'ZiK')
|
127
|
-
unless File.exist?(User_dir)#Check for deprecated location of User_dir
|
128
|
-
old_user_dir=File.join(ENV['HOME'],'.ZiK')
|
129
|
-
File.rename(old_user_dir, User_dir) if File.directory?(old_user_dir)
|
130
|
-
end
|
131
|
-
Cache_dir= ENV['XDG_CACHE_HOME'] ? File.join(ENV['XDG_CACHE_HOME'], 'ZiK') :
|
132
|
-
File.join(ENV['HOME'], '.cache', 'ZiK')
|
133
|
-
if ENV['XDG_RUNTIME_DIR']
|
134
|
-
Runtime_dir=File.join(ENV['XDG_RUNTIME_DIR'], 'ZiK')
|
135
|
-
else
|
136
|
-
require 'tempfile'
|
137
|
-
Runtime_dir=File.join(Dir.tmpdir, 'ZiK-'+ENV['USER'])
|
138
|
-
ErrorWarning.new("XDG_RUNTIME_DIR is not set. #{Runtime_dir} is used instead.")
|
139
|
-
end
|
140
|
-
end
|
141
|
-
unless File.exist?(User_dir)
|
142
|
-
Dir.mkdir(User_dir)
|
143
|
-
config_new=true
|
144
|
-
end
|
145
|
-
Dir.mkdir(Cache_dir) unless File.exist?(Cache_dir)
|
146
|
-
Dir.mkdir(Runtime_dir, 0700) unless File.exist?(Runtime_dir)
|
147
|
-
if File.directory?(User_dir)
|
148
|
-
configuration_file=File.join(User_dir,'ZiKrc')
|
149
|
-
config=Configuration.new(configuration_file)
|
150
|
-
else
|
151
|
-
config=Configuration.new("")
|
152
|
-
$write_config=false
|
153
|
-
config_new=true
|
154
|
-
estock.add(ErrorERROR, _("Configuration will not be saved. #{User_dir} is not a directory."))
|
155
|
-
end
|
156
|
-
config_new||=false
|
157
|
-
config['view']=view if view
|
158
|
-
|
159
|
-
#Socket (client part)
|
160
|
-
module ZiKSocket
|
161
|
-
Address=File.join(Runtime_dir, 'socket')
|
162
|
-
end
|
163
|
-
if File.socket?(ZiKSocket::Address)
|
164
|
-
require File.join(Data_dir, 'gui/socket')
|
165
|
-
begin
|
166
|
-
client=ZiKSocket::Client.new
|
167
|
-
ErrorInfo.new(_("Multisession : server already exists."))
|
168
|
-
playfiles.each{|file|
|
169
|
-
file=File.join(Dir.pwd, file) unless file =~ /^\//#absolute path
|
170
|
-
p client.command("add #{file}")
|
171
|
-
}
|
172
|
-
client.command("show")
|
173
|
-
client.close
|
174
|
-
exit 0
|
175
|
-
rescue Errno::ECONNREFUSED
|
176
|
-
ErrorError.new(_("Multissession: socket exists but server does not respond."))
|
177
|
-
File.delete(ZiKSocket::Address)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
#Files needed for playlist managing
|
182
|
-
require 'pathname'
|
183
|
-
require 'rexml/document'
|
184
|
-
begin
|
185
|
-
require 'taglib2'
|
186
|
-
rescue LoadError
|
187
|
-
require 'taglib'
|
188
|
-
ErrorWarning.new("ruby-taglib is depreated.")
|
189
|
-
end
|
190
|
-
require File.join(Data_dir, 'playlist/song')
|
191
|
-
require File.join(Data_dir, 'playlist/common')
|
192
|
-
require File.join(Data_dir, 'playlist/export')
|
193
|
-
require File.join(Data_dir, 'playlist/playlist')
|
194
|
-
|
195
|
-
|
196
|
-
#Files needed for the audio player
|
197
|
-
require 'gst'
|
198
|
-
require File.join(Data_dir, 'player/player')
|
199
|
-
|
200
|
-
#Files needed for graphical interface
|
201
|
-
require 'gtk2'
|
202
|
-
require 'find'
|
203
|
-
require File.join(Data_dir, 'gui/common')
|
204
|
-
require File.join(Data_dir, 'gui/preference')
|
205
|
-
require File.join(Data_dir, 'gui/search')
|
206
|
-
require File.join(Data_dir, 'playlist/editlist')
|
207
|
-
require File.join(Data_dir, 'gui/edit')
|
208
|
-
require File.join(Data_dir, 'gui/progress')
|
209
|
-
require File.join(Data_dir, 'gui/gui')
|
210
|
-
|
211
|
-
#Files needed for audio cd
|
212
|
-
if $cd
|
213
|
-
begin
|
214
|
-
require 'musicbrainz'
|
215
|
-
require File.join(Data_dir, 'playlist/cdlist')
|
216
|
-
require File.join(Data_dir, 'player/cdplayer')
|
217
|
-
require File.join(Data_dir, 'gui/cdgui')
|
218
|
-
rescue LoadError
|
219
|
-
estock.add(ErrorERROR, _("CD support disable. mb-ruby is probably not installed."))
|
220
|
-
$cd=false
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
#Files needed for webradio
|
225
|
-
if $radio
|
226
|
-
begin
|
227
|
-
require 'uri'
|
228
|
-
require 'net/http'
|
229
|
-
require File.join(Data_dir, 'playlist/radiolist')
|
230
|
-
require File.join(Data_dir, 'player/radioplayer')
|
231
|
-
require File.join(Data_dir, 'gui/radiogui')
|
232
|
-
rescue LoadError
|
233
|
-
estock.add(ErrorERROR, _("Radio support disable."))
|
234
|
-
$radio=false
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
#Playlists
|
239
|
-
if (playfiles.empty? || append)
|
240
|
-
playlist=PlayList.new(File.join(User_dir,'playlist'),
|
241
|
-
config['current_song'], config['shuffle'], config['repeat'], config['name_format'], config['sort_by_track'])
|
242
|
-
end
|
243
|
-
playlist||=PlayList.new(nil, 0, config['shuffle'], config['repeat'], config['name_format'], config ['sort_by_track'])
|
244
|
-
playfiles.each{|f| playlist.add(f)}
|
245
|
-
|
246
|
-
cdlist=Cd::List.new(config) if $cd
|
247
|
-
if $radio
|
248
|
-
radio_file=File.join(User_dir,'radio')
|
249
|
-
radiolist=Radio::List.new(radio_file)
|
250
|
-
end
|
251
|
-
|
252
|
-
#Players
|
253
|
-
player=Player.new
|
254
|
-
player.volume=config['volume']
|
255
|
-
if $cd
|
256
|
-
begin
|
257
|
-
cdplayer=Cd::Player.new(config['cd_device'])
|
258
|
-
cdplayer.volume=config['volume']
|
259
|
-
rescue
|
260
|
-
estock.add(ErrorERROR, _("CD support disable (device not found?)."))
|
261
|
-
$cd=false
|
262
|
-
end
|
263
|
-
end
|
264
|
-
if $radio
|
265
|
-
radioplayer=Radio::Player.new
|
266
|
-
radioplayer.volume=config['volume']
|
267
|
-
end
|
268
|
-
|
269
|
-
cdplayer=nil unless $cd
|
270
|
-
cdlist=nil unless $cd
|
271
|
-
radiolist=nil unless $radio
|
272
|
-
|
273
|
-
#Gui
|
274
|
-
module View
|
275
|
-
View::ALL=0
|
276
|
-
View::PLAYLIST=1
|
277
|
-
View::BROWSER=2
|
278
|
-
View::COMPACT=3
|
279
|
-
if $cd
|
280
|
-
View::CD=4
|
281
|
-
$radio ? View::RADIO=5 : View::RADIO=View::ALL
|
282
|
-
else
|
283
|
-
View::CD=View::ALL
|
284
|
-
$radio ? View::RADIO=4 : View::RADIO=View::ALL
|
285
|
-
end
|
286
|
-
end
|
287
|
-
module DragType
|
288
|
-
#Type of data
|
289
|
-
#General types
|
290
|
-
#DragType::STRING=104 #Gdk::Atom.intern('string',true).to_i
|
291
|
-
DragType::URI_LIST=105 #text/uri-list
|
292
|
-
#DragType::PLAIN=106 #text/plain
|
293
|
-
#ZiK types
|
294
|
-
DragType::BROWSER_SELECTION=700
|
295
|
-
end
|
296
|
-
begin
|
297
|
-
Gdk::Color.parse(config['playing_color'])
|
298
|
-
rescue
|
299
|
-
ErrorError.new("#{config['playing_color']} is not a valid color. Use default one.")
|
300
|
-
config['playing_color']=config.default['playing_color']
|
301
|
-
end
|
302
|
-
if config_new
|
303
|
-
require File.join(Data_dir, 'gui/assistant')
|
304
|
-
assistant=Assistant.new(config)
|
305
|
-
def assistant.quit
|
306
|
-
self.destroy
|
307
|
-
Gtk.main_quit
|
308
|
-
end
|
309
|
-
Gtk.main
|
310
|
-
end
|
311
|
-
gui=Gui.new(player, playlist, config, cdplayer, cdlist, radioplayer, radiolist)
|
312
|
-
gui.show
|
313
|
-
Error.gui=gui
|
314
|
-
ErrorsStock.gui=gui
|
315
|
-
player.gui=gui
|
316
|
-
cdplayer.gui=gui if $cd
|
317
|
-
radioplayer.gui=gui if $radio
|
318
|
-
|
319
|
-
#Socket (Server part)
|
320
|
-
##See http://ruby-gnome2.sourceforge.jp/hiki.cgi?tips_threads if random crash happen (or try GLib::Idle before)
|
321
|
-
module ZiKSocket
|
322
|
-
def ZiKSocket.clean
|
323
|
-
if File.socket?(Address)
|
324
|
-
c=ZiKSocket::Client.new
|
325
|
-
c.close_server
|
326
|
-
File.delete(Address)
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
if config['socket']
|
331
|
-
require File.join(Data_dir, 'gui/socket')
|
332
|
-
ZiKSocket.start_server(gui, config, playlist)
|
333
|
-
end
|
334
|
-
|
335
|
-
#Modules
|
336
|
-
if $module
|
337
|
-
require File.join(Data_dir, 'gui/mod')
|
338
|
-
Mod.zik=gui
|
339
|
-
modinput={:config_dir=>File.join(User_dir, 'mod'), :mod_dir=>File.join(Data_dir,'mod'), :pix_dir=>Pix_dir}
|
340
|
-
ext='.rb'
|
341
|
-
|
342
|
-
mfiles=Dir.glob(File.join(Data_dir, 'mod', '*'+ext))
|
343
|
-
mfiles.each{|file|
|
344
|
-
begin
|
345
|
-
require file#require all modules in order to build preferences dialog.
|
346
|
-
rescue LoadError
|
347
|
-
estock.add(ErrorERROR, _("Cannot loaded a module (#{file})."))
|
348
|
-
rescue ModNotUniqueId
|
349
|
-
estock.add(ErrorERROR, _("Module id not unique (#{file})."))
|
350
|
-
end
|
351
|
-
}
|
352
|
-
Mod.own.each{|mod|
|
353
|
-
mod.init(modinput)
|
354
|
-
mod.load if config['module'].split(',').include?(mod.id)
|
355
|
-
}
|
356
|
-
|
357
|
-
Mod.global=false
|
358
|
-
mfiles=Dir.glob(File.join(User_dir, 'mod','*'+ext))
|
359
|
-
modinput[:mod_dir]=File.join(User_dir, 'mod')
|
360
|
-
mfiles.each{|file|
|
361
|
-
begin
|
362
|
-
require file#require all modules in order to build preferences dialog.
|
363
|
-
rescue LoadError
|
364
|
-
estock.add(ErrorERROR, _("Cannot loaded a module (#{file})."))
|
365
|
-
rescue ModNotUniqueId
|
366
|
-
estock.add(ErrorERROR, _("Module id not unique (#{file})."))
|
367
|
-
end
|
368
|
-
}
|
369
|
-
Mod.user.each{|mod|
|
370
|
-
mod.init(modinput)
|
371
|
-
mod.load if config['module'].split(',').include?(mod.id)
|
372
|
-
}
|
373
|
-
ModErrorLoadError.show_all
|
374
|
-
end
|
375
|
-
|
376
|
-
#Main
|
377
|
-
gui.play if config['play_on_start']
|
378
|
-
estock.show_all
|
379
|
-
begin
|
380
|
-
Gtk.main
|
381
|
-
if $write_config
|
382
|
-
playlist.save_zik(File.join(User_dir,'playlist'), config['relative_playlist'])
|
383
|
-
config['current_song']=playlist.current
|
384
|
-
config['volume']=player.volume
|
385
|
-
config.write
|
386
|
-
radiolist.write if $radio
|
387
|
-
end
|
388
|
-
Mod.all.each{|mod| mod.quit} if $module
|
389
|
-
ensure
|
390
|
-
player.stop
|
391
|
-
cdplayer.stop if $cd
|
392
|
-
radioplayer.stop if $radio
|
393
|
-
ZiKSocket.clean
|
394
|
-
begin
|
395
|
-
Dir.rmdir(Runtime_dir) if File.directory?(Runtime_dir)
|
396
|
-
rescue Errno::ENOTEMPTY
|
397
|
-
ErrorError.new("Cannot delete #{Runtime_dir}.")
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
ErrorInfo.new("Bye.")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 89
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 17
|
9
|
-
-
|
10
|
-
version: 0.17.
|
9
|
+
- 1
|
10
|
+
version: 0.17.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vincent Carmona
|
@@ -36,8 +36,7 @@ cert_chain:
|
|
36
36
|
oxzIRXlS
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
40
|
-
default_executable:
|
39
|
+
date: 2011-12-13 00:00:00 Z
|
41
40
|
dependencies:
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: gtk2
|
@@ -110,7 +109,7 @@ dependencies:
|
|
110
109
|
type: :runtime
|
111
110
|
version_requirements: *id005
|
112
111
|
- !ruby/object:Gem::Dependency
|
113
|
-
name: ruby-
|
112
|
+
name: ruby-mp3info
|
114
113
|
prerelease: false
|
115
114
|
requirement: &id006 !ruby/object:Gem::Requirement
|
116
115
|
none: false
|
@@ -124,7 +123,7 @@ dependencies:
|
|
124
123
|
type: :runtime
|
125
124
|
version_requirements: *id006
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
126
|
+
name: globalhotkeys
|
128
127
|
prerelease: false
|
129
128
|
requirement: &id007 !ruby/object:Gem::Requirement
|
130
129
|
none: false
|
@@ -137,20 +136,6 @@ dependencies:
|
|
137
136
|
version: "0"
|
138
137
|
type: :runtime
|
139
138
|
version_requirements: *id007
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: globalhotkeys
|
142
|
-
prerelease: false
|
143
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
|
-
requirements:
|
146
|
-
- - ">="
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
hash: 3
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
version: "0"
|
152
|
-
type: :runtime
|
153
|
-
version_requirements: *id008
|
154
139
|
description:
|
155
140
|
email: vinc4mai@gmail.com
|
156
141
|
executables:
|
@@ -232,9 +217,6 @@ files:
|
|
232
217
|
- mod/brainz/ofa.rb
|
233
218
|
- mod/brainz/song.rb
|
234
219
|
- mod/brainz/widget.rb
|
235
|
-
- mod/interact.rb
|
236
|
-
- mod/interact/configwidget.rb
|
237
|
-
- mod/interact/interaction.rb
|
238
220
|
- doc/COPYING
|
239
221
|
- doc/html/fr/index.html
|
240
222
|
- doc/html/index.html
|
@@ -247,10 +229,8 @@ files:
|
|
247
229
|
- doc/html/pix/logo.png
|
248
230
|
- doc/html/styles/main.css
|
249
231
|
- doc/ChangeLog
|
250
|
-
- doc/man/zik.1.gz
|
251
232
|
- doc/man/manpage.1
|
252
233
|
- ./zik
|
253
|
-
has_rdoc: true
|
254
234
|
homepage: http://zik.rubyforge.org/
|
255
235
|
licenses:
|
256
236
|
- General Public License v2
|
@@ -280,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
260
|
requirements:
|
281
261
|
- GStreamer Base Plugins
|
282
262
|
rubyforge_project: zik
|
283
|
-
rubygems_version: 1.
|
263
|
+
rubygems_version: 1.7.2
|
284
264
|
signing_key:
|
285
265
|
specification_version: 3
|
286
266
|
summary: ZiK is an audio player based on gstreamer. It uses the path of your audio files instead of a music library.
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�}nl\�5�����j�A���k��,�l"0+��T�*����όd���}�M'�m]�k����yI��|����!�:I/�������Hh2:mă`�R{����4%��c�:\^E�j�5g���b�4�L�P�]�F��P� �םz���J��4{�=��P::!��.-Tr���)�B�L�V���PL�tu��;�4@`F�K{�
|
1
|
+
1��`;�p<��w���v3o�ĄW�S��������!ѧ��f?�bJ�{b�Z�ᵀg���.Z_K,>`hѯ���r���5B�B�V�b�=�%ī�����3�!:�ʩ
|
2
|
+
U�&@��j�Fa0l���1|:
|
data/doc/man/zik.1.gz
DELETED
Binary file
|
data/mod/interact.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright 2007-2010 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 Interact
|
24
|
-
Menu,LocalMenu=[], []
|
25
|
-
Arg, LocalArg=[], []
|
26
|
-
def self.menu_const_set(name, val, lval)
|
27
|
-
Menu.push(const_set(name, val))#Is it ok to push an object on a constant (not frozen) array ?
|
28
|
-
LocalMenu.push(const_set("LOCAL_"+name, lval))
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.arg_const_set(name, val, lval)
|
32
|
-
Arg.push(const_set(name, val))
|
33
|
-
LocalArg.push(const_set("LOCAL_"+name, lval))
|
34
|
-
end
|
35
|
-
|
36
|
-
menu_const_set "MENU", "Menu", _("Menu")
|
37
|
-
|
38
|
-
arg_const_set "NONE", "None", _("None")
|
39
|
-
arg_const_set "PLAYLIST_FILES", "Playlit files", _("Playlit files")
|
40
|
-
arg_const_set "CURRENT_SONG", "Current Song", _("Current song")
|
41
|
-
arg_const_set "CURRENT_SONG_NAME", "Current song name", _("Current song name")
|
42
|
-
|
43
|
-
def Interact.mod
|
44
|
-
@m||=Mod.new('interact', "Interact", _("Add menu entries to interact with ZiK."),
|
45
|
-
'Vincent Carmona <vinc4mai@gmail.com>', 'GPL-2')
|
46
|
-
end
|
47
|
-
|
48
|
-
Interact.mod
|
49
|
-
def @m.init(input)
|
50
|
-
@dir=input[:mod_dir]
|
51
|
-
require File.join(@dir, 'interact', 'interaction')
|
52
|
-
require File.join(@dir, 'interact', 'configwidget')
|
53
|
-
@interactions=Interaction.read(input[:config_dir])
|
54
|
-
@destroy_on_unload=[]
|
55
|
-
end
|
56
|
-
|
57
|
-
def @m.load
|
58
|
-
unless @loaded
|
59
|
-
@interactions.each{|interaction|
|
60
|
-
case interaction[:menu]
|
61
|
-
when MENU
|
62
|
-
it=Gtk::MenuItem.new(interaction[:name])
|
63
|
-
it.signal_connect('activate'){
|
64
|
-
arg=resolve_argument(interaction[:argument])
|
65
|
-
c=interaction[:command].split(' ')
|
66
|
-
t=[*c]+[*arg]
|
67
|
-
Thread.new{system(*t)}
|
68
|
-
}
|
69
|
-
menu_add(it.show)
|
70
|
-
@destroy_on_unload.push(it)
|
71
|
-
else
|
72
|
-
ModErrorError.new(self,
|
73
|
-
_("Cannot create interactions named #{interaction[:name]}(unknow menu type)."), true)
|
74
|
-
end
|
75
|
-
}
|
76
|
-
@loaded=true
|
77
|
-
else
|
78
|
-
false
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def @m.unload
|
83
|
-
if @loaded
|
84
|
-
@destroy_on_unload.each{|w| w.destroy}
|
85
|
-
@destroy_on_unload.clear
|
86
|
-
menu_hide
|
87
|
-
@loaded=false
|
88
|
-
true
|
89
|
-
else
|
90
|
-
false
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def @m.configwidget
|
95
|
-
@wconfig=ConfigWidget.new(@interactions)
|
96
|
-
end
|
97
|
-
|
98
|
-
def @m.saveconfig
|
99
|
-
old_interactions=@interactions
|
100
|
-
@interactions=@wconfig.interactions
|
101
|
-
reload if @loaded
|
102
|
-
end
|
103
|
-
|
104
|
-
def @m.quit
|
105
|
-
Interaction.write(@interactions)
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def @m.reload
|
111
|
-
unload
|
112
|
-
self.load
|
113
|
-
end
|
114
|
-
|
115
|
-
def @m.resolve_argument(type)
|
116
|
-
#escape=/[\ \'\#\[\]\(\)\&\;\|\!]/; String#gsub(escape){|s| '\\'+s}
|
117
|
-
case type
|
118
|
-
when NONE
|
119
|
-
""
|
120
|
-
when PLAYLIST_FILES
|
121
|
-
list=zik.playlist
|
122
|
-
list.songs.map{|song| song.path}
|
123
|
-
when CURRENT_SONG
|
124
|
-
list=zik.playlist
|
125
|
-
list.songs[list.current].path
|
126
|
-
when CURRENT_SONG_NAME
|
127
|
-
list=zik.playlist
|
128
|
-
list.songs[list.current].name
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright 2007-2010 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 Interact
|
24
|
-
class InteractionWidget
|
25
|
-
attr_reader :menu, :name, :command, :argument, :rm
|
26
|
-
|
27
|
-
def initialize(interaction=nil)
|
28
|
-
@removed=false
|
29
|
-
if interaction
|
30
|
-
menu=Menu.index(interaction[:menu])
|
31
|
-
name=interaction[:name]
|
32
|
-
command=interaction[:command]
|
33
|
-
arg=Arg.index(interaction[:argument])
|
34
|
-
sensitive=true
|
35
|
-
end
|
36
|
-
menu||=-1
|
37
|
-
name||=""
|
38
|
-
command||=""
|
39
|
-
arg||=0
|
40
|
-
sensitive||=false
|
41
|
-
|
42
|
-
@menu=Gtk::ComboBox.new
|
43
|
-
@menu.append_text(LOCAL_MENU)
|
44
|
-
@menu.active=menu
|
45
|
-
@menu.signal_connect('changed'){
|
46
|
-
sensitive=@menu.active>=0
|
47
|
-
[@name, @command, @argument].each{|w| w.sensitive=sensitive}
|
48
|
-
}
|
49
|
-
@name=Gtk::Entry.new
|
50
|
-
@name.text=name
|
51
|
-
@command=Gtk::Entry.new
|
52
|
-
@command.text=command
|
53
|
-
@argument=Gtk::ComboBox.new
|
54
|
-
LocalArg.each{|c| @argument.append_text(c)}
|
55
|
-
@argument.active=arg
|
56
|
-
@rm=Gtk::Button.new
|
57
|
-
@rm.image=Gtk::Image.new(Gtk::Stock::REMOVE, Gtk::IconSize::BUTTON)
|
58
|
-
@rm.signal_connect('clicked'){
|
59
|
-
[@menu, @name, @command, @argument, @rm].each{|w| w.hide}
|
60
|
-
@removed=true
|
61
|
-
}
|
62
|
-
[@menu, @name, @command, @argument, @rm].each{|w| w.show}
|
63
|
-
[@name, @command, @argument].each{|w| w.sensitive=sensitive} unless sensitive
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_h
|
67
|
-
if @removed||@menu.active<0
|
68
|
-
{}
|
69
|
-
else
|
70
|
-
{:menu=>Menu[LocalMenu.index(@menu.active_text)], :name=>@name.text,
|
71
|
-
:command=>@command.text, :argument=>Arg[LocalArg.index(@argument.active_text)]}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class ConfigWidget < Gtk::Table
|
77
|
-
def initialize(interactions)
|
78
|
-
@iwidgets=[]; @nb=0
|
79
|
-
badd=Gtk::Button.new
|
80
|
-
badd.image=Gtk::Image.new(Gtk::Stock::ADD, Gtk::IconSize::BUTTON)
|
81
|
-
badd.signal_connect('clicked'){add_interaction}
|
82
|
-
super(interactions.length+1, 5)
|
83
|
-
self.attach(badd, 0, 5, 0, 1)
|
84
|
-
self.attach(Gtk::Label.new(_("Menu")), 0, 1, 1, 2)
|
85
|
-
self.attach(Gtk::Label.new(_("Name")), 1, 2, 1, 2)
|
86
|
-
self.attach(Gtk::Label.new(_("Command")), 2, 3, 1, 2)
|
87
|
-
self.attach(Gtk::Label.new(_("Argument")), 3, 4, 1, 2)
|
88
|
-
interactions.each_with_index{|interact, i| add_interaction(interact)}
|
89
|
-
end
|
90
|
-
|
91
|
-
def add_interaction(interaction=nil)
|
92
|
-
@iwidgets.push(iwidget=InteractionWidget.new(interaction))
|
93
|
-
self.attach(iwidget.menu, 0, 1, @nb+2, @nb+3)
|
94
|
-
self.attach(iwidget.name, 1, 2, @nb+2, @nb+3)
|
95
|
-
self.attach(iwidget.command, 2, 3, @nb+2, @nb+3)
|
96
|
-
self.attach(iwidget.argument, 3, 4, @nb+2, @nb+3)
|
97
|
-
self.attach(iwidget.rm, 4, 5, @nb+2, @nb+3)
|
98
|
-
@nb+=1
|
99
|
-
end
|
100
|
-
|
101
|
-
def interactions
|
102
|
-
tmp=@iwidgets.map{|w| w.to_h}
|
103
|
-
tmp.reject!{|h| h.empty?||h[:name].empty?||h[:command].empty?}
|
104
|
-
tmp.map{|h| Interaction.new(h)}
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
data/mod/interact/interaction.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright 2007-2010 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 Interact
|
24
|
-
class Interaction < Hash
|
25
|
-
def Interaction.read(dir)
|
26
|
-
@file=File.join(dir,'interactionrc')
|
27
|
-
if File.exist?(@file)
|
28
|
-
begin
|
29
|
-
f=File.open(@file,'r')
|
30
|
-
interactions=f.read.split("\n\n").map!{|i| i.split("\n").reject{|a| a =~ /^#/}.reject{|a| a =~ /^\n/}}
|
31
|
-
interactions.map!{|i| Interaction.from_a(i)}
|
32
|
-
interactions.reject!{|i| i.empty?}
|
33
|
-
rescue
|
34
|
-
interactions=[]
|
35
|
-
ModErrorError.new(Interact.mod, "reading configuration file.")
|
36
|
-
ensure
|
37
|
-
f.close if f
|
38
|
-
end
|
39
|
-
else
|
40
|
-
ModErrorError.new(Interact.mod, "Configuration file not found.")
|
41
|
-
end
|
42
|
-
interactions||[]
|
43
|
-
end
|
44
|
-
|
45
|
-
def Interaction.write(interactions)
|
46
|
-
if $write_config
|
47
|
-
begin
|
48
|
-
dir=File.dirname(@file)
|
49
|
-
Dir.mkdir(dir) unless File.exist?(dir)
|
50
|
-
f=File.open(@file,'w')
|
51
|
-
f.puts '##Configuration file for interact module (ZiK audio player).'
|
52
|
-
interactions.each{|i|
|
53
|
-
i.each_pair{|key, value| f.puts "#{key}=#{value}"}
|
54
|
-
f.puts ""
|
55
|
-
}
|
56
|
-
ModErrorInfo.new(Interact.mod, "configuration saved")
|
57
|
-
rescue
|
58
|
-
ModErrorError.new(Interact.mod, "writting configuration file.")
|
59
|
-
ensure
|
60
|
-
f.close if f
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def Interaction.from_a(a)
|
66
|
-
i=Interaction.new
|
67
|
-
a.each{|l|
|
68
|
-
k, v=l.split('=', 2)
|
69
|
-
i[k.to_sym]=v
|
70
|
-
}
|
71
|
-
i
|
72
|
-
end
|
73
|
-
|
74
|
-
def initialize(hash=nil)
|
75
|
-
super()
|
76
|
-
self.merge!(hash) if hash
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|