quick_start 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/README.rdoc CHANGED
@@ -1,28 +1,27 @@
1
- = QuickStart: Simple tool which runs chosen programs on startup
1
+ = QuickStart
2
2
 
3
- It's best to use QuickStart with GNOME as it's build with GTK. After GNOME startup QuickStart window is shown,
4
- where one can choose set of applications started by one-click. Currently set of application is hardcoded as consists of
5
- * firefox
6
- * evolution
7
- * skype
8
- * gnome-terminal
3
+ GTK application used to quickly choose startup programs for current session.
4
+ Define set of applications and than check or uncheck the ones needed just
5
+ after window manager loaded.
9
6
 
10
- All aplications are selected by default.
7
+ == Installation
8
+
9
+ sudo gem sources -a http://gemcutter.org
10
+ sudo gem install quick_start
11
+
12
+ GNOME panel:
13
+ System -> Preferences -> Startup Applications, add new item and put /usr/bin/quick_start as command.
11
14
 
12
- The set should be configured and this is job which will be done soon.
15
+ == Configuration
16
+
17
+ Configuration is provided in ~/.quick_start
18
+ Just go there and see the examples
13
19
 
14
20
  == Dependencies
15
21
 
16
22
  * ruby
17
23
  * libglade2-ruby
18
24
 
19
- == Installation
20
-
21
- sudo gem install mlomnicki-quick_start
22
-
23
- At GNOME panel:
24
- System -> Preferences -> Startup Applications, add new item and put /usr/bin/quick_start as command.
25
-
26
25
  == About
27
26
 
28
27
  Author:: Michał Łomnicki <michal@lomnicki.com.pl>
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "quick_start"
5
+ gemspec.summary = 'GTK application used to quickly choose startup programs for current session'
6
+ gemspec.description = 'GTK application used to quickly choose startup programs for current session'
7
+ gemspec.email = "michal@lomnicki.com.pl"
8
+ gemspec.homepage = "http://github.com/mlomnicki/quick_start"
9
+ gemspec.authors = ["Michał Łomnicki"]
10
+ end
11
+ Jeweler::GemcutterTasks.new
12
+ rescue LoadError
13
+ puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
14
+ end
15
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
data/bin/quick_start CHANGED
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- LIBDIR = File.join( File.dirname(__FILE__), '..', 'lib' )
4
- require File.join( LIBDIR, 'quick_start' )
3
+ require File.join( File.dirname(__FILE__), '..', 'lib', 'quick_start' )
4
+
5
+ QuickStart::Core.load!
5
6
 
6
- PROG_PATH = File.join( LIBDIR, 'quick_start', 'quick_start.glade' )
7
- PROG_NAME = "QuickStart"
8
- qs = QuickStart::QuickStart2Glade.new(PROG_PATH, nil, PROG_NAME)
9
- qs.show
10
- Gtk.main
@@ -0,0 +1,48 @@
1
+ require 'pathname'
2
+ require 'fileutils'
3
+
4
+ module QuickStart
5
+
6
+ class Config
7
+
8
+ attr_reader :file
9
+
10
+ TEMPLATE_PATH = Pathname.new(File.join(File.dirname(__FILE__), 'templates', 'quick_start'))
11
+
12
+ def initialize(file)
13
+ @file = file
14
+ end
15
+
16
+ # firefox = /usr/bin/firefox
17
+ # gnome-terminal = /usr/bin/gnome-terminal, checked
18
+ # thunderbird = /usr/bin/mozilla-thunderbird, unchecked
19
+ def parse
20
+ readlines.each do |line|
21
+ next if line =~ /\s*#/
22
+ name, path_with_options = line.split('=', 2).map! { |arg| arg.strip }
23
+ path, comma_separated_options = path_with_options.split(',', 2).map! { |arg| arg.strip }
24
+ options = {}
25
+ comma_separated_options.split(',').each do |option|
26
+ options[option.to_sym] = true
27
+ end if comma_separated_options
28
+ executables << Executable.new(name, path, options)
29
+ end
30
+ end
31
+
32
+ def executables
33
+ @executables ||= []
34
+ end
35
+
36
+ def readlines
37
+ config = File.readable?(@file) ? @file : create_config!
38
+ return File.readlines(config)
39
+ end
40
+
41
+ def create_config!
42
+ FileUtils.cp(TEMPLATE_PATH, Core.config_path)
43
+ return Core.config_path
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,49 @@
1
+ module QuickStart
2
+
3
+ class QuickStartError < StandardError; end
4
+
5
+ class Core
6
+ class << self
7
+
8
+ def config_path
9
+ @config_path ||= File.join(root_config_path, config_filename)
10
+ end
11
+
12
+ def root_config_path
13
+ @root_config_path ||= ENV['HOME'] || raise(QuickStartError.new('$HOME environment variable must be set'))
14
+ end
15
+
16
+ def config_filename
17
+ @config_filename ||= ".quick_start".freeze
18
+ end
19
+
20
+ def glade_path
21
+ @glade_path ||= File.join(File.dirname( __FILE__ ), 'ui', 'quick_start.glade')
22
+ end
23
+
24
+ def title
25
+ @title ||= "QuickStart".freeze
26
+ end
27
+
28
+ def load!
29
+ gui = QuickStart2Glade.new(glade_path, nil, title)
30
+ gui.show
31
+ Gtk.main
32
+ end
33
+
34
+ def config
35
+ @config ||= load_config
36
+ end
37
+
38
+ protected
39
+ def load_config
40
+ config = Config.new(config_path)
41
+ config.parse
42
+ config
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,28 @@
1
+ module QuickStart
2
+ class Executable
3
+
4
+ attr_reader :name, :path, :options
5
+
6
+ def initialize(name, path, options = {})
7
+ @name = name
8
+ @path = path
9
+ @options = options
10
+ end
11
+
12
+ def checked
13
+ # FIXME
14
+ !options[:unchecked]
15
+ end
16
+
17
+ alias :checked? :checked
18
+
19
+ def checked=(value)
20
+ options[:checked] = value
21
+ end
22
+
23
+ def run
24
+ Runner.run(self)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ module QuickStart
2
+
3
+ class Runner
4
+
5
+ def self.run( executable )
6
+ $stderr.puts "running #{executable.name} #{executable.path}"
7
+ pid = Kernel.fork do
8
+ exec( executable.path )
9
+ end
10
+ Process.detach(pid)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,4 @@
1
+ #QuickStart configuration file
2
+ firefox = /usr/bin/firefox
3
+ mail = /usr/bin/mozilla-thunderbird, unchecked
4
+ gnome-terminal = /usr/bin/gnome-terminal
@@ -1,5 +1,3 @@
1
- require 'quick_start/program'
2
-
3
1
  module QuickStart
4
2
 
5
3
  class QuickStart2Glade
@@ -17,10 +15,10 @@ module QuickStart
17
15
  @window = glade['main_window']
18
16
 
19
17
  main_vbutton_box = Gtk::VButtonBox.new
20
- Program.map.each_pair do |name, path|
21
- main_vbutton_box.add( create_check_button( name.to_s ) )
22
- glade['box_config_programs_labels'].add( Gtk::Label.new( name.to_s ) )
23
- glade['box_config_programs_paths'].add( Gtk::Label.new( path ) )
18
+ Core.config.executables.each do |e|
19
+ main_vbutton_box.add( create_check_button( e ) )
20
+ glade['box_config_programs_labels'].add( Gtk::Label.new( e.name.to_s ) )
21
+ glade['box_config_programs_paths'].add( Gtk::Label.new( e.path ) )
24
22
  glade['box_config_programs_remove'].add( Gtk::Button.new( "Remove" ) )
25
23
  end
26
24
  glade['box_programs'].add( main_vbutton_box )
@@ -37,35 +35,37 @@ module QuickStart
37
35
  end
38
36
 
39
37
  def on_btn_run_clicked(widget)
40
- @selected_map.each_value do |program|
41
-
42
- if program[:active]
43
- show_status( "Running #{program[:name]}", program[:name] ) do
44
- Program.run( program[:name] )
45
- end
46
- end
38
+ Core.config.executables.each do |e|
39
+ next unless e.checked?
40
+ show_status( "Running #{e.name}", e.name ) do
41
+ e.run
42
+ end
47
43
  end
48
44
  Gtk.main_quit
49
45
  end
50
46
 
51
47
  protected
52
48
  def show_status( text, context, &block )
53
- status_bar=glade['status_bar']
49
+ status_bar = glade['status_bar']
54
50
  context = status_bar.get_context_id(context)
55
51
  status_bar.push( context, text )
56
52
  block.call
57
53
  status_bar.pop( context )
58
54
  end
59
55
 
60
- def create_check_button( name )
61
- button = Gtk::CheckButton.new( name.capitalize ).set_active( true ).set_name( "chb_#{name}" )
62
- @selected_map[button.name] = { :name => name, :active => true }
56
+ def create_check_button( executable )
57
+ button = Gtk::CheckButton.new( executable.name.capitalize ).set_active( executable.checked? ).set_name( "chb_#{executable.name}" )
63
58
  button.signal_connect('toggled') do |widget|
