From e55b9f9cfe2a3012b394441035c098a214d6933c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 14 Dec 2012 16:17:24 +0100 Subject: PanelStyle: use std::array to handle file names (bzr r2970.5.3) --- unity-shared/PanelStyle.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/unity-shared/PanelStyle.cpp b/unity-shared/PanelStyle.cpp index 0db2bbc5d..95c53d17f 100644 --- a/unity-shared/PanelStyle.cpp +++ b/unity-shared/PanelStyle.cpp @@ -21,6 +21,7 @@ #include "config.h" #include +#include #include #include @@ -192,19 +193,17 @@ BaseTexturePtr Style::GetBackground(int width, int height, float opacity) std::vector Style::GetWindowButtonFileNames(WindowButtonType type, WindowState state) { std::vector files; - std::string names[] = { "close", "minimize", "unmaximize", "maximize" }; - std::string states[] = { "", "_focused_prelight", "_focused_pressed", "_unfocused", - "_unfocused", "_unfocused_prelight", "_unfocused_pressed"}; + static const std::array names = {{ "close", "minimize", "unmaximize", "maximize" }}; + static const std::array states = {{ "", "_focused_prelight", "_focused_pressed", "_unfocused", + "_unfocused", "_unfocused_prelight", "_unfocused_pressed" }}; - std::ostringstream subpath; - subpath << "unity/" << names[static_cast(type)] - << states[static_cast(state)] << ".png"; + std::string subpath = "unity/" + names[static_cast(type)] + states[static_cast(state)] + ".png"; // Look in home directory const char* home_dir = g_get_home_dir(); if (home_dir) { - glib::String filename(g_build_filename(home_dir, ".themes", _theme_name.c_str(), subpath.str().c_str(), NULL)); + glib::String filename(g_build_filename(home_dir, ".themes", _theme_name.c_str(), subpath.c_str(), NULL)); if (g_file_test(filename.Value(), G_FILE_TEST_EXISTS)) files.push_back (filename.Value()); @@ -214,7 +213,7 @@ std::vector Style::GetWindowButtonFileNames(WindowButtonType type, if (!var) var = "/usr"; - glib::String filename(g_build_filename(var, "share", "themes", _theme_name.c_str(), subpath.str().c_str(), NULL)); + glib::String filename(g_build_filename(var, "share", "themes", _theme_name.c_str(), subpath.c_str(), NULL)); if (g_file_test(filename.Value(), G_FILE_TEST_EXISTS)) files.push_back (filename.Value()); -- cgit v1.2.3