Code

Simple tracking of time to display dialogs and main window.
[inkscape.git] / src / ui / dialog / dialog-manager.cpp
index f8c07cf535c16e4bd99c7687a8ae86e02f93f31d..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/align-and-distribute.h"
 #include "ui/dialog/document-metadata.h"
 #include "ui/dialog/document-properties.h"
-#include "ui/dialog/export.h"
 #include "ui/dialog/extension-editor.h"
 #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/layer-editor.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"
-#include "ui/dialog/text-properties.h"
+#include "ui/dialog/tile.h"
 #include "ui/dialog/tracedialog.h"
 #include "ui/dialog/transformation.h"
 #include "ui/dialog/undo-history.h"
-#include "ui/dialog/xml-editor.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,59 +87,63 @@ 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>);
-        registerFactory("Export",              &create<Export,               FloatingBehavior>);
         registerFactory("ExtensionEditor",     &create<ExtensionEditor,      FloatingBehavior>);
         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("LayerEditor",         &create<LayerEditor,          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>);
+#endif
         registerFactory("Swatches",            &create<SwatchesPanel,        FloatingBehavior>);
-        registerFactory("TextProperties",      &create<TextProperties,       FloatingBehavior>);
         registerFactory("TileDialog",          &create<TileDialog,           FloatingBehavior>);
         registerFactory("Trace",               &create<TraceDialog,          FloatingBehavior>);
         registerFactory("Transformation",      &create<Transformation,       FloatingBehavior>);
         registerFactory("UndoHistory",         &create<UndoHistory,          FloatingBehavior>);
-        registerFactory("XmlEditor",           &create<XmlEditor,            FloatingBehavior>);
+        registerFactory("InputDevices",        &create<InputDialog,          FloatingBehavior>);
 
     } else {
 
         registerFactory("AlignAndDistribute",  &create<AlignAndDistribute,   DockBehavior>);
         registerFactory("DocumentMetadata",    &create<DocumentMetadata,     DockBehavior>);
         registerFactory("DocumentProperties",  &create<DocumentProperties,   DockBehavior>);
-        registerFactory("Export",              &create<Export,               DockBehavior>);
         registerFactory("ExtensionEditor",     &create<ExtensionEditor,      DockBehavior>);
         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("LayerEditor",         &create<LayerEditor,          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>);
+#endif
         registerFactory("Swatches",            &create<SwatchesPanel,        DockBehavior>);
-        registerFactory("TextProperties",      &create<TextProperties,       DockBehavior>);
         registerFactory("TileDialog",          &create<TileDialog,           DockBehavior>);
         registerFactory("Trace",               &create<TraceDialog,          DockBehavior>);
         registerFactory("Transformation",      &create<Transformation,       DockBehavior>);
         registerFactory("UndoHistory",         &create<UndoHistory,          DockBehavior>);
-        registerFactory("XmlEditor",           &create<XmlEditor,            DockBehavior>);
+        registerFactory("InputDevices",        &create<InputDialog,          DockBehavior>);
 
     }
 }
@@ -147,6 +154,24 @@ DialogManager::~DialogManager() {
     //        Appears to cause a segfault if we do
 }
 
+
+DialogManager &DialogManager::getInstance()
+{
+    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();
+}
+
 /**
  * Registers a dialog factory function used to create the named dialog.
  */
@@ -208,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
@@ -227,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 :