helloSystem / Filer

A file manager that can also render the desktop
GNU General Public License v2.0
33 stars 8 forks source link

Consider adding airyx LaunchServices #116

Open probonopd opened 3 years ago

probonopd commented 3 years ago

https://github.com/helloSystem/Filer/compare/master...mszoek:airyx?expand=1 introduces LaunchServices to Filer :1st_place_medal:, hence addressing long-standing issues with how applications and documents are associated. It does so by introducing ObjC code whereas the rest of Filer is written in Qt/C++, and by introducing depenedencies on other Airyx components such as <LaunchServices/LaunchServices.h>.

#define COCOA
#import <LaunchServices/LaunchServices.h>
#import "cocoa.h"

cc @mszoek

mszoek commented 3 years ago

https://github.com/helloSystem/Filer/compare/master...mszoek:airyx?expand=1 introduces LaunchServices to Filer 🥇, hence addressing long-standing issues with how applications and documents are associated

Well... maybe starting to address them! :)

* Can we replace the ObjC code by Qt/C++ code to make it consistent with the rest of the code?

The ObjC++ in cocoa.mm is a stub that lets the rest of C++ Filer access the LS and Foundation frameworks. That code is used to e.g. load a .app bundle and extract its program arguments, display name, and icon file.

Most of the APIs provided by LS are actually plain C so they could be called directly from C++. (There are currently some NSString references in LaunchServices.h but they could be changed to CFStringRef to avoid needing Foundation.) I can probably switch from using Foundation NSBundle to use CoreFoundation (plain C) CFBundle as well. So that would get ObjC code out of Filer itself.

You would still need to have the frameworks themselves in /System/Library/Frameworks.

* Can we satisfy `<LaunchServices/LaunchServices.h>` with a Qt/C++ implementation of the same?

Wouldn't this involve duplicating all the work I've done on LS, rewriting it in C++ with Qt?

* Can we replace plist XML with something modern like json?

Of course! A property list is just a dictionary of keys and values. Just add a suitable Reader and Writer here: https://github.com/mszoek/airyx/tree/main/Frameworks/Foundation/NSPropertyList

Incidentally, I am also planning to make Filer use NSFileManager in Foundation and remove the libfm dependency.

probonopd commented 3 years ago

So that would get ObjC code out of Filer itself.

Sounds great.

We should definitely try to work toward a common codebase, as you are making changes I always wanted to make but never came around to (e.g., rename filer-qt to Filer, parse Info.plist, add LS, remove libfm,...).

You would still need to have the frameworks themselves in /System/Library/Frameworks.

How would one compile them on helloSystem?

mszoek commented 3 years ago

Check out the PR I submitted this evening. ObjC has been rewritten as C++ calling out to Qt and CoreFoundation. I also wrapped everything in ifdefs so it only builds my changes on Airyx. Let me know if it works OK on helloSystem; everything seems fine here!

To build the frameworks on helloSystem, you should be able to just do make prep frameworks installairyx in the top of the airyx git repo. See my .cirrus.yml for a list of build dependencies to be installed from pkg. Filer needs LaunchServices and CoreFoundation which in turn need Foundation and CFNetwork. Add -D__AIRYX__=1 to CFLAGS or use the Airyx clang toolchain (it automatically defines that) to build my version.