The Gnome Chemistry Utils  0.14.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
gcp::Application Class Reference

GChemPaint application base class. More...

#include <gcp/application.h>

Inheritance diagram for gcp::Application:
gcugtk::Application gcu::Application gcu::DialogOwner

Public Member Functions

 Application (gcugtk::CmdContextGtk *cc=NULL)
virtual ~Application ()
void ActivateTool (const std::string &toolname, bool activate)
void ActivateWindowsActionWidget (const char *path, bool activate)
virtual void ClearStatus ()
virtual void SetStatusText (const char *text)
virtual GtkWindow * GetWindow ()=0
ToolGetActiveTool ()
gcp::DocumentGetActiveDocument ()
void SetActiveDocument (gcp::Document *pDoc)
ToolGetTool (const std::string &name)
void SetTool (const std::string &toolname, Tool *tool)
GtkWidget * GetToolItem (const std::string &name)
void SetToolItem (const std::string &name, GtkWidget *w)
void SetCurZ (int Z)
int GetCurZ ()
void OnSaveAs ()
bool FileProcess (const gchar *filename, const gchar *mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc=NULL)
void SaveGcp (std::string const &filename, gcp::Document *pDoc)
void OpenGcp (std::string const &filename, gcp::Document *pDoc)
xmlDocPtr GetXmlDoc ()
void OnSaveAsImage ()
bool HaveInChI ()
int GetDocsNumber ()
void Zoom (double zoom)
void AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons)
void RegisterToolbar (char const *name, int index)
void OnToolChanged (GtkAction *current)
void AddTarget (Target *target)
void DeleteTarget (Target *target)
void NotifyIconification (bool iconified)
void NotifyFocus (bool has_focus, Target *target=NULL)
void CloseAll ()
std::list< std::string > & GetSupportedMimeTypes ()
void OnConfigChanged (GOConfNode *node, gchar const *name)
std::list< std::string > & GetExtensions (std::string &mime_type)
void OnThemeNamesChanged ()
void AddMenuCallback (BuildMenuCb cb)
void BuildMenu (gcu::UIManager *manager)
gcu::DocumentCreateNewDocument ()
virtual void OnFileNew (char const *Theme=NULL)=0
GdkCursor * GetCursor (CursorId id)
bool Have3DSupport ()
void AddCanvas (char const *path, gccv::Canvas *canvas)
void ReceiveTargets (GtkClipboard *clipboard, GtkSelectionData *selection_data)
bool GetHaveGhemical (void) const
bool GetHaveGChem3D (void) const
bool GetHaveAvogadro (void) const
bool GetUseAtomColors (void) const
- Public Member Functions inherited from gcugtk::Application
 Application (std::string name, std::string datadir=DATADIR, char const *help_name=NULL, char const *icon_name=NULL, CmdContextGtk *cc=NULL)
GtkWidget * GetImageResolutionWidget ()
GtkWidget * GetImageSizeWidget ()
virtual void ReceiveTargets (G_GNUC_UNUSED GtkClipboard *clipboard, G_GNUC_UNUSED GtkSelectionData *selection_data)
void ShowURI (GdkScreen *screen, std::string &uri)
void OnBug (GdkScreen *screen, char const *uri=PACKAGE_BUGREPORT)
void OnWeb (GdkScreen *screen, char const *uri="http://gchemutils.nongnu.org/")
void OnMail (GdkScreen *screen, char const *MailAddress="mailto:gchemutils-main@nongnu.org")
void OnLiveAssistance (GdkScreen *screen)
GtkRecentManager * GetRecentManager (void) const
- Public Member Functions inherited from gcu::Application
 Application (std::string name, std::string datadir=DATADIR, char const *help_name=NULL, char const *icon_name=NULL, CmdContext *cc=NULL)
void OnHelp (std::string s="")
bool HasHelp ()
std::string const & GetName () const
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)
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)
ObjectCreateObject (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)
CmdContextGetCmdContext ()
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 ()
DialogGetDialog (std::string name) const
void ClearDialogs ()

Protected Member Functions

void InitTools ()
void BuildTools () throw (std::runtime_error)
void ShowTools (bool visible)
- Protected Member Functions inherited from gcugtk::Application
virtual void NoMoreDocsEvent ()
void CreateDefaultCmdContext ()
bool LoopRunning ()
- Protected Member Functions inherited from gcu::Application
void RegisterBabelType (const char *mime_type, const char *type)

