Example #1
0
void ui_exit(void)
{
    ui_button_t b;
    int value1, value2;
    char *s = util_concat(_("Exit "), (machine_class != VICE_MACHINE_VSID) ? machine_name : "SID", 
                          _(" emulator"), NULL);

#ifdef HAVE_FULLSCREEN
    fullscreen_suspend(1);
#endif
    resources_get_int("ConfirmOnExit", &value1);
    resources_get_int("SaveResourcesOnExit", &value2);

    b = UI_BUTTON_YES;
    if ((value1) && (!value2)) {
        b = ui_ask_yesno(s, _("Do you really want to exit?"));
    }

    if (b == UI_BUTTON_YES) {
        if (value2) {
            b = UI_BUTTON_YES;
            if (value1) {
                b = ui_ask_confirmation(s, _("Save the current settings?"));
            }
            if (b == UI_BUTTON_YES) {
                if (resources_save(NULL) < 0) {
                    ui_error(_("Cannot save settings."));
                    b = UI_BUTTON_CANCEL;
                }
            }
        }
        if (b != UI_BUTTON_CANCEL) {
            /* ui_autorepeat_on(); */
            ui_restore_mouse();
#ifdef HAVE_FULLSCREEN
            fullscreen_suspend(0);
#endif
            ui_dispatch_events();

            lib_free(s);
#ifdef USE_UI_THREADS
            dthread_shutdown();
#endif
            exit(0);
        };
    }
    lib_free(s);
    vsync_suspend_speed_eval();
}
Example #2
0
static UI_CALLBACK(activate_monitor)
{
    int v;
    resources_get_int("MonitorServer", &v);

    if (v == 0) {
#ifdef HAVE_FULLSCREEN
        fullscreen_suspend(0);
#endif
        vsync_suspend_speed_eval();
        ui_dispatch_events();               /* popdown the menu */
        ui_autorepeat_on();

#ifdef HAVE_MOUSE
        ui_restore_mouse();
#endif
        if (!ui_emulation_is_paused()) {
            monitor_startup_trap();
        } else {
            monitor_startup(e_default_space);
#ifdef HAVE_FULLSCREEN
            fullscreen_resume();
#endif
        }
    }
}
Example #3
0
/* Report a message to the user, allow different buttons. */
ui_jam_action_t ui_jam_dialog(const char *format, ...)
{
    char str[1024];
    va_list ap;
    static GtkWidget *jam_dialog, *message;
    gint res;

    if (console_mode) {
        va_start(ap, format);
        vfprintf(stderr, format, ap);
        va_end(ap);
        exit(0);
    }

    vsync_suspend_speed_eval();
    jam_dialog = gtk_dialog_new_with_buttons("", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, _("Reset"), 0, _("Hard Reset"), 1, _("Monitor"), 2, _("Continue"), 3, NULL);
    g_signal_connect(G_OBJECT(jam_dialog), "destroy", G_CALLBACK(gtk_widget_destroyed), &jam_dialog);

    va_start(ap, format);
    vsprintf(str, format, ap);
    va_end(ap);
    message = gtk_label_new(str);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(jam_dialog))), message, TRUE, TRUE, 0);
    gtk_widget_show(message);
    gtk_dialog_set_default_response(GTK_DIALOG(jam_dialog), 0);

    ui_popup(jam_dialog, "VICE", FALSE);
    res = gtk_dialog_run(GTK_DIALOG(jam_dialog));
    ui_popdown(jam_dialog);
    if (jam_dialog) {
        gtk_widget_destroy(jam_dialog);
    }

    ui_dispatch_events();

    switch (res) {
        case 3:
            return UI_JAM_NONE;
        case 2:
            ui_restore_mouse();
#ifdef HAVE_FULLSCREEN
            fullscreen_suspend(0);
#endif
            return UI_JAM_MONITOR;
        case 1:
            return UI_JAM_HARD_RESET;
        case 0:
        default:
            return UI_JAM_RESET;
    }

    return 0;
}
Example #4
0
static UI_CALLBACK(activate_monitor)
{
#ifdef HAVE_FULLSCREEN
    fullscreen_suspend(0);
#endif
    vsync_suspend_speed_eval();
    ui_dispatch_events();               /* popdown the menu */
    ui_autorepeat_on();

#ifdef HAVE_MOUSE
    ui_restore_mouse();
#endif
    if (!ui_emulation_is_paused())
        monitor_startup_trap();
    else
        monitor_startup();
}
Example #5
0
static UI_CALLBACK(run_c1541)
{
#ifdef HAVE_FULLSCREEN
    fullscreen_suspend(0);
#endif
    vsync_suspend_speed_eval();
    sound_close();
    switch (system("xterm -sb -e c1541 &")) {
    case 127:
        ui_error(_("Couldn't run /bin/sh???"));
        break;
    case -1:
        ui_error(_("Couldn't run xterm"));
        break;
    case 0:
        break;
    default:
        ui_error(_("Unknown error while running c1541"));
    }
}
Example #6
0
static UI_CALLBACK(run_c1541)
{
    int i = 0;
    char *terms[6] = {
        "x-terminal-emulator",
        "konsole",
        "gterm",
        "aterm",
        "xterm -sb -rightbar",
        NULL
    };
    int err = -1;
#ifdef HAVE_FULLSCREEN
    fullscreen_suspend(0);
#endif
    vsync_suspend_speed_eval();
    sound_close();

    /* try a couple of known terminal programs */
    while ((err != 0) && (terms[i])) {
        err = runc1541(terms[i]);
        i++;
    }
    switch (err) {
        case 127: /* If a shell could not be executed in the child process,
                     then the return value is as though the child shell
                     terminated by calling _exit(2) with the status 127 */
            ui_error(_("Couldn't run /bin/sh???"));
            break;
        case -1: /*  If a child process could not be created,
                     or its status could not be retrieved */
            ui_error(_("Couldn't run terminal"));
            break;
        case 0:
            break;
        default:
            ui_error(_("Unknown error while running c1541"));
    }
}
Example #7
0
static UI_CALLBACK(browse_manual)
{
    const char *bcommand = NULL;

    resources_get_string("HTMLBrowserCommand", &bcommand);

    if (bcommand == NULL ||
            *bcommand == '\0') {
        ui_error(_("No HTML browser is defined."));
    } else {
        /* FIXME: Argh.  Ugly!  */
#define BROWSE_CMD_BUF_MAX 16384
        char buf[BROWSE_CMD_BUF_MAX];

#ifdef MACOSX_BUNDLE
        /* On Macs the manual path is relative to the bundle. */
        const char *boot_path;
        boot_path = archdep_boot_path();
        char *manual_path;
        manual_path = util_concat(boot_path,"/../doc/vice_toc.html",NULL);
#else
        static const char manual_path[] = DOCDIR "/vice_toc.html";
#endif

        char *res_ptr;
        int manual_path_len, cmd_len;

#ifdef HAVE_FULLSCREEN
        fullscreen_suspend(0);
#endif
        cmd_len = strlen(bcommand);
        manual_path_len = strlen(manual_path);

        res_ptr = strstr(bcommand, "%s");
        if (res_ptr == NULL) {
            /* No substitution. */
            if (cmd_len + 2 > BROWSE_CMD_BUF_MAX - 1) {
                ui_error(_("Browser command too long."));
                return;
            }
            sprintf(buf, "%s &", bcommand);
        } else {
            char *tmp_ptr, *cmd_ptr;
            int offs;

            /* Replace each occurrence of "%s" with the path of the HTML
               manual. */

            cmd_len += manual_path_len - 2;
            cmd_len += 2;       /* Trailing " &". */
            if (cmd_len > BROWSE_CMD_BUF_MAX - 1) {
                ui_error(_("Browser command too long."));
                return;
            }

            offs = res_ptr - bcommand;
            memcpy(buf, bcommand, offs);
            strcpy(buf + offs, manual_path);
            cmd_ptr = buf + offs + manual_path_len;
            res_ptr += 2;

            while ((tmp_ptr = strstr(res_ptr, "%s")) != NULL) {
                cmd_len += manual_path_len - 2;
                if (cmd_len > BROWSE_CMD_BUF_MAX - 1) {
                    ui_error(_("Browser command too long."));
                    return;
                }
                offs = tmp_ptr - res_ptr;
                memcpy(cmd_ptr, res_ptr, offs);
                strcpy(cmd_ptr + offs, manual_path);
                cmd_ptr += manual_path_len + offs;
                res_ptr = tmp_ptr + 2;
            }

            sprintf(cmd_ptr, "%s &", res_ptr);
        }

        log_debug(_("Executing `%s'..."), buf);
        if (system(buf) != 0)
            ui_error(_("Cannot run HTML browser."));

#ifdef MACOSX_BUNDLE
        lib_free(manual_path);
#endif
    }
}