Codebase list mednaffe / 7fe9eee
[Windows] Improve behavior when emulator and/or configuration files are not found AmatCoder 3 years ago
2 changed file(s) with 42 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
293293 MainWindow* mw = self;
294294 MainWindowPrivate* priv = main_window_get_instance_private (mw);
295295
296 if ((selection != NULL) || (priv->sensitive))
296 if ((selection != NULL) && (priv->sensitive))
297297 {
298298 main_window_set_all_sensitive (mw, FALSE, priv->show_tooltips);
299299
956956
957957 if (priv->med_process->MedExePath == NULL)
958958 {
959 main_window_show_error (self, "Mednafen executable not found!\n");
959 #ifdef G_OS_WIN32
960 main_window_show_error (self, "Mednafen executable not found in this folder!\n");
961 #else
962 main_window_show_error (self, "Mednafen executable not found in PATH!\n");
963 #endif
960964 main_window_set_all_sensitive (self, FALSE, priv->show_tooltips);
961965 }
962
963 med_process_read_conf (priv->med_process);
964
965 if (priv->med_process->MedVersion == NULL)
966 main_window_show_error (self, "Mednafen configuration file (mednafen.cfg) not found!\n");
967966 else
968967 {
969 gtk_label_set_label (priv->status_version, priv->med_process->MedVersion);
970 if (priv->med_process->MedExePath)
968 med_process_read_conf (priv->med_process);
969
970 if (priv->med_process->MedVersion == NULL)
971 main_window_show_error (self, "Mednafen configuration file (mednafen.cfg) not found!\n");
972 else
971973 {
972 gchar *tooltip = g_strconcat ("Executable: ", priv->med_process->MedExePath, "\nConfiguration: ", priv->med_process->MedConfPath, NULL);
973 gtk_widget_set_tooltip_text ((GtkWidget*) priv->status_version, tooltip);
974 g_free (tooltip);
974 gtk_label_set_label (priv->status_version, priv->med_process->MedVersion);
975 if (priv->med_process->MedExePath)
976 {
977 gchar *tooltip = g_strconcat ("Executable: ", priv->med_process->MedExePath, "\nConfiguration: ", priv->med_process->MedConfPath, NULL);
978 gtk_widget_set_tooltip_text ((GtkWidget*) priv->status_version, tooltip);
979 g_free (tooltip);
980 }
975981 }
976982 }
977983
988994 g_object_set_data ((GObject*) self, "listjoy", priv->listjoy);
989995
990996 gtk_window_set_default_icon_list (g_object_get_data (app, "icon_list"));
997
998 #ifdef G_OS_WIN32
999 gtk_entry_set_icon_from_icon_name (priv->custom_entry, GTK_ENTRY_ICON_SECONDARY, "gtk-clear");
1000 #endif
9911001
9921002 main_window_load_settings (self);
9931003 }
270270 {
271271 MedProcess *self = (MedProcess*) g_object_new (med_process_get_type(), NULL);
272272
273 gboolean b = FALSE;
273274 #ifdef G_OS_WIN32
274275 gchar *bin = g_find_program_in_path ("mednafen.exe");
275 self->MedExePath = g_strconcat("\"", bin, "\"", NULL);
276 g_free(bin);
276
277 if (bin != NULL)
278 {
279 self->MedExePath = g_strconcat("\"", bin, "\"", NULL);
280 b = TRUE;
281 }
282
283 g_free (bin);
277284 #else
278285 self->MedExePath = g_find_program_in_path ("mednafen");
279286 #endif
280
281287 if (self->MedExePath != NULL)
282288 {
283289 #ifdef G_OS_WIN32
290 GFile* test = med_process_get_conf_path (self);
291
284292 bin = g_strconcat(self->MedExePath, " --help", NULL);
285 gboolean b = WinExec(bin, SW_HIDE);
286 g_free(bin);
293 b = (WinExec (bin, SW_HIDE) > 31);
294
295 if (test == NULL)
296 Sleep (2000);
297 else
298 g_object_unref (test);
299
300 g_free (bin);
287301 #else
288302 gchar* stdout;
289303 gchar* stderr;
290304
291305 gchar *cl = g_shell_quote (self->MedExePath);
292 gboolean b = g_spawn_command_line_sync (cl, &stdout, &stderr, NULL, NULL);
306 b = g_spawn_command_line_sync (cl, &stdout, &stderr, NULL, NULL);
293307
294308 g_free (stdout);
295309 g_free (stderr);