Re: [MacRuby-devel] Scripting OmniGraffle

2011-11-19 Thread Sophie
Thanks, Kam. 

Thanks, Matt.

That was very helpful.

Sophie

> From: Kam Dahlin 
> To: "MacRuby development discussions."
>   
> Subject: Re: [MacRuby-devel] Scripting OmniGraffle
> Message-ID: <8a0549a1-912c-42d2-8a33-4a4a1950d...@me.com>
> Content-Type: text/plain; CHARSET=US-ASCII
> 
> Hi Sophie,
> 
> Here is a little example, that I hope makes things more clear.
> 
> graffle = 
> SBApplication.applicationWithBundleIdentifier("com.omnigroup.OmniGrafflePro")
> 
> win = graffle.windows.first
> canvas = win.canvas
> 
> circle = 
> OmniGraffleProfessionalShape.alloc.initWithProperties({:name=>"Circle", 
> :origin=>[100.00, 100.00], :size=>[300, 300]})
> canvas.shapes.addObject(circle)
> 
> The example above uses the class name that should match what is in the header 
> file that you generated. 
> 
> You can also use a slightly different method for getting the correct class:
> 
> circle = 
> graffle.classForScriptingClass("shape").alloc.initWithProperties({:name=>"Circle",
>  :origin=>[100.00, 100.0], :size=>[300.0, 300.0]})
> 
> the -classForScriptingClass method takes the name of the class you would use 
> in Applescript and then returns the class that the ScriptingBridge machinery 
> expects. Just a slightly different approach and useful if you know the name 
> of the class you would use in Applescript, but not the actual name used by 
> ScriptingBridge.
> 
> If you look in the header that you generated for OmniGraffle, you will see a 
> bunch of @property declarations in each of the class definitions. The names 
> of these properties you use as the keys in the initWithProperties method. 
> Alternately you could also do:
> 
> circle = OmniGraffleProfessionalShape.alloc.init
> canvas.shapes.addObject(circle)
> circle.setName("Circle")
> circle.setOrigin([100.0, 100.0])
> circle.setSize([300.0, 300.0])
> 
> If you are going to set properties on an object, it must be added to a 
> container first. 
> 
> Most of this is explained pretty well in the ScriptingBridge documentation, 
> which is probably worth a look: 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/AboutScriptingBridge/AboutScriptingBridge.html#//apple_ref/doc/uid/TP40006104-CH3-SW9
> 
> hth
> kam
> 
> P.S. the origin and size properties are actually defined as part of the 
> OmniGraffleProfessionalGraphic class which OmniGraffleProfessionalShape 
> inherits from.
> 
> On Nov 15, 2011, at 11:43 AM, Sophie wrote:
> 
>> Sorry for the sloppy subject line in my earlier question.
>> 
>> Thanks, Kam, Matt for your very helpful replies. 
>> 
>> Kam, any idea how I would initialize the alloc'd shape to be e.g. a Circle 
>> of some size at some position?
>> 
>> I generated the files with sdef & gen_bridge_metadata, found lots of useful 
>> things there. Is there something in these files that would lead me to:
>> 
>> shape = OmniGraffleShape.alloc.init 
>> canvas.shapes.addObject shape
>> 
>> ?  I don't see either alloc or init, or addObject in the 2 files.
>> 
>> Also, is there some reason why there is no corresponding "make ..." method 
>> in either file? Applescript gladly seems to call "make" (so does Ruby 
>> Appscript) on doc, canvas, or layer ... but I'm no Applescript guru :-(
>> 
>> Thanks !! 
>> 
>> 
> 

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Is this possible in MacRuby?

2011-11-19 Thread Joshua Ballanco
On Thu, Nov 17, 2011 at 1:07 PM, az...@gmx.net  wrote:

> Hi All,
>
> Is it possible to make a Lion app(/option) with MacRuby which allows you
> to change the opacity (alpha value) of other apps/windows via the View menu?
>
> So say I have a PDF open in Preview, I'd go to: view menu > transparency,
> and then set it to 50%
>
> Is this possible? Would it be a pain to do? I don't think I've seen any
> MacRuby apps that add functionality to other apps like this so am guessing
> it's not trivial.
>

Hi Aston,

Forgive the quick and dirty description... Properties of an application's
windows are controllable by the operating system or the application itself.
Allowing a different application access to the window is, generally
speaking, a violation of process separation. That said, you might look into
SIMBL. It allows you to inject code into a running process. Not as a
separate process, but it is possible to modify an already running process.

Hope that helps.

- Josh
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Is this possible in MacRuby?

2011-11-19 Thread az...@gmx.net
Hi Josh,

Ah I see, that makes sense now - as the app I wanted to replace (Afloat) 
installs SIMBL first - hence me wondering whether it might have been something 
possible with MacRuby (without SIMBL). 

Thanks for taking the time to reply, much appreciated.

Aston

On 20 Nov 2011, at 00:37, Joshua Ballanco wrote:

> On Thu, Nov 17, 2011 at 1:07 PM, az...@gmx.net  wrote:
> Hi All,
> 
> Is it possible to make a Lion app(/option) with MacRuby which allows you to 
> change the opacity (alpha value) of other apps/windows via the View menu?
> 
> So say I have a PDF open in Preview, I'd go to: view menu > transparency, and 
> then set it to 50%
> 
> Is this possible? Would it be a pain to do? I don't think I've seen any 
> MacRuby apps that add functionality to other apps like this so am guessing 
> it's not trivial.
> 
> Hi Aston,
> 
> Forgive the quick and dirty description... Properties of an application's 
> windows are controllable by the operating system or the application itself. 
> Allowing a different application access to the window is, generally speaking, 
> a violation of process separation. That said, you might look into SIMBL. It 
> allows you to inject code into a running process. Not as a separate process, 
> but it is possible to modify an already running process.
> 
> Hope that helps.
> 
> - Josh
> ___
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel