3 /// Utility functions specific to Barry Desktop
7 Copyright (C) 2009-2012, 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.
23 #include "barrydesktop.h"
24 #include "windowids.h"
26 const wxChar
*ButtonNames
[] = {
31 _T("browsedatabases"),
38 bool ButtonEnabled
[] = {
39 true, // backuprestore
42 true, // migratedevice
43 true, // browsedatabases
50 const wxChar
*StateNames
[] = {
57 //////////////////////////////////////////////////////////////////////////////
60 std::string
GetBaseFilename(const std::string
&filename
)
62 std::string file
= BARRYDESKTOP_BASEDATADIR
;
64 if( wxFileExists(wxString(file
.c_str(), wxConvUTF8
)) )
67 // fall back to the devel tree
71 /// Returns full path and filename for given filename.
72 /// 'filename' should have no directory component, as the
73 /// directory will be prepended and returned.
74 wxString
GetImageFilename(const wxString
&filename
)
76 // try the official install directory first
77 wxString file
= _T(BARRYDESKTOP_IMAGEDIR
);
79 if( wxFileExists(file
) )
82 // oops, assume we're running from the build directory,
83 // and use the images dir
84 file
= wxPathOnly(wxGetApp().argv
[0]);
85 file
+= _T("/../images/");
87 if( wxFileExists(file
) )
90 // hmmm.... maybe we're running from inside the libtool
91 // build subdirectories
92 file
= wxPathOnly(wxGetApp().argv
[0]);
93 file
+= _T("/../../images/");
98 wxString
GetButtonFilename(int id
, int state
)
100 return GetImageFilename(
101 wxString(ButtonNames
[id
- MainMenu_FirstButton
]) +
106 bool IsButtonEnabled(int id
)
108 return ButtonEnabled
[id
- MainMenu_FirstButton
];
111 bool IsParsable(const std::string
&dbname
)
114 #define HANDLE_PARSER(dbn) \
115 if( dbname == Barry::dbn::GetDBName() ) return true;
117 ALL_KNOWN_PARSER_TYPES
122 bool IsBuildable(const std::string
&dbname
)
124 #undef HANDLE_BUILDER
125 #define HANDLE_BUILDER(dbn) \
126 if( dbname == Barry::dbn::GetDBName() ) return true;
128 ALL_KNOWN_BUILDER_TYPES