Code

changes to install he - hebrew
[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, 2007 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<Event *> event;
57         Gtk::TreeModelColumn<unsigned int> type;
58         Gtk::TreeModelColumn<Glib::ustring> description;
59         Gtk::TreeModelColumn<int> child_count;
61         EventModelColumns()
62         { 
63             add(event); add(type); add(description); add(child_count);
64         }
65     };
67     /**
68      * Implementation of Inkscape::UndoStackObserver methods
69      * \brief Modifies the log's entries and the view's selection when triggered
70      */
72     void notifyUndoEvent(Event *log);
73     void notifyRedoEvent(Event *log);
74     void notifyUndoCommitEvent(Event *log);
75     void notifyClearUndoEvent();
76     void notifyClearRedoEvent();
78     /**
79      * Accessor functions
80      */
82     Glib::RefPtr<Gtk::TreeModel> getEventListStore() const { return _event_list_store; }
83     const EventModelColumns& getColumns() const            { return _columns; }
84     iterator getCurrEvent() const                          { return _curr_event; }
85     iterator getCurrEventParent() const                    { return _curr_event_parent; }
87     void setCurrEvent(iterator event)          { _curr_event = event; }
88     void setCurrEventParent(iterator event)    { _curr_event_parent = event; }
89     void blockNotifications(bool status=true)  { _notifications_blocked = status; }
91     /* 
92      * Callback types for TreeView changes.
93      */
95     enum CallbackTypes { 
96         CALLB_SELECTION_CHANGE, 
97         CALLB_EXPAND, 
98         CALLB_COLLAPSE, 
99         CALLB_LAST 
100     };
102     typedef std::map<const CallbackTypes, sigc::connection> CallbackMap;
104     /**
105      * Connect with a TreeView.
106      */
107     void connectWithDialog(Gtk::TreeView *event_list_view, CallbackMap *callback_connections);
109     /*
110      * Updates the sensitivity and names of SP_VERB_EDIT_UNDO and SP_VERB_EDIT_REDO to reflect the
111      * current state.
112      */
113     void updateUndoVerbs();
115 private:
116     bool _connected;             //< connected with dialog
117     SPDocument *_document;       //< document that is logged
119     const EventModelColumns _columns;
121     Glib::RefPtr<Gtk::TreeStore> _event_list_store; 
122     Glib::RefPtr<Gtk::TreeSelection> _event_list_selection;
123     Gtk::TreeView *_event_list_view;
125     iterator _curr_event;        //< current event in _event_list_store
126     iterator _last_event;        //< end position in _event_list_store
127     iterator _curr_event_parent; //< parent to current event, if any
129     bool _notifications_blocked; //< if notifications should be handled
131     // Map of connections used to temporary block/unblock callbacks in a TreeView
132     CallbackMap *_callback_connections;
134     /**
135      * Helper functions
136      */
138     const_iterator _getUndoEvent() const; //< returns the current undoable event or NULL if none
139     const_iterator _getRedoEvent() const; //< returns the current redoable event or NULL if none
141     void _clearUndo();  //< erase all previously commited events
142     void _clearRedo();  //< erase all previously undone events
144     // noncopyable, nonassignable
145     EventLog(EventLog const &other);
146     EventLog& operator=(EventLog const &other);
148 };
150 } // namespace Inkscape
152 #endif // INKSCAPE_EVENT_LOG_H
154 /*
155   Local Variables:
156   mode:c++
157   c-file-style:"stroustrup"
158   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
159   indent-tabs-mode:nil
160   fill-column:99
161   End:
162 */
163 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :