53
// check icon type (inkscape, gtk, none)
54
if ( SP_IS_ICON(icon->gobj()) ) {
54
// check icon type (inkscape, gtk, none)
55
if ( SP_IS_ICON(icon->gobj()) ) {
55
56
SPIcon* sp_icon = SP_ICON(icon->gobj());
56
57
sp_icon_fetch_pixbuf(sp_icon);
57
58
_property_icon = Glib::wrap(sp_icon->pb, true);
58
59
} else if ( GTK_IS_IMAGE(icon->gobj()) ) {
59
_property_icon = Gtk::Invisible().render_icon(Gtk::StockID(image),
60
_property_icon = Gtk::Invisible().render_icon(Gtk::StockID(image),
60
61
Gtk::ICON_SIZE_MENU);
71
72
property_pixbuf() = _icon_cache[_property_event_type];
74
Gtk::CellRendererPixbuf::render_vfunc(window, widget, background_area,
75
Gtk::CellRendererPixbuf::render_vfunc(window, widget, background_area,
75
76
cell_area, expose_area, flags);
88
89
std::ostringstream s;
89
90
s << _property_number << std::flush;
90
91
property_text() = s.str();
91
Gtk::CellRendererText::render_vfunc(window, widget, background_area,
92
Gtk::CellRendererText::render_vfunc(window, widget, background_area,
92
93
cell_area, expose_area, flags);
96
97
const CellRendererInt::Filter& CellRendererInt::no_filter = CellRendererInt::NoFilter();
98
static UndoHistory *_instance = 0;
100
/* local desktop event handlers */
101
static void on_document_replaced(SPDesktop* desktop, SPDocument*);
102
static void on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*);
103
static void on_deactivate_desktop(Inkscape::Application*, SPDesktop* desktop, void*);
106
UndoHistory::create()
99
UndoHistory& UndoHistory::getInstance()
108
if (_instance) return _instance;
109
_instance = new UndoHistory;
101
return *new UndoHistory();
114
105
UndoHistory::setDesktop(SPDesktop* desktop)
116
if (!desktop || !SP_ACTIVE_DOCUMENT) return;
118
_document = SP_ACTIVE_DOCUMENT;
107
Panel::setDesktop(desktop);
109
if (!desktop) return;
111
_document = sp_desktop_document(desktop);
120
113
_event_log = desktop->event_log;
134
127
UndoHistory::UndoHistory()
135
: Dialog ("dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
136
_desktop (SP_ACTIVE_DESKTOP),
137
_document (SP_ACTIVE_DOCUMENT),
138
_event_log (_desktop ? _desktop->event_log : NULL),
128
: UI::Widget::Panel ("", "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
129
_document (sp_desktop_document(getDesktop())),
130
_event_log (getDesktop() ? getDesktop()->event_log : NULL),
139
131
_columns (_event_log ? &_event_log->getColumns() : NULL),
140
132
_event_list_selection (_event_list_view.get_selection())
142
if( !_document || !_event_log || !_columns ) return;
144
set_size_request(300, 400);
146
get_vbox()->pack_start(_scrolled_window);
134
if ( !_document || !_event_log || !_columns ) return;
136
set_size_request(300, 200);
138
_getContents()->pack_start(_scrolled_window);
147
139
_scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
149
141
_event_list_store = _event_log->getEventListStore();
182
174
_scrolled_window.add(_event_list_view);
184
// connect desktop event callbacks
185
_document_replaced_connection = _desktop->connectDocumentReplaced(sigc::ptr_fun(on_document_replaced));
186
g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(on_activate_desktop), 0);
187
g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(on_deactivate_desktop), 0);
189
176
// connect EventLog callbacks
190
177
_callback_connections[EventLog::CALLB_SELECTION_CHANGE] =
191
178
_event_list_selection->signal_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::UndoHistory::_onListSelectionChange));
248
235
* of that parent's branch.
251
if ( !selected->children().empty() &&
238
if ( !selected->children().empty() &&
252
239
!_event_list_view.row_expanded(_event_list_store->get_path(selected)) )
254
241
selected = selected->children().end();
258
245
// An event before the current one has been selected. Undo to the selected event.
259
if ( _event_list_store->get_path(selected) <
260
_event_list_store->get_path(last_selected) )
246
if ( _event_list_store->get_path(selected) <
247
_event_list_store->get_path(last_selected) )
262
249
_event_log->blockNotifications();
264
251
while ( selected != last_selected ) {
266
253
sp_document_undo(_document);
268
255
if ( last_selected->parent() &&
318
UndoHistory::_onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path)
305
UndoHistory::_onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &/*path*/)
320
if ( iter == _event_list_selection->get_selected() )
307
if ( iter == _event_list_selection->get_selected() ) {
322
308
_event_list_selection->select(_event_log->getCurrEvent());
327
UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path)
313
UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &/*path*/)
329
315
// Collapsing a branch we're currently in is equal to stepping to the last event in that branch
330
if ( iter == _event_log->getCurrEvent() )
316
if ( iter == _event_log->getCurrEvent() ) {
332
317
EventLog::const_iterator curr_event_parent = _event_log->getCurrEvent();
333
318
EventLog::const_iterator curr_event = curr_event_parent->children().begin();
334
319
EventLog::const_iterator last = curr_event_parent->children().end();
350
335
const CellRendererInt::Filter& UndoHistory::greater_than_1 = UndoHistory::GreaterThan(1);
353
on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*)
355
if (!_instance) return;
357
_instance->_document_replaced_connection =
358
SP_ACTIVE_DESKTOP->connectDocumentReplaced(sigc::ptr_fun(on_document_replaced));
360
_instance->setDesktop(desktop);
364
on_deactivate_desktop(Inkscape::Application*, SPDesktop* desktop, void*)
366
if (!_instance) return;
368
_instance->_document_replaced_connection.disconnect();
372
on_document_replaced(SPDesktop* desktop, SPDocument*)
374
if (!_instance) return;
376
_instance->setDesktop(desktop);
379
337
} // namespace Dialog
380
338
} // namespace UI
381
339
} // namespace Inkscape