Author: kitone
Date: Sun Apr 12 10:57:33 2015
New Revision: 898
URL: http://svn.gna.org/viewcvs/subtitleeditor?rev=898&view=rev
Log:
Refactoring code to change extension of filename (dialog save document).
Modified:
trunk/ChangeLog
trunk/src/gui/dialogfilechooser.cc
trunk/src/utility.cc
trunk/src/utility.h
Modified: trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/subtitleeditor/trunk/ChangeLog?rev=898&r1=897&r2=898&view=diff
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sun Apr 12 10:57:33 2015
@@ -1,3 +1,10 @@
+2015-04-12 kitone <[email protected]>
+
+ * src/gui/dialogfilechooser.cc:
+ * src/utility.cc:
+ * src/utility.h:
+ Refactoring code to change extension of filename (dialog save document).
+
2015-04-12 kitone <[email protected]>
* configure.ac:
Modified: trunk/src/gui/dialogfilechooser.cc
URL:
http://svn.gna.org/viewcvs/subtitleeditor/trunk/src/gui/dialogfilechooser.cc?rev=898&r1=897&r2=898&view=diff
==============================================================================
--- trunk/src/gui/dialogfilechooser.cc (original)
+++ trunk/src/gui/dialogfilechooser.cc Sun Apr 12 10:57:33 2015
@@ -321,15 +321,8 @@
SubtitleFormatInfo sfinfo;
if(SubtitleFormatSystem::instance().get_info(get_format(), sfinfo) ==
false)
return;
-
- // Test if the name already have an extension then replace the
- // previous extension by the new one or simply add the extension to the
name.
- Glib::RefPtr<Glib::Regex> re = Glib::Regex::create("^(.*)(\\.)(.*)$");
- if(re->match(basename))
- basename = re->replace(basename, 0, "\\1." + sfinfo.extension,
Glib::RegexMatchFlags(0));
- else
- basename = basename + "." + sfinfo.extension;
-
+ // Change the extension according to the format selected
+ basename = utility::add_or_replace_extension(basename,
sfinfo.extension);
// Update only the current name
set_current_name(basename);
}
Modified: trunk/src/utility.cc
URL:
http://svn.gna.org/viewcvs/subtitleeditor/trunk/src/utility.cc?rev=898&r1=897&r2=898&view=diff
==============================================================================
--- trunk/src/utility.cc (original)
+++ trunk/src/utility.cc Sun Apr 12 10:57:33 2015
@@ -392,5 +392,18 @@
window.set_transient_for(*root);
}
+ /*
+ */
+ Glib::ustring add_or_replace_extension(const Glib::ustring &filename,
const Glib::ustring &extension)
+ {
+ Glib::ustring renamed;
+ Glib::RefPtr<Glib::Regex> re =
Glib::Regex::create("^(.*)(\\.)(.*)$");
+ if(re->match(filename))
+ renamed = re->replace(filename, 0, "\\1." + extension,
Glib::RegexMatchFlags(0));
+ else
+ renamed = filename + "." + extension;
+ return renamed;
+ }
+
}//namespace utility
Modified: trunk/src/utility.h
URL:
http://svn.gna.org/viewcvs/subtitleeditor/trunk/src/utility.h?rev=898&r1=897&r2=898&view=diff
==============================================================================
--- trunk/src/utility.h (original)
+++ trunk/src/utility.h Sun Apr 12 10:57:33 2015
@@ -223,7 +223,10 @@
*
*/
void set_transient_parent(Gtk::Window &window);
-
+
+ /*
+ */
+ Glib::ustring add_or_replace_extension(const Glib::ustring &filename,
const Glib::ustring &extension);
}
#endif//_utility_h
_______________________________________________
Subtitleeditor-commits mailing list
[email protected]
https://mail.gna.org/listinfo/subtitleeditor-commits