Class: Ruber::Application
- Inherits:
-
KDE::Application
- Object
- KDE::Application
- Ruber::Application
- Includes:
- PluginLike
- Defined in:
- lib/ruber/application/application.rb
Defined Under Namespace
Classes: DefaultDocumentExtension
Constant Summary collapse
- DEFAULT_PLUGIN_PATHS =
The default paths where to look for plugins.
It includes @$KDEHOME/share/apps/ruber/plugins@ and the @plugins@ subdirectory of the ruber installation directory
[ File.join(KDE::Global.dirs.find_dirs( 'data', '')[0], File.join('ruber','plugins')), RUBER_PLUGIN_DIR ]
- DEFAULT_PLUGINS =
The default plugins to load
Currently, they are: ruby_development, find_in_files, syntax_checker, command and state
%w[ruby_development find_in_files rake command syntax_checker state auto_end project_browser]
Instance Attribute Summary collapse
-
#cmd_line_options ⇒ Hash
readonly
The command line options passed to ruber (after they’ve been processed).
-
#status ⇒ Symbol
readonly
<<<<<<< HEAD ======= The state Ruber is in.
Attributes included from PluginLike
Instance Method Summary collapse
-
#initialize(manager, psf) ⇒ Application
constructor
Creates a new instance of Application.
-
#plugin_directories ⇒ Array<String>
(also: #plugin_dirs)
A list of the directories where Ruber looks for plugins.
-
#plugin_directories=(dirs) ⇒ Object
(also: #plugin_dirs=)
Sets the list of directories where Ruber looks for plugins.
-
#quit_ruber ⇒ nil
Quits ruber.
-
#quitting? ⇒ Boolean
Whether the application is quitting or not.
-
#running? ⇒ Boolean
Whether the application is running or not.
-
#safe_load_plugins(plugins, silent = false, dirs = nil) {|pso, ex| ... } ⇒ Boolen
Loads plugins handling the exceptions they may raise in the meanwhile.
-
#starting? ⇒ Boolean
Whether the application is starting or has already started.
Methods included from PluginLike
#add_extensions_to_project, #add_options_to_project, #add_widgets_to_project, #plugin_name, #query_close, #register_with_project, #remove_extensions_from_project, #remove_from_project, #remove_options_from_project, #remove_widgets_from_project, #restore_session, #save_settings, #session_data, #shutdown, #unload, #update_project
Methods inherited from KDE::Application
with_override_cursor, #with_override_cursor
Constructor Details
#initialize(manager, psf) ⇒ Application
Creates a new instance of Ruber::Application
It loads the core components and sets up a single shot timer which calls #setup and is fired as soon as the event loop starts.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ruber/application/application.rb', line 105 def initialize manager, psf super() @components = manager @components.parent = self Ruber.instance_variable_set :@components, @components initialize_plugin psf KDE::Global.dirs.addPrefix File.(File.join( RUBER_DATA_DIR, '..', 'data')) icon_path = KDE::Global.dirs.find_resource('icon', 'ruber') self.window_icon = Qt::Icon.new icon_path KDE::Global.main_component.about_data.program_icon_name = icon_path @cmd_line_options = KDE::CmdLineArgs.parsed_args @plugin_dirs = [] load_core_components @status = :starting Qt::Timer.single_shot(0, self, SLOT(:setup)) end |
Instance Attribute Details
#cmd_line_options ⇒ Hash (readonly)
Returns the command line options passed to ruber (after they’ve been processed).
74 75 76 |
# File 'lib/ruber/application/application.rb', line 74 def @cmd_line_options end |
#status ⇒ Symbol (readonly)
<<<<<<< HEAD
The state Ruber is in
Ruber can be in three states:
-
starting:= from the time it’s launched to when #setup returns
-
running:= from after #setup has returend to when the user chooses to quit it (either with the @File/Quit@ menu entry or clicking on the button on the title bar)
-
quitting:= from when the user chooses to quit Ruber onwards
>>>>>>> master
93 94 95 |
# File 'lib/ruber/application/application.rb', line 93 def status @status end |
Instance Method Details
#plugin_directories ⇒ Array<String> Also known as: plugin_dirs
Returns a list of the directories where Ruber looks for plugins.
125 126 127 |
# File 'lib/ruber/application/application.rb', line 125 def plugin_directories @plugin_dirs.dup end |
#plugin_directories=(dirs) ⇒ Object Also known as: plugin_dirs=
Sets the list of directories where Ruber looks for plugins
This also changes the setting in the global configuration object, but it *doesn’t* write the change to file. It’s up to whoever called this method to do so.
138 139 140 141 |
# File 'lib/ruber/application/application.rb', line 138 def plugin_directories= dirs @plugin_directories = dirs Ruber[:config][:general, :plugin_dirs] = @plugin_directories end |
#quit_ruber ⇒ nil
Quits ruber
Sets the application status to @:quitting@ and calls ComponentManager#shutdown
150 151 152 153 154 |
# File 'lib/ruber/application/application.rb', line 150 def quit_ruber @status = :quitting @components.shutdown nil end |
#quitting? ⇒ Boolean
Whether the application is quitting or not
otherwise
189 190 191 |
# File 'lib/ruber/application/application.rb', line 189 def quitting? @status == :quitting end |
#running? ⇒ Boolean
Whether the application is running or not
otherwise
178 179 180 |
# File 'lib/ruber/application/application.rb', line 178 def running? @status == :running end |
#safe_load_plugins(plugins, silent = false, dirs = nil) {|pso, ex| ... } ⇒ Boolen
Loads plugins handling the exceptions they may raise in the meanwhile
It is a wrapper around ComponentManager#load_plugins.
If it’s given a block, it simply calls ComponentManager#load_plugins passing it the block.
If no block is given, the behaviour in case of an exception depends on the silent argument:
-
if true, then the error will be silently ignored and the component manager will go on loading the remaining plugins. Errors caused by those will be ignored as well
-
if false, the user will be shown a ComponentLoadingErrorDialog. According to what the user chooses in the dialog, the component manager will behave in a different way, as described in ComponentManager#load_plugins
Note: this method doesn’t attempt to handle exceptions raised while computing or sorting dependencies.
226 227 228 229 230 231 232 233 |
# File 'lib/ruber/application/application.rb', line 226 def safe_load_plugins plugins, silent = false, dirs = nil, &blk if blk.nil? and silent then blk = proc{|_pl, _e| :silent} elsif blk.nil? blk = Proc.new{|pl, e| ComponentLoadingErrorDialog.new(pl.name, e, nil).exec} end @components.load_plugins plugins, dirs || @plugin_dirs, &blk end |
#starting? ⇒ Boolean
Whether the application is starting or has already started
You should seldom need this method. It’s mostly useful for plugins which need to erform different actions depending on whether they’re loaded at application startup (in which case it’ll return true) or later (when it’ll return false)
167 168 169 |
# File 'lib/ruber/application/application.rb', line 167 def starting? @status == :starting end |