mirror of
https://github.com/sbopkg/sbopkg
synced 2025-01-16 03:41:32 +01:00
Rework the main menu
Rework the main menu to reduce complexity and code replication. Thanks to "jsunx1" for suggesting this and for providing a similar implementation. Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
parent
0fcf52265b
commit
ef793216cd
1 changed files with 45 additions and 67 deletions
|
@ -2392,6 +2392,9 @@ check_for_latest () {
|
|||
|
||||
queue_menu () {
|
||||
# Separate menu for queue functions.
|
||||
if [ ! -e $TMP/sbopkg_backup_queue.lck ]; then
|
||||
load_backup_queue
|
||||
fi
|
||||
if [ -z "$Q" ]; then
|
||||
Q="View"
|
||||
fi
|
||||
|
@ -2544,51 +2547,9 @@ main_search() {
|
|||
fi
|
||||
}
|
||||
|
||||
main_menu () {
|
||||
# This is the main dialog menu.
|
||||
if [ -z "$R" ]; then
|
||||
R="Rsync"
|
||||
fi
|
||||
while [ 0 ]; do
|
||||
dialog --default-item "$R" --title \
|
||||
"SlackBuilds.org Package Browser (sbopkg version $SBOVER)" \
|
||||
--backtitle \
|
||||
"Currently using the SlackBuilds.org $SLACKVER repository." \
|
||||
--menu \
|
||||
"\nChoose one of the following or press <Cancel> to exit.\n" \
|
||||
17 69 9 \
|
||||
"Rsync" "Rsync with SlackBuilds.org" \
|
||||
"ChangeLog" "View the SlackBuilds.org ChangeLog" \
|
||||
"Packages" "List installed SBo packages" \
|
||||
"Updates" "List potential updates to installed SBo packages" \
|
||||
"Browse" "Browse the local SlackBuilds.org repository" \
|
||||
"Search" "Search the local SlackBuilds.org repository" \
|
||||
"Queue" "Manage the build queue" \
|
||||
"Utilities" "Go to the utilities menu" \
|
||||
"Exit" "Exit sbopkg" 2>$TMP/sbopkg_main_menu_answer
|
||||
main_updates () {
|
||||
local APP VERSIONBUILD ONOFF
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
save_backup_queue
|
||||
clear
|
||||
cleanup
|
||||
exit 0
|
||||
fi
|
||||
|
||||
R="$(cat $TMP/sbopkg_main_menu_answer)"
|
||||
|
||||
if [ "$R" = "Rsync" ]; then
|
||||
rsync_repo
|
||||
fi
|
||||
|
||||
if [ "$R" = "ChangeLog" ]; then
|
||||
show_changelog
|
||||
fi
|
||||
|
||||
if [ "$R" = "Packages" ]; then
|
||||
get_sbo_packages
|
||||
fi
|
||||
|
||||
if [ "$R" = "Updates" ]; then
|
||||
rm -f $TMP/sbopkg-update-queue
|
||||
check_for_updates
|
||||
if [ -e $TMP/sbopkg-update-queue ]; then
|
||||
|
@ -2607,33 +2568,50 @@ main_menu () {
|
|||
updates have been added to the build queue.")" 8 30
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$R" = "Browse" ]; then
|
||||
browse_categories
|
||||
main_menu () {
|
||||
# This is the main dialog menu.
|
||||
if [ -z "$R" ]; then
|
||||
R="Rsync"
|
||||
fi
|
||||
while :; do
|
||||
dialog --cancel-label "Exit" --default-item "$R" --title \
|
||||
"SlackBuilds.org Package Browser (sbopkg version $SBOVER)" \
|
||||
--backtitle \
|
||||
"Currently using the SlackBuilds.org $SLACKVER repository." \
|
||||
--menu \
|
||||
"\nChoose one of the following or press <Cancel> to exit.\n" \
|
||||
17 69 9 \
|
||||
"Rsync" "Rsync with SlackBuilds.org" \
|
||||
"ChangeLog" "View the SlackBuilds.org ChangeLog" \
|
||||
"Packages" "List installed SBo packages" \
|
||||
"Updates" "List potential updates to installed SBo packages" \
|
||||
"Browse" "Browse the local SlackBuilds.org repository" \
|
||||
"Search" "Search the local SlackBuilds.org repository" \
|
||||
"Queue" "Manage the build queue" \
|
||||
"Utilities" "Go to the utilities menu" \
|
||||
"Exit" "Exit sbopkg" 2>$TMP/sbopkg_main_menu_answer
|
||||
|
||||
if [ "$R" = "Search" ]; then
|
||||
main_search
|
||||
fi
|
||||
R="$(cat $TMP/sbopkg_main_menu_answer)"
|
||||
|
||||
if [ "$R" = "Queue" ]; then
|
||||
if [ ! -e $TMP/sbopkg_backup_queue.lck ]; then
|
||||
load_backup_queue
|
||||
fi
|
||||
queue_menu
|
||||
fi
|
||||
|
||||
if [ "$R" = "Utilities" ]; then
|
||||
utilities_menu
|
||||
fi
|
||||
|
||||
if [ "$R" = "Exit" ]; then
|
||||
case "$R" in
|
||||
"Rsync") rsync_repo ;;
|
||||
"ChangeLog") show_changelog ;;
|
||||
"Packages") get_sbo_packages ;;
|
||||
"Updates") main_updates ;;
|
||||
"Browse") browse_categories ;;
|
||||
"Search") main_search ;;
|
||||
"Utilities") utilities_menu ;;
|
||||
"Queue") queue_menu ;;
|
||||
*) # "Exit", or an empty string if Exit, instead of Ok,
|
||||
# was pressed
|
||||
save_backup_queue
|
||||
clear
|
||||
cleanup
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue