jamf / PPPC-Utility

Privacy Preferences Policy Control (PPPC) Utility
MIT License
748 stars 54 forks source link

Resolved #42 Deselecting all apps in the sidebar will disable Save and Upload buttons #45

Closed ty-wilson closed 4 years ago

ty-wilson commented 4 years ago

Removed bindings between the ExecutablesAC > canRemove and the save/upload buttons

ty-wilson commented 4 years ago

Resolves #42

ty-wilson commented 4 years ago

@watkyn Thanks for the input! I took some time to look into this, but I am not sure it will be possible to accomplish with the current UI. Basically the Save/Upload buttons cannot be updated dynamically depending with the contents of Applications.

First, the app list is managed by an NSArrayController (executablesAC) with only specific attributes that can be accessed, for example 'ExecutablesAC.canRemove'. I couldn't find a way to add an attribute, and I assume that is why it the current build they bound them to 'canRemove' since that simulates whether an item is in the list (but not very well).

Second, to get around that I tried updating the existing IBOutlet for the save/upload buttons when items are added or removed from the app list, but this is also problematic: When the '-' button is clicked, it can only call one action, and is already bound to executablesAC.remove. If we change that to a custom IBAction within a controller, it somewhat works and we can use the model directly to remove an item (model.selectedExecutables.remove). However the issue then becomes that we cannot tell which item is selected to be removed.

So at that point, I was able to build a version where it "works" as desired, but when you click '-' it always removes the first item in the list. I seem to be running into memory issues when trying to access exeutablesAC.selectedIndex to tell which item is highlighted. I assume that is executablesAC is managed by the UI, but not really sure on that. As the 'selectedIndex' is contained by the executablesAC and not stored elsewhere, I am thinking it won't be possible to create a custom action, without some sort of memory management added.

I think we need one of the following:

  1. add a custom bool attribute to NSArrayController so we can tell when it is empty and bind the buttons to that attribute
  2. create a way to access the selectedIndex of the current array within executablesAC so we can remove that app and update the buttons simultaneously, using some sort of memory management function
  3. to rebuild the app list to not be bound to an NSArrayController and instead build a customizable controller

I don't see that 1 or 3 are realistic, 2 seems possible but is outside of my abilities currently, and might be more changes than we want for such a simple issue.

Sorry for the long post, just want to help out if someone else looks into the issue. This can be closed/rejected in my opinion, when I have a better grasp of swift/objc I'll take another look.

watkyn commented 4 years ago

@ty-wilson awesome analysis, thanks! I'll update the issue with some of this info and we'll see what path we want to go down.

macblazer commented 4 years ago

See my comment in the issue #42