The Gnome Chemistry Utils
0.14.0
|
#include <gcu/application.h>
Public Member Functions | |
Application (std::string name, std::string datadir=DATADIR, char const *help_name=NULL, char const *icon_name=NULL, CmdContext *cc=NULL) | |
virtual | ~Application () |
void | OnHelp (std::string s="") |
bool | HasHelp () |
std::string const & | GetName () const |
virtual GtkWindow * | GetWindow () |
virtual bool | FileProcess (G_GNUC_UNUSED const gchar *filename, G_GNUC_UNUSED const gchar *mime_type, G_GNUC_UNUSED bool bSave, G_GNUC_UNUSED GtkWindow *window, G_GNUC_UNUSED Document *pDoc=NULL) |
char const * | GetCurDir () |
void | SetCurDir (char const *dir) |
void | SetCurDir (std::string const &dir) |
std::map< std::string, GdkPixbufFormat * > & | GetSupportedPixbufFormats () |
char const * | GetPixbufTypeName (std::string &filename, char const *mime_type) |
ContentType | Load (std::string const &uri, const char *mime_type, Document *Doc, const char *options=NULL) |
ContentType | Load (GsfInput *input, const char *mime_type, Document *Doc, const char *options=NULL) |
bool | Save (std::string const &uri, const char *mime_type, Object const *Obj, ContentType type, const char *options=NULL) |
bool | Save (GsfOutput *output, const char *mime_type, Object const *Obj, ContentType type, const char *options=NULL) |
virtual Document * | CreateNewDocument () |
std::string const & | GetIconName () |
void | RegisterOptions (GOptionEntry const *entries, char const *translation_domain=GETTEXT_PACKAGE) |
void | AddOptions (GOptionContext *context) |
TypeId | AddType (std::string TypeName, Object *(*CreateFunc)(), TypeId id=OtherType) |
Object * | CreateObject (const std::string &TypeName, Object *parent=NULL) |
void | AddRule (TypeId type1, RuleId rule, TypeId type2) |
void | AddRule (const std::string &type1, RuleId rule, const std::string &type2) |
const std::set< TypeId > & | GetRules (TypeId type, RuleId rule) |
const std::set< TypeId > & | GetRules (const std::string &type, RuleId rule) |
void | SetCreationLabel (TypeId Id, std::string Label) |
const std::string & | GetCreationLabel (TypeId Id) |
bool | BuildObjectContextualMenu (Object *target, UIManager *uim, Object *object, double x, double y) |
void | AddMenuCallback (TypeId Id, BuildMenuCb cb) |
const std::string & | GetCreationLabel (const std::string &TypeName) |
CmdContext * | GetCmdContext () |
char * | ConvertToCML (std::string const &uri, const char *mime_type, const char *options=NULL) |
char * | ConvertToCML (GsfInput *input, const char *mime_type, const char *options=NULL) |
void | ConvertFromCML (const char *cml, std::string const &uri, const char *mime_type, const char *options=NULL) |
void | ConvertFromCML (const char *cml, GsfOutput *output, const char *mime_type, const char *options=NULL) |
std::list< Database > const & | GetDatabases (char const *classname) |
std::set< Document * > | GetDocs (void) |
unsigned | GetScreenResolution (void) |
void | SetImageResolution (unsigned val) |
unsigned | GetImageResolution (void) const |
unsigned & | GetRefImageResolution (void) |
void | SetImageWidth (unsigned val) |
unsigned | GetImageWidth (void) const |
unsigned & | GetRefImageWidth (void) |
void | SetImageHeight (unsigned val) |
unsigned | GetImageHeight (void) const |
unsigned & | GetRefImageHeight (void) |
void | SetTransparentBackground (bool val) |
bool | GetTransparentBackground (void) const |
bool & | GetRefTransparentBackground (void) |
Public Member Functions inherited from gcu::DialogOwner | |
DialogOwner () | |
virtual | ~DialogOwner () |
Dialog * | GetDialog (std::string name) const |
void | ClearDialogs () |
Static Public Member Functions | |
static GOConfNode * | GetConfDir () |
static Application * | GetDefaultApplication () |
static Application * | GetApplication (char const *name) |
static Application * | GetApplication (std::string &name) |
Protected Member Functions | |
void | RegisterBabelType (const char *mime_type, const char *type) |
virtual void | CreateDefaultCmdContext () |
virtual bool | LoopRunning () |
virtual void | NoMoreDocsEvent () |
Protected Attributes | |
std::map< std::string, GdkPixbufFormat * > | m_SupportedPixbufFormats |
CmdContext * | m_CmdContext |
std::set< Document * > | m_Docs |
This class is a base class for applications. It provides some basic services.
Definition at line 57 of file gcu/application.h.
gcu::Application::Application | ( | std::string | name, |
std::string | datadir = DATADIR , |
||
char const * | help_name = NULL , |
||
char const * | icon_name = NULL , |
||
CmdContext * | cc = NULL |
||
) |
name | the name of the application. |
datadir | where data for the application are stored. |
help_name | the name to use for the help file (with .xml extension). If NULL, the name parameter is used. |
icon_name | the name to use for the default icon of all windows. If NULL, the help_name or name parameters will be used. |
cc | the gcu::CmdContext to use to diaplay the error messages, if NULL, the default one will be used if it exists. |
The datadir variable is used to build the full path to the help file: "file://"+datadir+"/gnome/help/"+name+"/"+LANG+"/"+name".xml".
|
virtual |
The destructor.
Reimplemented in gcp::Application, gcugtk::Application, and gcr::Application.
void gcu::Application::AddMenuCallback | ( | TypeId | Id, |
BuildMenuCb | cb | ||
) |
Id | the TypeId of the Object derived class |
cb | the BuildMenuCb callback to call when building the menu. |
adds a callback for modifying the contextual menu of objects of type Id.
void gcu::Application::AddOptions | ( | GOptionContext * | context | ) |
context,: | a GOptionContext |
Adds all registered options to the context. This should be called once just after creating the application and before parsing options.
type1 | the TypeId of the first class in the rule |
rule | the new rule value |
type2 | the TypeId of the second class in the rule |
Adds a rule.
void gcu::Application::AddRule | ( | const std::string & | type1, |
RuleId | rule, | ||
const std::string & | type2 | ||
) |
type1 | the name of the first class in the rule |
rule | the new rule value |
type2 | the name of the second class in the rule |
Adds a rule.
TypeId gcu::Application::AddType | ( | std::string | TypeName, |
Object *(*)() | CreateFunc, | ||
TypeId | id = OtherType |
||
) |
TypeName | the name of the new type. |
CreateFunc | a pointer to a function returning a pointer to a new object of the new type. |
id | the Id of the type to create if a standard one or OtherType for a new type. In this last case, this parameter can be omitted. |
This method is used to register a new type derived from Object.
bool gcu::Application::BuildObjectContextualMenu | ( | Object * | target, |
UIManager * | uim, | ||
Object * | object, | ||
double | x, | ||
double | y | ||
) |
target | a gcu::Object. |
uim | the UIManager to populate. |
object | the Object on which occured the mouse click. |
x | x coordinate of the mouse click. |
y | y coordinate of the mouse click. |
This method is called to build a contextual menu for the target. It is called by Object::BuildContextualMenu, so it should not be necessary to call it directly.
void gcu::Application::ConvertFromCML | ( | const char * | cml, |
std::string const & | uri, | ||
const char * | mime_type, | ||
const char * | options = NULL |
||
) |
cml | the CML string to convert. |
uri | the uri of the document to which the document will be saved. |
mime_type | the mime type of the document. |
options | options to pass to OpenBabel. |
This method converts CML to a target.
void gcu::Application::ConvertFromCML | ( | const char * | cml, |
GsfOutput * | output, | ||
const char * | mime_type, | ||
const char * | options = NULL |
||
) |
cml | the CML string to convert. |
output | a target GsfOutput. |
mime_type | the mime type of the document. |
options | options to pass to OpenBabel. |
This method converts CML to a target.
char* gcu::Application::ConvertToCML | ( | std::string const & | uri, |
const char * | mime_type, | ||
const char * | options = NULL |
||
) |
uri | the source to convert to CML. |
mime_type | the mime type of the document. |
options | options to pass to OpenBabel. |
This method converts the source to CML.
char* gcu::Application::ConvertToCML | ( | GsfInput * | input, |
const char * | mime_type, | ||
const char * | options = NULL |
||
) |
input | a source GsfInput. |
mime_type | the mime type of the document. |
options | options to pass to OpenBabel. |
This method converts the source to CML.
|
inlineprotectedvirtual |
Creates the default gcu::CmdContext for the application. This method must be overriden by derived classes since the default implementation does nothing.
Reimplemented in gcugtk::Application.
Definition at line 426 of file gcu/application.h.
|
inlinevirtual |
Virtual method used to create documents. Default behavior does nothing and returns NULL.
Reimplemented in gcp::Application.
Definition at line 209 of file gcu/application.h.
TypeName | the name of the new type. |
parent | the parent of the newly created object or NULL. if NULL, the parameter can be omitted. |
Used to create an object of type name TypeName. The AddType() method must have been called with the same TypeName parameter. if parent is given and not NULL, the new Object will be a child of parent. It will also be given a default Id.
|
inlinevirtual |
filename | the uri of the file. |
mime_type | the mime type of the file if known. |
bSave | true if saving, and false if loading. |
window | the current top level window. |
pDoc | an optional document. |
Called by the FileChooser when a file name has been selected. This method does nothing in the parent class and must be implemented in children classes if they use the FileChooser.
Definition at line 117 of file gcu/application.h.
|
static |
name,: | aa Application name |
|
static |
name,: | aa Application name |
CmdContext* gcu::Application::GetCmdContext | ( | ) |
|
static |
Method used to retrieve the base configuration node.
const std::string& gcu::Application::GetCreationLabel | ( | TypeId | Id | ) |
Id | the TypeId of a class |
const std::string& gcu::Application::GetCreationLabel | ( | const std::string & | TypeName | ) |
TypeName | the name of a class |
|
inline |
Definition at line 123 of file gcu/application.h.
|
inline |
classname | the name of a class such as "Molecule". |
Definition at line 410 of file gcu/application.h.
|
static |
|
inline |
Definition at line 475 of file gcu/application.h.
|
inline |
Retrieves the icon name that should be set to every window owned by the application.
Definition at line 221 of file gcu/application.h.
|
inline |
Definition at line 521 of file gcu/application.h.
|
inline |
Definition at line 493 of file gcu/application.h.
|
inline |
Definition at line 507 of file gcu/application.h.
|
inline |
Definition at line 97 of file gcu/application.h.
char const* gcu::Application::GetPixbufTypeName | ( | std::string & | filename, |
char const * | mime_type | ||
) |
filename | the file name. |
mime_type | the file mime type. |
A default extension is appended to filename if none is detected.
|
inline |
Definition at line 521 of file gcu/application.h.
|
inline |
Definition at line 493 of file gcu/application.h.
|
inline |
Definition at line 507 of file gcu/application.h.
|
inline |
Definition at line 533 of file gcu/application.h.
type | the TypeId of a class |
rule | a RuleId value |
type | the name of a class |
rule | a RuleId value |
|
inline |
Definition at line 479 of file gcu/application.h.
|
inline |
Definition at line 138 of file gcu/application.h.
References m_SupportedPixbufFormats.
|
inline |
Definition at line 533 of file gcu/application.h.
|
inlinevirtual |
Reimplemented in gcp::Application.
Definition at line 102 of file gcu/application.h.
bool gcu::Application::HasHelp | ( | ) |
ContentType gcu::Application::Load | ( | std::string const & | uri, |
const char * | mime_type, | ||
Document * | Doc, | ||
const char * | options = NULL |
||
) |
uri | the uri of the document to load. |
mime_type | the mime type of the document. |
Doc | the document instance which will contain the loaded data. |
options | an option string to pass to the parser or to OpenBabel when using it to convert to CML. |
This method loads a document using the appropriate gcu::Loader class instance.
ContentType gcu::Application::Load | ( | GsfInput * | input, |
const char * | mime_type, | ||
Document * | Doc, | ||
const char * | options = NULL |
||
) |
input | a GsfInput. |
mime_type | the mime type of the document. |
Doc | the document instance which will contain the loaded data. |
options | an option string to pass to the parser or to OpenBabel when using it to convert to CML. |
This method loads a document using the appropriate gcu::Loader class instance.
|
inlineprotectedvirtual |
Reimplemented in gcugtk::Application.
Definition at line 432 of file gcu/application.h.
|
inlineprotectedvirtual |
This method is called by the framework when all the documents have been removed from the set of opened documents. The default behavior is to do nothing Derived class might overide this method to change this.
Reimplemented in gcugtk::Application.
Definition at line 439 of file gcu/application.h.
void gcu::Application::OnHelp | ( | std::string | s = "" | ) |
s | an optional tag in the help file. Displays the help file using the file browser retrieved from GConf using the "/desktop/gnome/applications/help_viewer/exec" key. If a tag is given, it will be added to the help uri. For an application named "myapp" and a tag "mytag", the uri will be: helpfilename#myapp-mytag. |
|
protected |
mime_type | a mime type. |
type | the OpenBabel type string associated with mime_type. |
Registers the new file type so that it can be opened by the application. Actually, these files are translated to CML by OpenBabel and then loaded from CML.
void gcu::Application::RegisterOptions | ( | GOptionEntry const * | entries, |
char const * | translation_domain = GETTEXT_PACKAGE |
||
) |
entries,: | the entries to register. |
translation_domain,: | the entries to register. |
Adds new command line options. Typically called from a plugin. The new options are added to the main group.
bool gcu::Application::Save | ( | std::string const & | uri, |
const char * | mime_type, | ||
Object const * | Obj, | ||
ContentType | type, | ||
const char * | options = NULL |
||
) |
uri | the uri to which the document should be saved. |
mime_type | the mime type of the document. |
Obj | the object instance which contains the data to be saved. |
type | the type of the data to be saved (see gcu::ContentType). |
options | an option string to pass to the parser or to OpenBabel when using it to convert from CML. |
This method saves the document using the appropriate gcu::Loader class instance.
bool gcu::Application::Save | ( | GsfOutput * | output, |
const char * | mime_type, | ||
Object const * | Obj, | ||
ContentType | type, | ||
const char * | options = NULL |
||
) |
output | a GsfOutput. |
mime_type | the mime type of the document. |
Obj | the object instance which contains the data to be saved. |
type | the type of the data to be saved (see gcu::ContentType). |
options | an option string to pass to the parser or to OpenBabel when using it to convert from CML. |
This method saves the document using the appropriate gcu::Loader class instance using output as target.
void gcu::Application::SetCreationLabel | ( | TypeId | Id, |
std::string | Label | ||
) |
Id | the TypeId of a class |
Label | the string to display in a contextual menu |
Used to give a label for contextual menus used when the creation of an instance of the class seems possible.
void gcu::Application::SetCurDir | ( | char const * | dir | ) |
dir | the path to the new current directory. |
void gcu::Application::SetCurDir | ( | std::string const & | dir | ) |
dir | the path to the new current directory. |
|
inline |
Height | the new image height. |
Sets the image height used when exporting a pixmap. Applications can use either the image resolution or the width and height to select an exported image size, but not both.
Definition at line 521 of file gcu/application.h.
|
inline |
ImageResolution | the new image resolution. |
Sets the image resolution used when exporting a pixmap. Applications can use either the image resolution or the width and height to select an exported image size, but not both.
Definition at line 493 of file gcu/application.h.
|
inline |
Width | the new image width. |
Sets the image width used when exporting a pixmap. Applications can use either the image resolution or the width and height to select an exported image size, but not both.
Definition at line 507 of file gcu/application.h.
|
inline |
transparent | whether an export image should have a transparent background. |
Sets the transparency of the exported image when possible.
Definition at line 533 of file gcu/application.h.
|
protected |
The CmdContext used to display messages, might be NULL.
Definition at line 448 of file gcu/application.h.
|
protected |
The currently opened documents.
Definition at line 475 of file gcu/application.h.
Referenced by gcp::Application::GetDocsNumber().
|
protected |
std::map of the supported pixbuf formats. Keys are the mime type names.
Definition at line 443 of file gcu/application.h.
Referenced by GetSupportedPixbufFormats().