Code

Merge from trunk.
[inkscape.git] / src / widgets / desktop-widget.cpp
index 7a3e337ded52557484b94d5f626b51bbe21ae2f3..4620b15328e0137603f11dcf50078cf0426513a5 100644 (file)
@@ -56,6 +56,7 @@
 #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"
@@ -73,6 +74,7 @@ using Inkscape::round;
 using Inkscape::UnitTracker;
 using Inkscape::UI::UXManager;
 using Inkscape::UI::ToolboxFactory;
+using ege::AppearTimeTracker;
 
 #ifdef WITH_INKBOARD
 #endif
@@ -121,6 +123,30 @@ static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *item, gpointer data);
 
 SPViewWidgetClass *dtw_parent_class;
 
+static GTimer *baseTimer = 0;
+static bool timeReported = false;
+
+static void timeGoing(gchar const* id)
+{
+    if ( !baseTimer ) {
+        g_message("Starting time at point [%s]", id);
+        baseTimer = g_timer_new();
+    }
+}
+
+static void checkTime(gchar const* msg)
+{
+    if ( baseTimer && !timeReported ) {
+        timeReported = true;
+        g_timer_stop(baseTimer);
+        gulong msCount = 0;
+        gdouble secs = g_timer_elapsed( baseTimer, &msCount );
+        g_message("Time ended at %2.3f with [%s]", secs, msg);
+    }
+}
+
+
+
 class CMSPrefWatcher {
 public:
     CMSPrefWatcher() :
@@ -243,6 +269,8 @@ SPDesktopWidget::window_get_pointer()
     return Geom::Point(x,y);
 }
 
+static GTimer *overallTimer = 0;
+
 /**
  * Registers SPDesktopWidget class and returns its type number.
  */
@@ -250,6 +278,7 @@ GType SPDesktopWidget::getType(void)
 {
     static GtkType type = 0;
     if (!type) {
+        timeGoing("SPDesktopWidget::getType");
         GTypeInfo info = {
             sizeof(SPDesktopWidgetClass),
             0, // base_init
@@ -263,6 +292,8 @@ GType SPDesktopWidget::getType(void)
             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;
 }
@@ -273,6 +304,7 @@ GType SPDesktopWidget::getType(void)
 static void
 sp_desktop_widget_class_init (SPDesktopWidgetClass *klass)
 {
+    timeGoing("sp_desktop_widget_class_init");
     dtw_parent_class = (SPViewWidgetClass*)gtk_type_class (SP_TYPE_VIEW_WIDGET);
 
     GtkObjectClass *object_class = (GtkObjectClass *) klass;
@@ -289,6 +321,7 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass)
  */
 void SPDesktopWidget::init( SPDesktopWidget *dtw )
 {
+    timeGoing("SPDesktopWidget::init");
     GtkWidget *widget;
     GtkWidget *tbl;
     GtkWidget *canvas_tbl;
@@ -564,6 +597,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
     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;
+    }
 }
 
 /**