ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/prefs_editor_gtk.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/prefs_editor_gtk.cpp (file contents):
Revision 1.31 by gbeauche, 2005-11-22T21:53:24Z vs.
Revision 1.32 by gbeauche, 2006-04-16T16:32:45Z

# Line 1521 | Line 1521 | static void read_settings(void)
1521          read_memory_settings();
1522          read_jit_settings();
1523   }
1524 +
1525 +
1526 + #ifdef STANDALONE_GUI
1527 + #include <errno.h>
1528 +
1529 + /*
1530 + *  Fake unused data and functions
1531 + */
1532 +
1533 + uint8 XPRAM[XPRAM_SIZE];
1534 + void MountVolume(void *fh) { }
1535 + void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
1536 + void WarningAlert(const char *text) { }
1537 +
1538 +
1539 + /*
1540 + *  Display alert
1541 + */
1542 +
1543 + static void dl_destroyed(void)
1544 + {
1545 +        gtk_main_quit();
1546 + }
1547 +
1548 + static void display_alert(int title_id, int prefix_id, int button_id, const char *text)
1549 + {
1550 +        char str[256];
1551 +        sprintf(str, GetString(prefix_id), text);
1552 +
1553 +        GtkWidget *dialog = gtk_dialog_new();
1554 +        gtk_window_set_title(GTK_WINDOW(dialog), GetString(title_id));
1555 +        gtk_container_border_width(GTK_CONTAINER(dialog), 5);
1556 +        gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150);
1557 +        gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(dl_destroyed), NULL);
1558 +
1559 +        GtkWidget *label = gtk_label_new(str);
1560 +        gtk_widget_show(label);
1561 +        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0);
1562 +
1563 +        GtkWidget *button = gtk_button_new_with_label(GetString(button_id));
1564 +        gtk_widget_show(button);
1565 +        gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(dl_quit), GTK_OBJECT(dialog));
1566 +        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0);
1567 +        GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
1568 +        gtk_widget_grab_default(button);
1569 +        gtk_widget_show(dialog);
1570 +
1571 +        gtk_main();
1572 + }
1573 +
1574 +
1575 + /*
1576 + *  Display error alert
1577 + */
1578 +
1579 + static void ErrorAlert(const char *text)
1580 + {
1581 +        display_alert(STR_ERROR_ALERT_TITLE, STR_GUI_ERROR_PREFIX, STR_QUIT_BUTTON, text);
1582 + }
1583 +
1584 +
1585 + /*
1586 + *  Start standalone GUI
1587 + */
1588 +
1589 + int main(int argc, char *argv[])
1590 + {
1591 + #ifdef HAVE_GNOMEUI
1592 +        // Init GNOME/GTK
1593 +        char version[16];
1594 +        sprintf(version, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
1595 +        gnome_init("Basilisk II", version, argc, argv);
1596 + #else
1597 +        // Init GTK
1598 +        gtk_set_locale();
1599 +        gtk_init(&argc, &argv);
1600 + #endif
1601 +
1602 +        // Read preferences
1603 +        PrefsInit(argc, argv);
1604 +
1605 +        // Show preferences editor
1606 +        bool start = PrefsEditor();
1607 +
1608 +        // Exit preferences
1609 +        PrefsExit();
1610 +
1611 +        // Transfer control to the executable
1612 +        if (start) {
1613 +                char b2_path[PATH_MAX];
1614 +                strcpy(b2_path, argv[0]);
1615 +                char *p = strrchr(b2_path, '/');
1616 +                p = p ? p + 1 : b2_path;
1617 +                *p = '\0';
1618 +                strcat(b2_path, "BasiliskII");
1619 +                argv[0] = b2_path;
1620 +                execv(b2_path, argv);
1621 +
1622 +                char str[256];
1623 +                sprintf(str, GetString(STR_NO_B2_EXE_FOUND), b2_path, strerror(errno));
1624 +                ErrorAlert(str);
1625 +                return 1;
1626 +        }
1627 +
1628 +        return 0;
1629 + }
1630 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines