add option -d in order to indicate the path to configuration files
[zik.git] / main.rb
blobaed3c22c1621d1d4f345588d3bee10bde92b2bee
1 #!/usr/bin/env ruby
3 =begin
4 Copyright 2007-2008 Vincent Carmona
5 vinc-mai@caramail.com
7 This file is part of ZiK.
9     ZiK is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
14     ZiK is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
19     You should have received a copy of the GNU General Public License
20     along with ZiK; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 =end
24 #Ajouter: sorties en consoles pour savoir ce fait ZiK (+ option quiet?? -> voir optparse)
26 Pdir='pix_directory' #Pictures path
27 Ddir='doc_directory' #Documentations path
28 Ldir='locale_directory' #locale path
29 Version='0.5.5'
31 Dir.chdir('data_directory')
33 require 'gtk2'
34 require 'gst0.10'
35 require 'taglib'
38 require 'gettext'
40 require 'systray'
41 require 'tree'
42 require 'option'
43 require 'help'
44 require 'edittag'
45 require 'search'
47 require 'uri'
48 require 'net/http'
49 require 'tempfile'
51 require 'readplaylist'
53 require 'preference'
54 require 'playlist'
55 require 'player'
56 require 'gui'
58 Dir.chdir(ENV['HOME'])
60 version=Gtk::BINDING_VERSION
61 Gtk.init if version[0]==0 and version[1]<15#Gtk.init is call in Gtk.rb since version 0.15.0
62 Gst.init
63 Search.init
65 while ARGV.length!=0
66         case ARGV.shift
67         when '-d'#Change the path for configuration file and playlist file.
68                 dir=ARGV.shift;
69                 unless File.directory?(dir)
70                         $stderr.puts "#{dir} is not a directory."
71                         exit 1;
72                 end
73                 Home=File.expand_path(dir);
74         else
75                 $stderr.puts "Unknown option"
76                 exit 1;
77         end
78 end
80 Home=File.join(ENV['HOME'],'.ZiK') unless (defined? Home)
81 #---Create ZiK directory ---------
82 if !File.exist?(Home)
83         Dir.mkdir(Home)
84 end
86 window=Gui.new
87 window.show
88 Gtk.main