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