1 /* Themes.c- Theme stuff
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 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,
27 typedef struct _Panel
{
32 CallbackRec callbacks
;
53 #define ICON_FILE "theme"
55 static void showData(_Panel
* panel
)
60 static void finishedTileDownload(void *data
)
62 _Panel
*panel
= (_Panel
*) data
;
64 WMSetButtonText(panel
->totB
, _("Set"));
68 static void finishedBarDownload(void *data
)
70 _Panel
*panel
= (_Panel
*) data
;
72 WMSetButtonText(panel
->botB
, _("Set"));
76 static pid_t
downloadFile(WMScreen
* scr
, _Panel
* panel
, char *file
)
82 wsyserror("could not fork() process");
84 WMRunAlertPanel(scr
, GetWindow(panel
), _("Error"),
85 "Could not start download. fork() failed", _("OK"), NULL
, NULL
);
92 close(ConnectionNumber(WMScreenDisplay(scr
)));
97 static void downloadCallback(WMWidget
* w
, void *data
)
99 _Panel
*panel
= (_Panel
*) data
;
101 WMButton
*button
= (WMButton
*) w
;
104 if (button
== panel
->totB
) {
105 pid
= &panel
->tilePID
;
107 pid
= &panel
->barPID
;
111 newPid
= downloadFile(WMWidgetScreen(w
), panel
, NULL
);
115 WMSetButtonText(button
, _("Stop"));
117 if (button
== panel
->totB
) {
118 AddDeadChildHandler(newPid
, finishedTileDownload
, data
);
120 AddDeadChildHandler(newPid
, finishedBarDownload
, data
);
126 WMSetButtonText(button
, _("Download"));
130 static void createPanel(Panel
* p
)
132 _Panel
*panel
= (_Panel
*) p
;
134 panel
->box
= WMCreateBox(panel
->parent
);
135 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
137 panel
->saveB
= WMCreateCommandButton(panel
->box
);
138 WMResizeWidget(panel
->saveB
, 154, 24);
139 WMMoveWidget(panel
->saveB
, 15, 10);
140 WMSetButtonText(panel
->saveB
, _("Save Current Theme"));
142 panel
->list
= WMCreateList(panel
->box
);
143 WMResizeWidget(panel
->list
, 154, 150);
144 WMMoveWidget(panel
->list
, 15, 40);
146 panel
->loadB
= WMCreateCommandButton(panel
->box
);
147 WMResizeWidget(panel
->loadB
, 74, 24);
148 WMMoveWidget(panel
->loadB
, 15, 200);
149 WMSetButtonText(panel
->loadB
, _("Load"));
151 panel
->instB
= WMCreateCommandButton(panel
->box
);
152 WMResizeWidget(panel
->instB
, 74, 24);
153 WMMoveWidget(panel
->instB
, 95, 200);
154 WMSetButtonText(panel
->instB
, _("Install"));
156 /**************** Tile of the day ****************/
158 panel
->totF
= WMCreateFrame(panel
->box
);
159 WMResizeWidget(panel
->totF
, 210, 105);
160 WMMoveWidget(panel
->totF
, 240, 10);
161 WMSetFrameTitle(panel
->totF
, _("Tile of The Day"));
163 panel
->totL
= WMCreateLabel(panel
->totF
);
164 WMResizeWidget(panel
->totL
, 67, 67);
165 WMMoveWidget(panel
->totL
, 25, 25);
166 WMSetLabelRelief(panel
->totL
, WRSunken
);
168 panel
->totB
= WMCreateCommandButton(panel
->totF
);
169 WMResizeWidget(panel
->totB
, 86, 24);
170 WMMoveWidget(panel
->totB
, 105, 45);
171 WMSetButtonText(panel
->totB
, _("Download"));
172 WMSetButtonAction(panel
->totB
, downloadCallback
, panel
);
174 WMMapSubwidgets(panel
->totF
);
176 /**************** Bar of the day ****************/
178 panel
->botF
= WMCreateFrame(panel
->box
);
179 WMResizeWidget(panel
->botF
, 315, 95);
180 WMMoveWidget(panel
->botF
, 190, 125);
181 WMSetFrameTitle(panel
->botF
, _("Bar of The Day"));
183 panel
->botL
= WMCreateLabel(panel
->botF
);
184 WMResizeWidget(panel
->botL
, 285, 32);
185 WMMoveWidget(panel
->botL
, 15, 20);
186 WMSetLabelRelief(panel
->botL
, WRSunken
);
188 panel
->botB
= WMCreateCommandButton(panel
->botF
);
189 WMResizeWidget(panel
->botB
, 86, 24);
190 WMMoveWidget(panel
->botB
, 110, 60);
191 WMSetButtonText(panel
->botB
, _("Download"));
192 WMSetButtonAction(panel
->botB
, downloadCallback
, panel
);
194 WMMapSubwidgets(panel
->botF
);
196 WMRealizeWidget(panel
->box
);
197 WMMapSubwidgets(panel
->box
);
202 static void storeData(_Panel
* panel
)
206 Panel
*InitThemes(WMScreen
* scr
, WMWidget
* parent
)
210 panel
= wmalloc(sizeof(_Panel
));
211 memset(panel
, 0, sizeof(_Panel
));
213 panel
->sectionName
= _("Themes");
215 panel
->parent
= parent
;
217 panel
->callbacks
.createWidgets
= createPanel
;
218 panel
->callbacks
.updateDomain
= storeData
;
220 AddSection(panel
, ICON_FILE
);