Changeset 438
- Timestamp:
- 02/29/2008 10:30:02 (6 months ago)
- Location:
- trunk/shoes
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/shoes/app.c
r437 r438 63 63 rb_ary_push(shoes_world->apps, app); 64 64 return app; 65 } 66 67 // 68 // When a window is finished, call this to delete it from the master 69 // list. Returns 1 if all windows are gone. 70 // 71 static int 72 shoes_app_remove(shoes_app *app) 73 { 74 rb_ary_delete(shoes_world->apps, app->self); 75 return (RARRAY_LEN(shoes_world->apps) == 0); 65 76 } 66 77 … … 212 223 if (v != Qnil) 213 224 shoes_app_keypress(app, v); 225 return FALSE; 226 } 227 228 static gboolean 229 shoes_app_gtk_quit(GtkWidget *widget, GdkEvent *event, gpointer data) 230 { 231 shoes_app *app = (shoes_app *)data; 232 if (shoes_app_remove(app)) 233 gtk_main_quit(); 214 234 return FALSE; 215 235 } … … 940 960 { 941 961 case WM_DESTROY: 942 PostQuitMessage(0); 962 if (shoes_app_remove(app)) 963 PostQuitMessage(0); 943 964 return 0; 944 965 … … 1319 1340 Data_Get_Struct(app, shoes_app, app_t); 1320 1341 1321 if (NIL_P(shoes_world->app))1322 shoes_world->app = app;1323 1324 1342 rb_scan_args(argc, argv, "01&", &attr, &block); 1325 1343 rb_iv_set(app, "@main_app", block); … … 1359 1377 1360 1378 shoes_code 1361 shoes_app_start(VALUE a ppobj, VALUE allapps, char *uri)1379 shoes_app_start(VALUE allapps, char *uri) 1362 1380 { 1363 1381 int i; … … 1370 1388 Data_Get_Struct(appobj2, shoes_app, app); 1371 1389 1372 code = shoes_app_open(app, uri , appobj2 == appobj);1390 code = shoes_app_open(app, uri); 1373 1391 if (code != SHOES_OK) 1374 1392 return code; 1375 1393 } 1376 1394 1377 Data_Get_Struct(appobj, shoes_app, app); 1378 code = shoes_app_loop(app); 1395 code = shoes_app_loop(); 1379 1396 if (code != SHOES_OK) 1380 1397 return code; … … 1441 1458 1442 1459 shoes_code 1443 shoes_app_open(shoes_app *app, char *path , unsigned char is_main)1460 shoes_app_open(shoes_app *app, char *path) 1444 1461 { 1445 1462 shoes_code code = SHOES_OK; … … 1461 1478 g_signal_connect(G_OBJECT(gk->window), "key-press-event", 1462 1479 G_CALLBACK(shoes_app_gtk_keypress), app); 1463 if (is_main) 1464 { 1465 g_signal_connect(G_OBJECT(gk->window), "delete-event", 1466 G_CALLBACK(gtk_main_quit), NULL); 1467 } 1480 g_signal_connect(G_OBJECT(gk->window), "delete-event", 1481 G_CALLBACK(shoes_app_gtk_quit), app); 1468 1482 app->slot.canvas = gk->window; 1469 1483 #endif … … 1506 1520 InitCursor(); 1507 1521 1508 if (is_main) 1509 { 1510 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, 1511 NewAEEventHandlerUPP(shoes_app_quartz_quit), 0, false); 1512 if (err != noErr) 1513 { 1514 QUIT("Out of memory.", 0); 1515 } 1522 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, 1523 NewAEEventHandlerUPP(shoes_app_quartz_quit), 0, false); 1524 if (err != noErr) 1525 { 1526 QUIT("Out of memory.", 0); 1516 1527 } 1517 1528 … … 1610 1621 1611 1622 shoes_code 1612 shoes_app_loop( shoes_app *app)1623 shoes_app_loop() 1613 1624 { 1614 1625 shoes_code code = SHOES_OK; … … 1658 1669 if (msgs.message == WM_KEYDOWN || msgs.message == WM_KEYUP) 1659 1670 { 1660 VALUE appw = (VALUE)GetWindowLong(msgs.hwnd, GWL_USERDATA); 1661 shoes_app *appk; 1662 Data_Get_Struct(appw, shoes_app, appk); 1663 1671 shoes_app *appk = (shoes_app *)GetWindowLong(msgs.hwnd, GWL_USERDATA); 1664 1672 if (RARRAY_LEN(appk->slot.controls) > 0) 1665 1673 { … … 1678 1686 msg = false; 1679 1687 if (msg) 1680 msg = IsDialogMessage( app->slot.window, &msgs);1688 msg = IsDialogMessage(msgs.hwnd, &msgs); 1681 1689 1682 1690 if (!msg) -
trunk/shoes/app.h
r437 r438 50 50 shoes_code shoes_classex_init(); 51 51 #endif 52 shoes_code shoes_app_start(VALUE, VALUE,char *);53 shoes_code shoes_app_open(shoes_app *, char * , unsigned char);54 shoes_code shoes_app_loop( shoes_app *);52 shoes_code shoes_app_start(VALUE, char *); 53 shoes_code shoes_app_open(shoes_app *, char *); 54 shoes_code shoes_app_loop(); 55 55 shoes_code shoes_app_visit(shoes_app *, char *); 56 56 shoes_code shoes_app_paint(shoes_app *); -
trunk/shoes/canvas.c
r433 r438 2197 2197 shoes_load(RSTRING_PTR(uri), "/"); 2198 2198 2199 return shoes_world->app; 2200 } 2201 2199 // TODO: do I send back an array of created App objects I guess? 2200 return Qnil; 2201 } 2202 -
trunk/shoes/world.c
r437 r438 16 16 shoes_world_t *world = SHOE_ALLOC(shoes_world_t); 17 17 SHOE_MEMZERO(world, shoes_world_t, 1); 18 world->app = Qnil;19 18 world->apps = rb_ary_new(); 20 19 rb_gc_register_address(&world->apps); … … 86 85 } 87 86 88 if (!NIL_P(shoes_world->app)) 89 return shoes_app_start(shoes_world->app, shoes_world->apps, uri); 90 91 return SHOES_QUIT; 87 return shoes_app_start(shoes_world->apps, uri); 92 88 } 93 89 -
trunk/shoes/world.h
r437 r438 15 15 SHOES_WORLD_OS os; 16 16 char path[SHOES_BUFSIZE]; 17 VALUE app , apps;17 VALUE apps; 18 18 } shoes_world_t; 19 19 20 20 SHOES_EXTERN_VAR shoes_world_t *shoes_world; 21 21 22 // TODO: allow a window to be chosen as the main window 22 23 #define GLOBAL_APP(appvar) \ 23 24 shoes_app *appvar; \ 24 Data_Get_Struct( shoes_world->app, shoes_app, appvar)25 Data_Get_Struct(rb_ary_entry(shoes_world->apps, 0), shoes_app, appvar) 25 26 26 27 //
