Code

updated spanish.nsh and inkscape.nsi to reflect latest file-changes
[inkscape.git] / trunk / src / ui / dialog / undo-history.h
1 /** @file
2  * @brief Undo History dialog
3  */
4 /* Author:
5  *   Gustav Broberg <broberg@kth.se>
6  *
7  * Copyright (C) 2006 Authors
8  * Released under GNU GPL.  Read the file 'COPYING' for more information.
9  */
11 #ifndef INKSCAPE_UI_DIALOG_UNDO_HISTORY_H
12 #define INKSCAPE_UI_DIALOG_UNDO_HISTORY_H
14 #include <glibmm/refptr.h>
15 #include <gtkmm/cellrendererpixbuf.h>
16 #include <gtkmm/image.h>
17 #include <gtkmm/invisible.h>
18 #include <gtkmm/scrolledwindow.h>
19 #include <gtkmm/stock.h>
20 #include <gtkmm/treemodel.h>
21 #include <gtkmm/treeselection.h>
23 #include <functional>
24 #include <sstream>
26 #include "desktop.h"
27 #include "event-log.h"
29 #include "ui/widget/panel.h"
30 #include "widgets/icon.h"
32 namespace Inkscape {
33 namespace UI {
34 namespace Dialog {
37 /* Custom cell renderers */
39 class CellRendererSPIcon : public Gtk::CellRendererPixbuf {
40 public:
42     CellRendererSPIcon() :
43         Glib::ObjectBase(typeid(CellRendererPixbuf)),
44         Gtk::CellRendererPixbuf(),
45         _property_icon(*this, "icon", Glib::RefPtr<Gdk::Pixbuf>(0)),
46         _property_event_type(*this, "event_type", 0)
47     { }
48     
49     Glib::PropertyProxy<unsigned int> 
50     property_event_type() { return _property_event_type.get_proxy(); }
52 protected:
54     virtual void
55     render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
56                  Gtk::Widget& widget,
57                  const Gdk::Rectangle& background_area,
58                  const Gdk::Rectangle& cell_area,
59                  const Gdk::Rectangle& expose_area,
60                  Gtk::CellRendererState flags);
61 private:
63     Glib::Property<Glib::RefPtr<Gdk::Pixbuf> > _property_icon;
64     Glib::Property<unsigned int> _property_event_type;
65     std::map<const unsigned int, Glib::RefPtr<Gdk::Pixbuf> > _icon_cache;
66 };
69 class CellRendererInt : public Gtk::CellRendererText {
70 public:
72     struct Filter : std::unary_function<int, bool> {
73         virtual ~Filter() {}
74         virtual bool operator() (const int&) const =0;
75     };
77     CellRendererInt(const Filter& filter=no_filter) :
78         Glib::ObjectBase(typeid(CellRendererText)),
79         Gtk::CellRendererText(),
80         _property_number(*this, "number", 0),
81         _filter (filter)
82     { }
85     Glib::PropertyProxy<int> 
86     property_number() { return _property_number.get_proxy(); }
88     static const Filter& no_filter;
90  protected:
92     virtual void 
93     render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
94                  Gtk::Widget& widget,
95                  const Gdk::Rectangle& background_area,
96                  const Gdk::Rectangle& cell_area,
97                  const Gdk::Rectangle& expose_area,
98                  Gtk::CellRendererState flags);
100 private:
102     Glib::Property<int> _property_number;
103     const Filter& _filter;
105     struct NoFilter : Filter { bool operator() (const int& /*x*/) const { return true; } };
106 };
108 /**
109  * \brief Dialog for presenting document change history
110  *
111  * This dialog allows the user to undo and redo multiple events in a more convenient way
112  * than repateaded ctrl-z, ctrl-shift-z.
113  */
114 class UndoHistory : public Widget::Panel {
115 public:
116     virtual ~UndoHistory();
118     static UndoHistory &getInstance();
119     void setDesktop(SPDesktop* desktop);
121     sigc::connection _document_replaced_connection;
123 protected:
125     SPDocument *_document;
126     EventLog *_event_log;
128     const EventLog::EventModelColumns *_columns;
130     Gtk::ScrolledWindow _scrolled_window;    
132     Glib::RefPtr<Gtk::TreeModel> _event_list_store;
133     Gtk::TreeView _event_list_view;
134     Glib::RefPtr<Gtk::TreeSelection> _event_list_selection;
136     EventLog::CallbackMap _callback_connections;
138     void _onListSelectionChange();
139     void _onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
140     void _onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path);
142 private:
143     UndoHistory();
144   
145     // no default constructor, noncopyable, nonassignable
146     UndoHistory(UndoHistory const &d);
147     UndoHistory operator=(UndoHistory const &d);
149     struct GreaterThan : CellRendererInt::Filter {
150         GreaterThan(int _i) : i (_i) {}
151         bool operator() (const int& x) const { return x > i; }
152         int i;
153     };
155     static const CellRendererInt::Filter& greater_than_1;
156 };
158 } // namespace Dialog
159 } // namespace UI
160 } // namespace Inkscape
162 #endif //INKSCAPE_UI_DIALOG_UNDO_HISTORY_H
164 /*
165   Local Variables:
166   mode:c++
167   c-file-style:"stroustrup"
168   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
169   indent-tabs-mode:nil
170   fill-column:99
171   End:
172 */
173 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :