Code

do not embed transform if it's not translation and the object has a filter
[inkscape.git] / src / event-log.h
1 /**
2  * Inkscape::EventLog
3  *
4  * A simple log for maintaining a history of commited, undone and redone events along with their
5  * type. It implements the UndoStackObserver and should be registered with a
6  * CompositeUndoStackObserver for each document. The event log is then notified on all commit, undo
7  * and redo events and will store a representation of them in an internal Gtk::TreeStore.
8  *
9  * Consecutive events of the same type are grouped with the first event as a parent and following
10  * as its children.
11  *
12  * If a Gtk::TreeView is connected to the event log, the TreeView's selection and its nodes
13  * expanded/collapsed state will be updated as events are commited, undone and redone. Whenever
14  * this happens, the event log will block the TreeView's callbacks to prevent circular updates.
15  *
16  * Author:
17  *   Gustav Broberg <broberg@kth.se>
18  *
19  * Copyright (c) 2006 Authors
20  *
21  * Released under GNU GPL, read the file 'COPYING' for more information
22  */
24 #ifndef INKSCAPE_EVENT_LOG_H
25 #define INKSCAPE_EVENT_LOG_H
27 #include <gdkmm/pixbuf.h>
28 #include <glibmm/refptr.h>
29 #include <gtkmm/treestore.h>
30 #include <gtkmm/treeselection.h>
31 #include <gtkmm/treeview.h>
33 #include "undo-stack-observer.h"
34 #include "event.h"
36 namespace Inkscape {
38 /**
39  *     
40  */
41 class EventLog : public UndoStackObserver {
42         
43 public:
44     typedef Gtk::TreeModel::iterator iterator;
45     typedef Gtk::TreeModel::const_iterator const_iterator;
47     EventLog(SPDocument* document);
48     ~EventLog();
50     /**
51      * Event datatype
52      */
54     struct EventModelColumns : public Gtk::TreeModelColumnRecord
55     {
56         Gtk::TreeModelColumn<unsigned int> type;
57         Gtk::TreeModelColumn<Glib::ustring> description;
58         Gtk::TreeModelColumn<int> child_count;
60         EventModelColumns()
61         { 
62             add(type); add(description); add(child_count);
63         }
64     };
66     /**
67      * Implementation of Inkscape::UndoStackObserver methods
68      * \brief Modifies the log's entries and the view's selection when triggered
69      */
71     void notifyUndoEvent(Event *log);
72     void notifyRedoEvent(Event *log);
73     void notifyUndoCommitEvent(Event *log);
75     /**
76      * Accessor functions
77      */
79     Glib::RefPtr<Gtk::TreeModel> getEventListStore() const { return _event_list_store; }
80     const EventModelColumns& getColumns() const            { return _columns; }
81     iterator getCurrEvent() const                          { return _curr_event; }
82     iterator getCurrEventParent() const                    { return _curr_event_parent; }
84     void setCurrEvent(iterator event)          { _curr_event = event; }
85     void setCurrEventParent(iterator event)    { _curr_event_parent = event; }
86     void blockNotifications(bool status=true)  { _notifications_blocked = status; }
88     /* 
89      * Callback types for TreeView changes.
90      */
92     enum CallbackTypes { 
93         CALLB_SELECTION_CHANGE, 
94         CALLB_EXPAND, 
95         CALLB_COLLAPSE, 
96         CALLB_LAST 
97     };
99     typedef std::map<const CallbackTypes, sigc::connection> CallbackMap;
101     /**
102      * Connect with a TreeView.
103      */
104     void connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections);
106     /*
107      * Updates the sensitivity and names of SP_VERB_EDIT_UNDO and SP_VERB_EDIT_REDO to reflect the
108      * current state.
109      */
110     void updateUndoVerbs();
112 private:
113     bool _connected;             //< connected with dialog
114     SPDocument *_document;       //< document that is logged
116     const EventModelColumns _columns;
118     /**
119      * Helper functions for initialization
120      */
122     Glib::RefPtr<Gtk::TreeStore> _event_list_store; 
123     Glib::RefPtr<Gtk::TreeSelection> _event_list_selection;
124     Gtk::TreeView *_event_list_view;
126     iterator _curr_event;        //< current event in _event_list_store
127     iterator _last_event;        //< end position in _event_list_store
128     iterator _curr_event_parent; //< parent to current event, if any
130     bool _notifications_blocked; //< if notifications should be handled
132     // Map of connections used to temporary block/unblock callbacks in a TreeView
133     CallbackMap *_callback_connections;
135     const_iterator _getUndoEvent() const; //< returns the current undoable event or NULL if none
136     const_iterator _getRedoEvent() const; //< returns the current redoable event or NULL if none
138     // noncopyable, nonassignable
139     EventLog(EventLog const &other);
140     EventLog& operator=(EventLog const &other);
142 };
144 } // namespace Inkscape
146 #endif // INKSCAPE_EVENT_LOG_H
148 /*
149   Local Variables:
150   mode:c++
151   c-file-style:"stroustrup"
152   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
153   indent-tabs-mode:nil
154   fill-column:99
155   End:
156 */
157 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :