desktop: fixed bug in GroupCfgDlg that gave mistaken "not configured" error
[barry/progweb.git] / desktop / src / util.cc
blobb9577a87983212a75c302023316fc90dddda4e6b
1 ///
2 /// \file util.cc
3 /// Utility functions specific to Barry Desktop
4 ///
6 /*
7 Copyright (C) 2009-2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "util.h"
23 #include "barrydesktop.h"
24 #include "windowids.h"
26 const wxChar *ButtonNames[] = {
27 _T("backuprestore"),
28 _T("sync"),
29 _T("modem"),
30 _T("apploader"),
31 _T("deviceswitch"),
32 _T("browsedatabases"),
33 _T("media"),
34 _T("misc"),
38 const wxChar *StateNames[] = {
39 _T("-normal.png"),
40 _T("-focus.png"),
41 _T("-pushed.png"),
45 //////////////////////////////////////////////////////////////////////////////
46 // Utility functions
48 std::string GetBaseFilename(const std::string &filename)
50 std::string file = BARRYDESKTOP_BASEDATADIR;
51 file += filename;
52 if( wxFileExists(wxString(file.c_str(), wxConvUTF8)) )
53 return file;
55 // fall back to the devel tree
56 return filename;
59 /// Returns full path and filename for given filename.
60 /// 'filename' should have no directory component, as the
61 /// directory will be prepended and returned.
62 wxString GetImageFilename(const wxString &filename)
64 // try the official install directory first
65 wxString file = _T(BARRYDESKTOP_IMAGEDIR);
66 file += filename;
67 if( wxFileExists(file) )
68 return file;
70 // oops, assume we're running from the build directory,
71 // and use the images dir
72 file = wxPathOnly(wxGetApp().argv[0]);
73 file += _T("/../images/");
74 file += filename;
75 return file;
78 wxString GetButtonFilename(int id, int state)
80 return GetImageFilename(
81 wxString(ButtonNames[id - MainMenu_FirstButton]) +
82 StateNames[state]