linuxmint / xviewer

A generic Image viewer
GNU General Public License v2.0
75 stars 37 forks source link

Reflect External Changes - Fixes Issue 151 #152

Closed programmer-ceds closed 2 years ago

programmer-ceds commented 3 years ago

This PR addresses issue #151

It would appear to be intention that xviewer when the file that is currently being displayed is changed by an external program the display should update to reflect the changes. The update should happen without prompting the user unless the image has been altered within xviewer (for example flipped horizontally).

This display is updated automatically (with or without prompting as noted above) in the following situations:

In nemo right-click on the directory that contains the image and select "Open With/Other Application.../Image Viewer". In this case all of the images in that folder will "in-view" update if they are changed externally.

In nemo right-click on an image file and select "Open With/Other Application.../Image Viewer"

In a terminal window opened in the directory that includes an image type xviewer followed by a single image file name.

The display is NOT updated automatically in the following situations:

In nemo right-click on an image file and select "Open With Image Viewer" (i.e. not following the Open With route which does work)

In nemo double-click on an image or left-click once and then press Enter

In a terminal window opened in the containing directory type xviewer followed by two or more file names.

Note that what is probably the most common route of opening an image in xviewer (double-clicking the file in nemo) will mean that the external changes are not reflected in the current display.

The reason for the above behaviour is that function xviewer_list_store_add_files() only enables a monitor on the directory that includes the image(s) if it is activated with one (or more) directory names or it is activated with a single image file name.

Unfortunately double-clicking an an image file in nemo activates xviewer with the names of all of the files that are in the containing directory.

The change to the code is to enable a change monitor for each of the parent directories of the multiple image files (only one monitor for each directory regardless of the number of specified files are within that directory)

clefebvre commented 2 years ago

Works very well and solves the described issue.

Do we need to g_object_unref (file)?

I'm also wondering whether g_list_free_full (directory_list, g_free) is needed or not?