64
- @selected_map[widget.name][:active] = widget.active?
59
+ executable = Core.config.executables.detect { |e| e.name == widget_to_executable(widget) }
60
+ executable.checked = widget.active? if executable
65
61
  end
66
62
  button
67
63
  end
68
64
 
65
+ def widget_to_executable(widget)
66
+ widget.name.sub(/^chb_/, '')
67
+ end
68
+
69
69
  end
70
70
 
71
71
  end
data/lib/quick_start.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  require 'libglade2'
4
- require 'quick_start/quick_start_2_glade'
5
-
4
+ require 'quick_start/ui/quick_start_2_glade'
5
+ require 'quick_start/core'
6
+ require 'quick_start/runner'
7
+ require 'quick_start/executable'
8
+ require 'quick_start/config'
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{quick_start}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Micha\305\202 \305\201omnicki"]
12
+ s.date = %q{2010-02-19}
13
+ s.default_executable = %q{quick_start}
14
+ s.description = %q{GTK application used to quickly choose startup programs for current session}
15
+ s.email = %q{michal@lomnicki.com.pl}
16
+ s.executables = ["quick_start"]
17
+ s.extra_rdoc_files = [
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "MIT-LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/quick_start",
27
+ "lib/quick_start.rb",
28
+ "lib/quick_start/config.rb",
29
+ "lib/quick_start/core.rb",
30
+ "lib/quick_start/executable.rb",
31
+ "lib/quick_start/runner.rb",
32
+ "lib/quick_start/templates/quick_start",
33
+ "lib/quick_start/ui/quick_start.glade",
34
+ "lib/quick_start/ui/quick_start_2_glade.rb",
35
+ "quick_start.gemspec"
36
+ ]
37
+ s.homepage = %q{http://github.com/mlomnicki/quick_start}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{GTK application used to quickly choose startup programs for current session}
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ else
49
+ end
50
+ else
51
+ end
52
+ end
53
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_start
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Micha\xC5\x82 \xC5\x81omnicki"
@@ -9,27 +9,34 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-12 00:00:00 +02:00
12
+ date: 2010-02-19 00:00:00 +01:00
13
13
  default_executable: quick_start
14
14
  dependencies: []
15
15
 
16
- description:
16
+ description: GTK application used to quickly choose startup programs for current session
17
17
  email: michal@lomnicki.com.pl
18
18
  executables:
19
19
  - quick_start
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - MIT-LICENSE
24
23
  - README.rdoc
25
24
  files:
26
- - README.rdoc
25
+ - .gitignore
27
26
  - MIT-LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION
28
30
  - bin/quick_start
29
- - lib/quick_start/quick_start_2_glade.rb
30
- - lib/quick_start/quick_start.glade
31
- - lib/quick_start/program.rb
32
31
  - lib/quick_start.rb
32
+ - lib/quick_start/config.rb
33
+ - lib/quick_start/core.rb
34
+ - lib/quick_start/executable.rb
35
+ - lib/quick_start/runner.rb
36
+ - lib/quick_start/templates/quick_start
37
+ - lib/quick_start/ui/quick_start.glade
38
+ - lib/quick_start/ui/quick_start_2_glade.rb
39
+ - quick_start.gemspec
33
40
  has_rdoc: true
34
41
  homepage: http://github.com/mlomnicki/quick_start
35
42
  licenses: []
@@ -56,7 +63,7 @@ requirements: []
56
63
  rubyforge_project:
57
64
  rubygems_version: 1.3.5
58
65
  signing_key:
59
- specification_version: 2
60
- summary: Simple tool which runs chosen programs on startup
66
+ specification_version: 3
67
+ summary: GTK application used to quickly choose startup programs for current session
61
68
  test_files: []
62
69
 
@@ -1,29 +0,0 @@
1
- module QuickStart
2
-
3
- class Program
4
- @@map = {
5
- :firefox => '/usr/bin/firefox',
6
- :evolution => '/usr/bin/evolution',
7
- :skype => '/usr/bin/skype',
8
- :terminal => '/usr/bin/gnome-terminal'
9
- }
10
-
11
- class << self
12
-
13
- def map
14
- @@map
15
- end
16
-
17
- def run( name )
18
- puts "running #{name} #{@@map[name.to_sym]}"
19
- pid = Kernel.fork do
20
- exec( @@map[name.to_sym] )
21
- end
22
- Process.detach(pid)
23
- end
24
-
25
- end
26
-
27
- end
28
-
29
- end