Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
config_editor_plugin.cpp
1
2
/***************************************************************************
3
* config_editor_plugin.cpp - Base class for config editor plugins
4
*
5
* Created: Sun Mar 29 13:26:56 2009
6
* Copyright 2009 Daniel Beck
7
*
8
****************************************************************************/
9
10
/* This program 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
* This program 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 Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "config_editor_plugin.h"
24
25
using namespace
std;
26
using namespace
fawkes;
27
28
/** @class ConfigEditorPlugin tools/config_editor/config_editor_plugin.h
29
* Base class for plugins for the Fawkes config editor. A plugin
30
* allows to manipulate a certain part of the configuration, most
31
* often this is intended to be the config options for a Fawkes
32
* plugin.
33
* @author Daniel Beck
34
*/
35
36
/** @fn void ConfigEditorPlugin::pre_run()
37
* Config editor plugins need to implement this function. It is called
38
* before the actual dialog is opened. Ususally, plugins want to parse
39
* the configuration, here, and initialize the GUI elements of the
40
* dialog.
41
*/
42
43
/** @fn void ConfigEditorPlugin::post_run( int response )
44
* This method is called after the dialog is closed. Here, the input
45
* the user has made needs to be handled.
46
* @param response the response obtained from the run() method of the
47
* dialog (Gtk::RESPONSE_OK or Gtk::RESPONSE_CANCEL)
48
*/
49
50
/** @fn Gtk::Dialog* ConfigEditorPlugin::load_dialog()
51
* In this function the (custom) dialog of the plugin needs to be
52
* initialized.
53
* @return pointer to the loaded dialog
54
*/
55
56
/** @var ConfigEditorPlugin::m_dialog
57
* The (main-) dialog of the plugin.
58
*/
59
60
/** @var ConfigEditorPlugin::m_builder
61
* Gtk Builder created from the UI file of the plugin.
62
*/
63
64
/** @var ConfigEditorPlugin:: m_config
65
* The fawkes::Configuration.
66
*/
67
68
/** @var ConfigEditorPlugin::m_config_path
69
* The config prefix the plugin is attached to.
70
*/
71
72
/** Constructor.
73
* @param config_path the prefix of the part that can be configured
74
* with this plugin
75
* @param ui_file a Gtk Builder file which contains the definition the
76
* plugin's GUI components
77
*/
78
ConfigEditorPlugin::ConfigEditorPlugin
(
string
config_path,
string
ui_file)
79
{
80
m_config_path = config_path;
81
m_builder = Gtk::Builder::create_from_file(ui_file);
82
}
83
84
/** Destructor. */
85
ConfigEditorPlugin::~ConfigEditorPlugin
()
86
{
87
}
88
89
/** Get the config prefix specified for this config editor plugin.
90
* @return the config prefix
91
*/
92
std::string
93
ConfigEditorPlugin::get_config_path
()
const
94
{
95
return
m_config_path;
96
}
97
98
/** Set the configuration for the plugin to work on.
99
* @param config the configuration
100
*/
101
void
102
ConfigEditorPlugin::set_config
(
fawkes::Configuration
* config )
103
{
104
m_config = config;
105
}
106
107
/** Initialize the plugin.
108
* This method needs to be called before the plugin can be used.
109
*/
110
void
111
ConfigEditorPlugin::initialize
()
112
{
113
m_dialog = load_dialog();
114
}
115
116
/** Run the plugin.
117
* Usually, this means opening a dialog where config values can be
118
* manipulated and on closing these are written to the config.
119
*/
120
void
121
ConfigEditorPlugin::run
()
122
{
123
pre_run();
124
int
response = m_dialog->run();
125
post_run( response );
126
m_dialog->hide();
127
}
src
tools
config_editor
config_editor_plugin.cpp
Generated by
1.8.3.1