tazbug rev 6

Add tazbug GUI box
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 03 12:09:16 2012 +0200 (2012-04-03)
parents 57ecc2563ff9
children d51926a3b64e
files tazbug-box
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tazbug-box	Tue Apr 03 12:09:16 2012 +0200
     1.3 @@ -0,0 +1,190 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# SliTaz Bug GUI tool. All the account part 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 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 $btns --button="gtk-close":1
    1.33 +}
    1.34 +
    1.35 +# New message box
    1.36 +new_msg_main() {
    1.37 +	yad --form $opts \
    1.38 +		--title="Bug message" \
    1.39 +		--text="<b>SliTaz Bugs Message</b>" \
    1.40 +		--field="$(gettext "Bug ID")":NUM \
    1.41 +		--field="$(gettext "Message")":TXT \
    1.42 +		--button="$(gettext "Send message"):0" \
    1.43 +		--button="gtk-close:1"
    1.44 +}
    1.45 +
    1.46 +# New message main function
    1.47 +new_msg() {
    1.48 +	# Store box results
    1.49 +	main=$(new_msg_main)
    1.50 +	ret=$?
    1.51 +	# Deal with --button values
    1.52 +	case $ret in
    1.53 +		1) exit 0 ;;
    1.54 +		*) continue ;;
    1.55 +	esac
    1.56 +	id="$(echo $main | cut -d "|" -f 1 | cut -d "," -f 1)"
    1.57 +	msg="$(echo $main | cut -d "|" -f 2)"
    1.58 +	if [ "$msg" ]; then
    1.59 +		tazbug new-msg --bug=$id --msg="$msg" | output
    1.60 +	fi
    1.61 +}
    1.62 +
    1.63 +# New bug box
    1.64 +new_bug_main() {
    1.65 +	yad --form $opts \
    1.66 +		--title="Bug report" \
    1.67 +		--text="<b>SliTaz Bug Report</b>" \
    1.68 +		--field="$(gettext "Bug title")" \
    1.69 +		--field="$(gettext "Priority")":CB \
    1.70 +		--field="$(gettext "Packages")" \
    1.71 +		--field="$(gettext "Description")":TXT \
    1.72 +		--button="$(gettext "My account"):3" \
    1.73 +		--button="$(gettext "New message"):2" \
    1.74 +		--button="$(gettext "Send bug"):0" \
    1.75 +		--button="gtk-close:1" \
    1.76 +		"" "standard!critical" "" ""
    1.77 +}
    1.78 +
    1.79 +# New bug main function
    1.80 +new_bug() {
    1.81 +	# Store box results
    1.82 +	main=$(new_bug_main)
    1.83 +	ret=$?
    1.84 +	# Deal with --button values
    1.85 +	case $ret in
    1.86 +		1) exit 0 ;;
    1.87 +		2) $0 new-msg && exit 0 ;;
    1.88 +		3) $0 account && exit 0 ;;
    1.89 +		*) continue ;;
    1.90 +	esac
    1.91 +	bug="$(echo $main | cut -d "|" -f 1)"
    1.92 +	desc="$(echo $main | cut -d "|" -f 4)"
    1.93 +	priority="$(echo $main | cut -d "|" -f 2)"
    1.94 +	pkgs="$(echo $main | cut -d "|" -f 3)"
    1.95 +	if [ "$bug" ] && [ "$desc" ]; then
    1.96 +		tazbug new-bug --bug="$bug" --desc="$desc" --priority=$priority \
    1.97 +			--pkgs="$pkgs"
    1.98 +	fi
    1.99 +}
   1.100 +
   1.101 +# Account information.
   1.102 +account_info() {
   1.103 +	. $HOME/.config/slitaz/account.conf
   1.104 +	echo -e "Name\n$NAME
   1.105 +Login\n$LOGIN
   1.106 +Mail\n$MAIL
   1.107 +Secure key\n$KEY"
   1.108 +}
   1.109 +
   1.110 +# Main GUI box function with pure Yad spec
   1.111 +account_main() {
   1.112 +	account_info | yad --list $opts \
   1.113 +		--title="Bugs account" \
   1.114 +		--text="<b>SliTaz Bugs Account</b>" \
   1.115 +		--column "$(gettext "Account")" \
   1.116 +		--column "$(gettext "Value")" \
   1.117 +		--dclick-action="" \
   1.118 +		--button="$(gettext "Online bugs"):2" \
   1.119 +		--button="$(gettext "New bug"):3" \
   1.120 +		--button="$(gettext "New message"):4" \
   1.121 +		--button="gtk-close:1"
   1.122 +}
   1.123 +
   1.124 +# This is a function, usually the same name as the command if scripts
   1.125 +# have multiple commands and options.
   1.126 +account() {
   1.127 +	# Store box results
   1.128 +	main=$(account_main)
   1.129 +	ret=$?
   1.130 +	# Deal with --button values
   1.131 +	case $ret in
   1.132 +		1) exit 0 ;;
   1.133 +		2) browser $WEB_URL && exit 0 ;;
   1.134 +		3) $0 new-bug && exit 0 ;;
   1.135 +		4) $0 new-msg && exit 0 ;;
   1.136 +		*) continue ;;
   1.137 +	esac
   1.138 +}
   1.139 +
   1.140 +# Signup GUI box function with pure Yad spec
   1.141 +signup_main() {
   1.142 +	yad --form $opts --borders=4 \
   1.143 +		--title="Bugs Signup" \
   1.144 +		--text="<b>SliTaz Bugs Signup</b>" \
   1.145 +		--field="$(gettext "Real name")" \
   1.146 +		--field="$(gettext "Login name")" \
   1.147 +		--field="$(gettext "Email")" \
   1.148 +		--field="$(gettext "Password")":H \
   1.149 +		--button="gtk-ok:0" \
   1.150 +		--button="gtk-close:1"
   1.151 +}
   1.152 +
   1.153 +# Signup main function
   1.154 +signup() {
   1.155 +	# Store box results
   1.156 +	main=$(signup_main)
   1.157 +	ret=$?
   1.158 +	# Deal with --button values
   1.159 +	case $ret in
   1.160 +		1) exit 0 ;;
   1.161 +		2) browser http://bugs.slitaz.org/ && exit 0 ;;
   1.162 +		*) continue ;;
   1.163 +	esac
   1.164 +	name="$(echo $main | cut -d "|" -f 1)"
   1.165 +	user="$(echo $main | cut -d "|" -f 2)"
   1.166 +	mail="$(echo $main | cut -d "|" -f 3)"
   1.167 +	pass="$(echo $main | cut -d "|" -f 4)"
   1.168 +	tazbug signup --name="$name" --user=$user --mail=$mail \
   1.169 +		--pass="$pass" | output
   1.170 +}
   1.171 +
   1.172 +#
   1.173 +# Script commands
   1.174 +#
   1.175 +
   1.176 +case "$1" in
   1.177 +	usage|help)
   1.178 +		echo "Usage: $(basename $0) [new-msg|new-bug|account|signup]" ;;
   1.179 +	new-msg)
   1.180 +		new_msg ;;
   1.181 +	account)
   1.182 +		account ;;
   1.183 +	signup) 
   1.184 +		signup ;;
   1.185 +	*)
   1.186 +		if [ ! $HOME/.config/slitaz/account.conf ]; then
   1.187 +			signup
   1.188 +		fi
   1.189 +		new_bug ;;
   1.190 +esac
   1.191 +
   1.192 +exit 0
   1.193 +