Fri Mar 12 02:21:55 1999 Owen Taylor <otaylor@redhat.com> * capplets/theme-switcher/gui.c (browse_dialog_close): Add an error dialog if installing a theme fails. * capplets/theme-switcher/install.c (install_theme): Add a return value indicating success or failure. * capplets/theme-switcher/install.c (install_theme): Fixed reversed arguments for installing ungipped tarballs Fri Mar 12 01:12:15 1999 Owen Taylor <otaylor@redhat.com> [ Patch from Patrik Nordebo <isildur@a39.ryd.student.liu.se> ] * capplets/theme-switcher/install.c (install_theme): Removed useless call to wait(). Install themes in .themes, not .gtk/themes. Fri Mar 12 01:06:53 1999 Owen Taylor <otaylor@redhat.com> * capplets/theme-switcher/lister.c (edit_file_to_use): Fixed reversed lines that were causing initial creation not to work properly. * capplets/theme-switcher/demo.c (send_reread): You can't fsync() a pipe... * capplets/theme-switcher/gui.c: Don't select list items before they are added to the list ... removed hack that sort of worked around this. * capplets/theme-switcher/gui.c (make_main): Major un-rasterization. (Sort of a shame, this was some of the funniest code I've ever seen.) * capplets/theme-switcher/gui.c (install_theme_callback): Removed non-functional transient-for code. * capplets/theme-switcher/demo.c (demo_data_in): Removed brutal, unreliable kill -9 in favor of noticing when the IPC pipe closes. * capplets/theme-switcher/demo.c (demo_main): Solved problem where dup2() was going astray by not using it. * capplets/theme-switcher/gui.c (update_theme_entries): Fix cut-and-paste typo.
77 lines
1.7 KiB
Text
77 lines
1.7 KiB
Text
#include "da.h"
|
|
#include <errno.h>
|
|
|
|
gchar *
|
|
install_theme(gchar *file)
|
|
{
|
|
gchar s[4096];
|
|
gchar th[4096];
|
|
FILE *f;
|
|
guchar buf[1024];
|
|
gchar *theme_dir;
|
|
gchar *home;
|
|
|
|
if (isdir(file))
|
|
return FALSE;
|
|
|
|
theme_dir = gtk_rc_get_theme_dir();
|
|
if (geteuid() == 0)
|
|
g_snprintf(th, sizeof(th), "%s/", theme_dir);
|
|
else
|
|
{
|
|
home = g_get_home_dir();
|
|
if (!home)
|
|
{
|
|
g_free(theme_dir);
|
|
return g_strdup(_("Home directory doesn't exist!\n"));
|
|
}
|
|
g_snprintf(th, sizeof(th), "%s/.themes/", home);
|
|
}
|
|
g_free(theme_dir);
|
|
|
|
if (!isdir(th))
|
|
md(th);
|
|
|
|
if (!isfile(file))
|
|
return g_strdup(_("Theme does not exist"));
|
|
|
|
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); */
|
|
g_snprintf(s, sizeof(s),
|
|
"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",
|
|
th, file);
|
|
} else
|
|
s[0] = '\0';
|
|
|
|
if (*s)
|
|
{
|
|
gint status = system(s);
|
|
if (status < 0)
|
|
return g_strdup(g_strerror (errno));
|
|
else if (status != 0)
|
|
return g_strdup_printf(_("Command '%s' failed"), s);
|
|
else
|
|
return NULL;
|
|
}
|
|
else
|
|
return g_strdup(_("Unknown file format"));
|
|
}
|
|
|
|
return FALSE;
|
|
}
|