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