tazbug annotate tazbug-box @ rev 7
Add data/tazbug.desktop
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Apr 03 12:09:44 2012 +0200 (2012-04-03) |
parents | |
children | 95129e40c9df |
rev | line source |
---|---|
pankso@6 | 1 #!/bin/sh |
pankso@6 | 2 # |
pankso@6 | 3 # SliTaz Bug GUI tool. All the account part 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@6 | 29 --margins=8 --tail $btns --button="gtk-close":1 |
pankso@6 | 30 } |
pankso@6 | 31 |
pankso@6 | 32 # New message box |
pankso@6 | 33 new_msg_main() { |
pankso@6 | 34 yad --form $opts \ |
pankso@6 | 35 --title="Bug message" \ |
pankso@6 | 36 --text="<b>SliTaz Bugs Message</b>" \ |
pankso@6 | 37 --field="$(gettext "Bug ID")":NUM \ |
pankso@6 | 38 --field="$(gettext "Message")":TXT \ |
pankso@6 | 39 --button="$(gettext "Send message"):0" \ |
pankso@6 | 40 --button="gtk-close:1" |
pankso@6 | 41 } |
pankso@6 | 42 |
pankso@6 | 43 # New message main function |
pankso@6 | 44 new_msg() { |
pankso@6 | 45 # Store box results |
pankso@6 | 46 main=$(new_msg_main) |
pankso@6 | 47 ret=$? |
pankso@6 | 48 # Deal with --button values |
pankso@6 | 49 case $ret in |
pankso@6 | 50 1) exit 0 ;; |
pankso@6 | 51 *) continue ;; |
pankso@6 | 52 esac |
pankso@6 | 53 id="$(echo $main | cut -d "|" -f 1 | cut -d "," -f 1)" |
pankso@6 | 54 msg="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 55 if [ "$msg" ]; then |
pankso@6 | 56 tazbug new-msg --bug=$id --msg="$msg" | output |
pankso@6 | 57 fi |
pankso@6 | 58 } |
pankso@6 | 59 |
pankso@6 | 60 # New bug box |
pankso@6 | 61 new_bug_main() { |
pankso@6 | 62 yad --form $opts \ |
pankso@6 | 63 --title="Bug report" \ |
pankso@6 | 64 --text="<b>SliTaz Bug Report</b>" \ |
pankso@6 | 65 --field="$(gettext "Bug title")" \ |
pankso@6 | 66 --field="$(gettext "Priority")":CB \ |
pankso@6 | 67 --field="$(gettext "Packages")" \ |
pankso@6 | 68 --field="$(gettext "Description")":TXT \ |
pankso@6 | 69 --button="$(gettext "My account"):3" \ |
pankso@6 | 70 --button="$(gettext "New message"):2" \ |
pankso@6 | 71 --button="$(gettext "Send bug"):0" \ |
pankso@6 | 72 --button="gtk-close:1" \ |
pankso@6 | 73 "" "standard!critical" "" "" |
pankso@6 | 74 } |
pankso@6 | 75 |
pankso@6 | 76 # New bug main function |
pankso@6 | 77 new_bug() { |
pankso@6 | 78 # Store box results |
pankso@6 | 79 main=$(new_bug_main) |
pankso@6 | 80 ret=$? |
pankso@6 | 81 # Deal with --button values |
pankso@6 | 82 case $ret in |
pankso@6 | 83 1) exit 0 ;; |
pankso@6 | 84 2) $0 new-msg && exit 0 ;; |
pankso@6 | 85 3) $0 account && exit 0 ;; |
pankso@6 | 86 *) continue ;; |
pankso@6 | 87 esac |
pankso@6 | 88 bug="$(echo $main | cut -d "|" -f 1)" |
pankso@6 | 89 desc="$(echo $main | cut -d "|" -f 4)" |
pankso@6 | 90 priority="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 91 pkgs="$(echo $main | cut -d "|" -f 3)" |
pankso@6 | 92 if [ "$bug" ] && [ "$desc" ]; then |
pankso@6 | 93 tazbug new-bug --bug="$bug" --desc="$desc" --priority=$priority \ |
pankso@6 | 94 --pkgs="$pkgs" |
pankso@6 | 95 fi |
pankso@6 | 96 } |
pankso@6 | 97 |
pankso@6 | 98 # Account information. |
pankso@6 | 99 account_info() { |
pankso@6 | 100 . $HOME/.config/slitaz/account.conf |
pankso@6 | 101 echo -e "Name\n$NAME |
pankso@6 | 102 Login\n$LOGIN |
pankso@6 | 103 Mail\n$MAIL |
pankso@6 | 104 Secure key\n$KEY" |
pankso@6 | 105 } |
pankso@6 | 106 |
pankso@6 | 107 # Main GUI box function with pure Yad spec |
pankso@6 | 108 account_main() { |
pankso@6 | 109 account_info | yad --list $opts \ |
pankso@6 | 110 --title="Bugs account" \ |
pankso@6 | 111 --text="<b>SliTaz Bugs Account</b>" \ |
pankso@6 | 112 --column "$(gettext "Account")" \ |
pankso@6 | 113 --column "$(gettext "Value")" \ |
pankso@6 | 114 --dclick-action="" \ |
pankso@6 | 115 --button="$(gettext "Online bugs"):2" \ |
pankso@6 | 116 --button="$(gettext "New bug"):3" \ |
pankso@6 | 117 --button="$(gettext "New message"):4" \ |
pankso@6 | 118 --button="gtk-close:1" |
pankso@6 | 119 } |
pankso@6 | 120 |
pankso@6 | 121 # This is a function, usually the same name as the command if scripts |
pankso@6 | 122 # have multiple commands and options. |
pankso@6 | 123 account() { |
pankso@6 | 124 # Store box results |
pankso@6 | 125 main=$(account_main) |
pankso@6 | 126 ret=$? |
pankso@6 | 127 # Deal with --button values |
pankso@6 | 128 case $ret in |
pankso@6 | 129 1) exit 0 ;; |
pankso@6 | 130 2) browser $WEB_URL && exit 0 ;; |
pankso@6 | 131 3) $0 new-bug && exit 0 ;; |
pankso@6 | 132 4) $0 new-msg && exit 0 ;; |
pankso@6 | 133 *) continue ;; |
pankso@6 | 134 esac |
pankso@6 | 135 } |
pankso@6 | 136 |
pankso@6 | 137 # Signup GUI box function with pure Yad spec |
pankso@6 | 138 signup_main() { |
pankso@6 | 139 yad --form $opts --borders=4 \ |
pankso@6 | 140 --title="Bugs Signup" \ |
pankso@6 | 141 --text="<b>SliTaz Bugs Signup</b>" \ |
pankso@6 | 142 --field="$(gettext "Real name")" \ |
pankso@6 | 143 --field="$(gettext "Login name")" \ |
pankso@6 | 144 --field="$(gettext "Email")" \ |
pankso@6 | 145 --field="$(gettext "Password")":H \ |
pankso@6 | 146 --button="gtk-ok:0" \ |
pankso@6 | 147 --button="gtk-close:1" |
pankso@6 | 148 } |
pankso@6 | 149 |
pankso@6 | 150 # Signup main function |
pankso@6 | 151 signup() { |
pankso@6 | 152 # Store box results |
pankso@6 | 153 main=$(signup_main) |
pankso@6 | 154 ret=$? |
pankso@6 | 155 # Deal with --button values |
pankso@6 | 156 case $ret in |
pankso@6 | 157 1) exit 0 ;; |
pankso@6 | 158 2) browser http://bugs.slitaz.org/ && exit 0 ;; |
pankso@6 | 159 *) continue ;; |
pankso@6 | 160 esac |
pankso@6 | 161 name="$(echo $main | cut -d "|" -f 1)" |
pankso@6 | 162 user="$(echo $main | cut -d "|" -f 2)" |
pankso@6 | 163 mail="$(echo $main | cut -d "|" -f 3)" |
pankso@6 | 164 pass="$(echo $main | cut -d "|" -f 4)" |
pankso@6 | 165 tazbug signup --name="$name" --user=$user --mail=$mail \ |
pankso@6 | 166 --pass="$pass" | output |
pankso@6 | 167 } |
pankso@6 | 168 |
pankso@6 | 169 # |
pankso@6 | 170 # Script commands |
pankso@6 | 171 # |
pankso@6 | 172 |
pankso@6 | 173 case "$1" in |
pankso@6 | 174 usage|help) |
pankso@6 | 175 echo "Usage: $(basename $0) [new-msg|new-bug|account|signup]" ;; |
pankso@6 | 176 new-msg) |
pankso@6 | 177 new_msg ;; |
pankso@6 | 178 account) |
pankso@6 | 179 account ;; |
pankso@6 | 180 signup) |
pankso@6 | 181 signup ;; |
pankso@6 | 182 *) |
pankso@6 | 183 if [ ! $HOME/.config/slitaz/account.conf ]; then |
pankso@6 | 184 signup |
pankso@6 | 185 fi |
pankso@6 | 186 new_bug ;; |
pankso@6 | 187 esac |
pankso@6 | 188 |
pankso@6 | 189 exit 0 |
pankso@6 | 190 |