[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Advanced rubycocoa: full-screen applications? (Can I access CoreGraphics calls?

Ben Giddings

12/8/2005 10:59:00 PM

Hi guys,

I'm really pushing the RubyCocoa boundaries for a demo I'm trying to
build.

I want to display a QuartzComposer application full-screen (i.e. no
menu bar, no dock, etc.) and then control it by Ruby.

So far, I can get a windowed QuartzComposer application working, but
I don't know how to make it go full-screen.

I found instructions on how to make full-screen OSX applications, but
I can't figure out how to call the required methods / use the right
variables from within Ruby.

Here's the article on how to make a full-screen app from Cocoa:

http://www.cocoadevcentral.com/articles/...

But when I do the bit that tries to call CGDisplayCapture:

if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
// Note: you'll probably want to display a proper error
dialog here
}

I can't figure out how to call those methods or use the
kCGDirectMainDisplay method from within Ruby.

I've loaded the ApplicationServices framework, which should give me
access to the CoreGraphics calls, but... I don't know how to get to
them.

Any ideas?

Ben



8 Answers

FUJIMOTO Hisa

12/9/2005 12:30:00 AM

0

Hi folks,

On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:

> I want to display a QuartzComposer application full-screen (i.e. no
> menu bar, no dock, etc.) and then control it by Ruby.
>
> So far, I can get a windowed QuartzComposer application working, but
> I don't know how to make it go full-screen.
(snip)
> Any ideas?

I'm not bright about QuartsComposer and CoreGraphics, but source code
of TMPresents.app may be helpful for you. This is a Takahashi-method
fullscreen presentation application written with RubyCocoa.

* http://homepage3.nifty.com/kimuraw/proj/tmpre... (Japanese page)
* http://homepage.mac.com/kimuraw/archive/TMPresents-0....

thanks,
--
hisa


Ben Giddings

12/9/2005 3:34:00 AM

0

On Dec 8, 2005, at 19:30, FUJIMOTO Hisa wrote:
> I'm not bright about QuartsComposer and CoreGraphics, but source code
> of TMPresents.app may be helpful for you. This is a Takahashi-method
> fullscreen presentation application written with RubyCocoa.
>
> * http://homepage3.nifty.com/kimuraw/proj/tmpre...
> (Japanese page)
> * http://homepage.mac.com/kimuraw/archive/TMPresents-0....

Thanks Hisa,

That's a lot of helpful code. Unfortunately, I don't know what kinds
of documents it opens so I can't try it out, but the source code
looks like has a lot of very useful methods, and since they're named
in English, I think I'll be able to figure it out.

Thanks a lot!

Ben



FUJIMOTO Hisa

12/9/2005 4:52:00 AM

0

On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:
> That's a lot of helpful code. Unfortunately, I don't know what kinds
> of documents it opens so I can't try it out, but the source code

Document format of the app is simply plain text. Each page
is separated by a null line. e.g.

--- cut here ---
Page 1

Page 2 - Line 1
Page 2 - Line 3

Page 3
--- cut here ---

cheers,
--
hisa


Ben Giddings

12/9/2005 2:47:00 PM

0

On Dec 8, 2005, at 23:52, FUJIMOTO Hisa wrote:
> On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:
>> That's a lot of helpful code. Unfortunately, I don't know what kinds
>> of documents it opens so I can't try it out, but the source code
>
> Document format of the app is simply plain text. Each page
> is separated by a null line. e.g.

Hmm, I tried saving that text to a .txt file, but TMPresents wouldn't
give me the option to open that file. Everything except directories
is "greyed out" and I can't select them.

Is there a specific filename or mime type or something that the
dialog is looking for? It can't just be presentation.txt can it?

Ben



kimura wataru

12/12/2005 4:54:00 PM

0

Hi,

I fixed this problem and published new version.

http://homepage.mac.com/kimuraw/archive/TMPresents-0....
http://homepage.mac.com/kimuraw/archive/TMPresents-0.3...

I implemented fullscreen with NSWindow, the application can be deactive.

I think ruby can handle CoreGraphics API via DL::Symbol (extension
library "dl"), not RubyCocoa. An other way is to use Cocoa wrapper for
CoreGraphics, like DisplayKit.

require 'osx/cocoa'
bundle = OSX::NSBundle.bundleWithPath('/Library/Frameworks/DisplayKit.framework')
bundle.load
OSX.ns_import :DKDisplay # => class OSX::DKDisplay is available

DisplayKit: http://www.zobs.net/brian...


Fri, Dec 9, 2005 11:47:16 PM, Ben Giddings wrote:
>On Dec 8, 2005, at 23:52, FUJIMOTO Hisa wrote:
>> On 12/9/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:
>>> That's a lot of helpful code. Unfortunately, I don't know what kinds
>>> of documents it opens so I can't try it out, but the source code
>>
>> Document format of the app is simply plain text. Each page
>> is separated by a null line. e.g.
>
>Hmm, I tried saving that text to a .txt file, but TMPresents wouldn't
>give me the option to open that file. Everything except directories
>is "greyed out" and I can't select them.
>
>Is there a specific filename or mime type or something that the
>dialog is looking for? It can't just be presentation.txt can it?
>
>Ben
>
>



Ben Giddings

1/11/2006 12:52:00 AM

0

Hi Fujimoto-san and Kimura-san,

Thanks to your help, I was able to get my application to go full-
screen with no menubar or dock visible.

I think the problem I was having was that I was trying to write a
Ruby program that used Cocoa libraries. I was using all the right
calls, but I couldn't get rid of the menubar or dock. I used
TMPresents as an example, and changed how I was doing things.
Instead of a Ruby application, I made it an objective C application
that used Ruby classes. Once I did that, I was able to go full-screen.

However, I'm having another problem. My application is crashing, and
the error is somewhere in the Ruby libraries, not directly in my
code. Here's the program output:

2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


NRFApp has exited due to signal 6 (SIGABRT).

Another run went like this:

[Session started at 2006-01-10 03:31:42 -0500.]
Current time is: Tue Jan 10 03:31:42 2006

2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
correctly initialized. Did you forget to call super?
2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
correctly initialized. Did you forget to call super?
/Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Segmentation fault
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]


I've tried to debug the program using the XCode debugger (GDB
underneath) but I only get assembly output. I guess the problem is
that something, either Ruby or the RubyCocoa libs were built without
debugging symbols, or stripped. Unfortunately, I can't seem to
rebuild these properly to get debugging symbols, so I'm unable to
debug what's happening.

Can anybody help me understand how to debug and fix this problem? If
I can't get it working with RubyCocoa soon, I might have to give up
and write it in Objective-C (and I don't know Objective C!

Thanks,

Ben



Logan Capaldo

1/12/2006 11:13:00 PM

0


On Jan 10, 2006, at 7:52 PM, Ben Giddings wrote:

> Hi Fujimoto-san and Kimura-san,
>
> Thanks to your help, I was able to get my application to go full-
> screen with no menubar or dock visible.
>
> I think the problem I was having was that I was trying to write a
> Ruby program that used Cocoa libraries. I was using all the right
> calls, but I couldn't get rid of the menubar or dock. I used
> TMPresents as an example, and changed how I was doing things.
> Instead of a Ruby application, I made it an objective C application
> that used Ruby classes. Once I did that, I was able to go full-
> screen.
>
> However, I'm having another problem. My application is crashing,
> and the error is somewhere in the Ruby libraries, not directly in
> my code. Here's the program output:
>
> 2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
> correctly initialized. Did you forget to call super?
> 2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
> correctly initialized. Did you forget to call super?
> /Users/merc/Documents/Development/thingmagic/NRFApp/build/
> Development/NRFApp.app/Contents/Frameworks/RubyCocoa.framework/
> Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]
>
>
> NRFApp has exited due to signal 6 (SIGABRT).
>
> Another run went like this:
>
> [Session started at 2006-01-10 03:31:42 -0500.]
> Current time is: Tue Jan 10 03:31:42 2006
>
> 2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
> correctly initialized. Did you forget to call super?
> 2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
> correctly initialized. Did you forget to call super?
> /Users/merc/Documents/Development/thingmagic/NRFApp/build/
> Development/NRFApp.app/Contents/Frameworks/RubyCocoa.framework/
> Versions/A/Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG]
> Segmentation fault
> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]
>
>
> I've tried to debug the program using the XCode debugger (GDB
> underneath) but I only get assembly output. I guess the problem is
> that something, either Ruby or the RubyCocoa libs were built
> without debugging symbols, or stripped. Unfortunately, I can't
> seem to rebuild these properly to get debugging symbols, so I'm
> unable to debug what's happening.
>
> Can anybody help me understand how to debug and fix this problem?
> If I can't get it working with RubyCocoa soon, I might have to give
> up and write it in Objective-C (and I don't know Objective C!
>
> Thanks,
>
> Ben
>
>

I've had a very similar sounding problem in a pure Objective-C app.
Basically what happened was I didn't #retain something I should have
#retain'ed. I'll note that at first I thought it was in the
libraries too, and had similar issues to what you had attempting to
debug it. I don't know how you'd go about doing that from RubyCocoa--
theoretically you shouldn't have that problem in the first place.



Dave Howell

1/13/2006 9:52:00 AM

0


> However, I'm having another problem. My application is crashing, and
> the error is somewhere in the Ruby libraries, not directly in my code.
> Here's the program output:
>
> 2006-01-10 03:31:04.506 NRFApp[918] NRFView(0x60dba0) - NSView not
> correctly initialized. Did you forget to call super?
> 2006-01-10 03:31:04.531 NRFApp[918] QCView(0x60e870) - NSView not
> correctly initialized. Did you forget to call super?
> /Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
> NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
> Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Bus Error
> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]
>
>
> NRFApp has exited due to signal 6 (SIGABRT).
>
> Another run went like this:
>
> [Session started at 2006-01-10 03:31:42 -0500.]
> Current time is: Tue Jan 10 03:31:42 2006
>
> 2006-01-10 03:31:42.993 NRFApp[932] NRFView(0x60daf0) - NSView not
> correctly initialized. Did you forget to call super?
> 2006-01-10 03:31:43.063 NRFApp[932] QCView(0x60e7c0) - NSView not
> correctly initialized. Did you forget to call super?
> /Users/merc/Documents/Development/thingmagic/NRFApp/build/Development/
> NRFApp.app/Contents/Frameworks/RubyCocoa.framework/Versions/A/
> Resources/ruby/osx/objc/oc_wrapper.rb:17: [BUG] Segmentation fault
> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.0]
>

Aha! Hopefully you will soon have a more complete answer, but I guess
you missed my recent query which featured exactly the same "NSView"
error message.

Or to be more precise, the warning. "Did you forget to call super?" is
a red herring, a spurious message that you should ignore. My views, as
it turned out, were being created exactly as they should have been.

The incredibly exasperating Segmentation Fault is another matter, of
course. I had to put one Ruby XCode project aside entirely because I
couldn't get that to go away. However, at first, many of those were to
some degree my fault. I had some bugs in my code where I was calling
something without initializing it properly, or, well, I don't remember
what, but it was actually a mistake that I had made, which
Ruby/RubyCocoa/Cocoa was handling with extremely poor grace.

Until/unless somebody more knowledgeable than me chimes in, I suggest
you see if you can find some particular part of your code that seems to
trigger the segmentation fault, and make sure it's doing what it's
supposed to. If that doesn't help, consider upgrading your Ruby (and
especially your RubyCocoa if you're not running the latest version).