We’re getting to the point where we need to have the disclosures we added to GIMP communicate with a separate disclosure window to avoid the infinite pop-ups that we are currently using. The current GIMP Plug-In architecture does not let GIMP directly give information to plug-ins, which is exactly what we need to do. We have been thinking of possible ways to get around this, either by maintaining the disclosure window as a plug-in, or by putting the disclosure window directly into GIMP.
One way of communicating between GIMP and the disclosure window while maintaining a plug-in would be to use some sort of utility provided by the Operating System to communicate between the two. A basic possibility we first considered would be to have GIMP write to a text file, and then have the disclosure window continually check if there is text in that file, and then slurp up the text if there is any. The text file feels very extraneous, and I’m not sure how efficient it is to constantly check a text file (or how to do it, but that’s something we could figure out). When going along with this line of reasoning, we realize we could try to cut out the text file by opening a pipe.
Using a pipe for this is something that I’m not quite sure if it would work as a plug-in. This link shows the basics of piping with C. The important things to take from that is that both the reader and the writer are created at the same point in the program, so you need to fork to create a child process that is able to communicate with GIMP. This seems much cleaner than using a file, but I’m not positive that this will work for a couple reasons. This also has the “problem” of requiring the disclosure window continually check for input, but that is something that we can figure out if needed. For one, we need to have the writing file-handle available to all of our disclosure methods, and I’m not sure that we could do that when we initialize the plug-in. I think we would be forking the process as part of the “run” function of the plug-in, which I think is already separated from the main GIMP, so we couldn’t communicate the file-handle back to where it is needed. This second problem is something that could be fixed by moving the disclosure window into the source code of GIMP, which does not seem to be a huge problem, as we already need to modify GIMP’s source code quite a bit, so having a plug-in seems kind of silly, as any user would have to have our version of the source code for the plug-in to do anything. So, we think that we are going to have the disclosure window integrated into the source code of GIMP.
Integrating the disclosure window in GIMP’s source code would allow piping all disclosures to work fairly easily. I currently envision us forking a disclosure window as GIMP is initialized, and then declaring the file-handle to write to the disclosure window as a global in GIMP. This still has our recurring “problem” of continually checking for input, but aside from that I feel like it would be easy to implement. The other thing that is wonky is that this uses a global, which we would like to avoid if possible.
Our thought process at this point is that if we are just starting the disclosure window in the initialization of GIMP, we shouldn’t need to bother with forking or piping the disclosure window. It seems like we shouldn’t create a new process if we don’t need to, but then we need to figure out what methods we are using to pass disclosures to the window. We could probably use signals to communicate, but we need to figure out what instance to emit it with (emitting signals requires an instance of an object to emit), as we don’t really have a common instance to emit under. It might be possible that all the instances we have would be able to find the Gimp struct, but that seems like it could get very ugly if we had to go up multiple parent instances to find the Gimp struct, and I’m not positive that we have access to the Gimp struct in all of our disclosures. This is something that I think we could work around, and this approach also eliminates the need to wait to receive input, as signals take care of that internally.
The final idea I have for how to write to the disclosure window is just to write a procedure that takes a string and writes it to the disclosure window. This procedure might need the instance of the disclosure window that we are trying to write to, which again makes us declare a global, or pass around the instance throughout every function, which is not going to happen. We would also need to put a header with the disclosure method and the window data into all of the files that need to talk to the disclosure window.
These are all possible solutions to getting GIMP and our addition communicating properly. I think we will just end up with the last option, but we haven’t completely decided yet.