diff options
| author | Victor Kareh <[email protected]> | 2026-05-14 09:42:08 -0400 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2026-05-14 09:58:53 -0400 |
| commit | f5a5d7e36f123fe22e951b69af66dad15b00ea25 (patch) | |
| tree | 30e197c4032c3a7f8b2cb2181c3ef1e90bc5f503 /Mozo | |
| parent | 6f62195d2bf136fccfeb1f7cd32f7394a10d31c0 (diff) | |
| download | mozo-no-stale-desktop-copies.tar.bz2 mozo-no-stale-desktop-copies.tar.xz | |
Do not leave behind stale .desktop filesno-stale-desktop-copies
If the user clicked on Close in the Properties dialog, we should remove
the .desktop file we just copied to ~/.local/share/applications.
Heavily adapted from Alacarte https://gitlab.gnome.org/GNOME/alacarte/-/commit/fab91e9c
Fixes #17
Diffstat (limited to 'Mozo')
| -rw-r--r-- | Mozo/MainWindow.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Mozo/MainWindow.py b/Mozo/MainWindow.py index 070c738..7f1a488 100644 --- a/Mozo/MainWindow.py +++ b/Mozo/MainWindow.py @@ -28,6 +28,7 @@ import html import os import gettext import subprocess +import filecmp import shutil import urllib.parse try: @@ -307,9 +308,14 @@ class MainWindow: return True #this callback keeps you from editing the same item twice - def waitForEditProcess(self, process, file_path): + def waitForEditProcess(self, process, file_path, original_path): if process.poll() is not None: self.edit_pool.remove(file_path) + if original_path is not None and os.path.isfile(file_path): + if filecmp.cmp(file_path, original_path, shallow=False): + os.remove(file_path) + self.editor._MenuEditor__undo.pop() + self.editor.update_undo_redo_button_state() return False return True @@ -394,15 +400,18 @@ class MainWindow: file_path = os.path.join(util.getUserDirectoryPath(), os.path.split(item.get_desktop_file_path())[1]) file_type = 'Menu' + copied = False if not os.path.isfile(file_path): shutil.copy(item.get_desktop_file_path(), file_path) self.editor._MenuEditor__addUndo([(file_type, os.path.split(file_path)[1]),]) + copied = True else: self.editor._MenuEditor__addUndo([item,]) if file_path not in self.edit_pool: self.edit_pool.append(file_path) + original_path = item.get_desktop_file_path() if copied else None process = subprocess.Popen(['mate-desktop-item-edit', file_path], env=os.environ) - GLib.timeout_add(100, self.waitForEditProcess, process, file_path) + GLib.timeout_add(100, self.waitForEditProcess, process, file_path, original_path) def on_menu_tree_cursor_changed(self, treeview): selection = treeview.get_selection() |
