tazbug annotate tazbug-box @ rev 26
Small bug fix (it stable for 4.0)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Apr 10 12:34:20 2012 +0200 (2012-04-10) |
parents | 4e45eb4505eb |
children | 02a11d8d636e |
rev | line source |
---|---|
pankso@6 | 1 #!/bin/sh |
pankso@6 | 2 # |
paul@17 | 3 # SliTaz Bug GUI tool. All the account's parts may move to slitaz-account |
pankso@6 | 4 # if we use it for other sites and services so we use one centralized |
pankso@6 | 5 # SliTaz account. |
pankso@6 | 6 # |
pankso@6 | 7 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License |
pankso@6 | 8 # |
pankso@6 | 9 # Authors : Christophe Lincoln <pankso@slitaz.org> |
pankso@6 | 10 # |
pankso@6 | 11 [ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf |
pankso@6 | 12 [ -f "tazbug.conf" ] && . tazbug.conf |
pankso@6 | 13 |
pankso@6 | 14 opts="--window-icon=/usr/share/pixmaps/slitaz-icon.png --center \ |
pankso@6 | 15 --image=slitaz-icon --image-on-top --width=480 --height=340" |
pankso@6 | 16 |
pankso@6 | 17 # Internationalization: $(gettext "") |
pankso@6 | 18 . /usr/bin/gettext.sh |
pankso@6 | 19 TEXTDOMAIN='tazbug' |
pankso@6 | 20 export TEXTDOMAIN |
pankso@6 | 21 |
pankso@6 | 22 # |
pankso@6 | 23 # Functions |
pankso@6 | 24 # |
pankso@6 | 25 |
pankso@6 | 26 # Output cmd in GTK box. |
pankso@6 | 27 output() { |
pankso@6 | 28 yad $opts --text-info --text="<b>SliTaz Bug</b>" --title="SliTaz Bug" \ |
pankso@16 | 29 --margins=8 --tail --button="$(gettext "My account"):0" \ |
pankso@16 | 30 --button="gtk-close":1 |
pankso@16 | 31 case $? in |
pankso@16 | 32 0) $0 account ;; |
pankso@16 | 33 1) exit 0 ;; |
pankso@16 | 34 esac |
pankso@6 | 35 } |
pankso@6 | 36 |
pankso@6 | 37 # New message box |
pankso@6 | 38 new_msg_main() { |
pankso@6 | 39 yad --form $opts \ |
pankso@6 | 40 --title="Bug message" \ |
pankso@6 | 41 --text="<b>SliTaz Bugs Message</b>" \ |
pankso@6 | 42 --field="$(gettext "Bug ID")":NUM \ |
pankso@6 | 43 --field="$(gettext "Message")":TXT \ |
pankso@16 | 44 --button="$(gettext "New bug"):2" \ |
pankso@6 | 45 --button="$(gettext "Send message"):0" \ |
pankso@6 | 46 --button="gtk-close:1" |
pankso@6 | 47 } |
pankso@6 | 48 |
pankso@6 | 49 # New message main function |
pankso@6 | 50 new_msg() { |
pankso@6 | 51 # Store box results |
pankso@6 | 52 main=$(new_msg_main) |
pankso@6 | 53 ret=$? |
pankso@6 | 54 # Deal with --button values |
pankso@6 | 55 case $ret in |
pankso@6 | 56 1) exit 0 ;; |
pankso@16 | 57 2) $0 new-bug && exit 0 ;; |
pankso@6 | 58 *) continue ;; |
pankso@6 | 59 esac |
pankso@6 | 60 id="$(echo $main | cut -d "|" -f 1 | cut -d "," -f 1)" |
pankso@6 | 61 msg="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 62 if [ "$msg" ]; then |
pankso@6 | 63 tazbug new-msg --bug=$id --msg="$msg" | output |
pankso@6 | 64 fi |
pankso@6 | 65 } |
pankso@6 | 66 |
pankso@6 | 67 # New bug box |
pankso@6 | 68 new_bug_main() { |
pankso@6 | 69 yad --form $opts \ |
pankso@6 | 70 --title="Bug report" \ |
pankso@6 | 71 --text="<b>SliTaz Bug Report</b>" \ |
pankso@6 | 72 --field="$(gettext "Bug title")" \ |
pankso@6 | 73 --field="$(gettext "Priority")":CB \ |
pankso@6 | 74 --field="$(gettext "Packages")" \ |
pankso@6 | 75 --field="$(gettext "Description")":TXT \ |
pankso@6 | 76 --button="$(gettext "My account"):3" \ |
pankso@6 | 77 --button="$(gettext "New message"):2" \ |
pankso@6 | 78 --button="$(gettext "Send bug"):0" \ |
pankso@6 | 79 --button="gtk-close:1" \ |
pankso@6 | 80 "" "standard!critical" "" "" |
pankso@6 | 81 } |
pankso@6 | 82 |
pankso@6 | 83 # New bug main function |
pankso@6 | 84 new_bug() { |
pankso@6 | 85 # Store box results |
pankso@6 | 86 main=$(new_bug_main) |
pankso@6 | 87 ret=$? |
pankso@6 | 88 # Deal with --button values |
pankso@6 | 89 case $ret in |
pankso@6 | 90 1) exit 0 ;; |
pankso@6 | 91 2) $0 new-msg && exit 0 ;; |
pankso@6 | 92 3) $0 account && exit 0 ;; |
pankso@6 | 93 *) continue ;; |
pankso@6 | 94 esac |
pankso@6 | 95 bug="$(echo $main | cut -d "|" -f 1)" |
pankso@6 | 96 desc="$(echo $main | cut -d "|" -f 4)" |
pankso@6 | 97 priority="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 98 pkgs="$(echo $main | cut -d "|" -f 3)" |
pankso@6 | 99 if [ "$bug" ] && [ "$desc" ]; then |
pankso@6 | 100 tazbug new-bug --bug="$bug" --desc="$desc" --priority=$priority \ |
pankso@26 | 101 --pkgs="$pkgs" | output |
pankso@6 | 102 fi |
pankso@6 | 103 } |
pankso@6 | 104 |
pankso@6 | 105 # Account information. |
pankso@6 | 106 account_info() { |
pankso@6 | 107 . $HOME/.config/slitaz/account.conf |
pankso@16 | 108 cat << EOT |
pankso@16 | 109 $(gettext "Real name") |
pankso@16 | 110 $NAME |
pankso@16 | 111 $(gettext "User name") |
pankso@16 | 112 $USER |
pankso@16 | 113 Email |
pankso@16 | 114 $MAIL |
pankso@16 | 115 $(gettext "Secure key") |
pankso@16 | 116 $KEY |
pankso@16 | 117 EOT |
pankso@6 | 118 } |
pankso@6 | 119 |
pankso@6 | 120 # Main GUI box function with pure Yad spec |
pankso@6 | 121 account_main() { |
pankso@6 | 122 account_info | yad --list $opts \ |
pankso@6 | 123 --title="Bugs account" \ |
pankso@6 | 124 --text="<b>SliTaz Bugs Account</b>" \ |
pankso@6 | 125 --column "$(gettext "Account")" \ |
pankso@6 | 126 --column "$(gettext "Value")" \ |
pankso@6 | 127 --dclick-action="" \ |
pankso@6 | 128 --button="$(gettext "Online bugs"):2" \ |
pankso@6 | 129 --button="$(gettext "New bug"):3" \ |
pankso@6 | 130 --button="$(gettext "New message"):4" \ |
pankso@6 | 131 --button="gtk-close:1" |
pankso@6 | 132 } |
pankso@6 | 133 |
pankso@6 | 134 # This is a function, usually the same name as the command if scripts |
pankso@6 | 135 # have multiple commands and options. |
pankso@6 | 136 account() { |
pankso@6 | 137 # Store box results |
pankso@6 | 138 main=$(account_main) |
pankso@6 | 139 ret=$? |
pankso@6 | 140 # Deal with --button values |
pankso@6 | 141 case $ret in |
pankso@6 | 142 1) exit 0 ;; |
pankso@6 | 143 2) browser $WEB_URL && exit 0 ;; |
pankso@6 | 144 3) $0 new-bug && exit 0 ;; |
pankso@6 | 145 4) $0 new-msg && exit 0 ;; |
pankso@6 | 146 *) continue ;; |
pankso@6 | 147 esac |
pankso@6 | 148 } |
pankso@6 | 149 |
pankso@6 | 150 # Signup GUI box function with pure Yad spec |
pankso@6 | 151 signup_main() { |
pankso@6 | 152 yad --form $opts --borders=4 \ |
pankso@6 | 153 --title="Bugs Signup" \ |
pankso@6 | 154 --text="<b>SliTaz Bugs Signup</b>" \ |
pankso@6 | 155 --field="$(gettext "Real name")" \ |
pankso@6 | 156 --field="$(gettext "Login name")" \ |
pankso@6 | 157 --field="$(gettext "Email")" \ |
pankso@6 | 158 --field="$(gettext "Password")":H \ |
pankso@6 | 159 --button="gtk-ok:0" \ |
pankso@6 | 160 --button="gtk-close:1" |
pankso@6 | 161 } |
pankso@6 | 162 |
pankso@6 | 163 # Signup main function |
pankso@6 | 164 signup() { |
pankso@6 | 165 # Store box results |
pankso@6 | 166 main=$(signup_main) |
pankso@6 | 167 ret=$? |
pankso@6 | 168 # Deal with --button values |
pankso@6 | 169 case $ret in |
pankso@6 | 170 1) exit 0 ;; |
pankso@6 | 171 2) browser http://bugs.slitaz.org/ && exit 0 ;; |
pankso@6 | 172 *) continue ;; |
pankso@6 | 173 esac |
pankso@6 | 174 name="$(echo $main | cut -d "|" -f 1)" |
pankso@6 | 175 user="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 176 mail="$(echo $main | cut -d "|" -f 3)" |
pankso@6 | 177 pass="$(echo $main | cut -d "|" -f 4)" |
pankso@16 | 178 tazbug signup --name="$name" --user=$user --mail=$mail \ |
pankso@6 | 179 --pass="$pass" | output |
pankso@6 | 180 } |
pankso@6 | 181 |
pankso@6 | 182 # |
pankso@6 | 183 # Script commands |
pankso@6 | 184 # |
pankso@6 | 185 |
pankso@6 | 186 case "$1" in |
pankso@6 | 187 usage|help) |
pankso@6 | 188 echo "Usage: $(basename $0) [new-msg|new-bug|account|signup]" ;; |
pankso@6 | 189 new-msg) |
pankso@6 | 190 new_msg ;; |
pankso@6 | 191 account) |
pankso@6 | 192 account ;; |
pankso@6 | 193 signup) |
pankso@6 | 194 signup ;; |
pankso@6 | 195 *) |
pankso@15 | 196 if [ ! -f $HOME/.config/slitaz/account.conf ]; then |
pankso@6 | 197 signup |
pankso@6 | 198 fi |
pankso@6 | 199 new_bug ;; |
pankso@6 | 200 esac |
pankso@6 | 201 |
pankso@6 | 202 exit 0 |
pankso@6 | 203 |