Bring gnome-control-center window to front when already open

When the user clicks 'Change system keyboard layout' in GNOME, if
gnome-control-center is already running, its window should come to the
front instead of staying behind the installer window.

Create a wrapper script gnome-control-center-ext that:
- Uses gapplication launch to activate existing instance (brings window to front)
- Then launches gnome-control-center with keyboard panel argument

Update the desktop file to use this wrapper script instead of calling
gnome-control-center directly.

Resolves: rhbz#2415043
This commit is contained in:
Katerina Koukiou 2025-12-04 15:03:42 +01:00
parent d333492c7d
commit d19c3b4c1c
4 changed files with 37 additions and 3 deletions

View file

@ -92,7 +92,7 @@ po/LINGUAS:
#
all: $(DIST_TEST)
dist_libexec_SCRIPTS = webui-desktop browser-ext
dist_libexec_SCRIPTS = webui-desktop browser-ext gnome-control-center-ext
# makes sure it gets built as part of `make` and `make dist`
dist_noinst_DATA = \
$(DIST_TEST) \
@ -138,6 +138,7 @@ install: $(DIST_TEST) po/LINGUAS
mkdir -p $(DESTDIR)/usr/libexec/anaconda
cp webui-desktop $(DESTDIR)/usr/libexec/anaconda
cp browser-ext $(DESTDIR)/usr/libexec/anaconda
cp gnome-control-center-ext $(DESTDIR)/usr/libexec/anaconda
cp src/scripts/cockpit-coproc-wrapper.sh $(DESTDIR)/usr/libexec/anaconda/
mkdir -p $(DESTDIR)/usr/lib/systemd/system/
cp src/systemd/webui-cockpit-ws.service $(DESTDIR)/usr/lib/systemd/system/

View file

@ -1,7 +1,7 @@
[Desktop Entry]
Version=1.0
Name=Keyboard External
Exec=/usr/bin/gnome-control-center keyboard %u
Exec=/usr/libexec/anaconda/gnome-control-center-ext keyboard
Terminal=false
Type=Application
MimeType=x-scheme-handler/anaconda-gnome-control-center;
@ -13,4 +13,4 @@ X-Desktop-File-Install-Version=0.26
[Desktop Action Region]
Name=Region & Language
Exec=/usr/bin/gnome-control-center keyboard
Exec=/usr/libexec/anaconda/gnome-control-center-ext keyboard

32
gnome-control-center-ext Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (C) 2025 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Panel name argument is mandatory
if [[ -z "$1" ]]; then
echo "Error: Panel name argument is required" >&2
exit 1
fi
PANEL="$1"
# Use gapplication to activate existing instance (brings window to front if running)
# This handles single-instance app activation automatically
gapplication launch org.gnome.Settings 2>/dev/null
# Launch with panel argument
# Since gnome-control-center is single-instance, this will switch panels in existing window
exec /usr/bin/gnome-control-center "$PANEL"

View file

@ -88,6 +88,7 @@ exit 0
%{_datadir}/anaconda/firefox-theme/extlink/user.js
%{_libexecdir}/anaconda/webui-desktop
%{_libexecdir}/anaconda/browser-ext
%{_libexecdir}/anaconda/gnome-control-center-ext
%{_datadir}/applications/extlinks.desktop
%{_datadir}/applications/anaconda-gnome-control-center.desktop
%{_unitdir}/webui-cockpit-ws.service