diff options
| -rw-r--r-- | .github/workflows/builds.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 2 | ||||
| -rw-r--r-- | Mozo/MainWindow.py | 24 | ||||
| -rw-r--r-- | Mozo/MenuEditor.py | 10 | ||||
| -rw-r--r-- | Mozo/util.py | 6 |
5 files changed, 30 insertions, 14 deletions
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 0169a4b..e51c5cb 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -63,7 +63,7 @@ jobs: pacman --noconfirm -Sy git || true echo "::endgroup::" - name: Repository checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Install dependency packages run: .github/workflows/${{ env.DISTRO }}.sh - name: Enable ccache to speed up builds diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a42654..ab32e5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Repository checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Install dependency packages run: sudo .github/workflows/ubuntu.sh diff --git a/Mozo/MainWindow.py b/Mozo/MainWindow.py index 070c738..7a1dfdc 100644 --- a/Mozo/MainWindow.py +++ b/Mozo/MainWindow.py @@ -27,15 +27,19 @@ from gi.repository import MateMenu import html import os import gettext +import locale import subprocess +import filecmp import shutil import urllib.parse try: from Mozo import config gettext.bindtextdomain(config.GETTEXT_PACKAGE,config.localedir) gettext.textdomain(config.GETTEXT_PACKAGE) + locale.bindtextdomain(config.GETTEXT_PACKAGE,config.localedir) + locale.textdomain(config.GETTEXT_PACKAGE) GETTEXT_PACKAGE = config.GETTEXT_PACKAGE -except: +except Exception: GETTEXT_PACKAGE = "mozo" _ = gettext.gettext from Mozo.MenuEditor import MenuEditor @@ -259,10 +263,12 @@ class MainWindow: if isinstance(item, MateMenu.TreeSeparator): name = '---' elif isinstance(item, MateMenu.TreeEntry): + app_info = Gio.DesktopAppInfo.new(item.get_desktop_file_id()) + display_name = app_info.get_display_name() if app_info else item.get_desktop_file_id() if show: - name = html.escape(item.get_app_info().get_display_name()) + name = html.escape(display_name) else: - name = '<small><i>' + html.escape(item.get_app_info().get_display_name()) + '</i></small>' + name = '<small><i>' + html.escape(display_name) + '</i></small>' else: if show: name = html.escape(item.get_name()) @@ -307,9 +313,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 +405,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() diff --git a/Mozo/MenuEditor.py b/Mozo/MenuEditor.py index 892fab1..875a587 100644 --- a/Mozo/MenuEditor.py +++ b/Mozo/MenuEditor.py @@ -24,7 +24,7 @@ import xml.parsers.expat import locale import gi gi.require_version('MateMenu', '2.0') -from gi.repository import MateMenu, GLib +from gi.repository import MateMenu, GLib, Gio from Mozo import util class Menu: @@ -371,8 +371,8 @@ class MenuEditor(object): def editItem(self, item, icon, name, comment, command, use_term, parent=None, final=True): #if nothing changed don't make a user copy - app_info = item.get_app_info() - if icon == app_info.get_icon() and name == app_info.get_display_name() and comment == item.get_comment() and command == item.get_exec() and use_term == item.get_launch_in_terminal(): + app_info = Gio.DesktopAppInfo.new(item.get_desktop_file_id()) + if app_info is not None and icon == app_info.get_icon() and name == app_info.get_display_name() and comment == item.get_comment() and command == item.get_exec() and use_term == item.get_launch_in_terminal(): return #hack, item.get_parent() seems to fail a lot if not parent: @@ -577,7 +577,9 @@ class MenuEditor(object): def __isVisible(self, item): if isinstance(item, MateMenu.TreeEntry): - app_info = item.get_app_info() + app_info = Gio.DesktopAppInfo.new(item.get_desktop_file_id()) + if app_info is None: + return not item.get_is_excluded() return not (item.get_is_excluded() or app_info.get_nodisplay()) menu = self.__getMenu(item) if menu == self.applications: diff --git a/Mozo/util.py b/Mozo/util.py index a9bde70..d01df2f 100644 --- a/Mozo/util.py +++ b/Mozo/util.py @@ -24,7 +24,7 @@ import gi gi.require_version('Gtk', '3.0') gi.require_version('MateMenu', '2.0') from collections.abc import Sequence -from gi.repository import GLib, Gtk, Gdk, GdkPixbuf +from gi.repository import GLib, Gtk, Gdk, GdkPixbuf, Gio from gi.repository import MateMenu DESKTOP_GROUP = GLib.KEY_FILE_DESKTOP_GROUP @@ -149,8 +149,8 @@ def getIcon(item): if isinstance(item, MateMenu.TreeDirectory): gicon = item.get_icon() elif isinstance(item, MateMenu.TreeEntry): - app_info = item.get_app_info() - gicon = app_info.get_icon() + app_info = Gio.DesktopAppInfo.new(item.get_desktop_file_id()) + gicon = app_info.get_icon() if app_info else None elif isinstance(item, str): iconName = item if iconName and not '/' in iconName and iconName[-3:] in ('png', 'svg', 'xpm'): |