Protected Attributes

gcp::Documentm_pActiveDoc
Targetm_pActiveTarget
unsigned m_NumWindow

Additional Inherited Members

- Static Public Member Functions inherited from gcugtk::Application
static WindowState GetDefaultWindowState ()
static void OnReceiveTargets (GtkClipboard *clipboard, GtkSelectionData *selection_data, Application *App)

Detailed Description

GChemPaint application base class.

This class is used to represent a GChemPaint application. It is a virtual class since at least one method is pure virtual (gcp::Application::GetWindow)

Definition at line 100 of file gcp/application.h.

Constructor & Destructor Documentation

gcp::Application::Application ( gcugtk::CmdContextGtk cc = NULL)

The default constructor.

virtual gcp::Application::~Application ( )
virtual

The destructor.

Reimplemented from gcugtk::Application.

Member Function Documentation

void gcp::Application::ActivateTool ( const std::string &  toolname,
bool  activate 
)
Parameters
toolnamethe name of the tool.
activatewhether to activate or deactivate.

Activates or deactivates a tool in the GChempaint tool box.

To activate the selection tool:

ActivateTool ("Select", true);
void gcp::Application::ActivateWindowsActionWidget ( const char *  path,
bool  activate 
)
Parameters
paththe path to activate.
activatewhether to activate or deactivate.

Activates or deactivates the menu item corresponding to path according to the value of activate.

To deactivate the "Paste" menu item, use:

ActivateWindowsActionWidget ("/MainMenu/EditMenu/Paste", false);

Calls gcp::Window::ActivateActionWidget.

void gcp::Application::AddActions ( GtkRadioActionEntry const *  entries,
int  nb,
char const *  ui_description,
IconDesc const *  icons 
)
Parameters
entriesan array of GtkRadioActionEntry structures.
nbthe number of entries.
ui_descriptionan xml like text describing the user interface.
iconsan array of IconDesc structures for the icons used by the buttons.

Adds new buttons in the tools box. The code used in the selection plugin is:

static gcp::IconDesc icon_descs[] = {
{"gcp_Selection", gcp_selection_24},
{"gcp_Eraser", gcp_eraser_24},
{NULL, NULL}
};
static GtkRadioActionEntry entries[] = {
{ "Select", "gcp_Selection", N_("Select"), NULL,
N_("Select one or more objects"),
0 },
{ "Erase", "gcp_Eraser", N_("Erase"), NULL,
N_("Eraser"),
0 }
};
static const char *ui_description =
"<ui>"
" <toolbar name='SelectToolbar'>"
" <placeholder name='Select1'>"
" <toolitem action='Select'/>"
" <toolitem action='Erase'/>"
" </placeholder>"
" <placeholder name='Select2'/>"
" <placeholder name='Select3'/>"
" </toolbar>"
"</ui>";
void gcpSelectionPlugin::Populate (gcp::Application* App)
{
App->AddActions (entries, G_N_ELEMENTS (entries), ui_description, icon_descs);
App->RegisterToolbar ("SelectToolbar", 0);
new gcpSelectionTool (App);
new gcpEraserTool (App);
App->ActivateTool ("Select", true);
}
void gcp::Application::AddCanvas ( char const *  path,
gccv::Canvas canvas 
)
inline
Parameters
paththe path associated to a tool
canvasthe canvas used as icon for the tool

Associates a canvas to a tool for use as an icon for the tool button. Used to have scalable icons using the theme colors whenever possible.

Definition at line 425 of file gcp/application.h.

void gcp::Application::AddMenuCallback ( BuildMenuCb  cb)
Parameters
cb,:the BuildMenuCb callback to call when building the menu.

adds a callback for adding entries to the windows menus.

void gcp::Application::AddTarget ( Target target)
Parameters
targetthe Target to add.

Adds a Target to the list of known Targets and displays the tools box next to the Target.

void gcp::Application::BuildMenu ( gcu::UIManager manager)
Parameters
manager,:the gcu::UIManager to populate.

Populates the user interface by calling all callbacks registered with AddMenuCallback.

void gcp::Application::BuildTools ( ) throw (std::runtime_error)
protected

Builds the tools box. This method is called only once after startup by the framework.

