Replace string literal 'gnucash' with PROJECT_NAME parameter where it makes sense

The idea behind this is to not assume the project is always built
as "gnucash" exactly.
One example where it can be useful to use a different project name
would be when building multiple development versions of the project
on the same system and don't want these different versions share
the same settings in GSettings or the same stored passwords.
This commit is contained in:
Geert Janssens 2022-10-24 21:41:08 +02:00
parent 2c93c383ac
commit 734f90bd36
8 changed files with 21 additions and 20 deletions

View File

@ -39,7 +39,7 @@
static QofLogModule log_module = GNC_MOD_GUI;
#define DEFAULT_HOST "localhost"
#define DEFAULT_DATABASE "gnucash"
#define DEFAULT_DATABASE PROJECT_NAME
#define FILE_ACCESS_OPEN 0
#define FILE_ACCESS_SAVE_AS 1
#define FILE_ACCESS_EXPORT 2

View File

@ -200,14 +200,14 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent,
* referenced above. */
secret_password_store_sync (SECRET_SCHEMA_GNUCASH, SECRET_COLLECTION_DEFAULT,
"Dummy password", "dummy", NULL, &error,
"protocol", "gnucash",
"server", "gnucash",
"user", "gnucash",
"protocol", PROJECT_NAME,
"server", PROJECT_NAME,
"user", PROJECT_NAME,
NULL);
secret_password_clear_sync (SECRET_SCHEMA_GNUCASH, NULL, &error,
"protocol", "gnucash",
"server", "gnucash",
"user", "gnucash",
"protocol", PROJECT_NAME,
"server", PROJECT_NAME,
"user", PROJECT_NAME,
NULL);
/* Note: only use the port attribute if it was set by the user. */

View File

@ -226,7 +226,8 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
int
main(int argc, char **argv)
{
Gnucash::GnucashCli application (argv[0]);
const char *app_name = PROJECT_NAME "-cli";
Gnucash::GnucashCli application (app_name);
#ifdef __MINGW32__
boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8
#endif

View File

@ -287,7 +287,7 @@ Gnucash::Gnucash::configure_program_options (void)
// for gtk's options. The options themselves are already parsed out by
// gtk_init_check by the time this function is called though. So it really only
// serves to be able to display a help message.
g_set_prgname ("gnucash");
g_set_prgname (PROJECT_NAME);
auto context = g_option_context_new (m_tagline.c_str());
auto gtk_options = gtk_get_option_group(FALSE);
g_option_context_add_group (context, gtk_options);
@ -357,7 +357,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv
int
main(int argc, char ** argv)
{
Gnucash::Gnucash application (argv[0]);
Gnucash::Gnucash application (PROJECT_NAME);
#ifdef __MINGW32__
boost::nowide::args a(argc, argv); // Fix arguments - make them UTF-8
#endif

View File

@ -176,7 +176,7 @@ gnc_AB_BANKING_new (void)
}
else
{
api = AB_Banking_new ("gnucash", NULL, 0);
api = AB_Banking_new (PROJECT_NAME, NULL, 0);
g_return_val_if_fail (api, NULL);
/* These two values must be set because newest bank regulation requires

View File

@ -233,7 +233,7 @@ setup_business (Fixture* fixture, gconstpointer pData)
emp = gncEmployeeCreate (book);
gncEmployeeSetID (emp, "0001");
gncEmployeeSetUsername (emp, "gnucash");
gncEmployeeSetUsername (emp, PROJECT_NAME);
gncEmployeeSetLanguage (emp, "english");
gncEmployeeSetCurrency (emp, currency);

View File

@ -69,7 +69,7 @@ gchar *gnc_path_get_datadir()
gchar *gnc_path_get_pkgdatadir()
{
gchar *datadir = gnc_gbr_find_data_dir (DATADIR);
gchar *result = g_build_filename (datadir, "gnucash", (char*)NULL);
gchar *result = g_build_filename (datadir, PROJECT_NAME, (char*)NULL);
g_free (datadir);
//printf("Returning pkgdatadir %s\n", result);
return result;
@ -82,7 +82,7 @@ gchar *gnc_path_get_pkgdatadir()
gchar *gnc_path_get_pkgdocdir()
{
gchar *docdir = gnc_gbr_find_data_dir (DATADIR);
gchar *result = g_build_filename (docdir, "doc", "gnucash", (char*)NULL);
gchar *result = g_build_filename (docdir, "doc", PROJECT_NAME, (char*)NULL);
g_free (docdir);
//printf("Returning pkgdocdir %s\n", result);
return result;
@ -95,7 +95,7 @@ gchar *gnc_path_get_pkgdocdir()
gchar *gnc_path_get_pkgsysconfdir()
{
gchar *sysconfdir = gnc_gbr_find_etc_dir (SYSCONFDIR);
gchar *result = g_build_filename (sysconfdir, "gnucash", (char*)NULL);
gchar *result = g_build_filename (sysconfdir, PROJECT_NAME, (char*)NULL);
g_free (sysconfdir);
//printf("Returning pkgsysconfdir %s\n", result);
return result;
@ -113,7 +113,7 @@ gchar *gnc_path_get_pkglibdir()
/* Workaround for Bug 618646, {pkglibdir} will be bin/ on Windows */
gchar *result = gnc_gbr_find_bin_dir(libdir);
#else
gchar *result = g_build_filename (libdir, "gnucash", (char*)NULL);
gchar *result = g_build_filename (libdir, PROJECT_NAME, (char*)NULL);
#endif
g_free (libdir);
//printf("Returning pkglibdir %s\n", result);
@ -192,7 +192,7 @@ gchar *gnc_path_get_scmdir()
gchar *gnc_path_get_reportdir()
{
gchar *scmdir = gnc_path_get_scmdir ();
gchar *result = g_build_filename (scmdir, "gnucash", "report", (char*)NULL);
gchar *result = g_build_filename (scmdir, PROJECT_NAME, "report", (char*)NULL);
g_free (scmdir);
return result;
@ -205,7 +205,7 @@ gchar *gnc_path_get_reportdir()
gchar *gnc_path_get_reportsdir()
{
gchar *scmdir = gnc_path_get_scmdir ();
gchar *result = g_build_filename (scmdir, "gnucash", "reports", NULL);
gchar *result = g_build_filename (scmdir, PROJECT_NAME, "reports", NULL);
g_free (scmdir);
//printf("Returning reportsdir %s\n", result);
return result;

View File

@ -107,7 +107,7 @@ TEST_F(PathTest, gnc_path_get_datadir)
TEST_F(PathTest, gnc_path_get_sysconfdir)
{
gchar *dirname = gnc_file_path_relative_part(PREFIX, SYSCONFDIR);
gchar *sysconfpath = g_build_filename(m_prefix, dirname, "gnucash", NULL);
gchar *sysconfpath = g_build_filename(m_prefix, dirname, PROJECT_NAME, NULL);
g_free(dirname);
#ifdef ENABLE_BINRELOC
EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath);
@ -119,7 +119,7 @@ TEST_F(PathTest, gnc_path_get_sysconfdir)
g_free(sysconfpath);
g_unsetenv("GNC_UNINSTALLED");
g_unsetenv("GNC_BUILDDIR");
sysconfpath = g_build_filename(SYSCONFDIR, "gnucash", NULL);
sysconfpath = g_build_filename(SYSCONFDIR, PROJECT_NAME, NULL);
EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath);
g_free(sysconfpath);
#endif