Code

apply patch 1498946 by zbsz (fixes #1492545 "PNG resolution value export")
[inkscape.git] / src / helper / action.h
1 #ifndef __SP_ACTION_H__
2 #define __SP_ACTION_H__
4 /** \file
5  * Inkscape UI action implementation
6  */
8 /*
9  * Author:
10  *   Lauris Kaplinski <lauris@kaplinski.com>
11  *
12  * Copyright (C) 2003 Lauris Kaplinski
13  *
14  * This code is in public domain
15  */
17 /** A macro to get the GType for actions */
18 #define SP_TYPE_ACTION (sp_action_get_type())
19 /** A macro to cast and check the cast of changing an object to an action */
20 #define SP_ACTION(o) (NR_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction))
21 /** A macro to check whether or not something is an action */
22 #define SP_IS_ACTION(o) (NR_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION))
24 #include "helper/helper-forward.h"
25 #include "libnr/nr-object.h"
26 #include "forward.h"
28 //class Inkscape::UI::View::View; 
30 namespace Inkscape {
31 class Verb;
32 }
35 /** This is a structure that is used to hold all the possible
36     actions that can be taken with an action.  These are the
37     function pointers available. */
38 struct SPActionEventVector {
39     NRObjectEventVector object_vector;                                        /**< Parent class */
40     void (* perform)(SPAction *action, void *ldata, void *pdata);             /**< Actually do the action of the event.  Called by sp_perform_action */
41     void (* set_active)(SPAction *action, unsigned active, void *data);       /**< Callback for activation change */
42     void (* set_sensitive)(SPAction *action, unsigned sensitive, void *data); /**< Callback for a change in sensitivity */
43     void (* set_shortcut)(SPAction *action, unsigned shortcut, void *data);   /**< Callback for setting the shortcut for this function */
44 };
46 /** All the data that is required to be an action.  This
47     structure identifies the action and has the data to
48         create menus and toolbars for the action */
49 struct SPAction : public NRActiveObject {
50     unsigned sensitive : 1;  /**< Value to track whether the action is sensitive */
51     unsigned active : 1;     /**< Value to track whether the action is active */
52     Inkscape::UI::View::View *view;            /**< The View to which this action is attached */
53     gchar *id;               /**< The identifier for the action */
54     gchar *name;             /**< Full text name of the action */
55     gchar *tip;              /**< A tooltip to describe the action */
56     gchar *image;            /**< An image to visually identify the action */
57     Inkscape::Verb *verb;    /**< The verb that produced this action */
58 };
60 /** The action class is the same as its parent. */
61 struct SPActionClass {
62     NRActiveObjectClass parent_class; /**< Parent Class */
63 };
65 NRType sp_action_get_type();
67 SPAction *sp_action_new(Inkscape::UI::View::View *view,
68                         gchar const *id,
69                         gchar const *name,
70                         gchar const *tip,
71                         gchar const *image,
72                         Inkscape::Verb *verb);
74 void sp_action_perform(SPAction *action, void *data);
75 void sp_action_set_active(SPAction *action, unsigned active);
76 void sp_action_set_sensitive(SPAction *action, unsigned sensitive);
77 Inkscape::UI::View::View *sp_action_get_view(SPAction *action);
79 #endif
82 /*
83   Local Variables:
84   mode:c++
85   c-file-style:"stroustrup"
86   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
87   indent-tabs-mode:nil
88   fill-column:99
89   End:
90 */
91 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :