public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
 * shoes/ruby.c: new `shoes_catch_message` a central point where thread 
 messages arrive.
 * shoes/native.h: renamed `shoes_native_message` to 
 `shoes_throw_message`.
 * shoes/native/cocoa.m: the time funcs for os x.
why (author)
Sun Jul 20 20:32:37 -0700 2008
commit  16c8da4a22da7023abd2800a3ecaa9642a03b47a
tree    2519e5c87d8a7b799f5519d07ede64ac511ba65e
parent  bcad64c008afbe6ad5db2a217356d6ff615d544e
...
314
315
316
317
 
318
319
320
...
344
345
346
 
347
348
349
...
314
315
316
 
317
318
319
320
...
344
345
346
347
348
349
350
0
@@ -314,7 +314,7 @@ else
0
   PANGO_LIB = ENV['PANGO_LIB'] ? "-L#{ENV['PANGO_LIB']}" : `pkg-config --libs pango`.strip
0
 
0
   LINUX_CFLAGS = %[-I#{ENV['SHOES_DEPS_PATH'] || "/usr"}/include #{CAIRO_CFLAGS} #{PANGO_CFLAGS} -I#{Config::CONFIG['archdir']}]
0
- LINUX_LIB_NAMES = %W[#{ruby_so} png cairo pangocairo-1.0 ungif rt]
0
+ LINUX_LIB_NAMES = %W[#{ruby_so} png cairo pangocairo-1.0 ungif]
0
   FLAGS.each do |flag|
0
     LINUX_CFLAGS << " -D#{flag}" if ENV[flag]
0
   end
0
@@ -344,6 +344,7 @@ else
0
     LINUX_CFLAGS << " -DSHOES_GTK -fPIC #{`pkg-config --cflags gtk+-2.0`.strip} #{`curl-config --cflags`.strip}"
0
     LINUX_LDFLAGS =" #{`pkg-config --libs gtk+-2.0`.strip} #{`curl-config --libs`.strip} -fPIC -shared"
0
     LINUX_LIB_NAMES << 'jpeg'
0
+ LINUX_LIB_NAMES << 'rt'
0
     LINUX_LIB_NAMES << "vlc" if ENV['VIDEO']
0
   end
0
   LINUX_LIBS = LINUX_LIB_NAMES.map { |x| "-l#{x}" }.join(' ')
...
548
549
550
 
551
552
553
...
548
549
550
551
552
553
554
0
@@ -548,6 +548,7 @@ VALUE shoes_download_new(VALUE, VALUE, VALUE);
0
 VALUE shoes_download_alloc(VALUE);
0
 VALUE shoes_download_threaded(VALUE, VALUE, VALUE);
0
 int shoes_message_download(VALUE, void *);
0
+int shoes_catch_message(unsigned int name, VALUE obj, void *data);
0
 VALUE shoes_p(VALUE, VALUE);
0
 
0
 extern const double SHOES_PIM2, SHOES_PI, SHOES_RAD2PI;
...
126
127
128
 
129
130
131
...
126
127
128
129
130
131
132
0
@@ -126,6 +126,7 @@ typedef struct {
0
 #define DC(slot) slot.view
0
 #define HAS_DRAWABLE(slot) slot.context != NULL
0
 #define DRAWABLE(ref) ref
0
+#define SHOES_TIME struct timeval
0
 
0
 #endif
0
 
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ void shoes_native_cleanup(shoes_world_t *world);
0
 void shoes_native_quit();
0
 void shoes_get_time(SHOES_TIME *);
0
 unsigned long shoes_diff_time(SHOES_TIME *, SHOES_TIME *);
0
-int shoes_native_message(unsigned int, VALUE, void *);
0
+int shoes_throw_message(unsigned int, VALUE, void *);
0
 void shoes_native_slot_mark(SHOES_SLOT_OS *);
0
 void shoes_native_slot_reset(SHOES_SLOT_OS *);
0
 void shoes_native_slot_clear(shoes_canvas *);
...
506
507
508
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
510
511
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
0
@@ -506,6 +506,29 @@ void shoes_native_quit()
0
   RELEASE;
0
 }
0
 
0
+void shoes_get_time(SHOES_TIME *ts)
0
+{
0
+ gettimeofday(ts, NULL);
0
+}
0
+
0
+unsigned long shoes_diff_time(SHOES_TIME *start, SHOES_TIME *end)
0
+{
0
+ unsigned long usec;
0
+ if ((end->tv_usec-start->tv_usec)<0) {
0
+ usec = (end->tv_sec-start->tv_sec - 1) * 1000;
0
+ usec += (1000000 + end->tv_usec - start->tv_usec) / 1000;
0
+ } else {
0
+ usec = (end->tv_sec - start->tv_sec) * 1000;
0
+ usec += (end->tv_usec - start->tv_usec) / 1000;
0
+ }
0
+ return usec;
0
+}
0
+
0
+int shoes_throw_message(unsigned int name, VALUE obj, void *data)
0
+{
0
+ return shoes_catch_message(name, obj, data);
0
+}
0
+
0
 void shoes_native_slot_mark(SHOES_SLOT_OS *slot)
0
 {
0
   rb_gc_mark_maybe(slot->controls);
...
64
65
66
67
68
69
70
71
72
 
73
74
75
76
77
78
 
79
80
81
...
64
65
66
 
 
 
 
 
 
67
68
69
70
71
72
 
73
74
75
76
0
@@ -64,18 +64,13 @@ static gboolean
0
 shoes_gtk_catch_message(gpointer user) {
0
   shoes_gtk_msg *msg = (shoes_gtk_msg *)user;
0
   pthread_mutex_lock(&msg->mutex);
0
- switch (msg->name) {
0
- case SHOES_THREAD_DOWNLOAD:
0
- msg->ret = shoes_message_download(msg->obj, msg->data);
0
- free(msg->data);
0
- break;
0
- }
0
+ msg->ret = shoes_catch_message(msg->name, msg->obj, msg->data);
0
   pthread_cond_signal(&msg->cond);
0
   pthread_mutex_unlock(&msg->mutex);
0
   return FALSE;
0
 }
0
 
0
-int shoes_native_message(unsigned int name, VALUE obj, void *data)
0
+int shoes_throw_message(unsigned int name, VALUE obj, void *data)
0
 {
0
   int ret;
0
   shoes_gtk_msg *msg = SHOE_ALLOC(shoes_gtk_msg);
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
85
86
87
...
352
353
354
355
 
356
357
358
...
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
76
...
341
342
343
 
344
345
346
347
0
@@ -70,18 +70,7 @@ unsigned long shoes_diff_time(SHOES_TIME *start, SHOES_TIME *end)
0
   return *end - *start;
0
 }
0
 
0
-int shoes_windows_catch_message(unsigned int name, VALUE obj, void *data) {
0
- int ret = 0;
0
- switch (name) {
0
- case SHOES_THREAD_DOWNLOAD:
0
- ret = shoes_message_download(obj, data);
0
- free(data);
0
- break;
0
- }
0
- return ret;
0
-}
0
-
0
-int shoes_native_message(unsigned int name, VALUE obj, void *data)
0
+int shoes_throw_message(unsigned int name, VALUE obj, void *data)
0
 {
0
   return SendMessage(shoes_world->os.hidden, SHOES_WM_MESSAGE + name, obj, (LPARAM)data);
0
 }
0
@@ -352,7 +341,7 @@ LRESULT CALLBACK
0
 shoes_hidden_win32proc(HWND win, UINT msg, WPARAM w, LPARAM l)
0
 {
0
   if (msg > SHOES_WM_MESSAGE && msg < SHOES_WM_MESSAGE + SHOES_MAX_MESSAGE)
0
- return shoes_windows_catch_message(msg - SHOES_WM_MESSAGE, (VALUE)w, (void *)l);
0
+ return shoes_catch_message(msg - SHOES_WM_MESSAGE, (VALUE)w, (void *)l);
0
   return DefWindowProc(win, msg, w, l);
0
 }
0
 
...
3707
3708
3709
3710
 
3711
3712
3713
...
3771
3772
3773
 
 
 
 
 
 
 
 
 
 
 
3774
3775
3776
...
3707
3708
3709
 
3710
3711
3712
3713
...
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
0
@@ -3707,7 +3707,7 @@ shoes_doth_handler(shoes_download_event *de, void *data)
0
   shoes_doth_data *doth = (shoes_doth_data *)data;
0
   shoes_download_event *de2 = SHOE_ALLOC(shoes_download_event);
0
   SHOE_MEMCPY(de2, de, shoes_download_event, 1);
0
- return shoes_native_message(SHOES_THREAD_DOWNLOAD, doth->download, de2);
0
+ return shoes_throw_message(SHOES_THREAD_DOWNLOAD, doth->download, de2);
0
 }
0
 
0
 VALUE
0
@@ -3771,6 +3771,17 @@ EVENT_COMMON(download, download_klass, start);
0
 EVENT_COMMON(download, download_klass, progress);
0
 EVENT_COMMON(download, download_klass, finish);
0
 
0
+int shoes_catch_message(unsigned int name, VALUE obj, void *data) {
0
+ int ret = 0;
0
+ switch (name) {
0
+ case SHOES_THREAD_DOWNLOAD:
0
+ ret = shoes_message_download(obj, data);
0
+ free(data);
0
+ break;
0
+ }
0
+ return ret;
0
+}
0
+
0
 DEBUG_TYPE(info);
0
 DEBUG_TYPE(debug);
0
 DEBUG_TYPE(warn);

Comments

    No one has commented yet.