Class: Ruby_do
- Inherits:
-
Object
- Object
- Ruby_do
- Defined in:
- lib/ruby_do.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#ob ⇒ Object
readonly
Returns the value of attribute ob.
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
Autoloader for subclasses.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Ruby_do
constructor
A new instance of Ruby_do.
-
#join ⇒ Object
Joins the Gtk-main-loop.
-
#show_win_main ⇒ Object
Shows the main window.
-
#show_win_properties ⇒ Object
Opens the properties-window or focuses it if it is already open.
Constructor Details
#initialize(args = {}) ⇒ Ruby_do
Returns a new instance of Ruby_do.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ruby_do.rb', line 10 def initialize(args = {}) #Require various used libs. require "rubygems" #Enable local dev-mode. if File.exists?("#{File.dirname(__FILE__)}/../../knjrbfw") require "#{File.dirname(__FILE__)}/../../knjrbfw/lib/knjrbfw.rb" else require "knjrbfw" end if File.exists?("#{File.dirname(__FILE__)}/../../threadded_enumerator") require "#{File.dirname(__FILE__)}/../../threadded_enumerator/lib/threadded_enumerator.rb" else require "threadded_enumerator" end #Set arguments (config). homedir = Knj::Os.homedir path = "#{homedir}/.ruby_do" Dir.mkdir(path) if !File.exists?(path) @args = { :sock_path => "#{path}/sock", :db_path => "#{path}/database.sqlite3", :run_path => "#{path}/run" }.merge(args) #Checks if the run-file exists and creates it if not. if File.exists?(@args[:run_path]) pid = File.read(@args[:run_path]).to_i procs = Knj::Unix_proc.list("pids" => [pid]) if !procs.empty? puts "Ruby-Do is already running. Trying to show main window..." require "socket" UNIXSocket.open(@args[:sock_path]) do |sock| sock.puts "show_win_main" end exit #raise sprintf(_("Ruby-Do is already running with PID '%s'."), pid) end end File.open(@args[:run_path], "w") do |fp| fp.write(Process.pid) end #Require the rest of the heavy libs. require "gtk2" require "gettext" require "sqlite3" #Load database. @db = Knj::Db.new( :type => "sqlite3", :path => @args[:db_path], :return_keys => "symbols", :index_append_table_name => true ) #Update database structure. Knj::Db::Revision.new.init_db("db" => @db, "schema" => Ruby_do::Database::SCHEMA) #Object framework. @ob = Knj::Objects.new( :datarow => true, :class_path => "#{File.dirname(__FILE__)}/../models", :class_pre => "", :db => @db, :module => Ruby_do::Models ) #Start options-module. Knj::Opts.init("knjdb" => @db, "table" => "Option") #Start unix-socket to enable custom shortcuts. @unix_socket = Ruby_do::Unix_socket.new(:rdo => self) #Start plugins-engine. @plugin = Ruby_do::Plugin.new(:rdo => self) @plugin.register_plugins #Show main window if it is not set to be skipped. val = Knj::Opts.get("skip_main_on_startup").to_i if val != 1 self.show_win_main end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/ruby_do.rb', line 8 def args @args end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
8 9 10 |
# File 'lib/ruby_do.rb', line 8 def db @db end |
#ob ⇒ Object (readonly)
Returns the value of attribute ob.
8 9 10 |
# File 'lib/ruby_do.rb', line 8 def ob @ob end |
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
8 9 10 |
# File 'lib/ruby_do.rb', line 8 def plugin @plugin end |
Class Method Details
.const_missing(name) ⇒ Object
Autoloader for subclasses.
3 4 5 6 |
# File 'lib/ruby_do.rb', line 3 def self.const_missing(name) require "#{File.dirname(__FILE__)}/../include/#{name.to_s.downcase}.rb" return self.const_get(name) end |
Instance Method Details
#join ⇒ Object
Joins the Gtk-main-loop.
129 130 131 |
# File 'lib/ruby_do.rb', line 129 def join Gtk.main end |
#show_win_main ⇒ Object
Shows the main window. If already shown then tries to give it focus.
113 114 115 116 117 118 119 |
# File 'lib/ruby_do.rb', line 113 def show_win_main if !@win_main @win_main = Ruby_do::Gui::Win_main.new(:rdo => self) end @win_main.show end |
#show_win_properties ⇒ Object
Opens the properties-window or focuses it if it is already open.
122 123 124 125 126 |
# File 'lib/ruby_do.rb', line 122 def show_win_properties Knj::Gtk2::Window.unique!("preferences") do Ruby_do::Gui::Win_properties.new(:rdo => self) end end |