1 /* Themes.c- Theme stuff
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 typedef struct _Panel
{
33 CallbackRec callbacks
;
56 #define ICON_FILE "theme"
60 showData(_Panel
*panel
)
67 finishedTileDownload(void *data
)
69 _Panel
*panel
= (_Panel
*)data
;
71 WMSetButtonText(panel
->totB
, _("Set"));
78 finishedBarDownload(void *data
)
80 _Panel
*panel
= (_Panel
*)data
;
82 WMSetButtonText(panel
->botB
, _("Set"));
88 downloadFile(WMScreen
*scr
, _Panel
*panel
, char *file
)
94 wsyserror("could not fork() process");
96 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
97 "Could not start download. fork() failed",
105 close(ConnectionNumber(WMScreenDisplay(scr
)));
114 downloadCallback(WMWidget
*w
, void *data
)
116 _Panel
*panel
= (_Panel
*)data
;
118 WMButton
*button
= (WMButton
*)w
;
121 if (button
== panel
->totB
) {
122 pid
= &panel
->tilePID
;
124 pid
= &panel
->barPID
;
128 newPid
= downloadFile(WMWidgetScreen(w
), panel
, NULL
);
132 WMSetButtonText(button
, _("Stop"));
134 if (button
== panel
->totB
) {
135 AddDeadChildHandler(newPid
, finishedTileDownload
, data
);
137 AddDeadChildHandler(newPid
, finishedBarDownload
, data
);
143 WMSetButtonText(button
, _("Download"));
150 updateThemeList(_Panel
*panel
)
152 WMClearList(panel
->list
);
161 createPanel(Panel
*p
)
163 _Panel
*panel
= (_Panel
*)p
;
164 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
166 panel
->frame
= WMCreateFrame(panel
->win
);
167 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
168 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
170 panel
->saveB
= WMCreateCommandButton(panel
->frame
);
171 WMResizeWidget(panel
->saveB
, 154, 24);
172 WMMoveWidget(panel
->saveB
, 15, 10);
173 WMSetButtonText(panel
->saveB
, _("Save Current Theme"));
175 panel
->list
= WMCreateList(panel
->frame
);
176 WMResizeWidget(panel
->list
, 154, 150);
177 WMMoveWidget(panel
->list
, 15, 40);
179 panel
->loadB
= WMCreateCommandButton(panel
->frame
);
180 WMResizeWidget(panel
->loadB
, 74, 24);
181 WMMoveWidget(panel
->loadB
, 15, 200);
182 WMSetButtonText(panel
->loadB
, _("Load"));
184 panel
->instB
= WMCreateCommandButton(panel
->frame
);
185 WMResizeWidget(panel
->instB
, 74, 24);
186 WMMoveWidget(panel
->instB
, 95, 200);
187 WMSetButtonText(panel
->instB
, _("Install"));
190 /**************** Tile of the day ****************/
192 panel
->totF
= WMCreateFrame(panel
->frame
);
193 WMResizeWidget(panel
->totF
, 210, 105);
194 WMMoveWidget(panel
->totF
, 240, 10);
195 WMSetFrameTitle(panel
->totF
, _("Tile of The Day"));
197 panel
->totL
= WMCreateLabel(panel
->totF
);
198 WMResizeWidget(panel
->totL
, 67, 67);
199 WMMoveWidget(panel
->totL
, 25, 25);
200 WMSetLabelRelief(panel
->totL
, WRSunken
);
202 panel
->totB
= WMCreateCommandButton(panel
->totF
);
203 WMResizeWidget(panel
->totB
, 86, 24);
204 WMMoveWidget(panel
->totB
, 105, 45);
205 WMSetButtonText(panel
->totB
, _("Download"));
206 WMSetButtonAction(panel
->totB
, downloadCallback
, panel
);
208 WMMapSubwidgets(panel
->totF
);
210 /**************** Bar of the day ****************/
212 panel
->botF
= WMCreateFrame(panel
->frame
);
213 WMResizeWidget(panel
->botF
, 315, 95);
214 WMMoveWidget(panel
->botF
, 190, 125);
215 WMSetFrameTitle(panel
->botF
, _("Bar of The Day"));
217 panel
->botL
= WMCreateLabel(panel
->botF
);
218 WMResizeWidget(panel
->botL
, 285, 32);
219 WMMoveWidget(panel
->botL
, 15, 20);
220 WMSetLabelRelief(panel
->botL
, WRSunken
);
222 panel
->botB
= WMCreateCommandButton(panel
->botF
);
223 WMResizeWidget(panel
->botB
, 86, 24);
224 WMMoveWidget(panel
->botB
, 110, 60);
225 WMSetButtonText(panel
->botB
, _("Download"));
226 WMSetButtonAction(panel
->botB
, downloadCallback
, panel
);
228 WMMapSubwidgets(panel
->botF
);
230 WMRealizeWidget(panel
->frame
);
231 WMMapSubwidgets(panel
->frame
);
238 storeData(_Panel
*panel
)
245 InitThemes(WMScreen
*scr
, WMWindow
*win
)
249 panel
= wmalloc(sizeof(_Panel
));
250 memset(panel
, 0, sizeof(_Panel
));
252 panel
->sectionName
= _("Themes");
256 panel
->callbacks
.createWidgets
= createPanel
;
257 panel
->callbacks
.updateDomain
= storeData
;
259 AddSection(panel
, ICON_FILE
);