Re: [MacRuby-devel] Quartz 2D Graphics problem
Hi,
While you can't mix and match within one file, I think you can have a Class
that contains both Objective C methods and Macruby methods each defined in
their own file. Objective C classes are open and the Macruby methods will be
added to them.
Steve
On 21 Oct 2012, at 20:28, Colin Thomas-Arnold wrote:
> yup, you can't mix and match within one file.
>
>
> @colinta
> colinta.com
> github.com/colinta
>
>
>
>
> On Oct 21, 2012, at 1:22 PM, Robert Carl Rice wrote:
>
>> Hi,
>>
>> Actually, I already have PBSerialPort m & h files by Paolo Bosetti dropped
>> into my project and it works fine. I was wondering is a class could have
>> both Objective C and Ruby code but from this discussion I gather the class
>> must be either MacRuby or ObjC. Is this correct?
>>
>> Thanks,
>> Bob Rice
>>
>>
>> On Oct 21, 2012, at 2:40 PM, Jim Getzen wrote:
>>
>>> You don't need to make a framework or bundle to add Obj-C code to your
>>> project. I've been able to just add a .h/.m files directly to the project
>>> and call the Obj-C classes contained therein from my MacRuby code, just as
>>> if those classes were part of a framework.
>>>
>>> What you can't do, of course, is call straight C functions or constants
>>> without a bridgesupport file.
>>>
>>> Jim
>>>
>>>
>>> On Oct 21, 2012, at 12:59 PM, Mark Rada wrote:
>>>
>>> Adding some Objective-C code could be done with a framework as suggested,
>>> or by creating a bundle. The bundle process is essentially the same as
>>> creating a C extension for Ruby. Any MacRuby project with a C extension
>>> could be used as an example:
>>>
>>> https://github.com/pieter/macruby-bundle-example
>>> https://github.com/Marketcircle/AXElements/tree/master/ext/accessibility/key_coder
>>> https://github.com/alloy/ObjectiveBacon/tree/master/LanguageBindings/MacRuby/ext
>>>
>>> You can then simply "require 'bundle'" the bundle file that is compiled.
>>>
>>>
>>> On 2012-10-21, at 12:44 PM, Colin Thomas-Arnold wrote:
>>>
You can certainly compile a group of stuff as a framework, and add that
framework to your project, but I've never tried to just toss in .h/.m
files and access them from macruby.
Can anyone touch on that? I'm interested to hear what can be done there...
AFA translating your code into Obj-C...
Here's the short version:
self.context = [[NSGraphics currentContext] graphicsPort];
And here's the long version!
// the header file, YourClass.h
@interface YourClass : ParentClass
@property (assign, nonatomic) CGContextRef context;
// or void* instead of CGContextRef, but graphicsPort returns a
CGContextRef
@end
// the implementation file, YourClass.m
#import "YourClass.h"
@implementation YourClass
@synthesize context;
- drawRect:(CGRect)rect
{
self.context = [[NSGraphics currentContext] graphicsPort];
}
@end
@colinta
colinta.com
github.com/colinta
On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:
> Hi Mark,
>
> Unfortunately, I am not very familiar with objective C syntax. Is it easy
> to mix objective C statements with MacRuby?
> For example, How would code the @context =
> NSGraphicsContext.currentContext.graphicsPort in objective C?
>
> Thanks,
> Bob Rice
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
>>>
>>> ___
>>> MacRuby-devel mailing list
>>> [email protected]
>>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>>>
>>> ___
>>> MacRuby-devel mailing list
>>> [email protected]
>>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>>
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] Basic delayed email method
So playing around a little with this I was able to browse and find messages
via macruby. On the other hand I cannot figure out how to send a drafted
email. Here is what I have so far.
My drafts folder has 1 message in it ready to be sent.
mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail")
> my_account = mail.accounts.select { |account| account.name ==
> "MyAccountName" }.first
> drafts_folder = my_account.mailboxes.select { |mailbox| mailbox.name ==
> "Drafts" }.first
> draft = drafts_folder.messages.first
I need to use the send method somehow. I think I need to make a new
MailOutgoingMessage but I would like to make this message based on my
already existing draft message.
Any know how this is done?
I had hoped it would have been as simple as draft.send. :)
On Sat, Oct 20, 2012 at 2:14 PM, Mark Rada wrote:
> Hi Rob,
>
> I think Colin answered this fairly well. Personally, I prefer to use GCD
> when available because I find the API simpler and GCD stuff works with or
> without run loops.
>
> --
> Mark
>
>
> On 2012-10-20, at 2:40 PM, Robert Carl Rice wrote:
>
> > Hi Mark,
> >
> > I use NSTimer a lot in my apps. What is the advantage of using GCD API?
> >
> > There is an excellent tutorial on the web for specifically for setting
> up ScriptingBridge for Apple Mail but I forget where I saw it. On warning;
> if you set up ScriptingBridge for Apple Mail don't try to take a snapshot
> in Xcode 4. Xcode will follow the link to mail and include all of your
> mailboxes in the snapshot. I don't know if there is a way to stop this
> behavior.
> >
> > Bob Rice
> >
> > On Oct 19, 2012, at 6:50 PM, Mark Rada wrote:
> >
> >> Busy looping for an hour would be really bad. I assume you would have a
> sleep in there, but then you're still polling.
> >>
> >> If you are using MacRuby, looking at the GCD API would be a good idea.
> You could do something like this:
> >>
> >> def schedule_email q
> >> q.after(3600) do
> >> # Send email
> >> schedule_email q
> >> end
> >> end
> >>
> >> schedule_email Dispatch::Queue.new("com.rosson.delayed.email")
> >>
> >> NSRunLoop.currentRunLoop.run
> >>
> >>
> >>
> >> As for actually sending emails, if you want to have things go through
> Apple Mail you could use the ScriptingBridge framework which has a few
> tutorials online (but for iTunes):
> >>
> >>
> http://arstechnica.com/apple/2011/09/tutorial-os-x-automation-with-macruby-and-the-scripting-bridge/
> >>
> >> AXElements is another option that I am biased in favour of; but it may
> not be passive enough for your requirements.
> >>
> >> HTH,
> >> Mark
> >>
> >>
> >> On 2012-10-19, at 6:12 PM, Cliff Rosson wrote:
> >>
> >>> Hi Everyone,
> >>>
> >>> I am fairly new to macruby and am having trouble finding some basic
> documentation to help me out. I would like to write a simple app that sends
> a delayed email based on Time from mac mail.
> >>>
> >>> I am thinking of something like this,
> >>>
> >>> time = Time.now + 3600
> >>> while true
> >>> case time
> >>> when Time.now
> >>> #Send email
> >>> end
> >>> end
> >>>
> >>> Being able to respond to certain emails or send an email from a draft
> would be a huge benefit. Can anyone point me in the write direction to
> accomplish this? I am decently proficient in ruby but don't know where to
> start with MacRuby.
> >>>
> >>> Thanks everyone
> >>>
> >>> ___
> >>> MacRuby-devel mailing list
> >>> [email protected]
> >>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> >>
> >> ___
> >> MacRuby-devel mailing list
> >> [email protected]
> >> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> >>
> >
> > ___
> > MacRuby-devel mailing list
> > [email protected]
> > http://lists.macosforge.org/mailman/listinfo/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>
--
http://about.me/cliffrosson
vizualize.me/cliffrosson
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