virtual void gcp::Application::ClearStatus ( )
virtual

Clears the message in the status bar.

void gcp::Application::CloseAll ( )

Closes all open documents and ends the application.

gcu::Document* gcp::Application::CreateNewDocument ( )
virtual

Creates a new document using the default theme.

Returns
the newly created document.

Reimplemented from gcu::Application.

void gcp::Application::DeleteTarget ( Target target)
Parameters
targetthe Target to delete.

Deletes a Target from the list of known Targets. The tools box will be hidden if no Target remains active.

bool gcp::Application::FileProcess ( const gchar *  filename,
const gchar *  mime_type,
bool  bSave,
GtkWindow *  window,
gcu::Document pDoc = NULL 
)
Parameters
filenamethe URI of the file to save or open.
mime_typethe mime type.
bSavetrue when saving and false when opening.
windowa parent GtkWindow which is used for messabe boxes if any.
pDoca document (might be NULL when loading.

Callback called when the user clicks on the Save or Open button in the file chooser to process the file.

Returns
false on success, true otherwise.
gcp::Document* gcp::Application::GetActiveDocument ( )
inline
Returns
the active document.

Definition at line 163 of file gcp/application.h.

References m_pActiveDoc.

Tool* gcp::Application::GetActiveTool ( )
inline
Returns
the active tool.

Definition at line 159 of file gcp/application.h.

GdkCursor* gcp::Application::GetCursor ( CursorId  id)
inline
Parameters
ida CursorId
Returns
the corresponding GdkCursor if any.

Definition at line 412 of file gcp/application.h.

int gcp::Application::GetCurZ ( )
inline
Returns
the current atomic number.

Definition at line 205 of file gcp/application.h.

int gcp::Application::GetDocsNumber ( )
inline
Returns
the number of opened documents.

Definition at line 252 of file gcp/application.h.

References gcu::Application::m_Docs.

std::list<std::string>& gcp::Application::GetExtensions ( std::string &  mime_type)
Parameters
mime_typea mime type.
Returns
the list of file name extensions corresponding to the mime type.
gcp::Application::GetHaveAvogadro ( void  ) const
inline
Returns
true if avogadro is usable on startup.

Definition at line 508 of file gcp/application.h.

gcp::Application::GetHaveGChem3D ( void  ) const
inline
Returns
true if gchem3d is usable on startup.

Definition at line 504 of file gcp/application.h.

gcp::Application::GetHaveGhemical ( void  ) const
inline
Returns
true if ghemical is usable on startup.

Definition at line 500 of file gcp/application.h.

std::list<std::string>& gcp::Application::GetSupportedMimeTypes ( )
inline
Returns
a list of supported mime types.

Definition at line 355 of file gcp/application.h.

Tool* gcp::Application::GetTool ( const std::string &  name)
inline
Parameters
namethe name of a tool
Returns
the Tool corresponding to name.

Definition at line 174 of file gcp/application.h.

GtkWidget* gcp::Application::GetToolItem ( const std::string &  name)
inline
Parameters
namethe name of a tool
Returns
the GtkWidget corresponding to the Tool named name.

Definition at line 187 of file gcp/application.h.

gcp::Application::GetUseAtomColors ( void  ) const
inline
Returns
true if atomic symbols are displayed using the element symbolic color.

Definition at line 512 of file gcp/application.h.

virtual GtkWindow* gcp::Application::GetWindow ( )
pure virtual

This pure virtual method must be overloaded by derived classes.

Returns
the current active top level window if any, or NULL.

Reimplemented from gcu::Application.

xmlDocPtr gcp::Application::GetXmlDoc ( )
inline
Returns
a xmlDocPtr used for some undo/redo related operations. The text tools use it.

Definition at line 240 of file gcp/application.h.

bool gcp::Application::Have3DSupport ( )
inline
Returns
true if an appropriate 3D viewer is available.

Definition at line 417 of file gcp/application.h.

bool gcp::Application::HaveInChI ( )
inline
Returns
true if InChIs can be evaluated for molecules.

Definition at line 248 of file gcp/application.h.

void gcp::Application::InitTools ( )
protected

Initialize the tools box so that the selection tool is active. This method is called only once aafter startup by the framework.

void gcp::Application::NotifyFocus ( bool  has_focus,
Target target = NULL 
)
Parameters
has_focuswhether the Target has focus or not.
targetthe Target for which the event occured.

Shows the tools box next to target if has_focus is true and if target is not NULL.

void gcp::Application::NotifyIconification ( bool  iconified)
Parameters
iconifiedwhether the currently active Target is iconified or not.

If iconified is true, the tools box will be hidden if no Target remains active, otherwise it will be displayed next to the active Target.

void gcp::Application::OnConfigChanged ( GOConfNode *  node,
gchar const *  name 
)
Parameters
nodethe GONode which changed.
namethe name of the key.

Called by the framework when the configuration entry has changed to update a running application preferences if the system allows such callbacks.

virtual void gcp::Application::OnFileNew ( char const *  Theme = NULL)
pure virtual
Parameters
Themea gcp::Theme or NULL.

Creates a new document using the given theme or the default theme if Theme is NULL. This method must be overloaded by derived classes since it is pure virtual.

void gcp::Application::OnSaveAs ( )

Open the file save as dialog to save the current document with a new name.

void gcp::Application::OnSaveAsImage ( )

Saves the active view as an image.

void gcp::Application::OnThemeNamesChanged ( )

Called by the framework after a change of a theme name. Ensure evrything is correctly updated.

void gcp::Application::OnToolChanged ( GtkAction *  current)
Parameters
currentthe GtkAction for the activated tool.

Call by the framework when the active tool changed.

void gcp::Application::OpenGcp ( std::string const &  filename,
gcp::Document pDoc 
)
Parameters
filenamethe URI of the file to load.
pDoca document or NULL.

Loads a GChemPaint document.

void gcp::Application::ReceiveTargets ( GtkClipboard *  clipboard,
GtkSelectionData *  selection_data 
)
Parameters
clipboarda clipboard.
selection_datathe available data

Used as callback as gtk_clipboard_request_contents().

void gcp::Application::RegisterToolbar ( char const *  name,
int  index 
)
Parameters
namethe name of the toolbar.
indexthe rank of the toolbar in the toolbox.

Adds a new toolbar to the tools box. See the documentation of gcp::Application::AddActions() for a case use.

void gcp::Application::SaveGcp ( std::string const &  filename,
gcp::Document pDoc 
)
Parameters
filenamethe URI of the file to save.
pDocthe document to save.

Saves the active document in the native GChemPaint format.

void gcp::Application::SetActiveDocument ( gcp::Document pDoc)
inline
Parameters
pDocthe document becoming active.

Sets the new active document.

Definition at line 169 of file gcp/application.h.

References m_pActiveDoc.

void gcp::Application::SetCurZ ( int  Z)
inline
Parameters
Zthe new current atomic number.

Sets the new current atomic number. This number is used for new atoms.

Definition at line 201 of file gcp/application.h.

virtual void gcp::Application::SetStatusText ( const char *  text)
virtual
Parameters
texta text to display

Displays text in the status bar.

void gcp::Application::SetTool ( const std::string &  toolname,
Tool tool 
)
inline
Parameters
toolnamethe name of a new tool.
toolthe new Tool.

Adds a new tool to the tools box. This method is called from the Tool constructor.

Definition at line 182 of file gcp/application.h.

void gcp::Application::SetToolItem ( const std::string &  name,
GtkWidget *  w 
)
inline
Parameters
namethe name of a new tool.
wa GtkWidget.

Associates w to the Tool named name. SetTool() will return this widget when its argument is name.

Definition at line 195 of file gcp/application.h.

void gcp::Application::ShowTools ( bool  visible)
protected
Parameters
visiblewhether the tools box should be visible or not

Shows or hides the tools box.

void gcp::Application::Zoom ( double  zoom)
Parameters
zoomthe new zoom level.

Sets the zoom level for the active document window.

Member Data Documentation

unsigned gcp::Application::m_NumWindow
protected

Used to add a number to new files default names.

Definition at line 469 of file gcp/application.h.

gcp::Document* gcp::Application::m_pActiveDoc
protected

The active document.

Definition at line 461 of file gcp/application.h.

Referenced by GetActiveDocument(), and SetActiveDocument().

Target* gcp::Application::m_pActiveTarget
protected

The active target.

Definition at line 465 of file gcp/application.h.


The documentation for this class was generated from the following file: