summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e29eb09)
raw | patch | inline | side by side (parent: e29eb09)
author | Jon A. Cruz <jon@joncruz.org> | |
Sat, 18 Dec 2010 04:54:08 +0000 (20:54 -0800) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Sat, 18 Dec 2010 04:54:08 +0000 (20:54 -0800) |
src/dialogs/text-edit.cpp | patch | blob | history | |
src/dialogs/xml-tree.cpp | patch | blob | history | |
src/ui/dialog/dialog-manager.cpp | patch | blob | history | |
src/util/Makefile_insert | patch | blob | history | |
src/util/ege-appear-time-tracker.cpp | [new file with mode: 0644] | patch | blob |
src/util/ege-appear-time-tracker.h | [new file with mode: 0644] | patch | blob |
src/widgets/desktop-widget.cpp | patch | blob | history |
index 61f56e3f7fec8ac12aa32c4d3e1434937700173a..d741e2de096a98bda3b7b5a9d3254cd7f3bae644 100644 (file)
#include "svg/css-ostringstream.h"
#include "widgets/icon.h"
#include <xml/repr.h>
+#include "util/ege-appear-time-tracker.h"
using Inkscape::DocumentUndo;
+using ege::AppearTimeTracker;
#define VB_MARGIN 4
#define MIN_ONSCREEN_DISTANCE 50
void
sp_text_edit_dialog (void)
{
+ bool wantTiming = Inkscape::Preferences::get()->getBool("/dialogs/debug/trackAppear", false);
+ GTimer *timer = wantTiming ? g_timer_new() : 0;
+
if (!dlg) {
gchar title[500];
sp_text_edit_dialog_read_selection (dlg, TRUE, TRUE);
}
+ if ( wantTiming ) {
+ // Time tracker takes ownership of the timer.
+ AppearTimeTracker *tracker = new AppearTimeTracker(timer, GTK_WIDGET(dlg), "DialogText");
+ tracker->setAutodelete(true);
+ timer = 0;
+ }
+
gtk_window_present ((GtkWindow *) dlg);
} // end of sp_text_edit_dialog()
index c90cde490ba02dfd0812b1c57a19ddadfbe2934f..d25bdad723550b097117e8b346b2014b93241f8d 100644 (file)
--- a/src/dialogs/xml-tree.cpp
+++ b/src/dialogs/xml-tree.cpp
#include "../widgets/sp-xmlview-attr-list.h"
#include "../widgets/sp-xmlview-content.h"
#include "../widgets/sp-xmlview-tree.h"
+#include "util/ege-appear-time-tracker.h"
using Inkscape::DocumentUndo;
+using ege::AppearTimeTracker;
#define MIN_ONSCREEN_DISTANCE 50
void sp_xml_tree_dialog()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
if (!desktop) {
return;
}
+ bool wantTiming = Inkscape::Preferences::get()->getBool("/dialogs/debug/trackAppear", false);
+ GTimer *timer = wantTiming ? g_timer_new() : 0;
+
if (dlg == NULL)
{ // very long block
tree_reset_context();
} // end of if (dlg == NULL)
+ if ( wantTiming ) {
+ // Time tracker takes ownership of the timer.
+ AppearTimeTracker *tracker = new AppearTimeTracker(timer, GTK_WIDGET(dlg), "DialogXMLEditor");
+ tracker->setAutodelete(true);
+ timer = 0;
+ }
+
gtk_window_present((GtkWindow *) dlg);
g_assert(desktop != NULL);
index ff31c91c4910178b544ec84608ff7f76fa59037e..0c49690cce5b70d585cf003335271f410491b267 100644 (file)
#include "ui/dialog/floating-behavior.h"
#include "ui/dialog/dock-behavior.h"
//#include "ui/dialog/print-colors-preview-dialog.h"
+#include "util/ege-appear-time-tracker.h"
#include "preferences.h"
#ifdef ENABLE_SVG_FONTS
* Shows the named dialog, creating it if necessary.
*/
void DialogManager::showDialog(GQuark name) {
- Dialog *dialog=getDialog(name);
- if (dialog) {
+ bool wantTiming = Inkscape::Preferences::get()->getBool("/dialogs/debug/trackAppear", false);
+ GTimer *timer = (wantTiming) ? g_timer_new() : 0; // if needed, must be created/started before getDialog()
+ Dialog *dialog = getDialog(name);
+ if ( dialog ) {
+ if ( wantTiming ) {
+ gchar const * nameStr = g_quark_to_string(name);
+ ege::AppearTimeTracker *tracker = new ege::AppearTimeTracker(timer, dialog->gobj(), nameStr);
+ tracker->setAutodelete(true);
+ timer = 0;
+ }
dialog->present();
}
+
+ if ( timer ) {
+ g_timer_destroy(timer);
+ timer = 0;
+ }
}
} // namespace Dialog
index d2f0055315e0155baa22d2b1bbf2f574a6f62039..deff951d44f4f06bdf2d39ecb43c3861360a36d7 100644 (file)
--- a/src/util/Makefile_insert
+++ b/src/util/Makefile_insert
util/compose.hpp \
util/copy.h \
util/enums.h \
+ util/ege-appear-time-tracker.cpp \
+ util/ege-appear-time-tracker.h \
util/ege-tags.h \
util/ege-tags.cpp \
util/filter-list.h \
diff --git a/src/util/ege-appear-time-tracker.cpp b/src/util/ege-appear-time-tracker.cpp
--- /dev/null
@@ -0,0 +1,162 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Appear Time Tracker.
+ *
+ * The Initial Developer of the Original Code is
+ * Jon A. Cruz.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+#include "ege-appear-time-tracker.h"
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+
+namespace ege
+{
+
+namespace {
+
+void unhookHandler( gulong &id, GtkWidget *obj )
+{
+ if ( id ) {
+ if ( obj ) {
+ g_signal_handler_disconnect( G_OBJECT(obj), id );
+ }
+ id = 0;
+ }
+}
+
+} // namespace
+
+
+AppearTimeTracker::AppearTimeTracker(GTimer *timer, GtkWidget *widget, gchar const* name) :
+ _name(name ? name : ""),
+ _timer(timer),
+ _widget(widget),
+ _topMost(widget),
+ _autodelete(false),
+ _mapId(0),
+ _realizeId(0),
+ _hierarchyId(0)
+
+{
+ while (_topMost->parent) {
+ _topMost = _topMost->parent;
+ }
+ _mapId = g_signal_connect( G_OBJECT(_topMost), "map-event", G_CALLBACK(mapCB), this );
+ _realizeId = g_signal_connect( G_OBJECT(_topMost), "realize", G_CALLBACK(realizeCB), this );
+ _hierarchyId = g_signal_connect( G_OBJECT(_widget), "hierarchy-changed", G_CALLBACK(hierarchyCB), this );
+}
+
+AppearTimeTracker::~AppearTimeTracker()
+{
+ if ( _timer ) {
+ g_timer_destroy(_timer);
+ _timer = 0;
+ }
+
+ unhookHandler( _mapId, _topMost );
+ unhookHandler( _realizeId, _topMost );
+ unhookHandler( _hierarchyId, _widget );
+}
+
+void AppearTimeTracker::stop() {
+ if (_timer) {
+ g_timer_stop(_timer);
+ }
+}
+
+void AppearTimeTracker::setAutodelete(bool autodelete)
+{
+ if ( autodelete != _autodelete ) {
+ _autodelete = autodelete;
+ }
+}
+
+void AppearTimeTracker::report(gchar const* msg)
+{
+ gulong msCount = 0;
+ gdouble secs = g_timer_elapsed( _timer, &msCount );
+ g_message("Time ended at %2.3f with [%s] on [%s]", secs, msg, _name.c_str());
+}
+
+void AppearTimeTracker::handleHierarchyChange( GtkWidget * /*prevTop*/ )
+{
+ GtkWidget *newTop = _widget;
+ while (newTop->parent) {
+ newTop = newTop->parent;
+ }
+
+ if ( newTop != _topMost ) {
+ unhookHandler( _mapId, _topMost );
+ unhookHandler( _realizeId, _topMost );
+
+ _topMost = newTop;
+ _mapId = g_signal_connect( G_OBJECT(_topMost), "map-event", G_CALLBACK(mapCB), this );
+ _realizeId = g_signal_connect( G_OBJECT(_topMost), "realize", G_CALLBACK(realizeCB), this );
+ }
+}
+
+gboolean AppearTimeTracker::mapCB(GtkWidget * /*widget*/, GdkEvent * /*event*/, gpointer userData)
+{
+ AppearTimeTracker *tracker = reinterpret_cast<AppearTimeTracker*>(userData);
+ tracker->report("MAP");
+ if ( tracker->_autodelete ) {
+ delete tracker;
+ }
+ return FALSE;
+}
+
+void AppearTimeTracker::realizeCB(GtkWidget * /*widget*/, gpointer userData)
+{
+ AppearTimeTracker *tracker = reinterpret_cast<AppearTimeTracker*>(userData);
+ tracker->report("REALIZE");
+}
+
+void AppearTimeTracker::hierarchyCB(GtkWidget * /*widget*/, GtkWidget *prevTop, gpointer userData)
+{
+ AppearTimeTracker *tracker = reinterpret_cast<AppearTimeTracker*>(userData);
+ tracker->handleHierarchyChange( prevTop );
+}
+
+} // namespace ege
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/util/ege-appear-time-tracker.h b/src/util/ege-appear-time-tracker.h
--- /dev/null
@@ -0,0 +1,89 @@
+#ifndef SEEN_APPEAR_TIME_TRACKER_H
+#define SEEN_APPEAR_TIME_TRACKER_H
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Appear Time Tracker.
+ *
+ * The Initial Developer of the Original Code is
+ * Jon A. Cruz.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <glib/gtimer.h>
+#include <glibmm/ustring.h>
+
+typedef union _GdkEvent GdkEvent;
+typedef struct _GtkWidget GtkWidget;
+
+namespace ege
+{
+
+class AppearTimeTracker {
+public:
+ AppearTimeTracker(GTimer *timer, GtkWidget *widget, gchar const* name);
+ ~AppearTimeTracker();
+
+ void stop();
+
+ bool isAutodelete() const { return _autodelete; }
+ void setAutodelete(bool autodelete);
+
+private:
+ Glib::ustring _name;
+ GTimer *_timer;
+ GtkWidget *_widget;
+ GtkWidget *_topMost;
+ bool _autodelete;
+ gulong _mapId;
+ gulong _realizeId;
+ gulong _hierarchyId;
+
+ static gboolean mapCB(GtkWidget *widget, GdkEvent *event, gpointer userData);
+ static void realizeCB(GtkWidget *widget, gpointer userData);
+ static void hierarchyCB(GtkWidget *widget, GtkWidget *prevTop, gpointer userData);
+
+ void report(gchar const* msg);
+ void handleHierarchyChange( GtkWidget *prevTop );
+};
+
+} // namespace ege
+
+#endif // SEEN_APPEAR_TIME_TRACKER_H
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 7a3e337ded52557484b94d5f626b51bbe21ae2f3..3509a1040d20dc1789ccfe86511e8bbbfc4129ad 100644 (file)
#include "ui/widget/layer-selector.h"
#include "ui/widget/selected-style.h"
#include "ui/uxmanager.h"
+#include "util/ege-appear-time-tracker.h"
// We're in the "widgets" directory, so no need to explicitly prefix these:
#include "button.h"
using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::UI::ToolboxFactory;
+using ege::AppearTimeTracker;
#ifdef WITH_INKBOARD
#endif
return Geom::Point(x,y);
}
+static GTimer *overallTimer = 0;
+
/**
* Registers SPDesktopWidget class and returns its type number.
*/
0 // value_table
};
type = g_type_register_static(SP_TYPE_VIEW_WIDGET, "SPDesktopWidget", &info, static_cast<GTypeFlags>(0));
+ // Begin a timer to watch for the first desktop to appear on-screen
+ overallTimer = g_timer_new();
}
return type;
}
gtk_widget_show_all (dtw->vbox);
gtk_widget_grab_focus (GTK_WIDGET(dtw->canvas));
+
+ // If this is the first desktop created, report the time it takes to show up
+ if ( overallTimer ) {
+ if ( prefs->getBool("/dialogs/debug/trackAppear", false) ) {
+ // Time tracker takes ownership of the timer.
+ AppearTimeTracker *tracker = new AppearTimeTracker(overallTimer, GTK_WIDGET(dtw), "first SPDesktopWidget");
+ tracker->setAutodelete(true);
+ } else {
+ g_timer_destroy(overallTimer);
+ }
+ overallTimer = 0;
+ }
}
/**