From 8ac68e4712cb039d20c589440cd71ecd33e97b8c Mon Sep 17 00:00:00 2001 From: dooglus Date: Wed, 20 Feb 2008 02:06:58 +0000 Subject: [PATCH] Moved the check for whether an instance has a real filename into a new method, since it's used in a couple of places. git-svn-id: http://svn.voria.com/code@1782 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/instance.cpp | 17 ++++++++++++----- synfig-studio/trunk/src/gtkmm/instance.h | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/instance.cpp b/synfig-studio/trunk/src/gtkmm/instance.cpp index 2d4ecdb..597eaec 100644 --- a/synfig-studio/trunk/src/gtkmm/instance.cpp +++ b/synfig-studio/trunk/src/gtkmm/instance.cpp @@ -214,10 +214,8 @@ studio::Instance::open() Instance::Status studio::Instance::save() { - // the filename will be set to "Synfig Animation 1" or some such when first created - // and will be changed to an absolute path once it has been saved - // so if it still begins with "Synfig Animation " then we need to ask where to save it - if(get_file_name().find(DEFAULT_FILENAME_PREFIX)==0) + // if we don't have a real filename yet then we need to ask where to save it + if (!has_real_filename()) { if (dialog_save_as()) return STATUS_OK; @@ -232,6 +230,15 @@ studio::Instance::save() return STATUS_ERROR; } +// the filename will be set to "Synfig Animation 1" or some such when first created +// and will be changed to an absolute path once it has been saved +// so if it still begins with "Synfig Animation " then we don't have a real filename yet +bool +studio::Instance::has_real_filename() +{ + return get_file_name().find(DEFAULT_FILENAME_PREFIX) != 0; +} + bool studio::Instance::dialog_save_as() { @@ -264,7 +271,7 @@ studio::Instance::dialog_save_as() } } - if (get_file_name().find(DEFAULT_FILENAME_PREFIX) != 0) + if (has_real_filename()) filename = absolute_path(filename); // show the canvas' name if it has one, else its ID diff --git a/synfig-studio/trunk/src/gtkmm/instance.h b/synfig-studio/trunk/src/gtkmm/instance.h index d07474a..06a0fa4 100644 --- a/synfig-studio/trunk/src/gtkmm/instance.h +++ b/synfig-studio/trunk/src/gtkmm/instance.h @@ -178,6 +178,9 @@ public: bool save_as(const synfig::String &filename); + //! returns true if the instance has a real filename associated with it, rather than the made up "synfig animation 1" or some such + bool has_real_filename(); + //! Opens a "Save As" dialog, and then saves the composition to that file //! returns true if the save was successful bool dialog_save_as(); -- 2.7.4