Proxy icons in window titles (and the rest of macoslib)

Hello, friends!

I am sure that most (all) of you are familiar with the macoslib bundle (https://github.com/macoslib/macoslib). I have two questions related to this package:

I’ve been looking for a way to implement the proxy icons into the window title. However, even though the macoslib documentation suggests adding the entire shebang to my project (yes, yes, I know xojo will only compile what it thinks I need), that just seems like overkill for something that I think would be simple. I tried extracting just the bits that I needed to add this, but found the entire macoslib to be unbelievably tangled. Which got me thinking…

First: I might as well be up front and ask: can anyone give me pointers on adding this functionality to my window titles that doesn’t involve copying and pasting all of the macoslib into my project?

And second… Has anyone attempted to split the macoslib into smaller projects? I can’t believe how much good stuff is there, but it seems like it would be even more useful if it was easier to copy and paste into other projects.

Thoughts?

I’m sorry I can’t help you but I agree.
It would be great if MacOSLib was split into small parts somehow. Or if there were instructions or tools to do so.
I think MacOSLib is great but sometimes I would like to add, fix or learn something but I have no idea where to look.
Right now, I’m working on a project where I include MacOSLib only for TTsSmartPReferences (love that btw). But every time I hit Command+R, I see everything in MacOSLib being compiled. Apart from slowing down the compiling, it just feels sluggish and overkill.

Declare Sub setTitleWithRepresentedFilename Lib "Cocoa" Selector "setTitleWithRepresentedFilename:" _ (NSWindow As Ptr, filePath As CFStringRef) setTitleWithRepresentedFilename(Ptr(Handle), "abc.txt")
Note that Apple recommends that the window title bar has an icon only when the window represents a file. So don’t put an icon in the title bar in any other case.

Thanks, Eli!

This really makes my point. What I wanted to do took all of TWO lines of code, but it’s so deeply entrenched in macoslib that I couldn’t dig it out.

Marco – I’m afraid I don’t know what all TTsSmartPReferences does, but I’ve been using a modified form of what’s on this page when I need to save preferences: http://blog.xojo.com/2014/01/28/saving_preferences/. Super easy to copy/paste the module right into my projects.

Can someone fix Matthew’s link? It isn’t going where it says it is …

http://blog.xojo.com/2014/01/28/saving_preferences/

Op- sorry, Markus. Thanks, for reposting the link, Michel.

One last question, specifically about the proxy icons: If I need to clear it, is it OK to simply use the same code Eli posted and set the filename to an empty string?

This works for me, but I don’t know if that’s good practice, or if they have another function for that. (The macoslib calls a “RemoveWindowProxy” function, but it’s specifically for Carbon…)

I would wait for the new version Charles has announced. I experimented a bit with independent classes, and yes, while they are possible, the overhead of multiple declaration copies becomes ridiculous once you use more than a handful of them. And it’s no good solution at all if you want to use Mac feature throughout your app.
Only thing that could work would be to sort the classes into “necessary” and “optional” framework folders. This would still demand a lot of manual sorting by the developer (and, of course, insight on the needed frameworks).
I personally hope for the Xojo-made plugins probably next year. A plug-in that’s scanned only once should look (and behave) much nicer than an enormous library added to your source code. No fast solution for today, of course.

Michel, is the ‘saving_preferences’ example also working when sandboxed?
Peter

[quote=209784:@Hanspeter Stocker]Michel, is the ‘saving_preferences’ example also working when sandboxed?
Peter[/quote]

There should be no problem, since the preferences are saved in the ApplicationData folder, which a sandboxed application has access to. My own MAS apps use a simpler technique with a tab separated file, but it is saved in the same folder.