~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to cairo-dock_theme-creator.sh

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
Import upstream version 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# Theme creator for Cairo-Dock
 
4
#
 
5
# Copyright : (C) 2008 by Fabounet
 
6
# E-mail    : fabounet@glx-dock.org
 
7
#
 
8
#
 
9
# This program is free software; you can redistribute it and/or
 
10
# modify it under the terms of the GNU General Public License
 
11
# as published by the Free Software Foundation; either version 2
 
12
# of the License, or (at your option) any later version.
 
13
#
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
# http://www.gnu.org/licenses/licenses.html#GPL
 
19
 
 
20
# Auteur : Nochka85
 
21
# Contact : nochka85@glx-dock.org
 
22
# Version : 05/07/08
 
23
 
 
24
# Changelog
 
25
# 05/07/08 :    Ajout catégorie drive_internet ET specific_vlc_icon
 
26
# 05/07/08 :    Refonte totale du scipt + Ajout de fonctionnalités (choix des catégories dans une liste coché ou décoché)... ;-)
 
27
# 02/07/08 :    Ajout de l'option --test - 1ere mise en ligne sur le FTP ;-)
 
28
# 01/07/08 :    Ajout des catégories specific_firefox_icon, specific_thunderbird_icon, specific_inkscape_icon, specific_gimp_icon, launcher, settings, gohome ET system_search
 
29
# 30/06/08 :    Ajout de catégories + Ajout d'icônes spécifiques + Ajout options --relink --[category] --help 
 
30
# 29/06/08 :    Ajout detection format + répertoire source + amelioration diverse
 
31
# 29/06/08 :    Ebauche du programme
 
32
                
 
33
 
 
34
DEBUG=0 # Attention, ne pas oublier de remettre a 0 pour une MAJ du script ... quand ce sera dispo ;-)
 
35
 
 
36
# ICONS_DIR="/home/$USER/cairo-dock_theme-creator/"  ## Pour moi ;-)
 
37
ICONS_DIR="/home/$USER/.cairo-dock/icons_themes/"
 
38
 
 
39
# MAIN_CAT="web_browser mail_reader video_messenger video_player"  # Encore pour moi :-)
 
40
MAIN_CAT="web_browser file_browser mail_reader image_reader audio_player video_player writer bittorrent downloader cd_burner settings gohome system_search launcher image_editor text_messenger video_messenger terminal packages system_monitor calculator virtual_machine remote_control logo_distribution home_folder default_folder desktop computer webcam irc"
 
41
 
 
42
DRIVES_CAT="drive_usb_mounted drive_usb_unmounted network_folder harddrive drive_optical floppy_unmounted drive_internet"
 
43
 
 
44
#SPECIFICS_CAT="specific_firefox_icon"  # Encore pour moi :-)
 
45
SPECIFICS_CAT="googleearth specific_skype_icon specific_amsn_icon specific_gaim_icon specific_oowriter_icon specific_oodraw_icon specific_oocalc_icon specific_ooimpress_icon specific_oobase_icon specific_oomath_icon specific_update_manager specific_firefox_icon specific_thunderbird_icon specific_inkscape_icon specific_gimp_icon specific_vlc_icon"
 
46
 
 
47
 
 
48
 
 
49
## Catégories MAIN_CAT :
 
50
LINKS_WEB_BROWSER="firefox firefox-3.0 opera epiphany"
 
51
LINKS_FILE_BROWSER="nautilus konqueror thunar pcmanfm"
 
52
LINKS_MAIL_READER="thunderbird kmail evolution"
 
53
LINKS_IMAGE_READER="eog gqview gwenview f-spot"
 
54
LINKS_AUDIO_PLAYER="rhythmbox exaile xmms listen audacious beep-media-player bmp amarok"
 
55
LINKS_VIDEO_PLAYER="totem mplayer vlc xine kaffeine smplayer"
 
56
LINKS_WRITER="gedit kate oowriter ooo-writer abiword emacs mousepad"
 
57
LINKS_BITTORRENT="transmission deluge bittornado gnome-btdownload ktorrent"
 
58
LINKS_DOWNLOADER="amule emule filezilla"
 
59
LINKS_CD_BURNER="nautilus-burner graveman k3b brasero gnomebaker"
 
60
LINKS_SETTINGS="gnome-settings"
 
61
LINKS_GOHOME="gohome"
 
62
LINKS_SYSTEM_SEARCH="system-search tracker-search-tool"
 
63
LINKS_LAUNCHER="gnome-panel-launcher"
 
64
LINKS_IMAGE_EDITOR="gimp inkscape krita"
 
65
LINKS_TEXT_MESSENGER="gaim pidgin kopete emessene"
 
66
LINKS_VIDEO_MESSENGER="skype ekiga amsn"
 
67
LINKS_TERMINAL="gnome-terminal konsole xfce4-terminal"
 
68
LINKS_PACKAGES="synaptic adept pacman-g2 update-manager"
 
69
LINKS_SYSTEM_MONITOR="ksysguard gnome-system-monitor utilities-system-monitor conky"
 
70
LINKS_CALCULATOR="gnome-calculator accessories-calculator gcalctool crunch"
 
71
LINKS_VIRTUAL_MACHINE="VBox vmware-server"
 
72
LINKS_REMOTE_CONTROL="tsclient"
 
73
LINKS_LOGO_DISTRIBUTION="distributor-logo gnome-main-menu start-here"
 
74
LINKS_HOME_FOLDER="user-home gnome-fs-home folder_home"
 
75
LINKS_DEFAULT_FOLDER="folder gnome-fs-directory"
 
76
LINKS_DESKTOP="desktop"
 
77
LINKS_COMPUTER="computer"
 
78
LINKS_WEBCAM="cheese"
 
79
LINKS_IRC="xchat konversation kvirc"
 
80
 
 
81
## Catégories DRIVES_CAT :
 
82
LINKS_DRIVE_USB_MOUNTED="drive-harddisk-usb"
 
83
LINKS_DRIVE_USB_UNMOUNTED="drive-removable-media-usb"
 
84
LINKS_NETWORK_FOLDER="network folder-remote"
 
85
LINKS_HARDDRIVE="gnome-dev-harddisk drive-harddisk"
 
86
LINKS_DRIVE_OPTICAL="drive-optical"
 
87
LINKS_FLOPPY_UNMOUNTED="drive-removable-media"
 
88
LINKS_DRIVE_INTERNET="applications-internet gnome-globe package_network redhat-internet stock_internet xfce-internet"
 
89
 
 
90
## Catégories SPECIFICS_CAT :
 
91
LINKS_GOOGLEEARTH="googleearth"
 
92
LINKS_SPECIFIC_SKYPE_ICON="skype"
 
93
LINKS_SPECIFIC_AMSN_ICON="amsn"
 
94
LINKS_SPECIFIC_GAIM_ICON="gaim"
 
95
LINKS_SPECIFIC_OOWRITER_ICON="oowriter ooo-writer"
 
96
LINKS_SPECIFIC_OODRAW_ICON="oodraw ooo-draw"
 
97
LINKS_SPECIFIC_OOCALC_ICON="oocalc ooo-calc"
 
98
LINKS_SPECIFIC_OOIMPRESS_ICON="ooimpress ooo-impress"
 
99
LINKS_SPECIFIC_OOBASE_ICON="oobase ooo-base"
 
100
LINKS_SPECIFIC_OOMATH_ICON="oomath ooo-math"
 
101
LINKS_SPECIFIC_UPDATE_MANAGER="update-manager"
 
102
LINKS_SPECIFIC_FIREFOX_ICON="firefox firefox-3.0"
 
103
LINKS_SPECIFIC_THUNDERBIRD_ICON="thunderbird"
 
104
LINKS_SPECIFIC_INKSCAPE_ICON="inkscape"
 
105
LINKS_SPECIFIC_GIMP_ICON="gimp"
 
106
LINKS_SPECIFIC_VLC_ICON="vlc"
 
107
 
 
108
 
 
109
 
 
110
 
 
111
 
 
112
 
 
113
 
 
114
SCRIPT="cairo-dock_theme-creator.sh"            #OK
 
115
SCRIPT_SAVE="cairo-dock_theme-creator.sh.save"  #OK
 
116
SCRIPT_NEW="cairo-dock_theme-creator.sh.new"    #OK
 
117
HOST="http://theme_creator.glx-dock.org"        #OK
 
118
 
 
119
 
 
120
 
 
121
 
 
122
IFS=" "                         #OK
 
123
START_MENU=""                   #OK
 
124
TODO_LIST=""                    #OK
 
125
TODO_FINAL=""                   #OK
 
126
THEME_NAME=""                   #OK
 
127
WORK_DIR=""                     #OK
 
128
LINKS=""                        #OK
 
129
CURRENT_ICON=""                 #OK
 
130
START_DIR="/home/$USER/"        #OK
 
131
REDO_DIR=""                     #OK
 
132
GLOBAL_NAME=""                  #OK
 
133
FILENAME=""                     #OK
 
134
FORMAT=""                       #OK
 
135
DETAIL_LIST=""                  #OK
 
136
TRUE_FALSE=""                   #OK
 
137
TEST_FILE="test_links.log"      #OK
 
138
LOG_FILE="log.txt"
 
139
 
 
140
 
 
141
NORMAL="\\033[0;39m"
 
142
BLEU="\\033[1;34m"
 
143
VERT="\\033[1;32m" 
 
144
ROUGE="\\033[1;31m"
 
145
 
 
146
 
 
147
#############################################################################################################
 
148
links_definition() {
 
149
## Catégories MAIN_CAT :
 
150
        if [ $current_category = "web_browser" ]; then LINKS=$LINKS_WEB_BROWSER;
 
151
        elif [ $current_category = "file_browser" ]; then LINKS=$LINKS_FILE_BROWSER;
 
152
        elif [ $current_category = "mail_reader" ]; then LINKS=$LINKS_MAIL_READER;
 
153
        elif [ $current_category = "image_reader" ]; then LINKS=$LINKS_IMAGE_READER;
 
154
        elif [ $current_category = "audio_player" ]; then LINKS=$LINKS_AUDIO_PLAYER;
 
155
        elif [ $current_category = "video_player" ]; then LINKS=$LINKS_VIDEO_PLAYER;
 
156
        elif [ $current_category = "writer" ]; then LINKS=$LINKS_WRITER;
 
157
        elif [ $current_category = "bittorrent" ]; then LINKS=$LINKS_BITTORRENT;
 
158
        elif [ $current_category = "downloader" ]; then LINKS=$LINKS_DOWNLOADER;
 
159
        elif [ $current_category = "cd_burner" ]; then LINKS=$LINKS_CD_BURNER;
 
160
        elif [ $current_category = "settings" ]; then LINKS=$LINKS_SETTINGS;
 
161
        elif [ $current_category = "gohome" ]; then LINKS=$LINKS_GOHOME;
 
162
        elif [ $current_category = "system_search" ]; then LINKS=$LINKS_SYSTEM_SEARCH;
 
163
        elif [ $current_category = "launcher" ]; then LINKS=$LINKS_LAUNCHER;
 
164
        elif [ $current_category = "image_editor" ]; then LINKS=$LINKS_IMAGE_EDITOR;
 
165
        elif [ $current_category = "text_messenger" ]; then LINKS=$LINKS_TEXT_MESSENGER;
 
166
        elif [ $current_category = "video_messenger" ]; then LINKS=$LINKS_VIDEO_MESSENGER;
 
167
        elif [ $current_category = "terminal" ]; then LINKS=$LINKS_TERMINAL;
 
168
        elif [ $current_category = "packages" ]; then LINKS=$LINKS_PACKAGES;
 
169
        elif [ $current_category = "system_monitor" ]; then LINKS=$LINKS_SYSTEM_MONITOR;
 
170
        elif [ $current_category = "calculator" ]; then LINKS=$LINKS_CALCULATOR;
 
171
        elif [ $current_category = "virtual_machine" ]; then LINKS=$LINKS_VIRTUAL_MACHINE;
 
172
        elif [ $current_category = "remote_control" ]; then LINKS=$LINKS_REMOTE_CONTROL;
 
173
        elif [ $current_category = "logo_distribution" ]; then LINKS=$LINKS_LOGO_DISTRIBUTION;
 
174
        elif [ $current_category = "home_folder" ]; then LINKS=$LINKS_HOME_FOLDER;
 
175
        elif [ $current_category = "default_folder" ]; then LINKS=$LINKS_DEFAULT_FOLDER;
 
176
        elif [ $current_category = "desktop" ]; then LINKS=$LINKS_DESKTOP;
 
177
        elif [ $current_category = "computer" ]; then LINKS=$LINKS_COMPUTER;
 
178
        elif [ $current_category = "webcam" ]; then LINKS=$LINKS_WEBCAM;
 
179
        elif [ $current_category = "irc" ]; then LINKS=$LINKS_IRC;
 
180
 
 
181
 
 
182
## Catégories DRIVES_CAT :
 
183
        elif [ $current_category = "drive_usb_mounted" ]; then LINKS=$LINKS_DRIVE_USB_MOUNTED;
 
184
        elif [ $current_category = "drive_usb_unmounted" ]; then LINKS=$LINKS_DRIVE_USB_UNMOUNTED;
 
185
        elif [ $current_category = "network_folder" ]; then LINKS=$LINKS_NETWORK_FOLDER;
 
186
        elif [ $current_category = "harddrive" ]; then LINKS=$LINKS_HARDDRIVE;
 
187
        elif [ $current_category = "drive_optical" ]; then LINKS=$LINKS_DRIVE_OPTICAL;
 
188
        elif [ $current_category = "floppy_unmounted" ]; then LINKS=$LINKS_FLOPPY_UNMOUNTED;
 
189
        elif [ $current_category = "drive_internet" ]; then LINKS=$LINKS_DRIVE_INTERNET;
 
190
 
 
191
## Catégories SPECIFICS_CAT :
 
192
        elif [ $current_category = "googleearth" ]; then LINKS=$LINKS_GOOGLEEARTH;
 
193
        elif [ $current_category = "specific_skype_icon" ]; then LINKS=$LINKS_SPECIFIC_SKYPE_ICON;
 
194
        elif [ $current_category = "specific_amsn_icon" ]; then LINKS=$LINKS_SPECIFIC_AMSN_ICON;
 
195
        elif [ $current_category = "specific_gaim_icon" ]; then LINKS=$LINKS_SPECIFIC_GAIM_ICON;
 
196
        elif [ $current_category = "specific_oowriter_icon" ]; then LINKS=$LINKS_SPECIFIC_OOWRITER_ICON;
 
197
        elif [ $current_category = "specific_oodraw_icon" ]; then LINKS=$LINKS_SPECIFIC_OODRAW_ICON;
 
198
        elif [ $current_category = "specific_oocalc_icon" ]; then LINKS=$LINKS_SPECIFIC_OOCALC_ICON;
 
199
        elif [ $current_category = "specific_ooimpress_icon" ]; then LINKS=$LINKS_SPECIFIC_OOIMPRESS_ICON;
 
200
        elif [ $current_category = "specific_oobase_icon" ]; then LINKS=$LINKS_SPECIFIC_OOBASE_ICON;
 
201
        elif [ $current_category = "specific_oomath_icon" ]; then LINKS=$LINKS_SPECIFIC_OOMATH_ICON;
 
202
        elif [ $current_category = "specific_update_manager" ]; then LINKS=$LINKS_SPECIFIC_UPDATE_MANAGER;
 
203
        elif [ $current_category = "specific_firefox_icon" ]; then LINKS=$LINKS_SPECIFIC_FIREFOX_ICON;
 
204
        elif [ $current_category = "specific_thunderbird_icon" ]; then LINKS=$LINKS_SPECIFIC_THUNDERBIRD_ICON;
 
205
        elif [ $current_category = "specific_inkscape_icon" ]; then LINKS=$LINKS_SPECIFIC_INKSCAPE_ICON;
 
206
        elif [ $current_category = "specific_gimp_icon" ]; then LINKS=$LINKS_SPECIFIC_GIMP_ICON;
 
207
        elif [ $current_category = "specific_vlc_icon" ]; then LINKS=$LINKS_SPECIFIC_VLC_ICON;
 
208
        fi
 
209
}
 
210
 
 
211
 
 
212
#############################################################################################################
 
213
check_new_script() {
 
214
        cp $SCRIPT $SCRIPT_SAVE #pour moi :)
 
215
        echo -e "$NORMAL"""
 
216
        echo "Vérification de la disponibilité d'un nouveau script"
 
217
        wget $HOST/$SCRIPT -q -O $SCRIPT_NEW    
 
218
        diff $SCRIPT $SCRIPT_NEW >/dev/null
 
219
        if [ $? -eq 1 ]; then
 
220
                echo -e "$ROUGE"                
 
221
                echo "Veuillez relancer le script, une mise à jour a été téléchargée"
 
222
                echo -e "$NORMAL"
 
223
                mv $SCRIPT_NEW $SCRIPT
 
224
                chmod u+x $SCRIPT
 
225
                zenity --info --title="Cairo-Dock Theme Creator" --text="Une mise à jour a été téléchargée.     Cliquez sur Ok pour fermer le terminal."
 
226
                exit
 
227
        else
 
228
                echo ""
 
229
                echo -e "$VERT""Vous possédez la dernière version du script de Nochka85"
 
230
        fi
 
231
        echo -e "$NORMAL"
 
232
        rm $SCRIPT_NEW
 
233
}
 
234
 
 
235
 
 
236
#############################################################################################################
 
237
start_menu() {
 
238
# Remise à zéro des variables:
 
239
IFS=" "
 
240
START_MENU=""                   #OK
 
241
TODO_LIST=""                    #OK
 
242
TODO_FINAL=""                   #OK
 
243
THEME_NAME=""                   #OK
 
244
WORK_DIR=""                     #OK
 
245
LINKS=""                        #OK
 
246
CURRENT_ICON=""                 #OK
 
247
START_DIR="/home/$USER/"        #OK
 
248
REDO_DIR=""                     #OK
 
249
GLOBAL_NAME=""                  #OK
 
250
FILENAME=""                     #OK
 
251
FORMAT=""                       #OK
 
252
DETAIL_LIST=""                  #OK
 
253
TRUE_FALSE=""                   #OK
 
254
 
 
255
 
 
256
 
 
257
 
 
258
 
 
259
 
 
260
START_MENU=$(zenity --width=800 --height=400 --list --separator " " --column="Choix" --column="Action" --column="Observation" --radiolist --text="Choisissez l'action à effectuer (Cliquez sur "Annuler" pour quitter) :" --title="CD Theme Creator" \
 
261
true "NOUVEAU THEME D'ICÔNES" "Créez un nouveau thème d'icônes standard pour Cairo-dock" \
 
262
false "Re-créer les liens d'un thème d'icônes standard" "A effectuer en cas de liens cassés et/ou manquants dans un thème d'icônes créé avec ce script" \
 
263
false "Sélectionner les catégories dans une liste" "Sélectionnez vous même les catégories à traiter dans une liste (TOUT DECOCHE par défaut)" \
 
264
false "Désélectionner les catégories dans une liste" "Sélectionnez vous même les catégories à traiter dans une liste (TOUT COCHE par défaut)" \
 
265
false "Tester ou contrôler un thème d'icônes existant" "Retrouvez facilement les catégories et les liens qu'il manque à votre thème d'icônes")
 
266
 
 
267
 
 
268
if [ "$START_MENU" = "" ]; then 
 
269
        exit
 
270
else
 
271
        IFS="|"
 
272
        for temp in $START_MENU
 
273
                do
 
274
 
 
275
                if [ $temp = "NOUVEAU THEME D'ICÔNES" ]; then
 
276
                        new_theme
 
277
                        start_menu
 
278
                                                
 
279
                elif [ $temp = "Re-créer les liens d'un thème d'icônes standard" ]; then
 
280
                        relink
 
281
                        start_menu
 
282
 
 
283
                elif [ $temp = "Sélectionner les catégories dans une liste" ]; then 
 
284
                        select_false
 
285
                        start_menu
 
286
 
 
287
                elif [ $temp = "Désélectionner les catégories dans une liste" ]; then
 
288
                        select_true
 
289
                        start_menu
 
290
 
 
291
                elif [ $temp = "Tester ou contrôler un thème d'icônes existant" ]; then
 
292
                        do_report
 
293
                        start_menu
 
294
 
 
295
                fi
 
296
                done
 
297
fi
 
298
IFS=" "
 
299
}
 
300
 
 
301
#############################################################################################################
 
302
new_theme() {
 
303
choose_category         # Definition de $TODO_FINAL
 
304
working_directory       # Definition du nom du répertoire $WORK_DIR
 
305
new_directory           # Création du nouveau répertoire
 
306
cd $WORK_DIR
 
307
REDO_DIR="$START_DIR"
 
308
copy_categories         # Copie des icônes des différentes catégories                   
 
309
relink_icons            # Création des liens
 
310
zenity --info --title="CD Theme Creator" --text="Votre thème a été créé dans le répertoire:\n$WORK_DIR"
 
311
}
 
312
 
 
313
#############################################################################################################
 
314
relink() {
 
315
tempo_text="Spécifier le répertoire dans lequel re-créer les liens"
 
316
todo_relink
 
317
relink_icons
 
318
zenity --info --title="CD Theme Creator" --text="Tous les liens ont été re-créés dans :\n$WORK_DIR\n\nCliquer sur Valider pour revenir au menu principal..."
 
319
}
 
320
 
 
321
#############################################################################################################
 
322
select_false() {
 
323
TRUE_FALSE="FALSE"
 
324
select_true_false
 
325
}
 
326
 
 
327
#############################################################################################################
 
328
select_true() {
 
329
TRUE_FALSE="TRUE"
 
330
select_true_false
 
331
}
 
332
 
 
333
#############################################################################################################
 
334
select_true_false() {
 
335
choose_category
 
336
detail_list             # Definition de $TODO_FINAL et $WORK_DIR
 
337
cd $WORK_DIR
 
338
REDO_DIR="$START_DIR"
 
339
copy_categories         # Copie des icônes des différentes catégories                   
 
340
relink_icons            # Création des liens
 
341
zenity --info --title="CD Theme Creator" --text="Toutes les catégories sélectionnées ont été créés dans le répertoire:\n$WORK_DIR"
 
342
}
 
343
 
 
344
 
 
345
#############################################################################################################
 
346
choose_category() {
 
347
IFS=" "
 
348
TODO_LIST=$(zenity --width=750 --height=400 --list --column="Choix" --column="Catégories" --column="Observation" --checklist --text="Choisissez les catégories d'icônes à traiter\n\nATTENTION : Les icônes génériques sont OBLIGATOIRES\n" --title="CD Theme Creator" \
 
349
true "Icônes génériques" "Ce sont les icônes OBLIGATOIRES pour un thème standard cairo-dock" \
 
350
false "Icônes des VOLUMES" "Conseillés pour certaines applets de cairo-dock" \
 
351
false "Icônes spécifiques" "Permettent de "surcharger" les icônes génériques pour certaines applications (exemple : Firefox, Thunderbird,etc...)")
 
352
 
 
353
if [ "$TODO_LIST" = "" ]; then start_menu
 
354
 
 
355
else
 
356
        IFS="|"
 
357
        for temp in $TODO_LIST
 
358
                do
 
359
 
 
360
                if [ $temp = "Icônes génériques" ]; then 
 
361
                                                for categorie in $MAIN_CAT
 
362
                                                        do 
 
363
                                                                TODO_FINAL="$TODO_FINAL$categorie "
 
364
                                                        done
 
365
 
 
366
                elif [ $temp = "Icônes des VOLUMES" ]; then 
 
367
                                                for categorie in $DRIVES_CAT
 
368
                                                        do 
 
369
                                                                TODO_FINAL="$TODO_FINAL$categorie "
 
370
                                                        done
 
371
                
 
372
                elif [ $temp = "Icônes spécifiques" ]; then 
 
373
                                                for categorie in $SPECIFICS_CAT
 
374
                                                        do 
 
375
                                                                TODO_FINAL="$TODO_FINAL$categorie "
 
376
                                                        done
 
377
                fi
 
378
                done
 
379
fi
 
380
IFS=" "
 
381
}
 
382
 
 
383
 
 
384
#############################################################################################################
 
385
working_directory() {
 
386
THEME_NAME=$(zenity --entry --title="CD Theme Creator" --text="Entrez le nom de votre thème d'icônes (il sera placé dans $ICONS_DIR)")
 
387
if [ "$THEME_NAME" = "" ]; then
 
388
                                zenity --error --text "Aucun nom n'a été rentré ou l'opération a été annulée..."
 
389
                                TODO_FINAL=""
 
390
                                start_menu
 
391
else
 
392
WORK_DIR="$ICONS_DIR$THEME_NAME"/
 
393
fi
 
394
}
 
395
 
 
396
 
 
397
#############################################################################################################
 
398
new_directory() {
 
399
 if test -e $ICONS_DIR$THEME_NAME; then
 
400
                zenity --error --text "Le répertoire $THEME_NAME existe déjà dans \n $ICONS_DIR\nVeuillez entrer un autre nom pour votre thème d'icônes..."
 
401
                working_directory
 
402
                new_directory
 
403
 else
 
404
        mkdir -p $WORK_DIR
 
405
 fi
 
406
}
 
407
 
 
408
#############################################################################################################
 
409
copy_categories() {
 
410
for current_category in $TODO_FINAL
 
411
                do
 
412
                        choose_icon
 
413
                        if [ "$CURRENT_ICON" != "" ]; then
 
414
                                rm -f $WORK_DIR.$current_category.*
 
415
                                cp -f $CURRENT_ICON $WORK_DIR.$current_category.$FORMAT
 
416
                        fi
 
417
                done
 
418
}
 
419
 
 
420
 
 
421
#############################################################################################################
 
422
choose_icon() {
 
423
        zenity --info --title="CD Theme Creator" --text="Choisissez une image pour "$current_category"\n\nAnnuler pour passer\n"
 
424
        CURRENT_ICON=$(zenity --file-selection --filename $REDO_DIR --title="CD Theme Creator - Image "$current_category)
 
425
        if [ "$CURRENT_ICON" != "" ]; then
 
426
                REDO_DIR=`dirname $CURRENT_ICON`/               # Répertoire de l'icône
 
427
                GLOBAL_NAME=`basename $CURRENT_ICON`            # Nom de l'image avec son extension
 
428
                FILENAME=${GLOBAL_NAME%.*}                      # Nom du fichier SANS extension
 
429
                FORMAT=${GLOBAL_NAME##*.}                       # Extension SEULE
 
430
        fi
 
431
}
 
432
 
 
433
 
 
434
#############################################################################################################
 
435
todo_relink() {
 
436
TODO_FINAL=""
 
437
for categorie in $MAIN_CAT
 
438
        do 
 
439
                TODO_FINAL="$TODO_FINAL$categorie "
 
440
        done
 
441
 
 
442
for categorie in $DRIVES_CAT
 
443
        do 
 
444
                TODO_FINAL="$TODO_FINAL$categorie "
 
445
        done
 
446
 
 
447
for categorie in $SPECIFICS_CAT
 
448
        do 
 
449
                TODO_FINAL="$TODO_FINAL$categorie "
 
450
        done
 
451
 
 
452
zenity --info --title="CD Theme Creator" --text="$tempo_text"
 
453
WORK_DIR=$(zenity --file-selection --filename $ICONS_DIR --directory --title="CD Theme Creator")/
 
454
 
 
455
if [ "$WORK_DIR" = "/" ]; then
 
456
                                zenity --error --text "L'opération a été annulée..."
 
457
                                TODO_FINAL=""
 
458
                                start_menu
 
459
fi
 
460
}
 
461
 
 
462
 
 
463
 
 
464
#############################################################################################################
 
465
relink_icons() {
 
466
IFS=" "
 
467
        for current_category in $TODO_FINAL
 
468
                do
 
469
                        for FORMAT in "svg" "png"
 
470
                                do
 
471
                                        if test -e $WORK_DIR.$current_category.$FORMAT; then
 
472
                                                cd $WORK_DIR
 
473
                                                links_definition
 
474
                                                for links in $LINKS
 
475
                                                        do
 
476
                                                                rm -f $links.*
 
477
                                                                ln -s -f .$current_category.$FORMAT $links.$FORMAT
 
478
                                                        done
 
479
                                        fi
 
480
                                done
 
481
                done
 
482
}
 
483
 
 
484
 
 
485
 
 
486
#############################################################################################################
 
487
detail_list() {
 
488
DETAIL_LIST=""
 
489
for current_category in $TODO_FINAL
 
490
        do
 
491
                links_definition
 
492
                temp=""
 
493
                for links in $LINKS
 
494
                        do
 
495
                        temp="$temp[$links]"
 
496
                        done
 
497
 
 
498
                DETAIL_LIST="$DETAIL_LIST$TRUE_FALSE $current_category $temp "
 
499
        done
 
500
 
 
501
TODO_FINAL=""
 
502
TODO_FINAL=$(zenity --width=750 --height=400 --list --column="Choix" --column="Catégories" --column="Liste des applications concernées" --checklist --text="Choisissez les catégories d'icônes à traiter\n\nATTENTION : Les icônes génériques sont OBLIGATOIRES\n" --title="CD Theme Creator" $DETAIL_LIST)
 
503
DETAIL_LIST="$TODO_FINAL"
 
504
TODO_FINAL=""
 
505
IFS="|"
 
506
for temp in $DETAIL_LIST
 
507
        do
 
508
                TODO_FINAL="$TODO_FINAL$temp "
 
509
        done
 
510
IFS=" "
 
511
 
 
512
if [ "$TODO_FINAL" = "" ]; then
 
513
                                zenity --error --text "Aucune catégorie n'a été sélectionnée ou l'opération a été annulée..."
 
514
                                TODO_FINAL=""
 
515
                                start_menu
 
516
fi
 
517
 
 
518
 
 
519
 
 
520
zenity --info --title="CD Theme Creator" --text="Spécifier le répertoire dans lequel (re-)créer les liens"
 
521
WORK_DIR=$(zenity --file-selection --filename $ICONS_DIR --directory --title="CD Theme Creator")/
 
522
 
 
523
 
 
524
if [ "$WORK_DIR" = "/" ]; then
 
525
                                zenity --error --text "Aucun répertoire n'a été spécifié ou l'opération a été annulée..."
 
526
                                TODO_FINAL=""
 
527
                                start_menu
 
528
fi
 
529
 
 
530
 
 
531
}
 
532
 
 
533
 
 
534
#############################################################################################################
 
535
do_report() {
 
536
tempo_text="Spécifier le répertoire où tester les liens"
 
537
todo_relink             # Definition $TODO_FINAL et $WORK_DIR
 
538
cd $WORK_DIR
 
539
rm -f $TEST_FILE
 
540
IFS=" "
 
541
 
 
542
for current_category in $TODO_FINAL
 
543
        do
 
544
                for FORMAT in "png" "svg"
 
545
                        do
 
546
                                if test -e .$current_category.$FORMAT; then
 
547
                                        echo "OK : La categorie $current_category EXISTE au format $FORMAT">>$TEST_FILE
 
548
                                        CURRENT=.$current_category.$FORMAT
 
549
                                        links_definition
 
550
                                        for links in $LINKS
 
551
                                                do
 
552
                                                        if test -e $links.$FORMAT; then
 
553
                                                                cd $WORK_DIR
 
554
                                                        else
 
555
                                                                echo "          ATTENTION : le lien $links.$FORMAT est absent de la categorie $current_category">>$TEST_FILE
 
556
                                                        fi
 
557
                                                done
 
558
                                else
 
559
                                        echo "La categorie $current_category n'a pas ete creee en $FORMAT">>$TEST_FILE
 
560
                                fi
 
561
                        done
 
562
                echo "">>$TEST_FILE
 
563
                echo "">>$TEST_FILE
 
564
        done
 
565
 
 
566
zenity --info --title="CD Theme Creator" --text="Un fichier de rapport $TEST_FILE a été créé dans $WORK_DIR\nCliquer sur Valider pour continuer"
 
567
cat $TEST_FILE | zenity --text-info --title="CD Theme Creator - $TEST_FILE" --width 550 --height=700
 
568
}
 
569
 
 
570
 
 
571
 
 
572
 
 
573
#############################################################################################################
 
574
# DEBUT DU PROGRAMME
 
575
#############################################################################################################
 
576
 
 
577
 
 
578
if [ $DEBUG -ne 1 ]; then
 
579
        check_new_script
 
580
fi
 
581
 
 
582
 
 
583
case $1 in
 
584
 
 
585
        "--help")
 
586
                echo -e "$VERT""Usage:"         
 
587
                echo -e "$NORMAL""$0""$VERT""                           Créer un nouveau thème" 
 
588
                echo -e "$NORMAL""$0 --relink""$VERT""                  Re-créer les liens dans un répertoire avec des liens cassés"
 
589
                echo -e "$NORMAL""$0 --choose_all""$VERT""              Specifier la (ou les) catégorie(s) à traiter (Tout coché par défaut)"
 
590
                echo -e "$NORMAL""$0 --choose_none""$VERT""             Specifier la (ou les) catégorie(s) à traiter (Tout décoché par défaut)"
 
591
                echo -e "$NORMAL""$0 --test""$VERT""                    Vérifier qu'un thème est complet"
 
592
                echo -e "$NORMAL""$0 --help""$VERT""                    Afficher ce menu d'aide "
 
593
                echo ""
 
594
                echo ""
 
595
                echo -e "$NORMAL""Auteur : Nochka85"
 
596
                echo -e "$NORMAL""Contact : nochka85@glx-dock.org"
 
597
                echo ""
 
598
                exit
 
599
        ;;
 
600
 
 
601
        "--relink")
 
602
                relink
 
603
                exit
 
604
        ;;
 
605
 
 
606
        "--choose_all")
 
607
                select_true
 
608
                exit
 
609
        ;;
 
610
 
 
611
        "--choose_none")
 
612
                select_false
 
613
                exit
 
614
        ;;
 
615
                
 
616
        "--test")
 
617
                do_report
 
618
                exit
 
619
        ;;
 
620
esac
 
621
 
 
622
start_menu
 
623
exit
 
624
 
 
625
 
 
626