Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the Code Easier to Read and update #31

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

kalip2
Copy link

@kalip2 kalip2 commented Feb 16, 2024

In your project's README, you mentioned that when you first made this code, you didn't have much experience with Objective C/CoreFoundation. Even though you thought the code might not be great, the app works well and many people use it. I wanted to make the code easier to understand, so I changed the names of some functions and variables.

I fixed a part of the code called find_itemname() because it wasn't being used before. I also removed sidebar_insert() because it didn't do anything. It seems like you were waiting for find_itemname() to work properly before making sidebar_insert() useful. But after six years, no one has asked for it, so I deleted it.

I made the error checking clearer by putting it into two new functions, ValidArguments() and ValidateSideBarList(). This makes it easier to see what the add, remove, and list options are doing. I also made a new function called ClearSideBarItems() to remove everything at once, which means RemoveSideBarItem() now just removes one item with the help of the improved FindItemByName().

I updated the xcodeproj files needed to make the code work with the newest Mac Silicon chips.

It's a bit difficult to read the diffs, so checking out the final version of the code might be simpler: https://github.com/mosen/mysides/blob/ebd838ade305e850962f88f492dc1ac559834940/src/main.m

With these changes, the code should be easier for you or anyone else to read and work with in the future. You did a great job making something that helps so many people with automating their Macs, even after all this time.

@MakePerceive
Copy link

MakePerceive commented Aug 17, 2024

Thank you for this code, I use the sidebar all the time and will be automating this using SoundFlow (this runs the command-line code for me via stream deck triggers). It seems that in the latest version the "insert" option has been removed (to place an item at the beginning of the list / top of the sidebar). I installed via Homebrew (I think it may be the main install, not the fork?). Is it possible to add the "insert" function back in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants