~ubuntu-branches/ubuntu/natty/vice/natty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * uiplus256k.c
 *
 * Written by
 *  Marco van den Heuvel <blackystardust68@yahoo.com>
 *
 * This file is part of VICE, the Versatile Commodore Emulator.
 * See README for copyright notice.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307  USA.
 *
 */

#include "vice.h"
#ifdef AMIGA_M68K
#define _INLINE_MUIMASTER_H
#endif
#include "mui.h"

#include "uiautostart.h"
#include "intl.h"
#include "translate.h"

static video_canvas_t *autostart_canvas;

static int ui_autostart_enable_translate[] = {
    IDMS_DISABLED,
    IDS_ENABLED,
    0
};

static char *ui_autostart_enable[countof(ui_autostart_enable_translate)];

static const int ui_autostart_enable_values[] = {
    0,
    1,
    -1
};

static int ui_autostart_mode_translate[] = {
    IDS_AUTOSTART_VIRTUAL_FS,
    IDS_AUTOSTART_INJECT,
    IDS_AUTOSTART_DISK,
    0
};

static char *ui_autostart_mode[countof(ui_autostart_mode_translate)];

static const int ui_autostart_mode_values[] = {
    0,
    1,
    2,
    -1
};

static ui_to_from_t ui_to_from[] = {
    { NULL, MUI_TYPE_CYCLE, "AutostartWarp", ui_autostart_enable, ui_autostart_enable_values },
    { NULL, MUI_TYPE_CYCLE, "AutostartRunWithColon", ui_autostart_enable, ui_autostart_enable_values },
    { NULL, MUI_TYPE_CYCLE, "AutostartPrgMode", ui_autostart_mode, ui_autostart_mode_values },
    { NULL, MUI_TYPE_FILENAME, "AutostartPrgDiskImage", NULL, NULL },
    UI_END /* mandatory */
};

static ULONG Browse(struct Hook *hook, Object *obj, APTR arg)
{
    char *fname = NULL;

    fname = BrowseFile(translate_text(IDS_AUTOSTART_DISK_IMAGE_SELECT), "#?", autostart_canvas);

    if (fname != NULL) {
        set(ui_to_from[3].object, MUIA_String_Contents, fname);
    }

    return 0;
}

static APTR build_gui(void)
{
    APTR app, ui, ok, browse_button, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse, NULL };
#else
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)Browse, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           CYCLE(ui_to_from[0].object, translate_text(IDS_WARP_ON_AUTOSTART), ui_autostart_enable)
           CYCLE(ui_to_from[1].object, translate_text(IDS_RUN_WITH_COLON), ui_autostart_enable)
           CYCLE(ui_to_from[2].object, translate_text(IDS_AUTOSTART_PRG_MODE), ui_autostart_mode)
           FILENAME(ui_to_from[3].object, translate_text(IDS_AUTOSTART_DISK_IMAGE_FILENAME), browse_button)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseFileHook);
    }

    return ui;
}

void ui_autostart_settings_dialog(video_canvas_t *canvas)
{
    APTR window;

    autostart_canvas = canvas;
    intl_convert_mui_table(ui_autostart_enable_translate, ui_autostart_enable);
    intl_convert_mui_table(ui_autostart_mode_translate, ui_autostart_mode);

    window = mui_make_simple_window(build_gui(), translate_text(IDS_AUTOSTART_SETTINGS));

    if (window != NULL) {
        mui_add_window(window);
        ui_get_to(ui_to_from);
        set(window, MUIA_Window_Open, TRUE);
        if (mui_run() == BTN_OK) {
            ui_get_from(ui_to_from);
        }
        set(window, MUIA_Window_Open, FALSE);
        mui_rem_window(window);
        MUI_DisposeObject(window);
    }
}