~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/ui/dialog/undo-history.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Kees Cook, Ted Gould
  • Date: 2008-02-10 14:20:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210142016-vcnb2zqyhszu0xvb
Tags: 0.46~pre1-0ubuntu1
[ Kees Cook ]
* debian/control:
  - add libgtkspell-dev build-dep to gain GtkSpell features (LP: #183547).
  - update Standards version (no changes needed).
  - add Vcs and Homepage fields.
  - switch to new python-lxml dep.
* debian/{control,rules}: switch from dpatch to quilt for more sanity.
* debian/patches/20_fix_glib_and_gxx43_ftbfs.patch:
  - merged against upstream fixes.
  - added additional fixes for newly written code.
* debian/rules: enable parallel building.

[ Ted Gould ]
* Updating POTFILES.in to make it so things build correctly.
* debian/control:
  - add ImageMagick++ and libboost-dev to build-deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "inkscape.h"
23
23
#include "ui/icons.h"
24
24
#include "verbs.h"
 
25
#include "desktop-handles.h"
25
26
 
26
27
#include "undo-history.h"
27
28
 
31
32
 
32
33
/* Rendering functions for custom cell renderers */
33
34
 
34
 
void 
 
35
void
35
36
CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
36
37
                                 Gtk::Widget& widget,
37
38
                                 const Gdk::Rectangle& background_area,
50
51
 
51
52
        if (icon) {
52
53
 
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);
61
62
            } else {
62
63
                delete icon;
71
72
        property_pixbuf() = _icon_cache[_property_event_type];
72
73
    }
73
74
 
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);
76
77
}
77
78
 
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);
93
94
    }
94
95
}
95
96
 
96
97
const CellRendererInt::Filter& CellRendererInt::no_filter = CellRendererInt::NoFilter();
97
98
 
98
 
static UndoHistory *_instance = 0;
99
 
 
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*);
104
 
 
105
 
UndoHistory*
106
 
UndoHistory::create()
 
99
UndoHistory& UndoHistory::getInstance()
107
100
{
108
 
    if (_instance) return _instance;
109
 
    _instance = new UndoHistory;
110
 
    return _instance;
 
101
    return *new UndoHistory();
111
102
}
112
103
 
113
104
void
114
105
UndoHistory::setDesktop(SPDesktop* desktop)
115
106
{
116
 
    if (!desktop || !SP_ACTIVE_DOCUMENT) return;
117
 
 
118
 
    _document = SP_ACTIVE_DOCUMENT;
 
107
    Panel::setDesktop(desktop);
 
108
 
 
109
    if (!desktop) return;
 
110
 
 
111
    _document = sp_desktop_document(desktop);
119
112
 
120
113
    _event_log = desktop->event_log;
121
114
 
132
125
}
133
126
 
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())
141
 
142
 
    if( !_document || !_event_log || !_columns ) return;
143
 
 
144
 
    set_size_request(300, 400);
145
 
 
146
 
    get_vbox()->pack_start(_scrolled_window);
 
133
{
 
134
    if ( !_document || !_event_log || !_columns ) return;
 
135
 
 
136
    set_size_request(300, 200);
 
137
 
 
138
    _getContents()->pack_start(_scrolled_window);
147
139
    _scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
148
140
 
149
141
    _event_list_store = _event_log->getEventListStore();
181
173
 
182
174
    _scrolled_window.add(_event_list_view);
183
175
 
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);
188
 
 
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));
209
196
{
210
197
}
211
198
 
212
 
void 
 
199
void
213
200
UndoHistory::_onListSelectionChange()
214
201
{
215
202
 
239
226
        } else {  // this should not happen
240
227
            _event_list_selection->select(curr_event);
241
228
        }
242
 
        
 
229
 
243
230
    } else {
244
231
 
245
232
        EventLog::const_iterator last_selected = _event_log->getCurrEvent();
248
235
         * of that parent's branch.
249
236
         */
250
237
 
251
 
        if ( !selected->children().empty() && 
 
238
        if ( !selected->children().empty() &&
252
239
             !_event_list_view.row_expanded(_event_list_store->get_path(selected)) )
253
240
        {
254
241
            selected = selected->children().end();
256
243
        }
257
244
 
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) )
261
248
        {
262
249
            _event_log->blockNotifications();
263
250
 
264
251
            while ( selected != last_selected ) {
265
 
                
 
252
 
266
253
                sp_document_undo(_document);
267
254
 
268
255
                if ( last_selected->parent() &&
279
266
                    }
280
267
                }
281
268
            }
282
 
            _event_log->blockNotifications(false);        
 
269
            _event_log->blockNotifications(false);
283
270
            _event_log->updateUndoVerbs();
284
271
 
285
272
        } else { // An event after the current one has been selected. Redo to the selected event.
304
291
                    }
305
292
                }
306
293
            }
307
 
            _event_log->blockNotifications(false);        
308
 
        
 
294
            _event_log->blockNotifications(false);
 
295
 
309
296
        }
310
297
 
311
298
        _event_log->setCurrEvent(selected);
315
302
}
316
303
 
317
304
void
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*/)
319
306
{
320
 
    if ( iter == _event_list_selection->get_selected() )
321
 
    {
 
307
    if ( iter == _event_list_selection->get_selected() ) {
322
308
        _event_list_selection->select(_event_log->getCurrEvent());
323
309
    }
324
310
}
325
311
 
326
312
void
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*/)
328
314
{
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() )
331
 
    {
 
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();
349
334
 
350
335
const CellRendererInt::Filter& UndoHistory::greater_than_1 = UndoHistory::GreaterThan(1);
351
336
 
352
 
static void 
353
 
on_activate_desktop(Inkscape::Application*, SPDesktop* desktop, void*)
354
 
{
355
 
    if (!_instance) return;
356
 
 
357
 
    _instance->_document_replaced_connection = 
358
 
        SP_ACTIVE_DESKTOP->connectDocumentReplaced(sigc::ptr_fun(on_document_replaced));
359
 
 
360
 
    _instance->setDesktop(desktop);
361
 
}
362
 
 
363
 
static void 
364
 
on_deactivate_desktop(Inkscape::Application*, SPDesktop* desktop, void*)
365
 
{
366
 
    if (!_instance) return;
367
 
 
368
 
    _instance->_document_replaced_connection.disconnect();
369
 
}
370
 
 
371
 
static void 
372
 
on_document_replaced(SPDesktop* desktop, SPDocument*)
373
 
{
374
 
    if (!_instance) return;
375
 
 
376
 
    _instance->setDesktop(desktop);
377
 
}
378
 
 
379
337
} // namespace Dialog
380
338
} // namespace UI
381
339
} // namespace Inkscape