1998-09-23 02:39:17 +00:00
|
|
|
#include "da.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
install_theme(gchar *file)
|
|
|
|
{
|
|
|
|
gchar s[4096];
|
|
|
|
gchar th[4096];
|
|
|
|
FILE *f;
|
|
|
|
gint i;
|
|
|
|
guchar buf[1024];
|
|
|
|
gchar *theme_dir;
|
|
|
|
gchar *home;
|
|
|
|
|
|
|
|
if (isdir(file))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
theme_dir = gtk_rc_get_theme_dir();
|
|
|
|
if (geteuid() == 0)
|
|
|
|
g_snprintf(th, sizeof(th), "%s/", theme_dir);
|
|
|
|
else
|
|
|
|
{
|
1999-02-23 19:05:46 +00:00
|
|
|
home = g_get_home_dir();
|
1998-09-23 02:39:17 +00:00
|
|
|
if (!home)
|
|
|
|
{
|
|
|
|
g_free(theme_dir);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_snprintf(th, sizeof(th), "%s/.gtk/themes/", home);
|
|
|
|
}
|
|
|
|
g_free(theme_dir);
|
|
|
|
|
|
|
|
if (!isdir(th))
|
|
|
|
md(th);
|
|
|
|
|
|
|
|
if (isfile(file))
|
|
|
|
{
|
|
|
|
f = fopen(file, "r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
fread(buf, 1, 1000, f);
|
|
|
|
fclose(f);
|
|
|
|
if ((buf[0] == 31) && (buf[1] == 139))
|
|
|
|
{
|
|
|
|
/*gzipped tarball */
|
|
|
|
/*sprintf(s,"gzip -d -c < %s | tar -xf - -C %s",Theme_Tar_Ball,Theme_Path); */
|
1999-01-25 23:33:57 +00:00
|
|
|
g_snprintf(s, sizeof(s),
|
1998-09-23 02:39:17 +00:00
|
|
|
"gzip -d -c < %s | (cd %s ; tar -xf -)",
|
|
|
|
file, th);
|
|
|
|
}
|
|
|
|
else if ((buf[257] == 'u') && (buf[258] == 's') && (buf[259] == 't') &&
|
|
|
|
(buf[260] == 'a') && (buf[261] == 'r'))
|
|
|
|
{
|
|
|
|
/*vanilla tarball */
|
|
|
|
/*sprintf(s,"tar -xf - -C %s < %s",Theme_Path,Theme_Tar_Ball); */
|
|
|
|
g_snprintf(s, sizeof(s),
|
|
|
|
"(cd %s ; tar -xf %s",
|
|
|
|
file, th);
|
1999-01-25 23:33:57 +00:00
|
|
|
} else
|
|
|
|
s[0] = '\0';
|
|
|
|
|
|
|
|
if(*s) {
|
|
|
|
system(s);
|
|
|
|
wait(&i);
|
|
|
|
}
|
1998-09-23 02:39:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|