From cd3bf7da0942431699d11f5bec8dbf30428a415b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Fri, 18 Sep 2015 16:50:31 +0200 Subject: [PATCH] Automatically add the prefix where icons are installed to XDG_DATA_DIRS when missing --- gtk/main.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gtk/main.c b/gtk/main.c index e44a7158e..39af6802e 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2061,6 +2061,26 @@ static void sigint_handler(int signum){ gtk_main_quit(); } +static void populate_xdg_data_dirs_envvar(void) { +#ifndef WIN32 + int i; + const gchar *value = g_getenv("XDG_DATA_DIRS"); + if(value && strlen(value)) { + gchar **paths = g_strsplit(value, ":", -1); + for(i=0; paths[i] && strcmp(paths[i], PACKAGE_DATA_DIR) != 0; i++); + if(paths[i] == NULL) { + gchar *new_value = g_strdup_printf("%s:%s", value, PACKAGE_DATA_DIR); + g_setenv("XDG_DATA_DIRS", new_value, TRUE); + g_free(new_value); + } + g_strfreev(paths); + } else { + g_warning("The XDG_DATA_DIRS environment variable is not set. If you experience missing icons, " + "consider setting it"); + } +#endif +} + int main(int argc, char *argv[]){ char *config_file; const char *factory_config_file; @@ -2089,6 +2109,8 @@ int main(int argc, char *argv[]){ /*for pulseaudio:*/ g_setenv("PULSE_PROP_media.role", "phone", TRUE); #endif + + populate_xdg_data_dirs_envvar(); lang=linphone_gtk_get_lang(config_file); if (lang == NULL || lang[0]=='\0'){