/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/r3113/plugins/CDVDiso/src/Linux/Config.cpp
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/r3113/plugins/CDVDiso/src/Linux/Config.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations) (download)
Tue Sep 7 06:17:51 2010 UTC (10 years, 8 months ago) by william
File size: 7805 byte(s)
create working branch for pcsx2-0.9.7-r3113-debug
1 /* CDVDiso
2 * Copyright (C) 2002-2004 CDVDiso Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include "Config.h"
20
21 const char *s_strIniPath="./inis/CDVDiso.ini";
22 GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
23 GtkWidget *Edit, *CdEdit;
24
25 void LoadConf()
26 {
27 FILE *f;
28 char cfg[256];
29
30 //sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
31 strcpy(cfg, s_strIniPath);
32 f = fopen(cfg, "r");
33
34 if (f == NULL)
35 {
36 printf("Unable to load %s\n", cfg);
37 strcpy(IsoFile, DEV_DEF);
38 strcpy(CdDev, CDDEV_DEF);
39 BlockDump = 0;
40 SaveConf();
41 return;
42 }
43
44 fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
45 fscanf(f, "CdDev = %[^\n]\n", CdDev);
46 fscanf(f, "BlockDump = %d\n", &BlockDump);
47
48 if (!strncmp(IsoFile, "CdDev =", 9)) *IsoFile = 0; // quick fix
49 if (*CdDev == 0) strcpy(CdDev, CDDEV_DEF);
50
51 fclose(f);
52 }
53
54 void SaveConf()
55 {
56 FILE *f;
57 char cfg[256];
58
59 //sprintf(cfg, "%s/.PS2E", getenv("HOME"));
60
61 //mkdir(cfg, 0755);
62 //sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
63 strcpy(cfg, s_strIniPath);
64
65 f = fopen(cfg, "w");
66 if (f == NULL)
67 {
68 printf("Unable to save %s\n", cfg);
69 return;
70 }
71
72 fprintf(f, "IsoFile = %s\n", IsoFile);
73 fprintf(f, "CdDev = %s\n", CdDev);
74 fprintf(f, "BlockDump = %d\n", BlockDump);
75 fclose(f);
76 }
77
78 void SysMessage(char *fmt, ...)
79 {
80 va_list list;
81 char tmp[256];
82 char cmd[256];
83
84 va_start(list, fmt);
85 vsprintf(tmp, fmt, list);
86 va_end(list);
87
88 sprintf(cmd, "message \"%s\"", tmp);
89 SysMessageLoc(tmp);
90 }
91
92 void OnFile_Ok()
93 {
94 gchar *File;
95
96 gtk_widget_hide(FileSel);
97 File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
98 strcpy(IsoFile, File);
99 gtk_main_quit();
100 }
101
102 void OnFile_Cancel()
103 {
104 gtk_widget_hide(FileSel);
105 gtk_main_quit();
106 }
107
108 void CfgOpenFile()
109 {
110 GtkWidget *Ok, *Cancel;
111
112 FileSel = gtk_file_selection_new("Select Iso File");
113
114 Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
115 gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
116 GTK_SIGNAL_FUNC(OnFile_Ok), NULL);
117 gtk_widget_show(Ok);
118
119 Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
120 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked",
121 GTK_SIGNAL_FUNC(OnFile_Cancel), NULL);
122 gtk_widget_show(Cancel);
123
124 gtk_widget_show(FileSel);
125 gdk_window_raise(FileSel->window);
126
127 gtk_main();
128
129 SaveConf();
130 }
131
132 void OnMsg_Ok()
133 {
134 gtk_widget_destroy(MsgDlg);
135 gtk_main_quit();
136 }
137
138 void SysMessageLoc(char *fmt, ...)
139 {
140 GtkWidget *Ok, *Txt;
141 GtkWidget *Box, *Box1;
142 va_list list;
143 int w;
144 char msg[512];
145
146 va_start(list, fmt);
147 vsprintf(msg, fmt, list);
148 va_end(list);
149
150 if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
151
152 w = strlen(msg) * 6 + 20;
153
154 MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
155 gtk_widget_set_usize(MsgDlg, w, 70);
156 gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
157 gtk_window_set_title(GTK_WINDOW(MsgDlg), "cdriso Msg");
158 gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 0);
159
160 Box = gtk_vbox_new(0, 0);
161 gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
162 gtk_widget_show(Box);
163
164 Txt = gtk_label_new(msg);
165
166 gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
167 gtk_widget_show(Txt);
168
169 Box1 = gtk_hbutton_box_new();
170 gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
171 gtk_widget_show(Box1);
172
173 Ok = gtk_button_new_with_label("Ok");
174 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
175 gtk_container_add(GTK_CONTAINER(Box1), Ok);
176 GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
177 gtk_widget_show(Ok);
178
179 gtk_widget_show(MsgDlg);
180
181 gtk_main();
182 }
183
184 void OnOk (GtkButton *button, gpointer user_data)
185 {
186 char *tmp;
187
188 stop = true;
189 tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
190 strcpy(IsoFile, tmp);
191 tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
192 strcpy(CdDev, tmp);
193
194 if is_checked(ConfDlg, "checkBlockDump")
195 BlockDump = 1;
196 else
197 BlockDump = 0;
198
199 SaveConf();
200 gtk_widget_destroy(ConfDlg);
201 gtk_main_quit();
202 }
203
204 void OnCancel(GtkButton *button, gpointer user_data)
205 {
206 stop = true;
207 gtk_widget_destroy(ConfDlg);
208 gtk_main_quit();
209 }
210
211 void OnFileSel_Ok()
212 {
213 gchar *File;
214
215 File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
216 gtk_entry_set_text(GTK_ENTRY(Edit), File);
217 gtk_widget_destroy(FileSel);
218 }
219
220 void OnFileSel_Cancel()
221 {
222 gtk_widget_destroy(FileSel);
223 }
224
225 void OnFileSel(GtkButton *button, gpointer user_data)
226 {
227 GtkWidget *Ok, *Cancel;
228
229 FileSel = gtk_file_selection_new("Select Psx Iso File");
230 gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), IsoFile);
231
232 Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
233 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Ok), NULL);
234 gtk_widget_show(Ok);
235
236 Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
237 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Cancel), NULL);
238 gtk_widget_show(Cancel);
239
240 gtk_widget_show(FileSel);
241 gdk_window_raise(FileSel->window);
242 }
243
244
245 EXPORT_C_(void) CDVDconfigure()
246 {
247 int i;
248
249 LoadConf();
250
251 ConfDlg = create_Config();
252
253 Edit = lookup_widget(ConfDlg, "GtkEntry_Iso");
254 gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
255 CdEdit = lookup_widget(ConfDlg, "GtkEntry_CdDev");
256 gtk_entry_set_text(GTK_ENTRY(CdEdit), CdDev);
257
258 Progress = lookup_widget(ConfDlg, "GtkProgressBar_Progress");
259
260 BtnCompress = lookup_widget(ConfDlg, "GtkButton_Compress");
261 BtnDecompress = lookup_widget(ConfDlg, "GtkButton_Decompress");
262 BtnCreate = lookup_widget(ConfDlg, "GtkButton_Create");
263 BtnCreateZ = lookup_widget(ConfDlg, "GtkButton_CreateZ");
264
265 methodlist = NULL;
266 for (i = 0; i < 2; i++)
267 methodlist = g_list_append(methodlist, methods[i]);
268
269 Method = lookup_widget(ConfDlg, "GtkCombo_Method");
270 gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
271 if (strstr(IsoFile, ".Z") != NULL)
272 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
273 else
274 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
275
276 set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
277
278 gtk_widget_show_all(ConfDlg);
279 gtk_main();
280
281 return 0;
282 }
283
284 void OnAboutOk(GtkMenuItem * menuitem, gpointer userdata)
285 {
286 gtk_widget_hide(AboutDlg);
287 gtk_main_quit();
288 }
289
290 EXPORT_C_(void) CDVDabout()
291 {
292 GtkWidget *Label;
293 GtkWidget *Ok;
294 GtkWidget *Box, *BBox;
295 char AboutText[255];
296
297 sprintf(AboutText, "%s %d.%d\n", LibName, revision, build);
298
299 AboutDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
300 gtk_widget_set_usize(AboutDlg, 260, 80);
301 gtk_window_set_title(GTK_WINDOW(AboutDlg), "CDVD About Dialog");
302 gtk_window_set_position(GTK_WINDOW(AboutDlg), GTK_WIN_POS_CENTER);
303 gtk_container_set_border_width(GTK_CONTAINER(AboutDlg), 10);
304
305 Box = gtk_vbox_new(0, 0);
306 gtk_container_add(GTK_CONTAINER(AboutDlg), Box);
307 gtk_widget_show(Box);
308
309 Label = gtk_label_new(AboutText);
310 gtk_box_pack_start(GTK_BOX(Box), Label, FALSE, FALSE, 0);
311 gtk_widget_show(Label);
312
313 BBox = gtk_hbutton_box_new();
314 gtk_box_pack_start(GTK_BOX(Box), BBox, FALSE, FALSE, 0);
315 gtk_widget_show(BBox);
316
317 Ok = gtk_button_new_with_label("Ok");
318 gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
319 GTK_SIGNAL_FUNC(OnAboutOk), NULL);
320 gtk_container_add(GTK_CONTAINER(BBox), Ok);
321 GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
322 gtk_widget_show(Ok);
323
324 gtk_widget_show(AboutDlg);
325 gtk_main();
326 }

  ViewVC Help
Powered by ViewVC 1.1.22