[glom] Avoid showing %20 in the window title.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Avoid showing %20 in the window title.
- Date: Mon, 22 Feb 2010 22:58:23 +0000 (UTC)
commit b22529402361e0d90623a764b6b369a218fee10d
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Feb 22 23:58:13 2010 +0100
Avoid showing %20 in the window title.
* glom/libglom/document/bakery/document.cc: get_name():
Use Gio::FileInfo::get_display_name() instead of
Glib::filename_display_basename() or Glib::filename_display_name(), to avoid
showing %20 in the window title bar when there are spaces in the file name.
Noticed by Daniel Borgmann.
ChangeLog | 10 ++++++++
glom/libglom/document/bakery/document.cc | 35 ++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index da6ddfb..be49dda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-22 Murray Cumming <murrayc murrayc com>
+
+ Avoid showing %20 in the window title.
+
+ * glom/libglom/document/bakery/document.cc: get_name():
+ Use Gio::FileInfo::get_display_name() instead of
+ Glib::filename_display_basename() or Glib::filename_display_name(), to avoid
+ showing %20 in the window title bar when there are spaces in the file name.
+ Noticed by Daniel Borgmann.
+
1.13.5:
2010-02-08 Peter Penz <ppenz openismus com>
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 3a609ca..1e181a1 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -345,12 +345,43 @@ Glib::ustring Document::get_name() const
return util_file_uri_get_name(m_file_uri, m_file_extension);
}
+//Note that Glib::filename_display_basename() shows %20 for spaces so it isn't very useful.
+static Glib::ustring get_file_display_name(const Glib::ustring& uri)
+{
+ Glib::ustring result;
+
+ Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
+ Glib::RefPtr<const Gio::FileInfo> file_info;
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ file_info = file->query_info(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "App_Glom::get_file_display_name(): error: " << ex.what() << std::endl;
+ return result;
+ }
+#else
+ std::auto_ptr<Gio::Error> error;
+ file_info = uri->query_info(G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, Gio::FILE_QUERY_INFO_NONE, error);
+ if(error.get())
+ return result;
+#endif
+
+ if(!file_info)
+ return result;
+
+ return file_info->get_display_name();
+}
+
Glib::ustring Document::util_file_uri_get_name(const Glib::ustring& file_uri, const Glib::ustring& file_extension)
{
- Glib::ustring strResult = Glib::filename_display_basename(file_uri);
+ Glib::ustring strResult = get_file_display_name(file_uri);
//Remove the file extension:
- //TODO: Maybe filename_display_basename() should do this.
+ //TODO: Maybe g_filename_display_basename() and g_file_info_get_display_name() should do this.
if(!strResult.empty() && !file_extension.empty())
{
const Glib::ustring strExt = '.' + file_extension;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]