summaryrefslogtreecommitdiff
path: root/src/nautilus-tag-manager.c
Commit message (Collapse)AuthorAgeFilesLines
* general: Fix indentation nitpicksAntónio Fernandes2023-04-231-10/+10
| | | | Pass new uncrustify criteria. No logic changes.
* general: glib deprecations in name onlyCorey Berla2023-01-091-1/+1
|
* tag-manager: Skip tracker initialization in testsAntónio Fernandes2022-05-311-0/+26
| | | | | | | | | | Fixes test failures introduced by df78c517516cec20892f2a108df47613153ddf5b Before that commit, we used to fully initiate the tag manager only from NautilusApplication, because the tests didn't call set_cancellable(). Now that initialization is completed on construction, add a constructor which skips the part of initialization that the tests don't need.
* tag-manager: Stop getting full referencesAntónio Fernandes2022-05-301-10/+15
| | | | | | | | It's really annoying having to setup a local autocleanup variable in every function we want to use the NautilusTagManager API. Use a NautilusUndoManager-like API instead, with new() returning a reference and get() not.
* tag-manager: Use regular initializationAntónio Fernandes2022-05-301-21/+15
| | | | | | | | | | | | | | | | | Somehow we have ended up in a situation where the singleton object is not initialized on creation but instead when requires the NautilusApplication code to pass a GCancellable instance in order to complete the initialization. The passed cancellable pointer is stored by the application object in order to cancel it on finalization, but there is no other usage for this cancellabled from outside of the NautilusTagManager code. So, we can just cancel it in NautilusTagManager::finalize, such that there is no need for NautilusApplication to pass or store it. This way, we can move the initalization from ::set_cancellable() into ::init instead.
* tag-manager: Release home GFile in ::finalizeAntónio Fernandes2021-01-051-0/+1
|
* tag-manager: Don't leak stamp path stringAntónio Fernandes2021-01-051-3/+6
| | | | Also respect code style (return type in different line).
* tag-manager: Don't leak singleton referencesAntónio Fernandes2021-01-051-2/+11
| | | | | | | | | | | | We are leaking references to the singleton object in multiple places. It's not a problem during runtime, but this means it's not properly finalized when the application quits, leaking the tracker connection, which is detected by valgrind. Add g_autoptr() and g_clear_object() where missing. Also, to prevent future leaks, document nautilus_tag_manager_get() and uniformize its use as either an autovariable initializer or a field initializer.
* tag-manager: Inline previously shared codeAntónio Fernandes2020-12-221-44/+9
| | | | | | get_query_status() is a wrapper for tracker_sparql_cursor_next_finish() and it's weird for _finish() not to be called directly by the GAsyncReadyCallback function.
* tag-manager: Search for tracker3 in PATHAntoine Jacoutot2020-11-191-1/+1
| | | | | | | | | | Tracker 3 migration code tries to spawn tracker3 binary using G_SPAWN_SEARCH_PATH_FROM_ENVP flag. However, tracker3 is installed under /usr/local/bin/ on OpenBSD which isn't searched by envp. So the migration fails with the following warnings: "Tracker 2 migration: Couldn't run `tracker3`: Failed to execute child process "tracker3" (No such file or directory)." Let's use G_SPAWN_SEARCH_PATH instead of G_SPAWN_SEARCH_PATH_FROM_ENVP to fix this issue.
* tag-manager: Ignore starred files ouside $HOMEAntónio Fernandes2020-10-021-1/+18
| | | | | | | | | | | | At the moment we restrict starring to within Home, but the database might include URIs from outside of it. Such may happen after a file move operation, as per the previous commit. Keeping the moved URIs in the database is useful in case the move is undone, because we change the URI back. But otherwise, the non-home URIs remain in the database indefinitely. So, let's filter them out when listing the starred files.
* tag-manager: Update starred URIs on move & renameAntónio Fernandes2020-10-021-0/+134
| | | | | | | | | | | | | | | | | We don't rely on tracker-miner-fs's rename tracking for starred files anymore, as explained in 29105fc9f6abf2eca6f986104763d21b9f22f0fb. However, losing track of starred files, when they or their containing folders are renamed or moved, is a major regression for this feature. The common case is that the operation is performed using this very app, so, we can largely restore the feature by updating URI on every rename and move operation we perform. Additionally, this allows us to finally close a couple of old issues. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/161 and fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/169
* Import starred files data from Tracker 2.xSam Thursfield2020-09-021-0/+173
| | | | | | | | | | | Starred files data is now migrated from the Tracker 2.x database if found. This depends on the `tracker3` CLI tool, which should be present anywhere that we find libtracker-sparql 3.0. The --2to3 export functionality was added in https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/308 If/when the migration completes successfully, a stamp file named `~/.local/share/nautilus/tracker2-migration-complete` is created.
* Limit starred files to within user's home directorySam Thursfield2020-09-021-0/+13
| | | | | | | | | Previously starred files were limited to directories indexed by Tracker. Since the 'Port to Tracker 3' commit this is no longer the case. However, to avoid unbounded growth in the starred files database we want to prevent starring of network locations and removable devices for now as these entries might go stale and we don't have any way to clean them up.
* tag-manager: Track files rather than contentsSam Thursfield2020-09-021-436/+117
| | | | | | | | | | | | | | | | | | Nautilus is a file manager, so we should star files. Previously we starred the content resources extracted by Tracker Miner FS, instead. This had the advantage that the stars would follow file renames. It had the downside of being more complex and limited in which files can be starred. In Tracker 2.x, the feature only worked in folders indexed by Tracker Miner FS. With Tracker 3.x, it was additionally limited to files where Tracker had extracted metadata -- mainly just documents and media files. This commit takes the simpler approach of storing the star against the file URL. All files can now be starred, and stars will no longer persist when a file is moved or renamed. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/160
* Use Tracker Miners inside Flatpak when not available on the hostSam Thursfield2020-09-021-31/+37
| | | | | | | This means the Nautilus flatpak will be able to use Tracker on systems which don't have Tracker 3 available on the host. It comes at a cost of increased resource consumption inside the Flatpak due running an extra indexer process there.
* Port to Tracker 3Sam Thursfield2020-09-021-236/+331
| | | | | | | | | | | | | | | | | | | | | | | | Mostly the port is straightforward, we connect to tracker-miner-fs explicitly over D-Bus instead of the centralized tracker-store daemon we connected to previously. The search-engine-tracker test is now isolated from the user's real Tracker index using the `tracker-sandbox` script provided by Tracker, and it lets tracker-miner-fs index the test file rather than trying to synthesize the expected database contents. There are more changes in nautilus-tag-manager.c. Until now, starred file information was stored in the tracker-miner-fs database. This has some downsides, firstly the data is deleted if someone runs `tracker reset --hard`, secondly it isn't possible to do this from inside a Flatpak sandbox with Tracker 3.0. because the This commit changes the NautilusTagManager to set up a private database inside XDG_DATA_HOME/nautilus/tags. This stores the starred file information. The database is managed with Tracker, which allows us to continue using the rename-tracking that tracker-miner-fs provides. The same limitations apply as before that only files in indexed locations can be starred.
* tag-manager: Fix checks for cancellationSam Thursfield2020-09-021-3/+2
| | | | | | | | Only process query results if there's no error. Fix some checks so that we report errors except for G_IO_ERROR_CANCELLED, which happens normally as part of nautilus_application_finalize().
* tag-manager: Guard against null notifierErnestas Kulik2018-10-091-8/+14
| | | | | | tracker_notifier_new() may return a null pointer on error, and that’s exactly what happens sometimes (CI pipelines, https://gitlab.gnome.org/GNOME/tracker/issues/43).
* tag-manager: Comment the return element-type and memory ownership transferCarlos Soriano2018-03-271-0/+6
|
* tag-manager: Use custom tag for starred itemsAntónio Fernandes2018-03-131-1/+2
| | | | | | | | | | | | | | Currently we use nao:predefined-tag-favorite, which is used by other applications (example: gnome-photos) to tag favorite content. As such, favorite photos show up as starred files in Files. This is not what we currently want, because Favoriting has a different meaning and function than Starring. Instead, create our own custom tag <urn:gnome:nautilus:starred> and use that instead of nao:predefined-tag-favorite. Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/277
* tag-manager: Use a constant for the tag nameAntónio Fernandes2018-03-131-4/+7
| | | | | This ensures all uses of the tag id use the same string. It also makes it easy to change the tag id, as we are doing next commit.
* tag-manager: use platform-dependent conversion specifierErnestas Kulik2018-03-051-1/+1
| | | | | | | What is %ld on x86_64 machines might not be what %lld is on x86 machines. Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/283
* general: don’t shadow variablesErnestas Kulik2018-03-011-11/+12
| | | | | | | Shadowing variables is error-prone, since one might mean to refer to a variable that was declared earlier, but has the same name. Additionally, being more strict about variable scoping can help make the code more readable.
* general: mark static functions as suchErnestas Kulik2018-03-011-2/+2
| | | | | Non-static functions without any previous declaration cause warnings and are usually indicative of incorrectly marked static functions.
* general: fix old-style function declarationsErnestas Kulik2018-03-011-1/+2
| | | | | Parameterless function declarations imply indeterminate parameter count, while the implementations take no arguments.
* general: Run uncrustifyCarlos Soriano2018-02-131-49/+45
|
* general: Rename from 'favorite' to 'starred'Carlos Soriano2018-02-131-38/+38
| | | | | | | | It was a mix of both terms, given that tracker uses 'favorite' but we use 'starred' in the UI. Since the part that interact with tracker is minimal, is better to be consistent with the UI. This renames 'favorite' to 'starred' except the tracker queries.
* tag-manager: Escape urisCarlos Soriano2018-02-131-5/+5
| | | | | | | | | Files with apostrophes couldn't be starred because tracker cannot handle non ascii characters. So escape the uris of files before sending them to tracker. Closes https://gitlab.gnome.org/GNOME/nautilus/issues/163
* Add favorite filesAlexandru Pandelea2017-11-051-0/+884
Add option to make files Favorite, by either toggling a star in the list view, or from the context menu. https://bugzilla.gnome.org/show_bug.cgi?id=786039