Display 'already running' msg using yad (#157)

Display the "gpartedbin is already running" message as a graphical error box
using yad (Yet Another Dialog) if it's available, in addition to printing to
stdout.

GParted is a graphical tool so most users will not be launching the tool from a
terminal, so displaying a graphical dialog error box gives the user more
clarity.

Note: This commit does not add 'yad' as a dependency of GParted.

Also, the existing stdout message is not yet translated.

Closes #157 - Display 'GParted already running' error graphically
This commit is contained in:
Shasheen Ediriweera 2021-06-15 17:41:10 +09:30
parent 39e7156697
commit 8e37b5067c

View file

@ -27,12 +27,22 @@
# along with GParted. If not, see <http://www.gnu.org/licenses/>.
#
display_msg() {
MESSAGE="$1"
TITLE="$2"
printf "$MESSAGE\n"
which yad >/dev/null
yad_exists=$?
if [ $yad_exists -eq 0 ]; then
yad --center --width 300 --title="$TITLE" --button="OK:0" --text "$MESSAGE"
fi
}
#
# Only permit one instance of GParted to execute at a time
#
if pidof gpartedbin 1> /dev/null; then
echo "The process gpartedbin is already running."
echo "Only one gpartedbin process is permitted."
display_msg "The process gpartedbin is already running.\n\nOnly one gpartedbin process is permitted."
exit 1
fi
@ -51,7 +61,7 @@ if test "x`id -u`" != "x0"; then
# privileges.
#
if test "x@gksuprog@" = "x"; then
echo "Root privileges are required for running gparted."
display_msg "Root privileges are required for running gparted."
$BASE_CMD
exit 1
fi