[passepartout] dropped the save dialog variable and rewrote its handling



commit 4c5dcb9e6d5f74d1cf079d18c8efaed140ed55d8
Author: Sven Herzberg <herzi lanedo com>
Date:   Sat May 2 00:43:25 2009 +0200

    dropped the save dialog variable and rewrote its handling
    
    * src/pptout/window.cc,
    * src/pptout/window.h: some code cleanup to improve the startup time
---
 src/pptout/window.cc |   49 +++++++++++++++++++++++--------------------------
 src/pptout/window.h  |    5 ++---
 2 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/pptout/window.cc b/src/pptout/window.cc
index e7af99d..73160f8 100644
--- a/src/pptout/window.cc
+++ b/src/pptout/window.cc
@@ -104,13 +104,6 @@ FrameWindow::constructor_common (void)
 {
   p = new Private ();
 
-  save_dialog.reset(new Filesel(*this, _("Save As"),
-                                Gtk::FILE_CHOOSER_ACTION_SAVE));
-
-  // file filters
-  save_dialog->add_filter(p->pptout);
-  save_dialog->add_filter(p->all);
-
   print_dialog.reset(new PrintDialog(*this, document_view));
   text_frame_dialog.reset(new TextFrameDialog(*this, document_view));
 
@@ -183,8 +176,6 @@ FrameWindow::constructor_common (void)
   zoom_factor.signal_changed.connect
     (sigc::mem_fun(*this, &FrameWindow::zoom_factor_changed_action));
   
-  save_dialog->signal_hide().connect
-    (sigc::mem_fun(*this, &FrameWindow::save_dialog_done));
   import_dialog->signal_hide().connect
     (sigc::mem_fun(*this, &FrameWindow::import_dialog_done));
 
@@ -269,20 +260,6 @@ void FrameWindow::import_dialog_done() {
        dynamic_cast<ImageFilesel*>(import_dialog.get())->get_res());
 }
 
-void FrameWindow::save_dialog_done() {
-  DocMeta document = document_view.get_document_meta();
-
-  if(!save_dialog->was_cancelled() && document) {
-    std::string filename = save_dialog->get_filename();
-    if (!g_str_has_suffix (filename.c_str(), ".pp"))
-      {
-	filename += ".pp";
-      }
-    document.set_filename(filename);
-    document->save(filename);
-  }
-}
-
 void FrameWindow::close() {
   DocRef document = document_view.get_document();
   if(windows.size() > 1 || !document) {
@@ -322,10 +299,30 @@ FrameWindow::open_file (void)
 void
 FrameWindow::save_as (void)
 {
-  save_dialog->show ();
+  std::auto_ptr<Filesel> save_dialog (new Filesel (*this, _("Save As"),
+                                                   Gtk::FILE_CHOOSER_ACTION_SAVE));
+
+  save_dialog->add_filter(p->pptout);
+  save_dialog->add_filter(p->all);
+
+  save_dialog->run ();
+
+  DocMeta document = document_view.get_document_meta();
+
+  if(!save_dialog->was_cancelled() && document) {
+    std::string filename = save_dialog->get_filename();
+    if (!g_str_has_suffix (filename.c_str(), ".pp"))
+      {
+	filename += ".pp";
+      }
+    document.set_filename(filename);
+    document->save(filename);
+  }
 }
 
-void FrameWindow::save() {
+void
+FrameWindow::save (void)
+{
   DocRef document = document_view.get_document();
   if(!document)
     return;
@@ -335,7 +332,7 @@ void FrameWindow::save() {
   if(!filename.empty()) {
     document->save(filename);
   } else
-    save_dialog->show();
+    save_as ();
 }
 
 void
diff --git a/src/pptout/window.h b/src/pptout/window.h
index b18caa0..580fc5e 100644
--- a/src/pptout/window.h
+++ b/src/pptout/window.h
@@ -41,7 +41,7 @@ private:
   Gtk::Statusbar *cafe_opera;
   Zoomer zoom_factor;
   DocumentView document_view;
-  std::auto_ptr<Filesel> save_dialog, import_dialog;
+  std::auto_ptr<Filesel> import_dialog;
   std::auto_ptr<PrintDialog> print_dialog;
   std::auto_ptr<TextFrameDialog> text_frame_dialog;
   Pagesel *pagesel;
@@ -67,13 +67,12 @@ private:
   void zoom_factor_changed_action(float factor);
 
   void open_file (void);
+  void save (void);
   void save_as (void);
 
   void create_menus (Gtk::RecentFilter& filter);
-  void save_dialog_done();
   void show_preferences ();
   void import_dialog_done();
-  void save();
   void close();
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]