Code

Simple tracking of time to display dialogs and main window.
[inkscape.git] / src / ui / dialog / dialog-manager.cpp
index 227814cd1f45952b99f47e5a3b0bc0851f04983c..0c49690cce5b70d585cf003335271f410491b267 100644 (file)
@@ -1,13 +1,13 @@
-/**
- * \brief Object for managing a set of dialogs, including their signals and
+/** @file
+ * @brief Object for managing a set of dialogs, including their signals and
  *        construction/caching/destruction of them.
- *
- * Authors:
+ */
+/* Authors:
  *   Bryce W. Harrington <bryce@bryceharrington.org>
  *   Jon Phillips <jon@rejon.org>
  *   Gustav Broberg <broberg@kth.se>
  *
- * Copyright (C) 2004--2007 Authors
+ * Copyright (C) 2004-2007 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
  */
 #include "ui/dialog/fill-and-stroke.h"
 #include "ui/dialog/filter-effects-dialog.h"
 #include "ui/dialog/find.h"
+#include "ui/dialog/glyphs.h"
 #include "ui/dialog/inkscape-preferences.h"
 #include "ui/dialog/input.h"
 #include "ui/dialog/livepatheffect-editor.h"
 #include "ui/dialog/memory.h"
 #include "ui/dialog/messages.h"
 #include "ui/dialog/scriptdialog.h"
-#ifdef ENABLE_SVG_FONTS
-#include "ui/dialog/svg-fonts-dialog.h"
-#endif // ENABLE_SVG_FONTS
+#include "ui/dialog/tile.h"
 #include "ui/dialog/tracedialog.h"
 #include "ui/dialog/transformation.h"
 #include "ui/dialog/undo-history.h"
 #include "ui/dialog/panel-dialog.h"
-
-#include "dialogs/layers-panel.h"
-#include "dialogs/tiledialog.h"
-#include "dialogs/iconpreview.h"
-
+#include "ui/dialog/layers.h"
+#include "ui/dialog/icon-preview.h"
 #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
+#include "ui/dialog/svg-fonts-dialog.h"
+#endif // ENABLE_SVG_FONTS
 
 namespace Inkscape {
 namespace UI {
@@ -84,10 +87,10 @@ DialogManager::DialogManager() {
     using namespace Behavior;
     using namespace Inkscape::UI::Dialogs; // temporary
 
-    int dialogs_type = prefs_get_int_attribute_limited ("options.dialogtype", "value", DOCK, 0, 1);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    int dialogs_type = prefs->getIntLimited("/options/dialogtype/value", DOCK, 0, 1);
 
     if (dialogs_type == FLOATING) {
-
         registerFactory("AlignAndDistribute",  &create<AlignAndDistribute,   FloatingBehavior>);
         registerFactory("DocumentMetadata",    &create<DocumentMetadata,     FloatingBehavior>);
         registerFactory("DocumentProperties",  &create<DocumentProperties,   FloatingBehavior>);
@@ -95,12 +98,14 @@ DialogManager::DialogManager() {
         registerFactory("FillAndStroke",       &create<FillAndStroke,        FloatingBehavior>);
         registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog,  FloatingBehavior>);
         registerFactory("Find",                &create<Find,                 FloatingBehavior>);
+        registerFactory("Glyphs",              &create<GlyphsPanel,          FloatingBehavior>);
         registerFactory("IconPreviewPanel",    &create<IconPreviewPanel,     FloatingBehavior>);
         registerFactory("InkscapePreferences", &create<InkscapePreferences,  FloatingBehavior>);
         registerFactory("LayersPanel",         &create<LayersPanel,          FloatingBehavior>);
         registerFactory("LivePathEffect",      &create<LivePathEffectEditor, FloatingBehavior>);
         registerFactory("Memory",              &create<Memory,               FloatingBehavior>);
         registerFactory("Messages",            &create<Messages,             FloatingBehavior>);
+//        registerFactory("PrintColorsPreviewDialog",      &create<PrintColorsPreviewDialog,       FloatingBehavior>);
         registerFactory("Script",              &create<ScriptDialog,         FloatingBehavior>);
 #ifdef ENABLE_SVG_FONTS
         registerFactory("SvgFontsDialog",      &create<SvgFontsDialog,       FloatingBehavior>);
@@ -110,7 +115,7 @@ DialogManager::DialogManager() {
         registerFactory("Trace",               &create<TraceDialog,          FloatingBehavior>);
         registerFactory("Transformation",      &create<Transformation,       FloatingBehavior>);
         registerFactory("UndoHistory",         &create<UndoHistory,          FloatingBehavior>);
-        registerFactory("InputDevices",        &create<InputDialog,           FloatingBehavior>);
+        registerFactory("InputDevices",        &create<InputDialog,          FloatingBehavior>);
 
     } else {
 
@@ -121,12 +126,14 @@ DialogManager::DialogManager() {
         registerFactory("FillAndStroke",       &create<FillAndStroke,        DockBehavior>);
         registerFactory("FilterEffectsDialog", &create<FilterEffectsDialog,  DockBehavior>);
         registerFactory("Find",                &create<Find,                 DockBehavior>);
+        registerFactory("Glyphs",              &create<GlyphsPanel,          DockBehavior>);
         registerFactory("IconPreviewPanel",    &create<IconPreviewPanel,     DockBehavior>);
         registerFactory("InkscapePreferences", &create<InkscapePreferences,  DockBehavior>);
         registerFactory("LayersPanel",         &create<LayersPanel,          DockBehavior>);
         registerFactory("LivePathEffect",      &create<LivePathEffectEditor, DockBehavior>);
         registerFactory("Memory",              &create<Memory,               DockBehavior>);
         registerFactory("Messages",            &create<Messages,             DockBehavior>);
+//        registerFactory("PrintColorsPreviewDialog",      &create<PrintColorsPreviewDialog,       DockBehavior>);
         registerFactory("Script",              &create<ScriptDialog,         DockBehavior>);
 #ifdef ENABLE_SVG_FONTS
         registerFactory("SvgFontsDialog",      &create<SvgFontsDialog,       DockBehavior>);
@@ -150,16 +157,17 @@ DialogManager::~DialogManager() {
 
 DialogManager &DialogManager::getInstance()
 {
-    int dialogs_type = prefs_get_int_attribute_limited ("options.dialogtype", "value", DOCK, 0, 1);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    int dialogs_type = prefs->getIntLimited("/options/dialogtype/value", DOCK, 0, 1);
 
     /* Use singleton behavior for floating dialogs */
     if (dialogs_type == FLOATING) {
         static DialogManager *instance = 0;
-        
+
         if (!instance)
             instance = new DialogManager();
         return *instance;
-    } 
+    }
 
     return *new DialogManager();
 }
@@ -225,10 +233,23 @@ void DialogManager::showDialog(gchar const *name) {
  * 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
@@ -244,4 +265,4 @@ void DialogManager::showDialog(GQuark name) {
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :