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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 typedef struct _Panel
{
31 CallbackRec callbacks
;
52 #define ICON_FILE "theme"
54 static void showData(_Panel
* panel
)
59 static void finishedTileDownload(void *data
)
61 _Panel
*panel
= (_Panel
*) data
;
63 WMSetButtonText(panel
->totB
, _("Set"));
67 static void finishedBarDownload(void *data
)
69 _Panel
*panel
= (_Panel
*) data
;
71 WMSetButtonText(panel
->botB
, _("Set"));
75 static pid_t
downloadFile(WMScreen
* scr
, _Panel
* panel
, char *file
)
81 werror("could not fork() process");
83 WMRunAlertPanel(scr
, GetWindow(panel
), _("Error"),
84 "Could not start download. fork() failed", _("OK"), NULL
, NULL
);
91 close(ConnectionNumber(WMScreenDisplay(scr
)));
96 static void downloadCallback(WMWidget
* w
, void *data
)
98 _Panel
*panel
= (_Panel
*) data
;
100 WMButton
*button
= (WMButton
*) w
;
103 if (button
== panel
->totB
) {
104 pid
= &panel
->tilePID
;
106 pid
= &panel
->barPID
;
110 newPid
= downloadFile(WMWidgetScreen(w
), panel
, NULL
);
114 WMSetButtonText(button
, _("Stop"));
116 if (button
== panel
->totB
) {
117 AddDeadChildHandler(newPid
, finishedTileDownload
, data
);
119 AddDeadChildHandler(newPid
, finishedBarDownload
, data
);
125 WMSetButtonText(button
, _("Download"));
129 static void createPanel(Panel
* p
)
131 _Panel
*panel
= (_Panel
*) p
;
133 panel
->box
= WMCreateBox(panel
->parent
);
134 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
136 panel
->saveB
= WMCreateCommandButton(panel
->box
);
137 WMResizeWidget(panel
->saveB
, 154, 24);
138 WMMoveWidget(panel
->saveB
, 15, 10);
139 WMSetButtonText(panel
->saveB
, _("Save Current Theme"));
141 panel
->list
= WMCreateList(panel
->box
);
142 WMResizeWidget(panel
->list
, 154, 150);
143 WMMoveWidget(panel
->list
, 15, 40);
145 panel
->loadB
= WMCreateCommandButton(panel
->box
);
146 WMResizeWidget(panel
->loadB
, 74, 24);
147 WMMoveWidget(panel
->loadB
, 15, 200);
148 WMSetButtonText(panel
->loadB
, _("Load"));
150 panel
->instB
= WMCreateCommandButton(panel
->box
);
151 WMResizeWidget(panel
->instB
, 74, 24);
152 WMMoveWidget(panel
->instB
, 95, 200);
153 WMSetButtonText(panel
->instB
, _("Install"));
155 /**************** Tile of the day ****************/
157 panel
->totF
= WMCreateFrame(panel
->box
);
158 WMResizeWidget(panel
->totF
, 210, 105);
159 WMMoveWidget(panel
->totF
, 240, 10);
160 WMSetFrameTitle(panel
->totF
, _("Tile of The Day"));
162 panel
->totL
= WMCreateLabel(panel
->totF
);
163 WMResizeWidget(panel
->totL
, 67, 67);
164 WMMoveWidget(panel
->totL
, 25, 25);
165 WMSetLabelRelief(panel
->totL
, WRSunken
);
167 panel
->totB
= WMCreateCommandButton(panel
->totF
);
168 WMResizeWidget(panel
->totB
, 86, 24);
169 WMMoveWidget(panel
->totB
, 105, 45);
170 WMSetButtonText(panel
->totB
, _("Download"));
171 WMSetButtonAction(panel
->totB
, downloadCallback
, panel
);
173 WMMapSubwidgets(panel
->totF
);
175 /**************** Bar of the day ****************/
177 panel
->botF
= WMCreateFrame(panel
->box
);
178 WMResizeWidget(panel
->botF
, 315, 95);
179 WMMoveWidget(panel
->botF
, 190, 125);
180 WMSetFrameTitle(panel
->botF
, _("Bar of The Day"));
182 panel
->botL
= WMCreateLabel(panel
->botF
);
183 WMResizeWidget(panel
->botL
, 285, 32);
184 WMMoveWidget(panel
->botL
, 15, 20);
185 WMSetLabelRelief(panel
->botL
, WRSunken
);
187 panel
->botB
= WMCreateCommandButton(panel
->botF
);
188 WMResizeWidget(panel
->botB
, 86, 24);
189 WMMoveWidget(panel
->botB
, 110, 60);
190 WMSetButtonText(panel
->botB
, _("Download"));
191 WMSetButtonAction(panel
->botB
, downloadCallback
, panel
);
193 WMMapSubwidgets(panel
->botF
);
195 WMRealizeWidget(panel
->box
);
196 WMMapSubwidgets(panel
->box
);
201 static void storeData(_Panel
* panel
)
205 Panel
*InitThemes(WMScreen
* scr
, WMWidget
* parent
)
209 panel
= wmalloc(sizeof(_Panel
));
211 panel
->sectionName
= _("Themes");
213 panel
->parent
= parent
;
215 panel
->callbacks
.createWidgets
= createPanel
;
216 panel
->callbacks
.updateDomain
= storeData
;
218 AddSection(panel
, ICON_FILE
);