Commit 80cf78cd authored by Daniel Elstner's avatar Daniel Elstner
Browse files

:filename_short_display_name): Rename from Util::shorten_pathname().

* src/stringutils.{cc,h} (Util::filename_short_display_name):
Rename from Util::shorten_pathname().  Return the display name
of the shortened filename encoded in UTF-8.
(Util::expand_pathname): Remove as this function is no longer
being used anywhere.
* src/mainwindow.cc (MainWindow::set_title_filename): Use
Util::filename_short_display_name().

svn path=/trunk/; revision=644
parent 276eba50
2007-01-17 Daniel Elstner <daniel.kitta@gmail.com>
* src/stringutils.{cc,h} (Util::filename_short_display_name):
Rename from Util::shorten_pathname(). Return the display name
of the shortened filename encoded in UTF-8.
(Util::expand_pathname): Remove as this function is no longer
being used anywhere.
* src/mainwindow.cc (MainWindow::set_title_filename): Use
Util::filename_short_display_name().
2007-01-17 Daniel Elstner <daniel.kitta@gmail.com>
* Makefile.am (rxlocaledir): New variable that defines the locale
......
......@@ -781,7 +781,7 @@ void MainWindow::set_title_filename(const std::string& filename)
Glib::ustring title = Glib::filename_display_basename(filename);
title += " (";
title += Glib::filename_display_name(Util::shorten_pathname(Glib::path_get_dirname(filename)));
title += Util::filename_short_display_name(Glib::path_get_dirname(filename));
title += ") \342\200\223 " PACKAGE_NAME; // U+2013 EN DASH
window_->set_title(title);
......
......@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <glibmm.h>
#include <gdkmm/color.h>
#include <algorithm>
#include <iomanip>
#include <locale>
......@@ -32,7 +33,6 @@
#include <utility>
#include <vector>
namespace
{
......@@ -612,34 +612,22 @@ Glib::ustring Util::int_to_string(int number)
return Glib::locale_to_utf8(output.str());
}
std::string Util::shorten_pathname(const std::string& path)
Glib::ustring Util::filename_short_display_name(const std::string& filename)
{
const std::string homedir = Glib::get_home_dir();
const std::string::size_type len = homedir.length();
if (path.length() >= len
&& (path.length() == len || G_IS_DIR_SEPARATOR(path[len]))
&& path.compare(0, len, homedir) == 0)
if (filename.length() >= len
&& (filename.length() == len || G_IS_DIR_SEPARATOR(filename[len]))
&& filename.compare(0, len, homedir) == 0)
{
std::string result (1, '~');
result.append(path, len, std::string::npos);
return result;
}
std::string short_name (1, '~');
short_name.append(filename, len, std::string::npos);
return path;
}
std::string Util::expand_pathname(const std::string& path)
{
if (path.length() > 0 && path[0] == '~'
&& (path.length() == 1 || G_IS_DIR_SEPARATOR(path[1])))
{
std::string result = Glib::get_home_dir();
result.append(path, 1, std::string::npos);
return result;
return Glib::filename_display_name(short_name);
}
return path;
return Glib::filename_display_name(filename);
}
Glib::ustring Util::color_to_string(const Gdk::Color& color)
......
......@@ -29,7 +29,6 @@
namespace Gdk { class Color; }
namespace Util
{
......@@ -43,8 +42,7 @@ Glib::ustring substitute_references(const Glib::ustring& substitution,
const Glib::ustring& subject,
const CaptureVector& captures);
std::string shorten_pathname(const std::string& path);
std::string expand_pathname(const std::string& path);
Glib::ustring filename_short_display_name(const std::string& filename);
Glib::ustring int_to_string(int number);
Glib::ustring color_to_string(const Gdk::Color& color);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment