From 5693b3f3230a3d053158c0b1af05e7623eb44a37 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 4 Jul 2023 20:25:36 +0800 Subject: [PATCH 01/24] fix compatibility with python-pillow 10.0.0 --- dockbarx/iconfactory.py | 7 ++++++- dockbarx/theme.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dockbarx/iconfactory.py b/dockbarx/iconfactory.py index f796819..324d0ad 100644 --- a/dockbarx/iconfactory.py +++ b/dockbarx/iconfactory.py @@ -1017,7 +1017,12 @@ def __get_from_set(self, setname): def __resize_surface(self, surface, w, h): im = self.__surface2pil(surface) - im = im.resize((w, h), Image.ANTIALIAS) + try: + algo = Image.LANCZOS + except AttributeError: + # removed in python-pillow 10.0.0 + algo = Image.ANTIALIAS + im = im.resize((w, h), algo) return self.__pil2surface(im) def __command_print_size(self, surface): diff --git a/dockbarx/theme.py b/dockbarx/theme.py index fb087b3..af25f41 100644 --- a/dockbarx/theme.py +++ b/dockbarx/theme.py @@ -840,5 +840,10 @@ def __pil2surface(self, im): def __resize_surface(self, surface, w, h): im = self.__surface2pil(surface) - im = im.resize((w, h), Image.ANTIALIAS) + try: + algo = Image.LANCZOS + except AttributeError: + # removed in python-pillow 10.0.0 + algo = Image.ANTIALIAS + im = im.resize((w, h), algo) return self.__pil2surface(im) From 19dba7cc849662b5f2027b1277604586bb454ba9 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Fri, 28 Jul 2023 09:54:24 +0800 Subject: [PATCH 02/24] bump version --- README.md | 2 +- dockbarx/dockbar.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6817368..ab910d4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DockbarX -### Version 1.0-beta2 +### Version 1.0-beta3 ## About DockbarX The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a Xfce4 panel applet[^1] or a matepanel applet. DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. diff --git a/dockbarx/dockbar.py b/dockbarx/dockbar.py index 8344859..134f510 100644 --- a/dockbarx/dockbar.py +++ b/dockbarx/dockbar.py @@ -42,7 +42,7 @@ from . import i18n _ = i18n.language.gettext -VERSION = "1.0-beta2" +VERSION = "1.0-beta3" SPECIAL_RES_CLASSES = { diff --git a/setup.py b/setup.py index 64b0642..bc9ae03 100755 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ import sys import stat -VERSION = "1.0-beta2" +VERSION = "1.0-beta3" class build_trans(cmd.Command): description = "Compile .po files into .mo files" From 8257929e88e4309f8ff01ac73a4cd58ce0e8ae7d Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 14 Nov 2023 20:23:37 +0800 Subject: [PATCH 03/24] Improve the appearance of window title --- dbx_preference | 38 +++++++++++++++++--------------------- dockbarx/windowbutton.py | 12 +++++++----- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/dbx_preference b/dbx_preference index 59ecadb..2577b35 100755 --- a/dbx_preference +++ b/dbx_preference @@ -859,21 +859,6 @@ class PrefDialog(): popup_box.pack_start(self.shape_mask_cb, False, True, 5) - self.preview_size_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) - self.preview_size_spinbox.set_border_width(5) - spinlabel = Gtk.Label(label=_("Preview size")) - spinlabel.set_xalign(0) - spinlabel.set_yalign(0.5) - adj = Gtk.Adjustment.new(200, 50, 800, 1, 50, 0) - self.preview_size_spin = Gtk.SpinButton.new(adj, 0.5, 0) - self.preview_size_spinbox.pack_start(spinlabel, False, True, 0) - self.preview_size_spinbox.pack_start(self.preview_size_spin, - False, True, 5) - adj.connect("value_changed", self.__adjustment_changed, "preview_size") - self.preview_size_spinbox.show_all() - self.preview_size_spinbox.set_no_show_all(True) - popup_box.pack_start(self.preview_size_spinbox, False, True, 5) - self.window_title_width_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) self.window_title_width_spinbox.set_border_width(5) spinlabel = Gtk.Label(label=_("Window title width")) @@ -936,6 +921,22 @@ class PrefDialog(): vbox.pack_start(self.preview_keep_cb, False, True, 0) popup_box.pack_start(vbox, False, True, 5) + self.preview_size_spinbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) + self.preview_size_spinbox.set_border_width(5) + spinlabel = Gtk.Label(label=_("Preview size")) + spinlabel.set_xalign(0) + spinlabel.set_yalign(0.5) + adj = Gtk.Adjustment.new(200, 50, 800, 1, 50, 0) + self.preview_size_spin = Gtk.SpinButton.new(adj, 0.5, 0) + self.preview_size_spinbox.pack_start(spinlabel, False, True, 0) + self.preview_size_spinbox.pack_start(self.preview_size_spin, + False, True, 5) + adj.connect("value_changed", self.__adjustment_changed, "preview_size") + self.preview_size_spinbox.show_all() + self.preview_size_spinbox.set_no_show_all(True) + popup_box.pack_start(self.preview_size_spinbox, False, True, 5) + + # Locked list vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) label1 = Gtk.Label(label="%s"%_("Locked list")) @@ -1769,14 +1770,9 @@ class PrefDialog(): self.preview_keep_cb.set_active(self.globals.settings["preview_keep"]) self.preview_keep_cb.set_sensitive(self.globals.settings["preview"]) self.preview_size_spin.set_value(self.globals.settings["preview_size"]) + self.preview_size_spin.set_sensitive(self.globals.settings["preview"]) self.window_title_width_spin.set_value( self.globals.settings["window_title_width"]) - if self.globals.settings["preview"]: - self.preview_size_spinbox.show() - self.window_title_width_spinbox.hide() - else: - self.preview_size_spinbox.hide() - self.window_title_width_spinbox.show() # Advanced page stuff self.ignore_workspace_cb.set_active( diff --git a/dockbarx/windowbutton.py b/dockbarx/windowbutton.py index bf4cd43..555b219 100644 --- a/dockbarx/windowbutton.py +++ b/dockbarx/windowbutton.py @@ -348,7 +348,7 @@ def __init__(self, window, group): self.close_button.show() self.label = Gtk.Label() - self.label.set_ellipsize(Pango.EllipsizeMode.END) + self.label.set_ellipsize(Pango.EllipsizeMode.MIDDLE) self.label.set_halign(Gtk.Align.START) self.label.set_valign(Gtk.Align.CENTER) @@ -458,10 +458,11 @@ def __update_label(self, arg=None): text = "" + text + "" self.label.set_text(text) self.label.set_use_markup(True) - if self.globals.settings["preview"]: - # The label should be 140px wide unless there are more room - # because the preview takes up more. - label_size = 140 + self.__set_label_size() + + def __set_label_size(self): + if self.preview.get_visible(): + label_size = self.globals.settings["preview_size"] else: label_size = self.globals.settings["window_title_width"] @@ -575,6 +576,7 @@ def set_show_preview(self, show_preview): self.preview.show() else: self.preview.hide() + self.__set_label_size() def set_preview_image(self): pixbuf = self.take_preview() From 6b34d40a73ea6b0932208dc4a24da97e56fe7a7e Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Thu, 16 Nov 2023 12:21:19 +0800 Subject: [PATCH 04/24] Automatically use the most appropriate ellipsize mode --- dockbarx/groupbutton.py | 22 ++++++++++++++++++++++ dockbarx/windowbutton.py | 2 ++ 2 files changed, 24 insertions(+) diff --git a/dockbarx/groupbutton.py b/dockbarx/groupbutton.py index 3f7dd87..366ef76 100644 --- a/dockbarx/groupbutton.py +++ b/dockbarx/groupbutton.py @@ -478,6 +478,28 @@ def group_icon_changed(self, class_group): self.button.update_state(force_update=True) self.button.drag_source_set_icon_pixbuf(self.button.icon_factory.get_icon(32)) + def update_window_title_ellipsize_mode(self, title_label): + labels = [ win.item.label for win in self.get_windows() ] + if title_label not in labels: + labels.append(title_label) + if len(labels) <= 1: + return + titles = [] + titles_r = [] + for label in labels: + title = label.get_text() + titles.append(title); + titles_r.append(title[::-1]); + common_end = len(os.path.commonprefix(titles_r)) + common_start = len(os.path.commonprefix(titles)) + if common_end > 3 and common_end >= common_start: + mode = Pango.EllipsizeMode.END + elif common_start > 3: + mode = Pango.EllipsizeMode.START + else: + mode = Pango.EllipsizeMode.MIDDLE + for label in labels: + label.set_ellipsize(mode) #### Opacify def opacify(self, delay=0): diff --git a/dockbarx/windowbutton.py b/dockbarx/windowbutton.py index 555b219..ea1effa 100644 --- a/dockbarx/windowbutton.py +++ b/dockbarx/windowbutton.py @@ -450,6 +450,7 @@ def __clear_saved_preview(self, *args): def __update_label(self, arg=None): """Updates the style of the label according to window state.""" window = self.window_r() + group = self.group_r() text = escape(str(window.wnck.get_name())) if window.wnck.is_minimized(): color = self.globals.colors["color4"] @@ -459,6 +460,7 @@ def __update_label(self, arg=None): self.label.set_text(text) self.label.set_use_markup(True) self.__set_label_size() + group.update_window_title_ellipsize_mode(self.label) def __set_label_size(self): if self.preview.get_visible(): From 6f87d3071afdce30bc1f71399b98f146f4330a0c Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Thu, 16 Nov 2023 14:20:51 +0800 Subject: [PATCH 05/24] Remove unused launcher files --- dockbarx/dockbar.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/dockbarx/dockbar.py b/dockbarx/dockbar.py index 134f510..f487cc8 100644 --- a/dockbarx/dockbar.py +++ b/dockbarx/dockbar.py @@ -27,6 +27,7 @@ from gi.repository import GLib import sys import os +import shutil import dbus from . import cairowidgets import weakref @@ -993,6 +994,12 @@ def group_unpinned(self, identifier): desktop_entry = self.__get_desktop_entry_for_id(app.get_id()) group.set_desktop_entry(desktop_entry) group.update_name() + custom_launcher = os.path.join(get_app_homedir(), "launchers", "%s.desktop"%identifier) + if os.path.isfile(custom_launcher): + try: + os.remove(custom_launcher) + except: + pass def __make_groupbutton(self, identifier=None, desktop_entry=None, pinned=False, index=None, window=None): @@ -1498,16 +1505,20 @@ def edit_launcher(self, path, identifier): logger.warning("Error: file %s doesn't exist."%path) new_path = os.path.join(launcher_dir, os.path.basename(path)) if new_path != path: - os.system("cp %s %s"%(path, new_path)) + shutil.copy(path, new_path) else: new_path = os.path.join(launcher_dir, "%s.desktop"%identifier) + try: + mtime = os.path.getmtime(new_path) + except OSError: + mtime = None programs = ("gnome-desktop-item-edit", "mate-desktop-item-edit", "exo-desktop-item-edit") for program in programs: if check_program(program): process = subprocess.Popen([program, new_path], env=os.environ) GLib.timeout_add(100, self.__wait_for_launcher_editor, - process, path, new_path, identifier) + process, path, new_path, mtime, identifier) break else: editor = DesktopFileEditor() @@ -1516,7 +1527,7 @@ def edit_launcher(self, path, identifier): action = editor.run() if action == Gtk.ResponseType.OK: editor.save(new_path) - self.__wait_for_launcher_editor(None, path, new_path, identifier) + self.__wait_for_launcher_editor(None, path, new_path, mtime, identifier) editor.destroy() def update_pinned_apps_list(self, arg=None): @@ -1688,10 +1699,18 @@ def __identifier_dialog(self, identifier=None): return text def __wait_for_launcher_editor(self, process, - old_path, new_path, identifier): + old_path, new_path, mtime, identifier): if process is None or process.poll() != None: # Launcher editor closed. if os.path.isfile(new_path): + try: + if os.path.getmtime(new_path) == mtime: + # No modifications + if old_path != new_path: + os.remove(new_path) + return + except: + return # Update desktop_entry. desktop_entry = DesktopEntry(new_path) if identifier: From ecfe511bfa74cc3f5d92448106805dbe8c90efea Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 21 Nov 2023 20:34:18 +0800 Subject: [PATCH 06/24] Fix compatibility with python 3.12 --- README.md | 2 +- dockbarx/applets.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab910d4..e9ae2d2 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ https://aur.archlinux.org/packages/xfce4-dockbarx-plugin/ ## Manual Installation 1. Following dependencies needs to be installed (many of them might be installed already on your system): - - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib. + - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.4), python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib. - (Optional) gir1.2-zeitgeist-2.0 and zeitgeist, to access latest and most used documents. - (Optional) indicator-application or ayatana-indicator-application, to use the appindicator applet with DockX - (Optional) python3-pyudev (>= 0.15), to use the battery status applet with DockX diff --git a/dockbarx/applets.py b/dockbarx/applets.py index 881a35a..9fba5e2 100644 --- a/dockbarx/applets.py +++ b/dockbarx/applets.py @@ -22,7 +22,7 @@ from gi.repository import Gtk from gi.repository import Gdk import os -import imp +import importlib.util import dbus import weakref from gi.repository import GObject @@ -213,7 +213,9 @@ def get(self, name): iname, ext = os.path.splitext(os.path.split(e)[-1]) path = os.path.join(self.applets[name]["dir"], e) try: - applet = imp.load_source(iname, path) + spec = importlib.util.spec_from_file_location(iname, path) + applet = importlib.util.module_from_spec(spec) + spec.loader.exec_module(applet) except: message = "Error: Could not load applet from %s. " % path message += "Could not import the script." From 882310d69a845b2c312337ace4a34d07da4161df Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 21 Nov 2023 20:43:17 +0800 Subject: [PATCH 07/24] Fix python3 requirement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9ae2d2..86f506c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ https://aur.archlinux.org/packages/xfce4-dockbarx-plugin/ ## Manual Installation 1. Following dependencies needs to be installed (many of them might be installed already on your system): - - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.4), python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib. + - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.5), python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib. - (Optional) gir1.2-zeitgeist-2.0 and zeitgeist, to access latest and most used documents. - (Optional) indicator-application or ayatana-indicator-application, to use the appindicator applet with DockX - (Optional) python3-pyudev (>= 0.15), to use the battery status applet with DockX From 7c78e611452e744e2172e22aa2dc4ec307aff84f Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Sat, 2 Dec 2023 22:21:28 +0800 Subject: [PATCH 08/24] Use setuptools instead of distutils --- README.md | 9 +++++++-- pyproject.toml | 3 +++ setup.py | 42 ++++++++++++------------------------------ 3 files changed, 22 insertions(+), 32 deletions(-) create mode 100644 pyproject.toml diff --git a/README.md b/README.md index 86f506c..d9d7903 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,17 @@ https://aur.archlinux.org/packages/xfce4-dockbarx-plugin/ ## Manual Installation 1. Following dependencies needs to be installed (many of them might be installed already on your system): - - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.5), python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib. + - gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.5), python3-cairo (>= 1.11.0), python3-dbus, python3-gi, python3-gi-cairo, python3-pil, python3-xdg and python3-xlib. + - (Only for build) python3-pip, python3-polib, python3-setuptools - (Optional) gir1.2-zeitgeist-2.0 and zeitgeist, to access latest and most used documents. - (Optional) indicator-application or ayatana-indicator-application, to use the appindicator applet with DockX - (Optional) python3-pyudev (>= 0.15), to use the battery status applet with DockX - (Optional) python3-lxml, to use the settings migrating tool -2. Extract dockbarx. Change directory to where you extracted dockbarx and run the setup.py install `$ sudo ./setup.py install` +2. Extract dockbarx. Change directory to where you extracted dockbarx and run the following commands: +``` +sudo pip install --prefix=/usr . +sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ +``` ## Usage To run DockbarX as a stand alone dock use the command `dockx`. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0b3061d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "polib"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index bc9ae03..a2e6ece 100755 --- a/setup.py +++ b/setup.py @@ -17,20 +17,18 @@ # You should have received a copy of the GNU General Public License # along with dockbar. If not, see . -from distutils.core import setup -from distutils.core import setup -from distutils import cmd -from distutils.command.install_data import install_data as _install_data -from distutils.command.build import build as _build +from setuptools import setup +from setuptools import Command +from setuptools.command.install import install as _install +from setuptools.command.build import build as _build import polib import os import sys -import stat VERSION = "1.0-beta3" -class build_trans(cmd.Command): +class build_trans(Command): description = "Compile .po files into .mo files" def initialize_options(self): pass @@ -70,7 +68,7 @@ class build(_build): def run(self): _build.run(self) -class install_data(_install_data): +class install(_install): def run(self): for lang in os.listdir("build/locale/"): @@ -85,14 +83,14 @@ def run(self): lang_files.append(d_file) if os.path.exists(dt_file): lang_files.append(dt_file) - self.data_files.append( (lang_dir, lang_files) ) + self.distribution.data_files.append( (lang_dir, lang_files) ) # Scan folders for the right files - self.scan_path("/usr/share/dockbarx/themes", "themes", ext=".tar.gz") + self.scan_path("share/dockbarx/themes", "themes", ext=".tar.gz") self.scan_path("share/icons/", "icons", ext=".png") self.scan_path("share/dockbarx/applets/namebar_themes", "dockx_applets/namebar_themes", ext=".tar.gz") - _install_data.run(self) + _install.run(self) def scan_path(self, install_path, base_path, path="", ext=""): files = [] @@ -104,13 +102,13 @@ def scan_path(self, install_path, base_path, path="", ext=""): elif os.path.isfile(fpath) and fpath.endswith(ext): files.append(fpath) if files: - self.data_files.append((os.path.join(install_path, path), files)) + self.distribution.data_files.append((os.path.join(install_path, path), files)) cmdclass = { "build": build, "build_trans": build_trans, - "install_data": install_data, + "install": install, } data_files=[ @@ -142,7 +140,7 @@ def scan_path(self, install_path, base_path, path="", ext=""): ("share/mate-panel/ui/", ["mate_panel_applet/dockbarx-applet-menu.xml"]), ] -s = setup(name="Dockbarx", +setup(name="Dockbarx", version=VERSION, description="A dock-ish gnome-applet", author="Aleksey Shaferov and Matias Sars", @@ -153,19 +151,3 @@ def scan_path(self, install_path, base_path, path="", ext=""): ) - -if len(sys.argv) == 2 and sys.argv[1] == "install": - install_data_path = s.command_obj['install'].install_data - schema_path = os.path.join(install_data_path, "share/glib-2.0/schemas") - os.system("glib-compile-schemas %s" % schema_path) - # create sudo policy file for battery_status_helper.sh - helper_file = os.path.join(install_data_path, 'share/dockbarx/applets/battery_status_helper.sh') - sudo_policy_file = '/etc/sudoers.d/dockbarx-applet-battery-status-helper' - try: - f = open(sudo_policy_file, 'w') - f.write('ALL ALL=(root) NOPASSWD:%s\n' % helper_file) - f.close() - os.chmod(sudo_policy_file, stat.S_IRUSR | stat.S_IRGRP) - except: - pass - From cf8b636a33e2366e18bb6844ca4d5333111e17a1 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Mon, 4 Dec 2023 10:04:22 +0800 Subject: [PATCH 09/24] Fix install path --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a2e6ece..11bcdd0 100755 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ class install(_install): def run(self): for lang in os.listdir("build/locale/"): - lang_dir = os.path.join("/", "usr", "share", + lang_dir = os.path.join("share", "locale", lang, "LC_MESSAGES") lang_files = [] d_file = os.path.join("build", "locale", lang, From 320c3dfccafa96292e1a7e1a86c93c0df425735e Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Mon, 4 Dec 2023 16:13:19 +0800 Subject: [PATCH 10/24] Fix compatibility with old version of setuptools and pip --- README.md | 4 ++-- dockbarx/i18n.py | 58 ++++++++++++++++++++++++++---------------------- setup.py | 21 +++++------------- 3 files changed, 38 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index d9d7903..e057487 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ https://aur.archlinux.org/packages/xfce4-dockbarx-plugin/ - (Optional) python3-lxml, to use the settings migrating tool 2. Extract dockbarx. Change directory to where you extracted dockbarx and run the following commands: ``` -sudo pip install --prefix=/usr . -sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ +sudo pip install . +sudo glib-compile-schemas /usr/local/share/glib-2.0/schemas/ ``` ## Usage diff --git a/dockbarx/i18n.py b/dockbarx/i18n.py index 27168e9..2fc73fb 100644 --- a/dockbarx/i18n.py +++ b/dockbarx/i18n.py @@ -1,37 +1,41 @@ #!/usr/bin/python3 -import os, sys +import os +import sysconfig import locale import gettext - - -APP_NAME = "dockbarx" - - -APP_DIR = os.path.join (sys.prefix, - "share") -LOCALE_DIR = os.path.join(APP_DIR, "locale") - -mo_location = LOCALE_DIR - - -gettext.install (True) - -gettext.bindtextdomain (APP_NAME, - mo_location) -gettext.textdomain (APP_NAME) -language = gettext.translation (APP_NAME, - mo_location, - fallback = True) - - +APP_DOMAIN = "dockbarx" +THEME_DOMAIN = "dockbarx-themes" + +def find_mo_location(domain): + def_data_dirs = ( "/usr/local/share", "/usr/share" ) + data_dirs = os.environ.get("XDG_DATA_DIRS", "") + if not data_dirs: + home = os.environ.get("XDG_DATA_HOME", os.path.expanduser('~')) + data_dirs = os.path.join(home, ".local", "share") + data_dirs = data_dirs.split(":") + for d in def_data_dirs: + if d not in data_dirs: + data_dirs.append(d) + for d in data_dirs: + locale_dir = os.path.join(d, "locale") + if gettext.find(domain, locale_dir): + return locale_dir + return os.path.join(sysconfig.get_path("data"), "share") + + +gettext.install(True) + +app_mo_location = find_mo_location(APP_DOMAIN) +gettext.bindtextdomain(APP_DOMAIN, app_mo_location) +gettext.textdomain(APP_DOMAIN) +language = gettext.translation(APP_DOMAIN, app_mo_location, fallback = True) theme = None def load_theme_translation(): global theme - gettext.bindtextdomain("dockbarx-themes", mo_location) - theme = gettext.translation("dockbarx-themes", - mo_location, - fallback = True) + theme_mo_location = find_mo_location(THEME_DOMAIN) + gettext.bindtextdomain(THEME_DOMAIN, theme_mo_location) + theme = gettext.translation(THEME_DOMAIN, theme_mo_location, fallback = True) diff --git a/setup.py b/setup.py index 11bcdd0..5cca3e5 100755 --- a/setup.py +++ b/setup.py @@ -18,9 +18,8 @@ # along with dockbar. If not, see . from setuptools import setup -from setuptools import Command from setuptools.command.install import install as _install -from setuptools.command.build import build as _build +from setuptools.command.build_py import build_py as _build_py import polib import os @@ -28,15 +27,10 @@ VERSION = "1.0-beta3" -class build_trans(Command): - description = "Compile .po files into .mo files" - def initialize_options(self): - pass +class build_py(_build_py): - def finalize_options(self): - pass - - def run(self): + def build_package_data(self): + _build_py.build_package_data(self) po_dict = { "dockbarx": os.path.join(os.path.dirname(os.curdir), "po"), "dockbarx-themes": os.path.join(os.path.dirname(os.curdir), "po-themes") @@ -63,10 +57,6 @@ def run(self): po = polib.pofile(src); po.save_as_mofile(dest) -class build(_build): - sub_commands = _build.sub_commands + [("build_trans", None)] - def run(self): - _build.run(self) class install(_install): @@ -106,8 +96,7 @@ def scan_path(self, install_path, base_path, path="", ext=""): cmdclass = { - "build": build, - "build_trans": build_trans, + "build_py": build_py, "install": install, } From 6c3abc007923f5e6699d2b954ede918834c25b6d Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 01:27:07 +0800 Subject: [PATCH 11/24] Move mate panel applet into a separate repository --- README.md | 4 +- mate_panel_applet/dockbarx-applet-menu.xml | 4 - mate_panel_applet/dockbarx_mate_applet | 140 ------------------ .../org.mate.panel.DockbarX.mate-panel-applet | 14 -- ...panel.applet.DockbarXAppletFactory.service | 3 - setup.py | 4 - 6 files changed, 1 insertion(+), 168 deletions(-) delete mode 100644 mate_panel_applet/dockbarx-applet-menu.xml delete mode 100755 mate_panel_applet/dockbarx_mate_applet delete mode 100644 mate_panel_applet/org.mate.panel.DockbarX.mate-panel-applet delete mode 100644 mate_panel_applet/org.mate.panel.applet.DockbarXAppletFactory.service diff --git a/README.md b/README.md index e057487..e6e636a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### Version 1.0-beta3 ## About DockbarX -The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a Xfce4 panel applet[^1] or a matepanel applet. DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. +The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a [Xfce4 panel applet](https://github.com/xuzhen/xfce4-dockbarx-plugin) or a [MATE panel applet](https://github.com/xuzhen/dockbarx-mate-applet). DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. DockbarX is free software and is licensed under GPL3. @@ -123,5 +123,3 @@ A: Backup: ```dconf dump /org/dockbarx/ > dockbarx.xml```\ A: Dump the preferences from GConf database ```gconftool --dump /apps/dockbarx > dockbarx.xml```, run the migrating tool ```dbx_migrate_settings dockbarx.xml```, and move the application folder from ~/.dockbarx to ~/.local/share/dockbarx -[^1]: Using [xfce-dockbarx-plugin] (https://github.com/M7S/xfce4-dockbarx-plugin/tree/pygi-python3) - diff --git a/mate_panel_applet/dockbarx-applet-menu.xml b/mate_panel_applet/dockbarx-applet-menu.xml deleted file mode 100644 index 12f10c1..0000000 --- a/mate_panel_applet/dockbarx-applet-menu.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/mate_panel_applet/dockbarx_mate_applet b/mate_panel_applet/dockbarx_mate_applet deleted file mode 100755 index 72d973f..0000000 --- a/mate_panel_applet/dockbarx_mate_applet +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/python3 - -# dockbarx_mate_applet -# -# Copyright 2008, 2009, 2010 Aleksey Shaferov and Matias Sars -# Copyright 2017 Alexey Hohlov -# -# DockbarX is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# DockbarX is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with dockbar. If not, see . - -import gi -gi.require_version("Gtk", "3.0") -gi.require_version('MatePanelApplet', '4.0') -from gi.repository import Gtk, GLib -from gi.repository import MatePanelApplet - -try: - import sys - import dockbarx.dockbar - from dockbarx.log import * -except Exception as e: - print(e) - sys.exit(1) - -class DockbarMateApplet(object): - def __init__(self, applet, iid): - self.applet = applet - self.size = None - self.dockbar = dockbarx.dockbar.DockBar(self) - applet.set_flags(MatePanelApplet.AppletFlags.HAS_HANDLE | \ - MatePanelApplet.AppletFlags.EXPAND_MINOR | \ - MatePanelApplet.AppletFlags.EXPAND_MAJOR) - orients = {MatePanelApplet.AppletOrient.DOWN: "down", - MatePanelApplet.AppletOrient.UP: "up", - MatePanelApplet.AppletOrient.LEFT: "left", - MatePanelApplet.AppletOrient.RIGHT: "right"} - self.dockbar.set_orient(orients[applet.get_orient()]) - menu_actions = [("About", Gtk.STOCK_ABOUT, _("About"), None, None, self.dockbar.on_ppm_about), - ("Pref", Gtk.STOCK_PREFERENCES, _("Preferences"), None, None, self.dockbar.on_ppm_pref), - ("Reload", Gtk.STOCK_REFRESH, _("Refresh"), None, None, self.dockbar.reload)] - actiongroup = Gtk.ActionGroup.new("DockBarXAppletActions") - #actiongroup.set_translation_domain(dockbarx.defs.GETTEXT_PACKAGE) - actiongroup.add_actions(menu_actions, None) - applet.setup_menu_from_file("/usr/share/mate-panel/ui/dockbarx-applet-menu.xml", actiongroup) - - # Set the applet coordinates to be way ofscreen until they've - # been set correctly by a size allocate call. - self.applet_origin_x = -1000 - self.applet_origin_y = -1000 - applet.connect("delete-event", self.__cleanup) - applet.show_all() - - # Most of initializion must happen after dockbarx is - # realized since python mateapplets crash if it - # takes too long to realize. - GLib.idle_add(self.__load_on_realized) - - def __load_on_realized(self): - # Wait while gtk events are pending. - while Gtk.events_pending(): - Gtk.main_iteration() - # Load DockbarX. - self.dockbar.load() - # Add it to the applet. - self.applet.add(self.dockbar.get_container()) - self.applet.show_all() - # Connect events. - self.applet.connect("size-allocate", self.__on_applet_size_alloc) - #self.applet.connect("change_background", self.__on_change_background) - self.applet.connect("change-orient", self.__on_change_orient) - - def __on_applet_size_alloc(self, widget, allocation): - if self.applet.get_orient() in (MatePanelApplet.AppletOrient.DOWN, - MatePanelApplet.AppletOrient.UP): - size = allocation.height - else: - size = allocation.width - if self.size != size: - self.dockbar.set_size(size) - self.size = size - if not widget.get_window(): - return - #x,y = widget.get_window().get_origin() - x,y = widget.get_window().get_root_coords(0, 0) - if x == self.applet_origin_x or y == self.applet_origin_y: - # Nothing moved. - return - # Applet and/or panel moved, - # icon_geo needs to be updated. - self.applet_origin_x = x - self.applet_origin_y = y - self.dockbar.dockbar_moved() - - def __on_change_orient(self, arg1, data): - orients = {MatePanelApplet.AppletOrient.DOWN: "down", - MatePanelApplet.AppletOrient.UP: "up", - MatePanelApplet.AppletOrient.LEFT: "left", - MatePanelApplet.AppletOrient.RIGHT: "right"} - self.applet.remove(self.dockbar.get_container()) - self.dockbar.set_orient(orients[self.applet.get_orient()]) - self.applet.add(self.dockbar.get_container()) - - def __on_change_background(self, applet, type, color, pixmap): - applet.set_style(None) - rc_style = Gtk.RcStyle() - applet.modify_style(rc_style) - if type == MatePanelApplet.AppletBackgroundType.COLOR_BACKGROUND: - applet.modify_bg(Gtk.StateType.NORMAL, color) - elif type == MatePanelApplet.AppletBackgroundType.PIXMAP_BACKGROUND: - style = applet.style - style.bg_pixmap[Gtk.StateType.NORMAL] = pixmap - applet.set_style(style) - return - - def readd_container (self, container): - self.applet.add(container) - container.show_all() - - def __cleanup(self,event): - if hasattr(self.dockbar, "destroy"): - self.dockbar.destroy() - - -def applet_factory(applet, iid, data): - DockbarMateApplet(applet, iid) - return True - -MatePanelApplet.Applet.factory_main("DockbarXAppletFactory", True, - MatePanelApplet.Applet.__gtype__, - applet_factory, None) diff --git a/mate_panel_applet/org.mate.panel.DockbarX.mate-panel-applet b/mate_panel_applet/org.mate.panel.DockbarX.mate-panel-applet deleted file mode 100644 index 37b7dca..0000000 --- a/mate_panel_applet/org.mate.panel.DockbarX.mate-panel-applet +++ /dev/null @@ -1,14 +0,0 @@ -[Applet Factory] -Id=DockbarXAppletFactory -InProcess=false -Location=/usr/lib/mate-panel/dockbarx_mate_applet -Name=DockBarX Applet -Description=DockBarX Applet - -[DockbarXApplet] -Name=DockBarX Applet -Description=DockBarX Applet -Icon=dockbarx -MateComponentId=OAFIID:MATE_DockbarXApplet; - - diff --git a/mate_panel_applet/org.mate.panel.applet.DockbarXAppletFactory.service b/mate_panel_applet/org.mate.panel.applet.DockbarXAppletFactory.service deleted file mode 100644 index fe77ff1..0000000 --- a/mate_panel_applet/org.mate.panel.applet.DockbarXAppletFactory.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.mate.panel.applet.DockbarXAppletFactory -Exec=/usr/lib/mate-panel/dockbarx_mate_applet diff --git a/setup.py b/setup.py index 5cca3e5..72772eb 100755 --- a/setup.py +++ b/setup.py @@ -116,7 +116,6 @@ def scan_path(self, install_path, base_path, path="", ext=""): "dockx_applets/namebar_window_title.applet", "dockx_applets/namebar_window_title.py"]), ("bin", ["dbx_preference", "dbx_migrate_settings", "dockx"]), - ("lib/mate-panel/", ["mate_panel_applet/dockbarx_mate_applet"]), ("share/applications/", ["dbx_preference.desktop"]), ("share/applications/", ["DockX.desktop"]), ("share/glib-2.0/schemas/", ["org.dockbar.dockbarx.gschema.xml", @@ -124,9 +123,6 @@ def scan_path(self, install_path, base_path, path="", ext=""): "dockx_applets/org.dockbar.applets.hello-world.gschema.xml", "dockx_applets/org.dockbar.applets.batterystatus.gschema.xml", "dockx_applets/org.dockbar.applets.namebar.gschema.xml"]), - ("share/dbus-1/services/", ["mate_panel_applet/org.mate.panel.applet.DockbarXAppletFactory.service"]), - ("share/mate-panel/applets/", ["mate_panel_applet/org.mate.panel.DockbarX.mate-panel-applet"]), - ("share/mate-panel/ui/", ["mate_panel_applet/dockbarx-applet-menu.xml"]), ] setup(name="Dockbarx", From ca494ff9faa504fbefa6c2f06cb7b90a4125b2e2 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 13:57:56 +0800 Subject: [PATCH 12/24] Fix directories --- dbx_preference | 14 +++------ dockbarx/applets.py | 18 +++++------ dockbarx/common.py | 29 ------------------ dockbarx/dirutils.py | 68 +++++++++++++++++++++++++++++++++++++++++ dockbarx/dockbar.py | 13 +++----- dockbarx/i18n.py | 11 ++----- dockbarx/iconfactory.py | 10 ++---- dockbarx/log.py | 33 ++------------------ dockbarx/theme.py | 57 ++++++++++------------------------ 9 files changed, 109 insertions(+), 144 deletions(-) create mode 100644 dockbarx/dirutils.py diff --git a/dbx_preference b/dbx_preference index 2577b35..a82f966 100755 --- a/dbx_preference +++ b/dbx_preference @@ -32,6 +32,7 @@ import signal from dockbarx.common import * from dockbarx.applets import DockXApplets from dockbarx.theme import PopupStyle, DockTheme +from dockbarx.dirutils import get_app_dirs import dockbarx.i18n _ = dockbarx.i18n.language.gettext @@ -1498,18 +1499,13 @@ class PrefDialog(): self.globals.update_colors(None) def __find_themes(self): - # Reads the themes from $XDG_DATA_DIRS/dockbarx/themes and - # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes + # Reads the themes from APP_DIRS/themes # and returns a dict of the theme names and paths so # that a theme can be loaded. themes = {} theme_paths = [] - theme_folder = os.path.join(get_app_homedir(), "themes") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes") for d in data_dirs] - dirs.append(theme_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): @@ -1526,7 +1522,7 @@ class PrefDialog(): name = str(name) themes[name] = theme_path if not themes: - message = _("No working themes found in /usr/share/dockbarx/themes or ~/.local/share/dockbarx/themes") + message = _("No working themes found in any of these locations:\n\n%s") % "\n".join(dirs) flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT md = Gtk.MessageDialog(self.dialog, flags, diff --git a/dockbarx/applets.py b/dockbarx/applets.py index 9fba5e2..b39b8d7 100644 --- a/dockbarx/applets.py +++ b/dockbarx/applets.py @@ -30,7 +30,8 @@ from gi.repository import GLib from dbus.mainloop.glib import DBusGMainLoop from .log import logger -from .common import get_app_homedir, Globals +from .common import Globals +from .dirutils import get_app_dirs from . import i18n _ = i18n.language.gettext @@ -128,15 +129,13 @@ def __init__(self): self.globals = Globals() def find_applets(self): - # Reads the applets from /usr/share/dockbarx/applets and - # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/applets + # Reads the applets from DATA_DIRS/dockbarx/applets # and returns a dict of the applets file names and paths so that a # applet can be loaded. self.applets = {} - home_folder = os.path.expanduser("~") - applets_folder = os.path.join(get_app_homedir(), "applets") - dirs = ["/usr/share/dockbarx/applets", applets_folder] - for dir in dirs: + app_dirs = get_app_dirs() + applets_dirs = [ os.path.join(d, "applets") for d in app_dirs ] + for dir in applets_dirs: if not(os.path.exists(dir) and os.path.isdir(dir)): continue for f in os.listdir(dir): @@ -149,8 +148,9 @@ def find_applets(self): logger.debug("Error: Did not load applet from %s: %s" % (path, err)) continue name = applet["name"] - applet["dir"] = dir - self.applets[name] = applet + if name not in self.applets: + applet["dir"] = dir + self.applets[name] = applet def read_applet_file(self, path): try: diff --git a/dockbarx/common.py b/dockbarx/common.py index b0caf73..b757cf0 100644 --- a/dockbarx/common.py +++ b/dockbarx/common.py @@ -97,35 +97,6 @@ def check_program(name): prog = os.path.join(dir, name) if os.path.exists(prog): return prog -appdir = None -def get_app_homedir(): - global appdir - if appdir is not None: - return appdir - homedir = os.environ['HOME'] - default = os.path.join(homedir, '.local', 'share') - appdir = os.path.join( - os.getenv('XDG_DATA_HOME', default), - 'dockbarx' - ) - """ - Migration Path - From "$HOME/.dockbarx" to "${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx" - """ - old_appdir = os.path.join(homedir, '.dockbarx') - if os.path.exists(old_appdir) and os.path.isdir(old_appdir): - try: - os.rename(old_appdir, appdir) - except OSError: - sys.stderr.write( - "Could not move dir '%s' to '%s'. Move the contents of '%s' to '%s' manually and then remove the first location.\n" - % (old_appdir, appdir, old_appdir, appdir) - ) - """ - End Migration Path - """ - return appdir - class Connector(): """A class to simplify disconnecting of signals""" diff --git a/dockbarx/dirutils.py b/dockbarx/dirutils.py new file mode 100644 index 0000000..42ab2ae --- /dev/null +++ b/dockbarx/dirutils.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +# dirutils.py +# +# Copyright 2023 Xu Zhen +# +# DockBar is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# DockBar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with dockbar. If not, see . + +import os +import sys +from collections import OrderedDict + +appdir = None +def get_app_homedir(): + global appdir + if appdir is not None: + return appdir + homedir = os.environ.get("XDG_DATA_HOME", os.environ.get("HOME", os.path.expanduser('~'))) + appdir = os.path.join(homedir, '.local', 'share', "dockbarx") + """ + Migration Path + From "$HOME/.dockbarx" to "${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx" + """ + old_appdir = os.path.join(homedir, '.dockbarx') + if os.path.exists(old_appdir) and os.path.isdir(old_appdir): + try: + os.rename(old_appdir, appdir) + except OSError: + sys.stderr.write( + "Could not move dir '%s' to '%s'. Move the contents of '%s' to '%s' manually and then remove the first location.\n" + % (old_appdir, appdir, old_appdir, appdir) + ) + """ + End Migration Path + """ + return appdir + +def get_app_dirs(): + data_dirs = get_data_dirs() + app_dirs = [ os.path.join(d, "dockbarx") for d in data_dirs ] + return app_dirs + +def get_data_dirs(user_first=True): + data_dirs = [] + home_dir = os.environ.get("XDG_DATA_HOME", os.environ.get("HOME", os.path.expanduser('~'))) + user_dir = os.path.join(home_dir, ".local", "share") + if user_first: + data_dirs.append(user_dir) + env = os.environ.get("XDG_DATA_DIRS") + if env: + data_dirs.extend(env.split(":")) + if not user_first: + data_dirs.append(user_dir) + data_dirs.extend( ( "/usr/local/share", "/usr/share" ) ) + # dict.fromkeys can be used instead for python 3.7+ + return list(OrderedDict.fromkeys(data_dirs)) + diff --git a/dockbarx/dockbar.py b/dockbarx/dockbar.py index f487cc8..16ff87a 100644 --- a/dockbarx/dockbar.py +++ b/dockbarx/dockbar.py @@ -37,6 +37,7 @@ from .common import * +from .dirutils import get_app_homedir, get_data_dirs from .log import logger from .key_listener import KeyListener @@ -1624,15 +1625,9 @@ def __remove_desktop_entry_id_from_list(self, id): break def __get_desktop_entry_for_id(self, id): - # Search for the desktop id first in ~/.local/share/applications - # and then in XDG_DATA_DIRS/applications - user_folder = os.environ.get("XDG_DATA_HOME", - os.path.join(os.path.expanduser("~"), - ".local", "share")) - data_folders = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - folders = "%s:%s"%(user_folder, data_folders) - for folder in folders.split(":"): + # Search for the desktop id in DATA_DIRS/applications + folders = get_data_dirs() + for folder in folders: dirname = os.path.join(folder, "applications") basename = id run = True diff --git a/dockbarx/i18n.py b/dockbarx/i18n.py index 2fc73fb..deb57d2 100644 --- a/dockbarx/i18n.py +++ b/dockbarx/i18n.py @@ -4,20 +4,13 @@ import sysconfig import locale import gettext +from .dirutils import get_data_dirs APP_DOMAIN = "dockbarx" THEME_DOMAIN = "dockbarx-themes" def find_mo_location(domain): - def_data_dirs = ( "/usr/local/share", "/usr/share" ) - data_dirs = os.environ.get("XDG_DATA_DIRS", "") - if not data_dirs: - home = os.environ.get("XDG_DATA_HOME", os.path.expanduser('~')) - data_dirs = os.path.join(home, ".local", "share") - data_dirs = data_dirs.split(":") - for d in def_data_dirs: - if d not in data_dirs: - data_dirs.append(d) + data_dirs = get_data_dirs() for d in data_dirs: locale_dir = os.path.join(d, "locale") if gettext.find(domain, locale_dir): diff --git a/dockbarx/iconfactory.py b/dockbarx/iconfactory.py index 324d0ad..f1cc7d9 100644 --- a/dockbarx/iconfactory.py +++ b/dockbarx/iconfactory.py @@ -34,6 +34,7 @@ from .theme import Theme from .common import Globals +from .dirutils import get_data_dirs from .log import logger from . import i18n @@ -584,13 +585,8 @@ def __icon_from_file_name(self, icon_name, icon_size = -1): return None def __icon_search_in_data_path(self, icon_name, icon_size): - data_folders = os.environ.get("XDG_DATA_HOME", - os.path.join(os.path.expanduser("~"), - ".local/share")) - data_folders += ":" + os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - - for data_folder in data_folders.split(":"): + data_folders = get_data_dirs() + for data_folder in data_folders: if data_folder == "": continue paths = (os.path.join(data_folder, "pixmaps", icon_name), diff --git a/dockbarx/log.py b/dockbarx/log.py index 20e59b0..360f82e 100644 --- a/dockbarx/log.py +++ b/dockbarx/log.py @@ -21,6 +21,7 @@ import logging.handlers import os import sys +from .dirutils import get_app_homedir # To avoid infinite recursion in some cases, e.g. out of disk space logging.raiseExceptions = False @@ -28,37 +29,7 @@ logging.basicConfig(format="%(message)s", level=logging.DEBUG) logger = logging.getLogger("DockbarX") file_handler = None - -appdir = None -def get_app_homedir(): - global appdir - if appdir is not None: - return appdir - homedir = os.environ['HOME'] - default = os.path.join(homedir, '.local', 'share') - appdir = os.path.join( - os.getenv('XDG_DATA_HOME', default), - 'dockbarx' - ) - """ - Migration Path - From "$HOME/.dockbarx" to "${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx" - """ - old_appdir = os.path.join(homedir, '.dockbarx') - if os.path.exists(old_appdir) and os.path.isdir(old_appdir): - try: - os.rename(old_appdir, appdir) - except OSError: - sys.stderr.write( - "Could not move dir '%s' to '%s'. Move the contents of '%s' to '%s' manually and then remove the first location.\n" - % (old_appdir, appdir, old_appdir, appdir) - ) - """ - End Migration Path - """ - return appdir - - + def log_to_file(): log_dir = os.path.join(get_app_homedir(), "log") if not os.path.exists(log_dir): diff --git a/dockbarx/theme.py b/dockbarx/theme.py index af25f41..61fdeef 100644 --- a/dockbarx/theme.py +++ b/dockbarx/theme.py @@ -29,7 +29,7 @@ import array from .common import ODict from .common import Globals -from .common import get_app_homedir +from .dirutils import get_app_dirs from .log import logger from PIL import Image @@ -149,18 +149,13 @@ def on_theme_changed(self, arg=None): self.reload() def find_themes(self): - # Reads the themes from $XDG_DATA_DIRS/dockbarx/themes and - # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes + # Reads the themes from APP_DIRS/themes # and returns a dict of the theme names and paths so # that a theme can be loaded. themes = {} theme_paths = [] - theme_folder = os.path.join(get_app_homedir(), "themes") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes") for d in data_dirs] - dirs.append(theme_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): @@ -179,10 +174,10 @@ def find_themes(self): md = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, - _("No working themes found in /usr/share/dockbarx/themes or ~/.local/share/dockbarx/themes")) + _("No working themes found in any of these locations:\n\n%s") % "\n".join(dirs)) md.run() md.destroy() - raise NoThemesError("No working themes found in /usr/share/dockbarx/themes or ${XDG_DATA_HOME:-$HOME/.local/share}/.dockbarx/themes") + raise NoThemesError("No working themes found") return themes def reload(self): @@ -412,18 +407,12 @@ def get(self, key, default=None): return self.settings.get(key, default) def find_styles(self): - # Reads the styles from $XDG_DATA_DIRS/dockbarx/themes/popup_styles and - # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes/popup_styles + # Reads the styles from APP_DIRS/themes/popup_styles # and returns a dict of the style file names and paths so that a # style can be loaded styles = {} - style_paths = [] - style_folder = os.path.join(get_app_homedir(), "themes", "popup_styles") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes/popup_styles") for d in data_dirs] - dirs.append(style_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes", "popup_styles") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): @@ -533,12 +522,8 @@ def get_styles(self, theme_name=None): # For DockbarX preference. This function makes a dict of the names and # file names of the styles for all styles that can be opened correctly. styles = {} - style_folder = os.path.join(get_app_homedir(), "themes", "popup_styles") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes/popup_styles") for d in data_dirs] - dirs.append(style_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes", "popup_styles") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): @@ -627,18 +612,12 @@ def get_bg(self, bar, size=None): return self.resized_bg[bar] def find_themes(self): - # Reads the themes from $XDG_DATA_DIRS/dockbarx/themes/dock and - # ${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx/themes/dock + # Reads the themes from APP_DIRS/themes/dock # and returns a dict of the theme names and paths so # that a theme can be loaded. themes = {} - theme_paths = [] - theme_folder = os.path.join(get_app_homedir(), "themes/dock") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes/dock") for d in data_dirs] - dirs.append(theme_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes", "dock") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): @@ -754,12 +733,8 @@ def get_themes(self): # For DockbarX preference. This function makes a dict of the names and # file names of the themes for all themes that can be opened correctly. themes = {} - theme_folder = os.path.join(get_app_homedir(), "themes", "dock") - data_dirs = os.environ.get("XDG_DATA_DIRS", - "/usr/local/share/:/usr/share/") - data_dirs = data_dirs.split(":") - dirs = [os.path.join(d, "dockbarx/themes/dock") for d in data_dirs] - dirs.append(theme_folder) + app_dirs = get_app_dirs() + dirs = [os.path.join(d, "themes", "dock") for d in app_dirs] for dir in dirs: if os.path.exists(dir) and os.path.isdir(dir): for f in os.listdir(dir): From 9f780f93f4ec26e408bf29c4585ebff959d10707 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 14:08:52 +0800 Subject: [PATCH 13/24] Reorganize the directory structure --- applets/Creating applets | 3 + .../appindicator}/appindicator.applet | 0 .../appindicator}/appindicator.py | 0 .../batterystatus}/battery_status.applet | 0 .../batterystatus}/battery_status.py | 0 .../batterystatus}/battery_status_helper.sh | 0 ...dockbarx.applets.batterystatus.gschema.xml | 0 {dockx_applets => applets/clock}/clock.applet | 0 {dockx_applets => applets/clock}/clock.py | 0 .../org.dockbar.applets.clock.gschema.xml | 0 .../hello_world}/hello_world.applet | 0 .../hello_world}/hello_world.py | 0 ...rg.dockbar.applets.hello-world.gschema.xml | 0 .../namebar}/namebar_common.py | 15 +- .../namebar}/namebar_window_buttons.applet | 0 .../namebar}/namebar_window_buttons.py | 9 +- .../namebar}/namebar_window_title.applet | 0 .../namebar}/namebar_window_title.py | 7 +- .../org.dockbar.applets.namebar.gschema.xml | 0 .../namebar/themes}/Dust-ish.tar.gz | Bin .../namebar/themes}/Human-ish.tar.gz | Bin .../namebar/themes}/New Wave-ish.tar.gz | Bin DockX.desktop => data/DockX.desktop | 0 .../dbx_preference.desktop | 0 .../icons}/hicolor/128x128/apps/dockbarx.png | Bin .../icons}/hicolor/16x16/apps/dockbarx.png | Bin .../icons}/hicolor/22x22/apps/dockbarx.png | Bin .../icons}/hicolor/24x24/apps/dockbarx.png | Bin .../icons}/hicolor/36x36/apps/dockbarx.png | Bin .../icons}/hicolor/48x48/apps/dockbarx.png | Bin .../icons}/hicolor/64x64/apps/dockbarx.png | Bin .../icons}/hicolor/72x72/apps/dockbarx.png | Bin .../icons}/hicolor/96x96/apps/dockbarx.png | Bin .../org.dockbar.dockbarx.gschema.xml | 0 {po-themes => data/po-themes}/bg.po | 0 {po-themes => data/po-themes}/cs.po | 0 {po-themes => data/po-themes}/da.po | 0 {po-themes => data/po-themes}/de.po | 0 .../po-themes}/dockbarx-themes.pot | 0 {po-themes => data/po-themes}/el.po | 0 {po-themes => data/po-themes}/en_GB.po | 0 {po-themes => data/po-themes}/es.po | 0 {po-themes => data/po-themes}/eu.po | 0 {po-themes => data/po-themes}/fi.po | 0 {po-themes => data/po-themes}/fr.po | 0 {po-themes => data/po-themes}/hu.po | 0 {po-themes => data/po-themes}/it.po | 0 {po-themes => data/po-themes}/ja.po | 0 {po-themes => data/po-themes}/ko.po | 0 {po-themes => data/po-themes}/lt.po | 0 {po-themes => data/po-themes}/nl.po | 0 {po-themes => data/po-themes}/pl.po | 0 {po-themes => data/po-themes}/pt_BR.po | 0 {po-themes => data/po-themes}/ro.po | 0 {po-themes => data/po-themes}/ru.po | 0 {po-themes => data/po-themes}/sk.po | 0 {po-themes => data/po-themes}/sv.po | 0 {po-themes => data/po-themes}/th.po | 0 {po-themes => data/po-themes}/uk.po | 0 {po-themes => data/po-themes}/zh_CN.po | 0 {po-themes => data/po-themes}/zh_TW.po | 0 {po => data/po}/ar.po | 0 {po => data/po}/bg.po | 0 {po => data/po}/cs.po | 0 {po => data/po}/da.po | 0 {po => data/po}/de.po | 0 {po => data/po}/dockbarx.pot | 0 {po => data/po}/el.po | 0 {po => data/po}/en_GB.po | 0 {po => data/po}/es.po | 0 {po => data/po}/eu.po | 0 {po => data/po}/fi.po | 0 {po => data/po}/fr.po | 0 {po => data/po}/hu.po | 0 {po => data/po}/id.po | 0 {po => data/po}/it.po | 0 {po => data/po}/ja.po | 0 {po => data/po}/ko.po | 0 {po => data/po}/lt.po | 0 {po => data/po}/nl.po | 0 {po => data/po}/pl.po | 0 {po => data/po}/pt.po | 0 {po => data/po}/pt_BR.po | 0 {po => data/po}/ro.po | 0 {po => data/po}/ru.po | 0 {po => data/po}/sk.po | 0 {po => data/po}/sv.po | 0 {po => data/po}/tr.po | 0 {po => data/po}/uk.po | 0 {po => data/po}/zh_CN.po | 0 {po => data/po}/zh_TW.po | 0 {themes => data/themes}/Colors.tar.gz | Bin {themes => data/themes}/Deep.tar.gz | Bin {themes => data/themes}/Glass_DMD.tar.gz | Bin {themes => data/themes}/Magic_trans.tar.gz | Bin {themes => data/themes}/dock/Colors.tar.gz | Bin {themes => data/themes}/dock/Glass_DMD.tar.gz | Bin .../themes}/dock/Magic_trans.tar.gz | Bin {themes => data/themes}/dock/dbx.tar.gz | Bin {themes => data/themes}/dock/deep.tar.gz | Bin {themes => data/themes}/dock/folded.tar.gz | Bin .../themes}/dock/glass-dock.tar.gz | Bin {themes => data/themes}/dock/invisible.tar.gz | Bin {themes => data/themes}/dockxyz.tar.gz | Bin {themes => data/themes}/glassified.tar.gz | Bin .../themes}/popup_styles/Colors.tar.gz | Bin .../themes}/popup_styles/DMD_Glass.tar.gz | Bin .../themes}/popup_styles/Elegance.tar.gz | Bin .../themes}/popup_styles/Magic_trans.tar.gz | Bin .../themes}/popup_styles/Radiance.tar.gz | Bin .../themes}/popup_styles/dbx.tar.gz | Bin .../themes}/popup_styles/deep.tar.gz | Bin .../themes}/popup_styles/gradent.tar.gz | Bin .../themes}/popup_styles/old.tar.gz | Bin .../themes}/popup_styles/square.tar.gz | Bin {themes => data/themes}/sunny-c.tar.gz | Bin dockbarx/applets.py | 34 ++--- dockx_applets/Creating applets | 3 - make_translate_template.sh | 3 - scripts/make_translate_template.sh | 3 + setup.py | 130 +++++++----------- .../dbx_migrate_settings | 0 dbx_preference => utils/dbx_preference | 0 dockx => utils/dockx | 0 124 files changed, 82 insertions(+), 125 deletions(-) create mode 100644 applets/Creating applets rename {dockx_applets => applets/appindicator}/appindicator.applet (100%) rename {dockx_applets => applets/appindicator}/appindicator.py (100%) rename {dockx_applets => applets/batterystatus}/battery_status.applet (100%) rename {dockx_applets => applets/batterystatus}/battery_status.py (100%) rename {dockx_applets => applets/batterystatus}/battery_status_helper.sh (100%) rename dockx_applets/org.dockbar.applets.batterystatus.gschema.xml => applets/batterystatus/org.dockbarx.applets.batterystatus.gschema.xml (100%) rename {dockx_applets => applets/clock}/clock.applet (100%) rename {dockx_applets => applets/clock}/clock.py (100%) rename {dockx_applets => applets/clock}/org.dockbar.applets.clock.gschema.xml (100%) rename {dockx_applets => applets/hello_world}/hello_world.applet (100%) rename {dockx_applets => applets/hello_world}/hello_world.py (100%) rename {dockx_applets => applets/hello_world}/org.dockbar.applets.hello-world.gschema.xml (100%) rename {dockx_applets => applets/namebar}/namebar_common.py (97%) rename {dockx_applets => applets/namebar}/namebar_window_buttons.applet (100%) rename {dockx_applets => applets/namebar}/namebar_window_buttons.py (98%) rename {dockx_applets => applets/namebar}/namebar_window_title.applet (100%) rename {dockx_applets => applets/namebar}/namebar_window_title.py (98%) rename {dockx_applets => applets/namebar}/org.dockbar.applets.namebar.gschema.xml (100%) rename {dockx_applets/namebar_themes => applets/namebar/themes}/Dust-ish.tar.gz (100%) rename {dockx_applets/namebar_themes => applets/namebar/themes}/Human-ish.tar.gz (100%) rename {dockx_applets/namebar_themes => applets/namebar/themes}/New Wave-ish.tar.gz (100%) rename DockX.desktop => data/DockX.desktop (100%) rename dbx_preference.desktop => data/dbx_preference.desktop (100%) rename {icons => data/icons}/hicolor/128x128/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/16x16/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/22x22/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/24x24/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/36x36/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/48x48/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/64x64/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/72x72/apps/dockbarx.png (100%) rename {icons => data/icons}/hicolor/96x96/apps/dockbarx.png (100%) rename org.dockbar.dockbarx.gschema.xml => data/org.dockbar.dockbarx.gschema.xml (100%) rename {po-themes => data/po-themes}/bg.po (100%) rename {po-themes => data/po-themes}/cs.po (100%) rename {po-themes => data/po-themes}/da.po (100%) rename {po-themes => data/po-themes}/de.po (100%) rename {po-themes => data/po-themes}/dockbarx-themes.pot (100%) rename {po-themes => data/po-themes}/el.po (100%) rename {po-themes => data/po-themes}/en_GB.po (100%) rename {po-themes => data/po-themes}/es.po (100%) rename {po-themes => data/po-themes}/eu.po (100%) rename {po-themes => data/po-themes}/fi.po (100%) rename {po-themes => data/po-themes}/fr.po (100%) rename {po-themes => data/po-themes}/hu.po (100%) rename {po-themes => data/po-themes}/it.po (100%) rename {po-themes => data/po-themes}/ja.po (100%) rename {po-themes => data/po-themes}/ko.po (100%) rename {po-themes => data/po-themes}/lt.po (100%) rename {po-themes => data/po-themes}/nl.po (100%) rename {po-themes => data/po-themes}/pl.po (100%) rename {po-themes => data/po-themes}/pt_BR.po (100%) rename {po-themes => data/po-themes}/ro.po (100%) rename {po-themes => data/po-themes}/ru.po (100%) rename {po-themes => data/po-themes}/sk.po (100%) rename {po-themes => data/po-themes}/sv.po (100%) rename {po-themes => data/po-themes}/th.po (100%) rename {po-themes => data/po-themes}/uk.po (100%) rename {po-themes => data/po-themes}/zh_CN.po (100%) rename {po-themes => data/po-themes}/zh_TW.po (100%) rename {po => data/po}/ar.po (100%) rename {po => data/po}/bg.po (100%) rename {po => data/po}/cs.po (100%) rename {po => data/po}/da.po (100%) rename {po => data/po}/de.po (100%) rename {po => data/po}/dockbarx.pot (100%) rename {po => data/po}/el.po (100%) rename {po => data/po}/en_GB.po (100%) rename {po => data/po}/es.po (100%) rename {po => data/po}/eu.po (100%) rename {po => data/po}/fi.po (100%) rename {po => data/po}/fr.po (100%) rename {po => data/po}/hu.po (100%) rename {po => data/po}/id.po (100%) rename {po => data/po}/it.po (100%) rename {po => data/po}/ja.po (100%) rename {po => data/po}/ko.po (100%) rename {po => data/po}/lt.po (100%) rename {po => data/po}/nl.po (100%) rename {po => data/po}/pl.po (100%) rename {po => data/po}/pt.po (100%) rename {po => data/po}/pt_BR.po (100%) rename {po => data/po}/ro.po (100%) rename {po => data/po}/ru.po (100%) rename {po => data/po}/sk.po (100%) rename {po => data/po}/sv.po (100%) rename {po => data/po}/tr.po (100%) rename {po => data/po}/uk.po (100%) rename {po => data/po}/zh_CN.po (100%) rename {po => data/po}/zh_TW.po (100%) rename {themes => data/themes}/Colors.tar.gz (100%) rename {themes => data/themes}/Deep.tar.gz (100%) rename {themes => data/themes}/Glass_DMD.tar.gz (100%) rename {themes => data/themes}/Magic_trans.tar.gz (100%) rename {themes => data/themes}/dock/Colors.tar.gz (100%) rename {themes => data/themes}/dock/Glass_DMD.tar.gz (100%) rename {themes => data/themes}/dock/Magic_trans.tar.gz (100%) rename {themes => data/themes}/dock/dbx.tar.gz (100%) rename {themes => data/themes}/dock/deep.tar.gz (100%) rename {themes => data/themes}/dock/folded.tar.gz (100%) rename {themes => data/themes}/dock/glass-dock.tar.gz (100%) rename {themes => data/themes}/dock/invisible.tar.gz (100%) rename {themes => data/themes}/dockxyz.tar.gz (100%) rename {themes => data/themes}/glassified.tar.gz (100%) rename {themes => data/themes}/popup_styles/Colors.tar.gz (100%) rename {themes => data/themes}/popup_styles/DMD_Glass.tar.gz (100%) rename {themes => data/themes}/popup_styles/Elegance.tar.gz (100%) rename {themes => data/themes}/popup_styles/Magic_trans.tar.gz (100%) rename {themes => data/themes}/popup_styles/Radiance.tar.gz (100%) rename {themes => data/themes}/popup_styles/dbx.tar.gz (100%) rename {themes => data/themes}/popup_styles/deep.tar.gz (100%) rename {themes => data/themes}/popup_styles/gradent.tar.gz (100%) rename {themes => data/themes}/popup_styles/old.tar.gz (100%) rename {themes => data/themes}/popup_styles/square.tar.gz (100%) rename {themes => data/themes}/sunny-c.tar.gz (100%) delete mode 100644 dockx_applets/Creating applets delete mode 100755 make_translate_template.sh create mode 100755 scripts/make_translate_template.sh rename dbx_migrate_settings => utils/dbx_migrate_settings (100%) rename dbx_preference => utils/dbx_preference (100%) rename dockx => utils/dockx (100%) diff --git a/applets/Creating applets b/applets/Creating applets new file mode 100644 index 0000000..b763ea0 --- /dev/null +++ b/applets/Creating applets @@ -0,0 +1,3 @@ +An applet for Dockbarx stand alone dock needs to be a text file named %name%.applet, where %name% can be whatever you want. It doesn't have to be the same as the name of the directory you specify within the file. + +See hello_world for a simple example or clock for a more complex one. diff --git a/dockx_applets/appindicator.applet b/applets/appindicator/appindicator.applet similarity index 100% rename from dockx_applets/appindicator.applet rename to applets/appindicator/appindicator.applet diff --git a/dockx_applets/appindicator.py b/applets/appindicator/appindicator.py similarity index 100% rename from dockx_applets/appindicator.py rename to applets/appindicator/appindicator.py diff --git a/dockx_applets/battery_status.applet b/applets/batterystatus/battery_status.applet similarity index 100% rename from dockx_applets/battery_status.applet rename to applets/batterystatus/battery_status.applet diff --git a/dockx_applets/battery_status.py b/applets/batterystatus/battery_status.py similarity index 100% rename from dockx_applets/battery_status.py rename to applets/batterystatus/battery_status.py diff --git a/dockx_applets/battery_status_helper.sh b/applets/batterystatus/battery_status_helper.sh similarity index 100% rename from dockx_applets/battery_status_helper.sh rename to applets/batterystatus/battery_status_helper.sh diff --git a/dockx_applets/org.dockbar.applets.batterystatus.gschema.xml b/applets/batterystatus/org.dockbarx.applets.batterystatus.gschema.xml similarity index 100% rename from dockx_applets/org.dockbar.applets.batterystatus.gschema.xml rename to applets/batterystatus/org.dockbarx.applets.batterystatus.gschema.xml diff --git a/dockx_applets/clock.applet b/applets/clock/clock.applet similarity index 100% rename from dockx_applets/clock.applet rename to applets/clock/clock.applet diff --git a/dockx_applets/clock.py b/applets/clock/clock.py similarity index 100% rename from dockx_applets/clock.py rename to applets/clock/clock.py diff --git a/dockx_applets/org.dockbar.applets.clock.gschema.xml b/applets/clock/org.dockbar.applets.clock.gschema.xml similarity index 100% rename from dockx_applets/org.dockbar.applets.clock.gschema.xml rename to applets/clock/org.dockbar.applets.clock.gschema.xml diff --git a/dockx_applets/hello_world.applet b/applets/hello_world/hello_world.applet similarity index 100% rename from dockx_applets/hello_world.applet rename to applets/hello_world/hello_world.applet diff --git a/dockx_applets/hello_world.py b/applets/hello_world/hello_world.py similarity index 100% rename from dockx_applets/hello_world.py rename to applets/hello_world/hello_world.py diff --git a/dockx_applets/org.dockbar.applets.hello-world.gschema.xml b/applets/hello_world/org.dockbar.applets.hello-world.gschema.xml similarity index 100% rename from dockx_applets/org.dockbar.applets.hello-world.gschema.xml rename to applets/hello_world/org.dockbar.applets.hello-world.gschema.xml diff --git a/dockx_applets/namebar_common.py b/applets/namebar/namebar_common.py similarity index 97% rename from dockx_applets/namebar_common.py rename to applets/namebar/namebar_common.py index 58a18cb..68077a9 100644 --- a/dockx_applets/namebar_common.py +++ b/applets/namebar/namebar_common.py @@ -37,12 +37,9 @@ def get_namebar_homedir(): global namebar_appdir if namebar_appdir is not None: return namebar_appdir - homedir = os.environ['HOME'] - default = os.path.join(homedir, '.local', 'share') - namebar_appdir = os.path.join( - os.getenv('XDG_DATA_HOME', default), - 'namebar' - ) + homedir = os.environ.get("XDG_DATA_HOME", os.environ.get("HOME", os.path.expanduser('~'))) + namebar_appdir = os.path.join(homedir, '.local', 'share', "namebar") + """ Migration Path From "$HOME/.namebar" to "${XDG_DATA_HOME:-$HOME/.local/share}/namebar" @@ -52,9 +49,7 @@ def get_namebar_homedir(): try: os.rename(old_appdir, namebar_appdir) except OSError: - sys.stderr.write('Could not move dir "%s" to "%s". \ - Move the contents of "%s" to "%s" manually \ - and then remove the first location.' + sys.stderr.write('Could not move dir "%s" to "%s". Move the contents of "%s" to "%s" manually and then remove the first location.\n' % (old_appdir, namebar_appdir, old_appdir, namebar_appdir)) """ End Migration Path @@ -453,7 +448,7 @@ def find_themes(self): # a theme can be loaded themes = {} theme_paths = [] - dirs = [os.path.join(os.path.dirname(__file__), "namebar_themes"), + dirs = [os.path.join(os.path.dirname(__file__), "themes"), os.path.join(get_namebar_homedir(), "themes")] for dir in dirs: if os.path.exists(dir): diff --git a/dockx_applets/namebar_window_buttons.applet b/applets/namebar/namebar_window_buttons.applet similarity index 100% rename from dockx_applets/namebar_window_buttons.applet rename to applets/namebar/namebar_window_buttons.applet diff --git a/dockx_applets/namebar_window_buttons.py b/applets/namebar/namebar_window_buttons.py similarity index 98% rename from dockx_applets/namebar_window_buttons.py rename to applets/namebar/namebar_window_buttons.py index 4a86493..5c3010e 100644 --- a/dockx_applets/namebar_window_buttons.py +++ b/applets/namebar/namebar_window_buttons.py @@ -29,11 +29,8 @@ import dockbarx.i18n _ = dockbarx.i18n.language.gettext -from pathlib import Path -file = Path(__file__).resolve() -parent, root = file.parent, file.parents[1] -sys.path.append(str(root)) -from applets.namebar_common import get_namebar_homedir, create_context_menu, PrefDialog, Theme +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from namebar.namebar_common import get_namebar_homedir, create_context_menu, PrefDialog, Theme try: action_minimize = Wnck.WindowType.ACTION_MINIMIZE @@ -149,7 +146,7 @@ def find_themes(self): # a theme can be loaded themes = {} theme_paths = [] - dirs = [os.path.join(os.path.dirname(__file__), "namebar_themes"), + dirs = [os.path.join(os.path.dirname(__file__), "themes"), os.path.join(get_namebar_homedir(), "themes")] for dir in dirs: if os.path.exists(dir): diff --git a/dockx_applets/namebar_window_title.applet b/applets/namebar/namebar_window_title.applet similarity index 100% rename from dockx_applets/namebar_window_title.applet rename to applets/namebar/namebar_window_title.applet diff --git a/dockx_applets/namebar_window_title.py b/applets/namebar/namebar_window_title.py similarity index 98% rename from dockx_applets/namebar_window_title.py rename to applets/namebar/namebar_window_title.py index c8580d6..6cd5530 100644 --- a/dockx_applets/namebar_window_title.py +++ b/applets/namebar/namebar_window_title.py @@ -29,11 +29,8 @@ from tarfile import open as taropen from dockbarx.applets import DockXApplet -from pathlib import Path -file = Path(__file__).resolve() -parent, root = file.parent, file.parents[1] -sys.path.append(str(root)) -from applets.namebar_common import create_context_menu, PrefDialog +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from namebar.namebar_common import create_context_menu, PrefDialog class WindowTitleApplet(DockXApplet): def __init__(self, dbx_dict): diff --git a/dockx_applets/org.dockbar.applets.namebar.gschema.xml b/applets/namebar/org.dockbar.applets.namebar.gschema.xml similarity index 100% rename from dockx_applets/org.dockbar.applets.namebar.gschema.xml rename to applets/namebar/org.dockbar.applets.namebar.gschema.xml diff --git a/dockx_applets/namebar_themes/Dust-ish.tar.gz b/applets/namebar/themes/Dust-ish.tar.gz similarity index 100% rename from dockx_applets/namebar_themes/Dust-ish.tar.gz rename to applets/namebar/themes/Dust-ish.tar.gz diff --git a/dockx_applets/namebar_themes/Human-ish.tar.gz b/applets/namebar/themes/Human-ish.tar.gz similarity index 100% rename from dockx_applets/namebar_themes/Human-ish.tar.gz rename to applets/namebar/themes/Human-ish.tar.gz diff --git a/dockx_applets/namebar_themes/New Wave-ish.tar.gz b/applets/namebar/themes/New Wave-ish.tar.gz similarity index 100% rename from dockx_applets/namebar_themes/New Wave-ish.tar.gz rename to applets/namebar/themes/New Wave-ish.tar.gz diff --git a/DockX.desktop b/data/DockX.desktop similarity index 100% rename from DockX.desktop rename to data/DockX.desktop diff --git a/dbx_preference.desktop b/data/dbx_preference.desktop similarity index 100% rename from dbx_preference.desktop rename to data/dbx_preference.desktop diff --git a/icons/hicolor/128x128/apps/dockbarx.png b/data/icons/hicolor/128x128/apps/dockbarx.png similarity index 100% rename from icons/hicolor/128x128/apps/dockbarx.png rename to data/icons/hicolor/128x128/apps/dockbarx.png diff --git a/icons/hicolor/16x16/apps/dockbarx.png b/data/icons/hicolor/16x16/apps/dockbarx.png similarity index 100% rename from icons/hicolor/16x16/apps/dockbarx.png rename to data/icons/hicolor/16x16/apps/dockbarx.png diff --git a/icons/hicolor/22x22/apps/dockbarx.png b/data/icons/hicolor/22x22/apps/dockbarx.png similarity index 100% rename from icons/hicolor/22x22/apps/dockbarx.png rename to data/icons/hicolor/22x22/apps/dockbarx.png diff --git a/icons/hicolor/24x24/apps/dockbarx.png b/data/icons/hicolor/24x24/apps/dockbarx.png similarity index 100% rename from icons/hicolor/24x24/apps/dockbarx.png rename to data/icons/hicolor/24x24/apps/dockbarx.png diff --git a/icons/hicolor/36x36/apps/dockbarx.png b/data/icons/hicolor/36x36/apps/dockbarx.png similarity index 100% rename from icons/hicolor/36x36/apps/dockbarx.png rename to data/icons/hicolor/36x36/apps/dockbarx.png diff --git a/icons/hicolor/48x48/apps/dockbarx.png b/data/icons/hicolor/48x48/apps/dockbarx.png similarity index 100% rename from icons/hicolor/48x48/apps/dockbarx.png rename to data/icons/hicolor/48x48/apps/dockbarx.png diff --git a/icons/hicolor/64x64/apps/dockbarx.png b/data/icons/hicolor/64x64/apps/dockbarx.png similarity index 100% rename from icons/hicolor/64x64/apps/dockbarx.png rename to data/icons/hicolor/64x64/apps/dockbarx.png diff --git a/icons/hicolor/72x72/apps/dockbarx.png b/data/icons/hicolor/72x72/apps/dockbarx.png similarity index 100% rename from icons/hicolor/72x72/apps/dockbarx.png rename to data/icons/hicolor/72x72/apps/dockbarx.png diff --git a/icons/hicolor/96x96/apps/dockbarx.png b/data/icons/hicolor/96x96/apps/dockbarx.png similarity index 100% rename from icons/hicolor/96x96/apps/dockbarx.png rename to data/icons/hicolor/96x96/apps/dockbarx.png diff --git a/org.dockbar.dockbarx.gschema.xml b/data/org.dockbar.dockbarx.gschema.xml similarity index 100% rename from org.dockbar.dockbarx.gschema.xml rename to data/org.dockbar.dockbarx.gschema.xml diff --git a/po-themes/bg.po b/data/po-themes/bg.po similarity index 100% rename from po-themes/bg.po rename to data/po-themes/bg.po diff --git a/po-themes/cs.po b/data/po-themes/cs.po similarity index 100% rename from po-themes/cs.po rename to data/po-themes/cs.po diff --git a/po-themes/da.po b/data/po-themes/da.po similarity index 100% rename from po-themes/da.po rename to data/po-themes/da.po diff --git a/po-themes/de.po b/data/po-themes/de.po similarity index 100% rename from po-themes/de.po rename to data/po-themes/de.po diff --git a/po-themes/dockbarx-themes.pot b/data/po-themes/dockbarx-themes.pot similarity index 100% rename from po-themes/dockbarx-themes.pot rename to data/po-themes/dockbarx-themes.pot diff --git a/po-themes/el.po b/data/po-themes/el.po similarity index 100% rename from po-themes/el.po rename to data/po-themes/el.po diff --git a/po-themes/en_GB.po b/data/po-themes/en_GB.po similarity index 100% rename from po-themes/en_GB.po rename to data/po-themes/en_GB.po diff --git a/po-themes/es.po b/data/po-themes/es.po similarity index 100% rename from po-themes/es.po rename to data/po-themes/es.po diff --git a/po-themes/eu.po b/data/po-themes/eu.po similarity index 100% rename from po-themes/eu.po rename to data/po-themes/eu.po diff --git a/po-themes/fi.po b/data/po-themes/fi.po similarity index 100% rename from po-themes/fi.po rename to data/po-themes/fi.po diff --git a/po-themes/fr.po b/data/po-themes/fr.po similarity index 100% rename from po-themes/fr.po rename to data/po-themes/fr.po diff --git a/po-themes/hu.po b/data/po-themes/hu.po similarity index 100% rename from po-themes/hu.po rename to data/po-themes/hu.po diff --git a/po-themes/it.po b/data/po-themes/it.po similarity index 100% rename from po-themes/it.po rename to data/po-themes/it.po diff --git a/po-themes/ja.po b/data/po-themes/ja.po similarity index 100% rename from po-themes/ja.po rename to data/po-themes/ja.po diff --git a/po-themes/ko.po b/data/po-themes/ko.po similarity index 100% rename from po-themes/ko.po rename to data/po-themes/ko.po diff --git a/po-themes/lt.po b/data/po-themes/lt.po similarity index 100% rename from po-themes/lt.po rename to data/po-themes/lt.po diff --git a/po-themes/nl.po b/data/po-themes/nl.po similarity index 100% rename from po-themes/nl.po rename to data/po-themes/nl.po diff --git a/po-themes/pl.po b/data/po-themes/pl.po similarity index 100% rename from po-themes/pl.po rename to data/po-themes/pl.po diff --git a/po-themes/pt_BR.po b/data/po-themes/pt_BR.po similarity index 100% rename from po-themes/pt_BR.po rename to data/po-themes/pt_BR.po diff --git a/po-themes/ro.po b/data/po-themes/ro.po similarity index 100% rename from po-themes/ro.po rename to data/po-themes/ro.po diff --git a/po-themes/ru.po b/data/po-themes/ru.po similarity index 100% rename from po-themes/ru.po rename to data/po-themes/ru.po diff --git a/po-themes/sk.po b/data/po-themes/sk.po similarity index 100% rename from po-themes/sk.po rename to data/po-themes/sk.po diff --git a/po-themes/sv.po b/data/po-themes/sv.po similarity index 100% rename from po-themes/sv.po rename to data/po-themes/sv.po diff --git a/po-themes/th.po b/data/po-themes/th.po similarity index 100% rename from po-themes/th.po rename to data/po-themes/th.po diff --git a/po-themes/uk.po b/data/po-themes/uk.po similarity index 100% rename from po-themes/uk.po rename to data/po-themes/uk.po diff --git a/po-themes/zh_CN.po b/data/po-themes/zh_CN.po similarity index 100% rename from po-themes/zh_CN.po rename to data/po-themes/zh_CN.po diff --git a/po-themes/zh_TW.po b/data/po-themes/zh_TW.po similarity index 100% rename from po-themes/zh_TW.po rename to data/po-themes/zh_TW.po diff --git a/po/ar.po b/data/po/ar.po similarity index 100% rename from po/ar.po rename to data/po/ar.po diff --git a/po/bg.po b/data/po/bg.po similarity index 100% rename from po/bg.po rename to data/po/bg.po diff --git a/po/cs.po b/data/po/cs.po similarity index 100% rename from po/cs.po rename to data/po/cs.po diff --git a/po/da.po b/data/po/da.po similarity index 100% rename from po/da.po rename to data/po/da.po diff --git a/po/de.po b/data/po/de.po similarity index 100% rename from po/de.po rename to data/po/de.po diff --git a/po/dockbarx.pot b/data/po/dockbarx.pot similarity index 100% rename from po/dockbarx.pot rename to data/po/dockbarx.pot diff --git a/po/el.po b/data/po/el.po similarity index 100% rename from po/el.po rename to data/po/el.po diff --git a/po/en_GB.po b/data/po/en_GB.po similarity index 100% rename from po/en_GB.po rename to data/po/en_GB.po diff --git a/po/es.po b/data/po/es.po similarity index 100% rename from po/es.po rename to data/po/es.po diff --git a/po/eu.po b/data/po/eu.po similarity index 100% rename from po/eu.po rename to data/po/eu.po diff --git a/po/fi.po b/data/po/fi.po similarity index 100% rename from po/fi.po rename to data/po/fi.po diff --git a/po/fr.po b/data/po/fr.po similarity index 100% rename from po/fr.po rename to data/po/fr.po diff --git a/po/hu.po b/data/po/hu.po similarity index 100% rename from po/hu.po rename to data/po/hu.po diff --git a/po/id.po b/data/po/id.po similarity index 100% rename from po/id.po rename to data/po/id.po diff --git a/po/it.po b/data/po/it.po similarity index 100% rename from po/it.po rename to data/po/it.po diff --git a/po/ja.po b/data/po/ja.po similarity index 100% rename from po/ja.po rename to data/po/ja.po diff --git a/po/ko.po b/data/po/ko.po similarity index 100% rename from po/ko.po rename to data/po/ko.po diff --git a/po/lt.po b/data/po/lt.po similarity index 100% rename from po/lt.po rename to data/po/lt.po diff --git a/po/nl.po b/data/po/nl.po similarity index 100% rename from po/nl.po rename to data/po/nl.po diff --git a/po/pl.po b/data/po/pl.po similarity index 100% rename from po/pl.po rename to data/po/pl.po diff --git a/po/pt.po b/data/po/pt.po similarity index 100% rename from po/pt.po rename to data/po/pt.po diff --git a/po/pt_BR.po b/data/po/pt_BR.po similarity index 100% rename from po/pt_BR.po rename to data/po/pt_BR.po diff --git a/po/ro.po b/data/po/ro.po similarity index 100% rename from po/ro.po rename to data/po/ro.po diff --git a/po/ru.po b/data/po/ru.po similarity index 100% rename from po/ru.po rename to data/po/ru.po diff --git a/po/sk.po b/data/po/sk.po similarity index 100% rename from po/sk.po rename to data/po/sk.po diff --git a/po/sv.po b/data/po/sv.po similarity index 100% rename from po/sv.po rename to data/po/sv.po diff --git a/po/tr.po b/data/po/tr.po similarity index 100% rename from po/tr.po rename to data/po/tr.po diff --git a/po/uk.po b/data/po/uk.po similarity index 100% rename from po/uk.po rename to data/po/uk.po diff --git a/po/zh_CN.po b/data/po/zh_CN.po similarity index 100% rename from po/zh_CN.po rename to data/po/zh_CN.po diff --git a/po/zh_TW.po b/data/po/zh_TW.po similarity index 100% rename from po/zh_TW.po rename to data/po/zh_TW.po diff --git a/themes/Colors.tar.gz b/data/themes/Colors.tar.gz similarity index 100% rename from themes/Colors.tar.gz rename to data/themes/Colors.tar.gz diff --git a/themes/Deep.tar.gz b/data/themes/Deep.tar.gz similarity index 100% rename from themes/Deep.tar.gz rename to data/themes/Deep.tar.gz diff --git a/themes/Glass_DMD.tar.gz b/data/themes/Glass_DMD.tar.gz similarity index 100% rename from themes/Glass_DMD.tar.gz rename to data/themes/Glass_DMD.tar.gz diff --git a/themes/Magic_trans.tar.gz b/data/themes/Magic_trans.tar.gz similarity index 100% rename from themes/Magic_trans.tar.gz rename to data/themes/Magic_trans.tar.gz diff --git a/themes/dock/Colors.tar.gz b/data/themes/dock/Colors.tar.gz similarity index 100% rename from themes/dock/Colors.tar.gz rename to data/themes/dock/Colors.tar.gz diff --git a/themes/dock/Glass_DMD.tar.gz b/data/themes/dock/Glass_DMD.tar.gz similarity index 100% rename from themes/dock/Glass_DMD.tar.gz rename to data/themes/dock/Glass_DMD.tar.gz diff --git a/themes/dock/Magic_trans.tar.gz b/data/themes/dock/Magic_trans.tar.gz similarity index 100% rename from themes/dock/Magic_trans.tar.gz rename to data/themes/dock/Magic_trans.tar.gz diff --git a/themes/dock/dbx.tar.gz b/data/themes/dock/dbx.tar.gz similarity index 100% rename from themes/dock/dbx.tar.gz rename to data/themes/dock/dbx.tar.gz diff --git a/themes/dock/deep.tar.gz b/data/themes/dock/deep.tar.gz similarity index 100% rename from themes/dock/deep.tar.gz rename to data/themes/dock/deep.tar.gz diff --git a/themes/dock/folded.tar.gz b/data/themes/dock/folded.tar.gz similarity index 100% rename from themes/dock/folded.tar.gz rename to data/themes/dock/folded.tar.gz diff --git a/themes/dock/glass-dock.tar.gz b/data/themes/dock/glass-dock.tar.gz similarity index 100% rename from themes/dock/glass-dock.tar.gz rename to data/themes/dock/glass-dock.tar.gz diff --git a/themes/dock/invisible.tar.gz b/data/themes/dock/invisible.tar.gz similarity index 100% rename from themes/dock/invisible.tar.gz rename to data/themes/dock/invisible.tar.gz diff --git a/themes/dockxyz.tar.gz b/data/themes/dockxyz.tar.gz similarity index 100% rename from themes/dockxyz.tar.gz rename to data/themes/dockxyz.tar.gz diff --git a/themes/glassified.tar.gz b/data/themes/glassified.tar.gz similarity index 100% rename from themes/glassified.tar.gz rename to data/themes/glassified.tar.gz diff --git a/themes/popup_styles/Colors.tar.gz b/data/themes/popup_styles/Colors.tar.gz similarity index 100% rename from themes/popup_styles/Colors.tar.gz rename to data/themes/popup_styles/Colors.tar.gz diff --git a/themes/popup_styles/DMD_Glass.tar.gz b/data/themes/popup_styles/DMD_Glass.tar.gz similarity index 100% rename from themes/popup_styles/DMD_Glass.tar.gz rename to data/themes/popup_styles/DMD_Glass.tar.gz diff --git a/themes/popup_styles/Elegance.tar.gz b/data/themes/popup_styles/Elegance.tar.gz similarity index 100% rename from themes/popup_styles/Elegance.tar.gz rename to data/themes/popup_styles/Elegance.tar.gz diff --git a/themes/popup_styles/Magic_trans.tar.gz b/data/themes/popup_styles/Magic_trans.tar.gz similarity index 100% rename from themes/popup_styles/Magic_trans.tar.gz rename to data/themes/popup_styles/Magic_trans.tar.gz diff --git a/themes/popup_styles/Radiance.tar.gz b/data/themes/popup_styles/Radiance.tar.gz similarity index 100% rename from themes/popup_styles/Radiance.tar.gz rename to data/themes/popup_styles/Radiance.tar.gz diff --git a/themes/popup_styles/dbx.tar.gz b/data/themes/popup_styles/dbx.tar.gz similarity index 100% rename from themes/popup_styles/dbx.tar.gz rename to data/themes/popup_styles/dbx.tar.gz diff --git a/themes/popup_styles/deep.tar.gz b/data/themes/popup_styles/deep.tar.gz similarity index 100% rename from themes/popup_styles/deep.tar.gz rename to data/themes/popup_styles/deep.tar.gz diff --git a/themes/popup_styles/gradent.tar.gz b/data/themes/popup_styles/gradent.tar.gz similarity index 100% rename from themes/popup_styles/gradent.tar.gz rename to data/themes/popup_styles/gradent.tar.gz diff --git a/themes/popup_styles/old.tar.gz b/data/themes/popup_styles/old.tar.gz similarity index 100% rename from themes/popup_styles/old.tar.gz rename to data/themes/popup_styles/old.tar.gz diff --git a/themes/popup_styles/square.tar.gz b/data/themes/popup_styles/square.tar.gz similarity index 100% rename from themes/popup_styles/square.tar.gz rename to data/themes/popup_styles/square.tar.gz diff --git a/themes/sunny-c.tar.gz b/data/themes/sunny-c.tar.gz similarity index 100% rename from themes/sunny-c.tar.gz rename to data/themes/sunny-c.tar.gz diff --git a/dockbarx/applets.py b/dockbarx/applets.py index b39b8d7..d6680de 100644 --- a/dockbarx/applets.py +++ b/dockbarx/applets.py @@ -135,22 +135,24 @@ def find_applets(self): self.applets = {} app_dirs = get_app_dirs() applets_dirs = [ os.path.join(d, "applets") for d in app_dirs ] - for dir in applets_dirs: - if not(os.path.exists(dir) and os.path.isdir(dir)): - continue - for f in os.listdir(dir): - name, ext = os.path.splitext(os.path.split(f)[-1]) - if not(ext.lower() == ".applet"): - continue - path = os.path.join(dir, f) - applet, err = self.read_applet_file(path) - if err is not None: - logger.debug("Error: Did not load applet from %s: %s" % (path, err)) - continue - name = applet["name"] - if name not in self.applets: - applet["dir"] = dir - self.applets[name] = applet + for d in applets_dirs: + num_sep = d.count(os.path.sep) + for root, dirs, files in os.walk(d): + for f in files: + name, ext = os.path.splitext(os.path.basename(f)) + if ext.lower() != ".applet": + continue + path = os.path.join(root, f) + applet, err = self.read_applet_file(path) + if err is not None: + logger.debug("Error: Did not load applet from %s: %s" % (path, err)) + continue + name = applet["name"] + if name not in self.applets: + applet["dir"] = root + self.applets[name] = applet + if num_sep + 1 <= root.count(os.path.sep): + del dirs[:] def read_applet_file(self, path): try: diff --git a/dockx_applets/Creating applets b/dockx_applets/Creating applets deleted file mode 100644 index 4bf358e..0000000 --- a/dockx_applets/Creating applets +++ /dev/null @@ -1,3 +0,0 @@ -An applet for Dockbarx stand alone dock needs to be a python file named dbx_applet_%name%.py, where %name% can be whatever you want. It doesn't have to be the same as the name of the applet you specify within the file. - -See dbx_applet_hello_world.py for a simple example or dbx_applet_clock.py for a more complex one. diff --git a/make_translate_template.sh b/make_translate_template.sh deleted file mode 100755 index 9e9dce3..0000000 --- a/make_translate_template.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Run this to make a dockbarx.pot template file for translation of dockbarx. -xgettext --language=Python --keyword=_ --output=po/dockbarx.pot --from-code=UTF-8 `find . -name "*.py" -not -path "./build/*"` dockx dbx_preference diff --git a/scripts/make_translate_template.sh b/scripts/make_translate_template.sh new file mode 100755 index 0000000..eed545d --- /dev/null +++ b/scripts/make_translate_template.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Run this to make a dockbarx.pot template file for translation of dockbarx. +xgettext --language=Python --keyword=_ --output="$(dirname "$0")/../data/po/dockbarx.pot" --from-code=UTF-8 `find "$(dirname "$0")/.." -name "*.py" -not -path "./build/*"` utils/* diff --git a/setup.py b/setup.py index 72772eb..969cd08 100755 --- a/setup.py +++ b/setup.py @@ -27,111 +27,77 @@ VERSION = "1.0-beta3" +dbx_files = [] + +def scan_path(file_list, dest, base_path, ext="", exclude_ext=None, fixed_dest=False): + files = [] + for f in os.listdir(base_path): + fpath = os.path.join(base_path, f) + if fpath == ".git": + continue + elif os.path.isdir(fpath): + instdir = dest if fixed_dest else os.path.join(dest, f) + scan_path(file_list, instdir, os.path.join(base_path, f), ext, exclude_ext, fixed_dest) + elif os.path.isfile(fpath) and fpath.endswith(ext) and (exclude_ext is None or not fpath.endswith(exclude_ext)): + files.append(fpath) + if files: + file_list.append( ( dest, files ) ) + +scan_path(dbx_files, "bin", "utils") +scan_path(dbx_files, "share/applications", "data", ext=".desktop") +scan_path(dbx_files, "share/dockbarx/applets", "applets", exclude_ext=".gschema.xml") +scan_path(dbx_files, "share/dockbarx/themes", "data/themes", ext=".tar.gz") +scan_path(dbx_files, "share/glib-2.0/schemas", os.curdir, ext=".gschema.xml", fixed_dest=True) +scan_path(dbx_files, "share/icons", "data/icons", ext=".png") + class build_py(_build_py): def build_package_data(self): _build_py.build_package_data(self) - po_dict = { - "dockbarx": os.path.join(os.path.dirname(os.curdir), "po"), - "dockbarx-themes": os.path.join(os.path.dirname(os.curdir), "po-themes") - } - for (mo_file, po_dir) in list(po_dict.items()): - for path, names, filenames in os.walk(po_dir): - for f in filenames: - if f.endswith(".po"): - lang = f[:len(f) - 3] - src = os.path.join(path, f) - dest_path = os.path.join("build", "locale", lang, "LC_MESSAGES") - dest = os.path.join(dest_path, "%s.mo"%mo_file) - if not os.path.exists(dest_path): - os.makedirs(dest_path) - if not os.path.exists(dest): - print("Compiling %s for %s" % (src, mo_file)) - po = polib.pofile(src); - po.save_as_mofile(dest) - else: - src_mtime = os.stat(src)[8] - dest_mtime = os.stat(dest)[8] - if src_mtime > dest_mtime: - print("Compiling %s for %s" % (src, mo_file)) - po = polib.pofile(src); - po.save_as_mofile(dest) + self.build_trans() + def build_trans(self): + po_dict = { + os.path.join(os.path.dirname(os.curdir), "data/po") : "dockbarx", + os.path.join(os.path.dirname(os.curdir), "data/po-themes") : "dockbarx-themes" + } + for path in po_dict.keys(): + for f in os.listdir(path): + if f.endswith(".po"): + lang = f[:len(f) - 3] + src = os.path.join(path, f) + domain = po_dict[path] + dest_path = os.path.join("build", "locale", lang, "LC_MESSAGES") + dest = os.path.join(dest_path, "%s.mo" % domain) + if not os.path.exists(dest_path): + os.makedirs(dest_path) + print("Compiling %s for %s" % (src, domain)) + po = polib.pofile(src); + po.save_as_mofile(dest) + scan_path(dbx_files, "share/locale", "build/locale", ext=".mo") class install(_install): def run(self): - for lang in os.listdir("build/locale/"): - lang_dir = os.path.join("share", - "locale", lang, "LC_MESSAGES") - lang_files = [] - d_file = os.path.join("build", "locale", lang, - "LC_MESSAGES", "dockbarx.mo") - dt_file = os.path.join("build", "locale", lang, - "LC_MESSAGES", "dockbarx-themes.mo") - if os.path.exists(d_file): - lang_files.append(d_file) - if os.path.exists(dt_file): - lang_files.append(dt_file) - self.distribution.data_files.append( (lang_dir, lang_files) ) - # Scan folders for the right files - self.scan_path("share/dockbarx/themes", "themes", ext=".tar.gz") - self.scan_path("share/icons/", "icons", ext=".png") - self.scan_path("share/dockbarx/applets/namebar_themes", - "dockx_applets/namebar_themes", - ext=".tar.gz") + if self.distribution.data_files is None: + self.distribution.data_files = dbx_files + else: + for d in dbx_files: + self.distribution.data_files.append(d) _install.run(self) - def scan_path(self, install_path, base_path, path="", ext=""): - files = [] - for f in os.listdir(os.path.join(base_path, path)): - fpath = os.path.join(base_path, path, f) - if os.path.isdir(fpath): - self.scan_path(install_path, base_path, - os.path.join(path, f), ext) - elif os.path.isfile(fpath) and fpath.endswith(ext): - files.append(fpath) - if files: - self.distribution.data_files.append((os.path.join(install_path, path), files)) - cmdclass = { "build_py": build_py, "install": install, } -data_files=[ - ("share/dockbarx/applets", ["dockx_applets/clock.py", - "dockx_applets/clock.applet", - "dockx_applets/appindicator.py", - "dockx_applets/appindicator.applet", - "dockx_applets/hello_world.py", - "dockx_applets/hello_world.applet", - "dockx_applets/battery_status.py", - "dockx_applets/battery_status.applet", - "dockx_applets/battery_status_helper.sh", - "dockx_applets/namebar_common.py", - "dockx_applets/namebar_window_buttons.applet", - "dockx_applets/namebar_window_buttons.py", - "dockx_applets/namebar_window_title.applet", - "dockx_applets/namebar_window_title.py"]), - ("bin", ["dbx_preference", "dbx_migrate_settings", "dockx"]), - ("share/applications/", ["dbx_preference.desktop"]), - ("share/applications/", ["DockX.desktop"]), - ("share/glib-2.0/schemas/", ["org.dockbar.dockbarx.gschema.xml", - "dockx_applets/org.dockbar.applets.clock.gschema.xml", - "dockx_applets/org.dockbar.applets.hello-world.gschema.xml", - "dockx_applets/org.dockbar.applets.batterystatus.gschema.xml", - "dockx_applets/org.dockbar.applets.namebar.gschema.xml"]), - ] - setup(name="Dockbarx", version=VERSION, description="A dock-ish gnome-applet", author="Aleksey Shaferov and Matias Sars", url="http://launchpad.net/dockbar/", packages=["dockbarx"], - data_files=data_files, cmdclass=cmdclass ) diff --git a/dbx_migrate_settings b/utils/dbx_migrate_settings similarity index 100% rename from dbx_migrate_settings rename to utils/dbx_migrate_settings diff --git a/dbx_preference b/utils/dbx_preference similarity index 100% rename from dbx_preference rename to utils/dbx_preference diff --git a/dockx b/utils/dockx similarity index 100% rename from dockx rename to utils/dockx From 70c4cbe44a7feb0bffdbddd3c608105e71383e0d Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 15:05:27 +0800 Subject: [PATCH 14/24] Disallow import all --- dockbarx/__init__.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/dockbarx/__init__.py b/dockbarx/__init__.py index 3d2cd56..ecf7241 100644 --- a/dockbarx/__init__.py +++ b/dockbarx/__init__.py @@ -1,13 +1,2 @@ #!/usr/bin/python3 -__all__ = ["dockbar", - "groupbutton", - "windowbutton", - "cairowidgets", - "icon_factory", - "theme", - "common", - "i18n", - "log", - "mediabuttons", - "zg"] From 0d01977017cfb680d3dad9eda1f0adfe3cee1832 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 17:10:52 +0800 Subject: [PATCH 15/24] Fix TypeError when running on Xwayland --- dockbarx/groupbutton.py | 22 ++++++++++++---------- dockbarx/windowbutton.py | 31 ++++++++++++++++--------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/dockbarx/groupbutton.py b/dockbarx/groupbutton.py index 366ef76..644b5bf 100644 --- a/dockbarx/groupbutton.py +++ b/dockbarx/groupbutton.py @@ -942,17 +942,18 @@ def action_select_or_minimize_group(self, widget, event, minimize=True): unminimized = False for window in minimized_windows: ignored = False + window_workspace = window.wnck.get_workspace() # Check if the window is on another workspace if not window.wnck.is_pinned() \ - and window.wnck.get_workspace() is not None \ - and window.wnck.get_workspace() != active_workspace: + and window_workspace is not None \ + and window_workspace != active_workspace: if mode == "move": - ws = screen.get_active_workspace() - window.wnck.move_to_workspace(ws) + window.wnck.move_to_workspace(active_workspace) else: # mode == "ignore" or "switch" ignored = True # Check if the window is on another viewport - if not window.wnck.is_in_viewport(active_workspace): + if active_workspace is not None \ + and not window.wnck.is_in_viewport(active_workspace): if mode == "move": wx, wy, ww, wh = window.wnck.get_geometry() window.wnck.set_geometry(0,3, @@ -983,17 +984,18 @@ def action_select_or_minimize_group(self, widget, event, minimize=True): grtop = False continue ignored = False + window_workspace = wnck_window.get_workspace() if not wnck_window.is_pinned() \ - and wnck_window.get_workspace() is not None \ - and active_workspace != wnck_window.get_workspace(): + and window_workspace is not None \ + and active_workspace != window_workspace: if mode == "move": - ws = screen.get_active_workspace() - wnck_window.move_to_workspace(ws) + wnck_window.move_to_workspace(active_workspace) moved = True else: # mode == "ignore" or "switch" ignored = True ignorelist.append(self[wnck_window]) - if not wnck_window.is_in_viewport(screen.get_active_workspace()): + if active_workspace is not None \ + and not wnck_window.is_in_viewport(active_workspace): if mode == "move": wx, wy, ww, wh = wnck_window.get_geometry() wnck_window.set_geometry(0,3,wx%screen.get_width(), diff --git a/dockbarx/windowbutton.py b/dockbarx/windowbutton.py index ea1effa..b6eb7fe 100644 --- a/dockbarx/windowbutton.py +++ b/dockbarx/windowbutton.py @@ -109,10 +109,9 @@ def set_active(self, mode): self.update_preview_later() def is_on_current_desktop(self): + ws = self.wnck.get_workspace() aws = self.screen.get_active_workspace() - if (self.wnck.get_workspace() is None or \ - self.wnck.get_workspace() == aws) and \ - self.wnck.is_in_viewport(aws): + if ws is None or aws is None or (ws == aws and self.wnck.is_in_viewport(aws)): return True else: return False @@ -251,18 +250,20 @@ def action_select_or_minimize_window(self, widget=None, t = event.time else: t = GdkX11.x11_get_server_time(Gdk.get_default_root_window()) - if self.wnck.get_workspace() is not None \ - and self.screen.get_active_workspace() != self.wnck.get_workspace(): - self.wnck.get_workspace().activate(t) - if not self.wnck.is_in_viewport(self.screen.get_active_workspace()): - win_x,win_y,win_w,win_h = self.wnck.get_geometry() - self.screen.move_viewport(win_x-(win_x%self.screen.get_width()), - win_y-(win_y%self.screen.get_height())) - # Hide popup since mouse movement won't - # be tracked during compiz move effect - # which means popup list can be left open. - group = self.group_r() - group.popup.hide() + ws = self.wnck.get_workspace() + aws = self.screen.get_active_workspace() + if ws is not None and aws is not None: + if aws != ws: + ws.activate(t) + if not self.wnck.is_in_viewport(aws): + win_x,win_y,win_w,win_h = self.wnck.get_geometry() + self.screen.move_viewport(win_x-(win_x%self.screen.get_width()), + win_y-(win_y%self.screen.get_height())) + # Hide popup since mouse movement won't + # be tracked during compiz move effect + # which means popup list can be left open. + group = self.group_r() + group.popup.hide() if self.wnck.is_minimized(): self.wnck.unminimize(t) elif self.wnck.is_active() and minimize: From 262b3bd180ad3f34bdc6280fd9315af63a990b97 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 18:13:50 +0800 Subject: [PATCH 16/24] Fix compatibility with new version of systemd --- applets/batterystatus/battery_status.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/applets/batterystatus/battery_status.py b/applets/batterystatus/battery_status.py index c130814..471f0ee 100644 --- a/applets/batterystatus/battery_status.py +++ b/applets/batterystatus/battery_status.py @@ -43,6 +43,7 @@ from gi.repository import Pango import dbus import pyudev # >= 0.15 +from xml.etree import ElementTree from dockbarx.applets import DockXApplet, DockXAppletDialog import dockbarx.i18n _ = dockbarx.i18n.language.gettext @@ -404,8 +405,11 @@ class SystemdUtils(GObject.GObject): BUS_NAME = "org.freedesktop.login1" LOGIN_PATH = "/org/freedesktop/login1" LOGIN_IFNAME = "org.freedesktop.login1.Manager" - SESSION_PATH = "/org/freedesktop/login1/session/self" + SESSION_ROOT_PATH = "/org/freedesktop/login1/session" + SESSION_PATH_NEW = "/org/freedesktop/login1/session/auto" + SESSION_PATH_OLD = "/org/freedesktop/login1/session/self" SESSION_IFNAME = "org.freedesktop.login1.Session" + INTROSPECTABLE_IFNAME = "org.freedesktop.DBus.Introspectable" __gsignals__ = { "error": (GObject.SignalFlags.RUN_FIRST, None, (str,)) @@ -425,7 +429,18 @@ def __init__(self): self.__session_iface = None try: if self.__bus is not None: - session_object = self.__bus.get_object(self.BUS_NAME, self.SESSION_PATH) + use_old_path = True + session_object = self.__bus.get_object(self.BUS_NAME, self.SESSION_ROOT_PATH) + iface = dbus.Interface(session_object, self.INTROSPECTABLE_IFNAME) + xml_string = iface.Introspect() + for child in ElementTree.fromstring(xml_string): + if child.tag != "node": + continue + child_path = "/".join((self.SESSION_ROOT_PATH, child.attrib["name"])) + if child_path == self.SESSION_PATH_NEW: + use_old_path = False + break + session_object = self.__bus.get_object(self.BUS_NAME, self.SESSION_PATH_OLD if use_old_path else self.SESSION_PATH_NEW) self.__session_iface = dbus.Interface(session_object, self.SESSION_IFNAME) except dbus.exceptions.DBusException as exception: self.emit("error", exception.__str__()) From f54e7d693f5d1d4c0169015e92ed17a8612ea53b Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Tue, 5 Dec 2023 22:23:52 +0800 Subject: [PATCH 17/24] Fix file names --- ...s.clock.gschema.xml => org.dockbarx.applets.clock.gschema.xml} | 0 ...d.gschema.xml => org.dockbarx.applets.hello-world.gschema.xml} | 0 ...mebar.gschema.xml => org.dockbarx.applets.namebar.gschema.xml} | 0 ...bar.dockbarx.gschema.xml => org.dockbarx.dockbarx.gschema.xml} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename applets/clock/{org.dockbar.applets.clock.gschema.xml => org.dockbarx.applets.clock.gschema.xml} (100%) rename applets/hello_world/{org.dockbar.applets.hello-world.gschema.xml => org.dockbarx.applets.hello-world.gschema.xml} (100%) rename applets/namebar/{org.dockbar.applets.namebar.gschema.xml => org.dockbarx.applets.namebar.gschema.xml} (100%) rename data/{org.dockbar.dockbarx.gschema.xml => org.dockbarx.dockbarx.gschema.xml} (100%) diff --git a/applets/clock/org.dockbar.applets.clock.gschema.xml b/applets/clock/org.dockbarx.applets.clock.gschema.xml similarity index 100% rename from applets/clock/org.dockbar.applets.clock.gschema.xml rename to applets/clock/org.dockbarx.applets.clock.gschema.xml diff --git a/applets/hello_world/org.dockbar.applets.hello-world.gschema.xml b/applets/hello_world/org.dockbarx.applets.hello-world.gschema.xml similarity index 100% rename from applets/hello_world/org.dockbar.applets.hello-world.gschema.xml rename to applets/hello_world/org.dockbarx.applets.hello-world.gschema.xml diff --git a/applets/namebar/org.dockbar.applets.namebar.gschema.xml b/applets/namebar/org.dockbarx.applets.namebar.gschema.xml similarity index 100% rename from applets/namebar/org.dockbar.applets.namebar.gschema.xml rename to applets/namebar/org.dockbarx.applets.namebar.gschema.xml diff --git a/data/org.dockbar.dockbarx.gschema.xml b/data/org.dockbarx.dockbarx.gschema.xml similarity index 100% rename from data/org.dockbar.dockbarx.gschema.xml rename to data/org.dockbarx.dockbarx.gschema.xml From 6b40bacf417db5430aec2ac461e29c3d3a432ec1 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Wed, 6 Dec 2023 10:46:07 +0800 Subject: [PATCH 18/24] Fix condition and description --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 969cd08..4bc5868 100755 --- a/setup.py +++ b/setup.py @@ -32,10 +32,10 @@ def scan_path(file_list, dest, base_path, ext="", exclude_ext=None, fixed_dest=False): files = [] for f in os.listdir(base_path): - fpath = os.path.join(base_path, f) - if fpath == ".git": + if f == ".git": continue - elif os.path.isdir(fpath): + fpath = os.path.join(base_path, f) + if os.path.isdir(fpath): instdir = dest if fixed_dest else os.path.join(dest, f) scan_path(file_list, instdir, os.path.join(base_path, f), ext, exclude_ext, fixed_dest) elif os.path.isfile(fpath) and fpath.endswith(ext) and (exclude_ext is None or not fpath.endswith(exclude_ext)): @@ -94,7 +94,7 @@ def run(self): setup(name="Dockbarx", version=VERSION, - description="A dock-ish gnome-applet", + description="A dock-ish applet", author="Aleksey Shaferov and Matias Sars", url="http://launchpad.net/dockbar/", packages=["dockbarx"], From 31209c2f96eeb97e8755893c7b026bec8b2d53bd Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Wed, 6 Dec 2023 15:22:07 +0800 Subject: [PATCH 19/24] Fix path --- scripts/make_translate_template.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make_translate_template.sh b/scripts/make_translate_template.sh index eed545d..4ec1e11 100755 --- a/scripts/make_translate_template.sh +++ b/scripts/make_translate_template.sh @@ -1,3 +1,3 @@ #!/bin/sh # Run this to make a dockbarx.pot template file for translation of dockbarx. -xgettext --language=Python --keyword=_ --output="$(dirname "$0")/../data/po/dockbarx.pot" --from-code=UTF-8 `find "$(dirname "$0")/.." -name "*.py" -not -path "./build/*"` utils/* +xgettext --language=Python --keyword=_ --output="$(dirname "$0")/../data/po/dockbarx.pot" --from-code=UTF-8 `find "$(dirname "$0")/.." -name "*.py" -not -path "./build/*"` "$(dirname "$0")"/../utils/* From 29423842c0dadbafccd9802c0f681e6d76a4df68 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Sat, 16 Dec 2023 17:42:32 +0800 Subject: [PATCH 20/24] Update README --- README.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e6e636a..c506330 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,31 @@ ### Version 1.0-beta3 ## About DockbarX -The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a [Xfce4 panel applet](https://github.com/xuzhen/xfce4-dockbarx-plugin) or a [MATE panel applet](https://github.com/xuzhen/dockbarx-mate-applet). DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. +The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a [Xfce4 panel plugin](https://github.com/xuzhen/xfce4-dockbarx-plugin), as a [MATE panel applet](https://github.com/xuzhen/dockbarx-mate-applet) or as a [LXQt panel plugin](https://github.com/xuzhen/dockbarx-lxqt-plugin). DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. DockbarX is free software and is licensed under GPL3. -## Install in Ubuntu 18.04+ from PPA +## Install in Ubuntu from PPA The main DockbarX PPA is not maintained for the moment. You can use Xu Zhen's unofficial DockbarX PPA instead. To add the PPA and install the application in Ubuntu (and derivatives), use the following commands: ``` sudo add-apt-repository ppa:xuzhen666/dockbarx -sudo apt-get update -sudo apt-get install dockbarx +sudo apt update +sudo apt install dockbarx ``` -If you want to use dockbarx as a Xfce panel applet you also need this command +If you want to use dockbarx as a panel plugin you also need these commands ``` -sudo apt-get install xfce4-dockbarx-plugin -``` - -If you want to use dockbarx as a MATE panel applet you also need this command -``` -sudo apt-get install dockbarx-mate-panel-applet +sudo apt install xfce4-dockbarx-plugin # for Xfce4 panel +sudo apt install dockbarx-mate-panel-applet # for MATE panel +sudo apt install dockbarx-lxqt-plugin # for LXQt panel ``` To get more themes for DockbarX and DockX use this command ``` -sudo apt-get install dockbarx-themes-extra +sudo apt install dockbarx-themes-extra ``` ## Install in archlinux From ab8b856d9eb338ac83e0167573685c465204cf8b Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Wed, 3 Jan 2024 17:03:36 +0800 Subject: [PATCH 21/24] Fix centered mode for applets --- utils/dockx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/dockx b/utils/dockx index ac7dcbd..9719216 100755 --- a/utils/dockx +++ b/utils/dockx @@ -740,8 +740,8 @@ class DockX(CairoDockX): orient = Gtk.Orientation.HORIZONTAL boxes = [Gtk.Box.new(orient, 0), Gtk.Box.new(orient, 0), Gtk.Box.new(orient, 0)] self.box.pack_start(boxes[0], True, True, 0) - self.box.pack_start(boxes[1], False, False, 0) - self.box.pack_start(boxes[2], True, True, 0) + self.box.set_center_widget(boxes[1]) + self.box.pack_end(boxes[2], True, True, 0) else: boxes = None return boxes From b82bc3837a0b8be6296e98a0b07561b72badf501 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Sat, 8 Jun 2024 16:52:53 +0800 Subject: [PATCH 22/24] Fix path --- dockbarx/dirutils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dockbarx/dirutils.py b/dockbarx/dirutils.py index 42ab2ae..c6835be 100644 --- a/dockbarx/dirutils.py +++ b/dockbarx/dirutils.py @@ -26,13 +26,15 @@ def get_app_homedir(): global appdir if appdir is not None: return appdir - homedir = os.environ.get("XDG_DATA_HOME", os.environ.get("HOME", os.path.expanduser('~'))) - appdir = os.path.join(homedir, '.local', 'share', "dockbarx") + home_dir = os.environ.get("HOME", os.path.expanduser('~')) + user_dir = os.environ.get("XDG_DATA_HOME", os.path.join(home_dir, '.local', 'share')) + appdir = os.path.join(user_dir, "dockbarx") + """ Migration Path From "$HOME/.dockbarx" to "${XDG_DATA_HOME:-$HOME/.local/share}/dockbarx" """ - old_appdir = os.path.join(homedir, '.dockbarx') + old_appdir = os.path.join(home_dir, '.dockbarx') if os.path.exists(old_appdir) and os.path.isdir(old_appdir): try: os.rename(old_appdir, appdir) @@ -53,8 +55,8 @@ def get_app_dirs(): def get_data_dirs(user_first=True): data_dirs = [] - home_dir = os.environ.get("XDG_DATA_HOME", os.environ.get("HOME", os.path.expanduser('~'))) - user_dir = os.path.join(home_dir, ".local", "share") + home_dir = os.environ.get("HOME", os.path.expanduser('~')) + user_dir = os.environ.get("XDG_DATA_HOME", os.path.join(home_dir, '.local', 'share')) if user_first: data_dirs.append(user_dir) env = os.environ.get("XDG_DATA_DIRS") From 3c5e6b38cc113b07cf3b087c1f82a065a25c2392 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Sun, 9 Jun 2024 21:24:14 +0800 Subject: [PATCH 23/24] bump version --- README.md | 2 +- dockbarx/dockbar.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c506330..11f6d2d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DockbarX -### Version 1.0-beta3 +### Version 1.0-beta4 ## About DockbarX The gtk3/python3 version of DockbarX is a lightweight taskbar / panel replacement for Linux which works as a stand-alone dock (called DockX), as a [Xfce4 panel plugin](https://github.com/xuzhen/xfce4-dockbarx-plugin), as a [MATE panel applet](https://github.com/xuzhen/dockbarx-mate-applet) or as a [LXQt panel plugin](https://github.com/xuzhen/dockbarx-lxqt-plugin). DockbarX is a fork of dockbar made by Aleksey Shaferov. DockbarX branch is developed by Matias Särs. diff --git a/dockbarx/dockbar.py b/dockbarx/dockbar.py index 16ff87a..9290a98 100644 --- a/dockbarx/dockbar.py +++ b/dockbarx/dockbar.py @@ -44,7 +44,7 @@ from . import i18n _ = i18n.language.gettext -VERSION = "1.0-beta3" +VERSION = "1.0-beta4" SPECIAL_RES_CLASSES = { diff --git a/setup.py b/setup.py index 4bc5868..ee653ea 100755 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ import os import sys -VERSION = "1.0-beta3" +VERSION = "1.0-beta4" dbx_files = [] From 6559a5338e3053484d5b04d2a9c3502886b227f0 Mon Sep 17 00:00:00 2001 From: Xu Zhen Date: Sun, 9 Jun 2024 22:42:27 +0800 Subject: [PATCH 24/24] Fix SyntaxWarning --- dockbarx/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockbarx/common.py b/dockbarx/common.py index b757cf0..57715f3 100644 --- a/dockbarx/common.py +++ b/dockbarx/common.py @@ -293,7 +293,7 @@ def launch(self, uri=None, command=None): if file.startswith("file://"): file = file[7:] - file = file.replace("%20","\ ") + file = file.replace("%20","\\ ") file = unquote(file) files.append(file)