summaryrefslogtreecommitdiff
path: root/src/nautilus-clipboard.c
Commit message (Collapse)AuthorAgeFilesLines
* clipboard: Reimplement clipboard_clear_if_colliding_urisCorey Berla2023-01-091-22/+18
| | | | | This functions clears the clipboard if any of its contents becomes potentially invalid.
* clipboard: Make Nautilus Clipboard more resilientCorey Berla2022-12-201-13/+36
| | | | | | | | | | | | | | | | | | We are making the assumption that the clipboard data is always correctly formatted. Given that the "x-special/gnome-copied-files" doesn't necessarily have a defined specification and that some other software programs seem to be passing bad data, we need to be more careful about the assumptions we make. Let's add a few more checks: 1) The first line must begin with "copy" or "cut" 2) All subsequent lines must either be a valid URI or an empty string (after stripping out '\n') 3) If there are any errors in the clipboard, return an error rather than an empty clipboard Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2539
* clipboard: Check for empty string when deserializingCorey Berla2022-07-151-0/+5
| | | | | | | | | | | It's possible that nautilus_clipbaord_from_string() receives an empty string. When an empty string is received nautilus crashes because g_str_equal() cannot handle the null value returned from g_strsplit(). We could simply change g_str_equal() to g_strcmp0() but that opens up the possibility for the for loop to give unexpected results (it only checks for NULL starting at index=1). Check if the results from g_strsplit()[0] == NULL and return early.
* clipboard: Initialize g_autofree variable to NULLCorey Berla2022-07-071-1/+1
|
* list-view: Reenable clipboard monitoring for cut itemsAntónio Fernandes2022-03-271-0/+12
| | | | | | No visual result expected for now. This GtkTreeView-based view is not here for long anyway. Just doing this to copy the approach into the grid view next commit.
* clipboard: Reintroduce non-local clipboard handlingAntónio Fernandes2022-03-271-109/+138
| | | | | | | | | | | | | | | | | | | The old implementation supported providing 3 clipboard targers: - the "x-special/gnome-copied-files" MIME Type - the "text/uri-list" MIME Type - plain text clipboard We would build slightly different strings for each target. For pasting, only the first target was supported, but the provider could be any other program, not necessarily ourselves. In order to restore this non-local clipboard functionality, we need to serialize content into these target types or deserialize into a GType. - For the first one, we register our own custom [de]serializers, which replicate the old implementation format. - For the other two, we have GDK do it from GTK_TYPE_FILE_LIST.
* general: Reimplement clipboard actionsAntónio Fernandes2022-03-271-34/+56
| | | | | | | | | | | | GdkClipboard is a new API very unlike the now-gone GtkClipboard. It uses GValue for clipboard data, which allows in-process operation to use the local data structures directly. For this, extend our ClipboardInfo struct into a full blown NautilusClipboard boxed type. Non-local clipboard operation still needs reimplementation.
* clipboard: Drop now unnecessary codeAntónio Fernandes2022-03-271-75/+2
| | | | | | | | Before porting to GdkClipboard, and in order to get a clean diff, let's start by removing functions definitions which deal with the old GtkClipboard API and nothing specific with our custom content, as well as wrapper to get clipboard from a widget, which now is provided directly by GTK.
* general: Disable clipboardAntónio Fernandes2021-12-311-0/+2
| | | | | | | GTK 4 changes how clipboard is interacted with, compared to GTK 3. Disable this code before the switch. It shall be reimplemented once we are building against GTK 4.
* Revert "clipboard: Use text based clipboard only"António Fernandes2021-03-071-58/+58
| | | | | | | | | | | | | | | | | | | | | | After removing the non-default "icons on desktop" functionality from nautilus, a gnome-shell extension was created as a substitute. This extension needed to interoperate with nautilus for file operations, but its access to clipboard was limited to plain text, so, in order to ensure interoperation, nautilus had to use plain text clipboard only. However, this temporary regression resulted in implementation details leaking into the text clipboard, instead of a plain file path. But now St.Clipboard can handle any type of clipboard content[1], the extension will be able to handle any clipboard type, so we can finally fix this regression on our side. This reverts commit 1f77023b5769c773dd9261e5294c0738bf6a3115 and its fixup commit be53569b339b4494647758a9afa0fdd30184455b Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/634 [1] GNOME/gnome-shell@ec367623
* general: Run uncrustify scriptOndrej Holy2020-04-051-1/+0
| | | | | There are some style issue since the last run. Let's run it again before enabling style-check CI job.
* clipboard: Fix incorrect item URIs collision checkArtem Serostanov2020-03-261-1/+1
| | | | | | | | | | | | | Nautilus is supposed to clear items in the clipboard in case when items moved by drag-and-drop were were present in the clipboard. However, the item URI collision check algorithm compares moved (or copied) items with themselves instead of clipboard contents, resulting in the clipboard being cleared on every drag-and-drop operation. Fix the algorithm to address this issue. Closes: https://gitlab.gnome.org/GNOME/nautilus/issues/1235
* general: Null-initialize some more auto variablesErnestas Kulik2018-12-121-1/+1
|
* clipboard: Fix commentErnestas Kulik2018-08-031-1/+1
| | | What.
* clipboard: Prevent crash when selection data is emptyErnestas Kulik2018-08-021-7/+13
| | | | | | | | | Somehow, magically, it can happen that the clipboard contains an empty string, which wreaks havoc in convert_selection_data_to_str_list(), since the loop counter goes from 0 to the number of lines in the data string minus one. This commit adds a check for the number of lines and returns early. Additionally, this introduces automatic cleanup for a variable and fixes mismatched types.
* clipboard: Use text based clipboard onlyCarlos Soriano2018-08-021-59/+54
| | | | | | | | Now that we have better integration with the shell extension, and it simplifies regular clipboard handling. A nice feature is that now you can perform operations on GEdit or any other text editor by writing the correct commands :D
* general: format code with newer UncrustifyCarlos Soriano2016-11-301-2/+1
| | | | | Some issues were fixed, and now we can rerun Uncrustify to format correctly more part of the code.
* clipboard: free item listErnestas Kulik2016-11-231-12/+6
| | | | | | | The item list in nautilus_clipboard_is_cut_from_selection_data () is never freed. https://bugzilla.gnome.org/show_bug.cgi?id=774232
* general: rework clipboard handlingCarlos Soriano2016-09-291-26/+214
| | | | | | | | | | | | | | | | | | | | | | | We were using a custom clipboard monitor, due to some old behaviour in 2004 where not all X servers supported XFIXES, which allows to monitor global clipboard changes between processes, which are needed in Nautilus for copy, paste and link operations, and their availability check. Since Nautilus was a single process, it was working for most of the time. However recently we split the desktop in a different process, so we were not able to correctly set the GDK action for clipboard, since we were relying on sharing the same clipboard in the same process. In order to fix this, this patch reworks the clipboard handling to a more modern way, using the owner-changed signal present in XFIXES. This fixes the clipboard changing between the desktop and Nautilus and interproccess clipboard handling, fixes small corner cases, and in the way this patch makes the code design and ownership of clipboard more clearer. https://bugzilla.gnome.org/show_bug.cgi?id=771046
* general: run uncrustifyCarlos Soriano2016-08-291-84/+99
| | | | | | | | And make the style of Nautilus the same for all files. Hopefully we can fix all the style issues we can find in the next days, so expect a little of movement on this. https://bugzilla.gnome.org/show_bug.cgi?id=770564
* general: merge libnautilus-private to srcwip/csoriano/private-to-srcCarlos Soriano2016-04-251-0/+133
And fix make distcheck. Although libnautilus-private seem self contained, it was actually depending on the files on src/ for dnd. Not only that, but files in libnautilus-private also were depending on dnd files, which you can guess it's wrong. Before the desktop split, this was working because the files were distributed, but now was a problem since we reestructured the code, and now nautilus being a library make distcheck stop working. First solution was try to fix this inter dependency of files, but at some point I realized that there was no real point on splitting some of those files, because for example, is perfectly fine for dnd to need to access the window functions, and it's perfectly fine for the widgets in the private library to need to access to all dnd functions. So seems to me the private library of nautilus is somehow an artificial split, which provides more problems than solutions. We needed libnautilus-private to have a private library that we could isolate from extensions, but I don't think it worth given the problems it provides, and also, this not so good logical split. Right now, since with the desktop split we created a libnautilus to be used by the desktop part of nautilus, extensions have access to all the API of nautilus. We will think in future how this can be handled if we want. So for now, merge the libnautilus-private into src, and let's rethink a better logic to split the code and the private parts of nautilus than what we had. Thanks a lot to Rafael Fonseca for helping in get this done. https://bugzilla.gnome.org/show_bug.cgi?id=765543