#!/bin/bash
SOURCE="$0"
source /usr/lib/elive-tools/functions
EL_REPORTS="1"
el_make_environment
. gettext.sh
TEXTDOMAIN="elive-tools"
export TEXTDOMAIN



main(){
    guitool="$(which zenity) --window-icon=/usr/share/icons/gnome/256x256/apps/logo-elive.png"

    #message_intro="$( printf "$( eval_gettext "Before reporting an issue, it's very important to know to where to report it, if you are unsure just use our forums so that we can assist. Remember that by reporting and fixing a bug you will directly benefit including others facing the same problem." )" "" )"

    message_option1="$( printf "$( eval_gettext "I have an issue with something specific to Elive" )" "" )"
    message_option2="$( printf "$( eval_gettext "I have an issue with the desktop itself" )" "" )"
    message_option3="$( printf "$( eval_gettext "I have an issue with an application unrelated to Elive" )" "" )"
    message_option4="$( printf "$( eval_gettext "I have a problem with my hardware drivers" )" "" )"
    message_option5="$( printf "$( eval_gettext "Help, guide me" )" "" )"



    message_report_info_elive="$( printf "$( eval_gettext "Use the next page to report the issue. Please provide the necessary details we need to reproduce and fix it. For discussions about an issue, please use our forums instead." )" "" )"


    #$guitool --info --text="$message_intro"


    answer="$( $guitool --height=260 --width=700 --list --column="" --column="$( eval_gettext "Option" )" --hide-column="1" \
        "elive" "$message_option1" \
        "desktop" "$message_option2" \
        "application" "$message_option3" \
        "drivers" "$message_option4" \
        "help" "$message_option5" \
        2>/dev/null || echo cancel )"

    #el_debug "answer: $answer"

    case "$answer" in
        elive|drivers)
            $guitool --info --text="$message_report_info_elive"
            web-launcher "https://bugs.elivecd.org"
            ;;
        desktop)
            $guitool --info --text="$( eval_gettext "You're using the Enlightenment desktop customized by Elive, so make sure the issue isn't specific to Elive, you can get help in our forums, then report the problem to either Elive or the Enlightenment developers." )"
            if $guitool --question --cancel-label="No" --text="$( eval_gettext "Do you want to report the issue to the Enlightenment (your desktop) developers? Select NO if you want to report it to Elive instead." )" ; then
                if [[ -n "$EROOT" ]] ; then
                    $guitool --info --text="Important: Make sure you have a login or register. Select Maniphest to report the issue. Select 'Create Task' in the corner. Be descriptive in the title and details. Assign it to 'raster' so the author can be informed about it, set the Tag to 'enlightenment-git'." &
                    sleep 4
                else
                    $guitool --info --text="Important: Make sure you have a login or register. Select Maniphest to report the issue. Select 'Create Task' in the corner. Be descriptive in the title and details. Assign it to 'kwo' so the author can be informed about it, set the Tag to 'enlightenment16'." &
                    sleep 4
                fi
                web-launcher "https://phab.enlightenment.org"
            else
                web-launcher "https://bugs.elivecd.org"
            fi
            ;;
        application)
            $guitool --info --text="$( eval_gettext "First, check if the application is from Debian or packaged by Elive by running 'apt-cache policy packagename' to see the repository, if it's from Debian, report the issue to them, but make sure it’s not caused by Elive’s user settings. If it’s from Elive, report it to the application’s project site, remember that Elive usually builds packages from original sources, feel free to use our forums to get help." )"
            ;;
        help)
            web-launcher "https://forum.elivelinux.org/c/system/bugs/33"
            ;;
        cancel)
            $guitool --info --text="$( eval_gettext "If you need more help, you can use our forums on the Elive website." )"
            ;;
    esac

    # bye
    $guitool --info --text="$( eval_gettext "Thank you for your collaboration." )"
}

#
#  MAIN
#
main "$@"

# vim: set foldmethod=marker :
