tazbug diff old/tazbug-box @ rev 151

Fix in users plugin (from tinycm)
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 28 22:59:52 2017 +0100 (2017-02-28)
parents 3acb15d87d6e
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/old/tazbug-box	Tue Feb 28 22:59:52 2017 +0100
     1.3 @@ -0,0 +1,203 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# SliTaz Bug GUI tool. All the account parts may move to slitaz-account
     1.7 +# if we use it for other sites and services so we use one centralized
     1.8 +# SliTaz account.
     1.9 +#
    1.10 +# Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
    1.11 +#
    1.12 +# Authors : Christophe Lincoln <pankso@slitaz.org>
    1.13 +#
    1.14 +[ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf
    1.15 +[ -f "tazbug.conf" ] && . tazbug.conf
    1.16 +
    1.17 +opts="--window-icon=/usr/share/pixmaps/slitaz-icon.png --center \
    1.18 +--image=slitaz-icon --image-on-top --width=480 --height=340"
    1.19 +
    1.20 +# Internationalization: $(gettext "")
    1.21 +. /usr/bin/gettext.sh
    1.22 +TEXTDOMAIN='tazbug'
    1.23 +export TEXTDOMAIN
    1.24 +
    1.25 +#
    1.26 +# Functions
    1.27 +#
    1.28 +
    1.29 +# Output cmd in GTK box.
    1.30 +output() {
    1.31 +	yad $opts --text-info --text="<b>SliTaz Bug</b>" --title="SliTaz Bug" \
    1.32 +		--margins=8 --tail --button="$(gettext "My account"):0" \
    1.33 +		--button="gtk-close":1
    1.34 +	case $? in
    1.35 +		0) $0 account ;;
    1.36 +		1) exit 0 ;;
    1.37 +	esac
    1.38 +}
    1.39 +
    1.40 +# New message box
    1.41 +new_msg_main() {
    1.42 +	yad --form $opts \
    1.43 +		--title="Bug message" \
    1.44 +		--text="<b>SliTaz Bugs Message</b>" \
    1.45 +		--field="$(gettext "Bug ID")":NUM \
    1.46 +		--field="$(gettext "Message")":TXT \
    1.47 +		--button="$(gettext "New bug"):2" \
    1.48 +		--button="$(gettext "Send message"):0" \
    1.49 +		--button="gtk-close:1"
    1.50 +}
    1.51 +
    1.52 +# New message main function
    1.53 +new_msg() {
    1.54 +	# Store box results
    1.55 +	main=$(new_msg_main)
    1.56 +	ret=$?
    1.57 +	# Deal with --button values
    1.58 +	case $ret in
    1.59 +		1) exit 0 ;;
    1.60 +		2) $0 new-bug && exit 0 ;;
    1.61 +		*) continue ;;
    1.62 +	esac
    1.63 +	id="$(echo $main | cut -d "|" -f 1 | cut -d "," -f 1)"
    1.64 +	msg="$(echo $main | cut -d "|" -f 2)"
    1.65 +	if [ "$msg" ]; then
    1.66 +		tazbug new-msg --bug=$id --msg="$msg" | output
    1.67 +	fi
    1.68 +}
    1.69 +
    1.70 +# New bug box
    1.71 +new_bug_main() {
    1.72 +	yad --form $opts \
    1.73 +		--title="Bug report" \
    1.74 +		--text="<b>SliTaz Bug Report</b>" \
    1.75 +		--field="$(gettext "Bug title")" \
    1.76 +		--field="$(gettext "Priority")":CB \
    1.77 +		--field="$(gettext "Packages")" \
    1.78 +		--field="$(gettext "Description")":TXT \
    1.79 +		--button="$(gettext "My account"):3" \
    1.80 +		--button="$(gettext "New message"):2" \
    1.81 +		--button="$(gettext "Send bug"):0" \
    1.82 +		--button="gtk-close:1" \
    1.83 +		"" "standard!critical" "" ""
    1.84 +}
    1.85 +
    1.86 +# New bug main function
    1.87 +new_bug() {
    1.88 +	# Store box results
    1.89 +	main=$(new_bug_main)
    1.90 +	ret=$?
    1.91 +	# Deal with --button values
    1.92 +	case $ret in
    1.93 +		1) exit 0 ;;
    1.94 +		2) $0 new-msg && exit 0 ;;
    1.95 +		3) $0 account && exit 0 ;;
    1.96 +		*) continue ;;
    1.97 +	esac
    1.98 +	bug="$(echo $main | cut -d "|" -f 1)"
    1.99 +	desc="$(echo $main | cut -d "|" -f 4)"
   1.100 +	priority="$(echo $main | cut -d "|" -f 2)"
   1.101 +	pkgs="$(echo $main | cut -d "|" -f 3)"
   1.102 +	if [ "$bug" ] && [ "$desc" ]; then
   1.103 +		tazbug new-bug --bug="$bug" --desc="$desc" --priority=$priority \
   1.104 +			--pkgs="$pkgs" | output
   1.105 +	fi
   1.106 +}
   1.107 +
   1.108 +# Account information.
   1.109 +account_info() {
   1.110 +	. $HOME/.config/slitaz/account.conf
   1.111 +	cat << EOT
   1.112 +$(gettext "Real name")
   1.113 +$NAME
   1.114 +$(gettext "User name")
   1.115 +$USER
   1.116 +Email
   1.117 +$MAIL
   1.118 +$(gettext "Secure key")
   1.119 +$KEY
   1.120 +EOT
   1.121 +}
   1.122 +
   1.123 +# Main GUI box function with pure Yad spec
   1.124 +account_main() {
   1.125 +	account_info | yad --list $opts \
   1.126 +		--title="Bugs account" \
   1.127 +		--text="<b>SliTaz Bugs Account</b>" \
   1.128 +		--column "$(gettext "Account")" \
   1.129 +		--column "$(gettext "Value")" \
   1.130 +		--dclick-action="" \
   1.131 +		--button="$(gettext "Online bugs"):2" \
   1.132 +		--button="$(gettext "New bug"):3" \
   1.133 +		--button="$(gettext "New message"):4" \
   1.134 +		--button="gtk-close:1"
   1.135 +}
   1.136 +
   1.137 +# This is a function, usually the same name as the command if scripts
   1.138 +# have multiple commands and options.
   1.139 +account() {
   1.140 +	# Store box results
   1.141 +	main=$(account_main)
   1.142 +	ret=$?
   1.143 +	# Deal with --button values
   1.144 +	case $ret in
   1.145 +		1) exit 0 ;;
   1.146 +		2) browser $WEB_URL && exit 0 ;;
   1.147 +		3) $0 new-bug && exit 0 ;;
   1.148 +		4) $0 new-msg && exit 0 ;;
   1.149 +		*) continue ;;
   1.150 +	esac
   1.151 +}
   1.152 +
   1.153 +# Signup GUI box function with pure Yad spec
   1.154 +signup_main() {
   1.155 +	yad --form $opts --borders=4 \
   1.156 +		--title="Bugs Signup" \
   1.157 +		--text="<b>SliTaz Bugs Signup</b>" \
   1.158 +		--field="$(gettext "Real name")" \
   1.159 +		--field="$(gettext "Login name")" \
   1.160 +		--field="$(gettext "Email")" \
   1.161 +		--field="$(gettext "Password")":H \
   1.162 +		--button="gtk-ok:0" \
   1.163 +		--button="gtk-close:1"
   1.164 +}
   1.165 +
   1.166 +# Signup main function
   1.167 +signup() {
   1.168 +	# Store box results
   1.169 +	main=$(signup_main)
   1.170 +	ret=$?
   1.171 +	# Deal with --button values
   1.172 +	case $ret in
   1.173 +		1) exit 0 ;;
   1.174 +		2) browser http://bugs.slitaz.org/ && exit 0 ;;
   1.175 +		*) continue ;;
   1.176 +	esac
   1.177 +	name="$(echo $main | cut -d "|" -f 1)"
   1.178 +	user="$(echo $main | cut -d "|" -f 2)"
   1.179 +	mail="$(echo $main | cut -d "|" -f 3)"
   1.180 +	pass="$(echo $main | cut -d "|" -f 4)"
   1.181 +	tazbug signup --name="$name" --user=$user --mail=$mail \
   1.182 +		--pass="$pass" | output
   1.183 +}
   1.184 +
   1.185 +#
   1.186 +# Script commands
   1.187 +#
   1.188 +
   1.189 +case "$1" in
   1.190 +	usage|help)
   1.191 +		echo "Usage: $(basename $0) [new-msg|new-bug|account|signup]" ;;
   1.192 +	new-msg)
   1.193 +		new_msg ;;
   1.194 +	account)
   1.195 +		account ;;
   1.196 +	signup) 
   1.197 +		signup ;;
   1.198 +	*)
   1.199 +		if [ ! -f $HOME/.config/slitaz/account.conf ]; then
   1.200 +			signup
   1.201 +		fi
   1.202 +		new_bug ;;
   1.203 +esac
   1.204 +
   1.205 +exit 0
   1.206 +