index 7be667383a82b1c6f445065cae1f8168284a5849..c8f5d2c2e43fcbb96dd596bdd66aca3ecd8662b3 100644 (file)
const gchar *name, unsigned int psize );
}
+#define noICON_VERBOSE 1
+
namespace Inkscape {
namespace UI {
namespace Dialog {
desktop(0),
document(0),
timer(0),
+ renderTimer(0),
pending(false),
+ minDelay(0.1),
+ targetId(),
hot(1),
selectionButton(0),
desktopChangeConn(),
Glib::ustring label(*labels[i]);
buttons[i] = new Gtk::ToggleToolButton(label);
buttons[i]->set_active( i == hot );
- Gtk::Frame *frame = new Gtk::Frame();
- frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- frame->add(*images[i]);
- buttons[i]->set_icon_widget(*Gtk::manage(frame));
+ if ( prefs->getBool("/iconpreview/showFrames", true) ) {
+ Gtk::Frame *frame = new Gtk::Frame();
+ frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+ frame->add(*images[i]);
+ buttons[i]->set_icon_widget(*Gtk::manage(frame));
+ } else {
+ buttons[i]->set_icon_widget(*images[i]);
+ }
tips.set_tip((*buttons[i]), label);
delete timer;
timer = 0;
}
+ if ( renderTimer ) {
+ renderTimer->stop();
+ delete renderTimer;
+ renderTimer = 0;
+ }
selChangedConn.disconnect();
docModConn.disconnect();
//#########################################################################
+#if ICON_VERBOSE
+static Glib::ustring getTimestr()
+{
+ Glib::ustring str;
+ GTimeVal now = {0, 0};
+ g_get_current_time(&now);
+ glong secs = now.tv_sec % 60;
+ glong mins = (now.tv_sec / 60) % 60;
+ gchar *ptr = g_strdup_printf(":%02ld:%02ld.%06ld", mins, secs, now.tv_usec);
+ str = ptr;
+ g_free(ptr);
+ ptr = 0;
+ return str;
+}
+#endif // ICON_VERBOSE
+
void IconPreviewPanel::setDesktop( SPDesktop* desktop )
{
Panel::setDesktop(desktop);
if (!timer) {
timer = new Glib::Timer();
}
- if (timer->elapsed() < 0.1) {
+ if (timer->elapsed() < minDelay) {
+#if ICON_VERBOSE
+ g_message( "%s Deferring refresh as too soon. calling queueRefresh()", getTimestr().c_str() );
+#endif //ICON_VERBOSE
// Do not refresh too quickly
queueRefresh();
} else if ( desktop ) {
+#if ICON_VERBOSE
+ g_message( "%s Refreshing preview.", getTimestr().c_str() );
+#endif // ICON_VERBOSE
+ bool hold = Inkscape::Preferences::get()->getBool("/iconpreview/selectionHold", true);
+ SPObject *target = 0;
if ( selectionButton && selectionButton->get_active() )
{
- Inkscape::Selection * sel = sp_desktop_selection(desktop);
- if ( sel ) {
- //g_message("found a selection to play with");
-
- GSList const *items = sel->itemList();
- SPObject *target = 0;
- while ( items && !target ) {
- SPItem* item = SP_ITEM( items->data );
- SPObject * obj = SP_OBJECT(item);
- gchar const *id = obj->getId();
- if ( id ) {
- target = obj;
+ target = (hold && !targetId.empty()) ? desktop->doc()->getObjectById( targetId.c_str() ) : 0;
+ if ( !target ) {
+ targetId.clear();
+ Inkscape::Selection * sel = sp_desktop_selection(desktop);
+ if ( sel ) {
+ //g_message("found a selection to play with");
+
+ GSList const *items = sel->itemList();
+ while ( items && !target ) {
+ SPItem* item = SP_ITEM( items->data );
+ SPObject * obj = SP_OBJECT(item);
+ gchar const *id = obj->getId();
+ if ( id ) {
+ targetId = id;
+ target = obj;
+ }
+
+ items = g_slist_next(items);
}
-
- items = g_slist_next(items);
- }
- if ( target ) {
- renderPreview(target);
}
}
} else {
- SPObject *target = desktop->currentRoot();
- if ( target ) {
- renderPreview(target);
- }
+ target = desktop->currentRoot();
}
+ if ( target ) {
+ renderPreview(target);
+ }
+#if ICON_VERBOSE
+ g_message( "%s resetting timer", getTimestr().c_str() );
+#endif // ICON_VERBOSE
timer->reset();
}
}
if (!timer) {
timer = new Glib::Timer();
}
- if ( timer->elapsed() > 0.1 ) {
+ if ( timer->elapsed() > minDelay ) {
+#if ICON_VERBOSE
+ g_message( "%s refreshCB() timer has progressed", getTimestr().c_str() );
+#endif // ICON_VERBOSE
callAgain = false;
refreshPreview();
+#if ICON_VERBOSE
+ g_message( "%s refreshCB() setting pending false", getTimestr().c_str() );
+#endif // ICON_VERBOSE
pending = false;
}
return callAgain;
{
if (!pending) {
pending = true;
+#if ICON_VERBOSE
+ g_message( "%s queueRefresh() Setting pending true", getTimestr().c_str() );
+#endif // ICON_VERBOSE
if (!timer) {
timer = new Glib::Timer();
}
void IconPreviewPanel::modeToggled()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("/iconpreview/selectionOnly", (selectionButton && selectionButton->get_active()));
+ bool selectionOnly = (selectionButton && selectionButton->get_active());
+ prefs->setBool("/iconpreview/selectionOnly", selectionOnly);
+ if ( !selectionOnly ) {
+ targetId.clear();
+ }
refreshPreview();
}
{
SPDocument * doc = SP_OBJECT_DOCUMENT(obj);
gchar const * id = obj->getId();
+ if ( !renderTimer ) {
+ renderTimer = new Glib::Timer();
+ }
+ renderTimer->reset();
-// g_message(" setting up to render '%s' as the icon", id );
+#if ICON_VERBOSE
+ g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id );
+#endif // ICON_VERBOSE
NRArenaItem *root = NULL;
sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey);
nr_object_unref((NRObject *) arena);
+ renderTimer->stop();
+ minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 );
+#if ICON_VERBOSE
+ g_message(" render took %f seconds.", renderTimer->elapsed());
+#endif // ICON_VERBOSE
}
void IconPreviewPanel::updateMagnify()