12 static gzFile gzf = NULL;
14 static int gzopen_frontend(const char *path, int oflags, int mode)
18 if ((fd = open(path, oflags, mode)) < 0) return -1;
19 if (!(gzf = gzdopen(fd, "rb"))) return -1;
23 static int gzclose_frontend(int nothing)
25 g_return_val_if_fail(gzf != NULL, 0);
29 static ssize_t gzread_frontend(int nothing, void *buf, size_t s)
31 return gzread(gzf, buf, s);
34 static ssize_t gzwrite_frontend(int nothing, const void *buf, size_t s)
36 return gzwrite(gzf, buf, s);
40 (openfunc_t) gzopen_frontend,
41 (closefunc_t) gzclose_frontend,
42 (readfunc_t) gzread_frontend,
43 (writefunc_t) gzwrite_frontend
46 gboolean install_theme(char *path, char *theme)
54 dest = g_build_path(G_DIR_SEPARATOR_S, g_get_home_dir(), ".themes", NULL);
55 r = mkdir(dest, 0777);
56 if (r == -1 && errno != EEXIST) {
57 w = gtk_message_dialog_new(GTK_WINDOW(mainwin),
58 GTK_DIALOG_DESTROY_WITH_PARENT |
62 _("Unable to create directory \"%s\": %s"),
63 dest, strerror(errno));
64 gtk_dialog_run(GTK_DIALOG(w));
65 gtk_widget_destroy(w);
68 if (chdir(dest) == -1) {
69 w = gtk_message_dialog_new(GTK_WINDOW(mainwin),
70 GTK_DIALOG_DESTROY_WITH_PARENT |
74 _("Unable to move to directory \"%s\": %s"),
75 dest, strerror(errno));
76 gtk_dialog_run(GTK_DIALOG(w));
77 gtk_widget_destroy(w);
81 if (tar_open(&t, path, &funcs, 0, O_RDONLY, TAR_GNU) == -1) {
82 w = gtk_message_dialog_new(GTK_WINDOW(mainwin),
83 GTK_DIALOG_DESTROY_WITH_PARENT |
87 _("Unable to open the file \"%s\": %s"),
88 path, strerror(errno));
89 gtk_dialog_run(GTK_DIALOG(w));
90 gtk_widget_destroy(w);
94 glob = g_strdup_printf("%s/openbox-3/*", theme);
95 r = tar_extract_glob(t, glob, dest);
100 w = gtk_message_dialog_new(GTK_WINDOW(mainwin),
101 GTK_DIALOG_DESTROY_WITH_PARENT |
105 _("Unable to extract the file \"%s\".\nIt does not appear to be a valid Openbox theme archive (in tar.gz format)."),
106 path, strerror(errno));
107 gtk_dialog_run(GTK_DIALOG(w));
108 gtk_widget_destroy(w);
114 w = gtk_message_dialog_new(GTK_WINDOW(mainwin),
115 GTK_DIALOG_DESTROY_WITH_PARENT |
119 _("%s was installed to %s"),
121 gtk_dialog_run(GTK_DIALOG(w));
122 gtk_widget_destroy(w);