Chameleon

Chameleon Commit Details

Date:2012-01-25 01:15:08 (12 years 3 months ago)
Author:armel cadet-petit
Commit:1810
Parents: 1809
Message:another fix
Changes:
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/libsa/prf.c
M/branches/cparm/i386/libsaio/console.c
M/branches/cparm/i386/modules/GUI/gui.h

File differences

branches/cparm/i386/libsaio/console.c
254254
255255
256256
257
257
258258
259259
260260
char *str = NULL;
va_start(ap, fmt);
len = prf(fmt, ap, NULL, NULL);
len = prf(fmt, ap, 0, 0);
if (len > 0)
{
str = newEmptyStringWithLength(len);
branches/cparm/i386/modules/GUI/gui.c
3434
3535
3636
37
38
39
3740
3841
3942
......
7881
7982
8083
84
85
8186
8287
8388
......
910915
911916
912917
913
918
914919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
915957
916958
917959
918960
919
961
920962
921963
922964
923965
924
925966
926
967
927968
928969
929970
930
971
931972
932973
933974
934975
935976
936977
937
978
938979
939
940
941
942
943980
944981
945
946
982
983
984
985
986
987
988
989
990
991
992
993
947994
948995
949996
950997
951
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
9521009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
9531028
954
1029
9551030
956
957
958
959
960
961
962
963
1031
1032
1033
1034
9641035
965
966
1036
1037
1038
1039
9671040
968
1041
1042
1043
1044
1045
1046
1047
9691048
9701049
9711050
#define DBG(x...)
#endif
themeList_t* themeList = NULL;
gui_t gui;// gui structure
font_t font_small;
font_t font_console;
#endif
static void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected);
static int startGUI(void);
static void free_theme_list();
static void add_theme(const char* theme, uint8_t nb);
static int randomTheme(char *dirspec, const char **theme);
static void loadThemeValues(config_file_t *theme);
static void setupDeviceList(config_file_t *theme);
gui.screen.font_console_color = (color & 0x00FFFFFF);
}
#define MAX_tHEME 255
#define MAX_THEMES 255
static void add_theme(const char* theme, uint8_t nb)
{
themeList_t* new_theme = malloc(sizeof(themeList_t));
if (new_theme)
{
new_theme->next = themeList;
themeList = new_theme;
new_theme->nb = nb;
new_theme->theme = newString(theme);
}
}
static void free_theme_list()
{
themeList_t* entry = themeList;
while(entry)
{
#if DEBUG_GUI
printf("freeing %s (nb = %d)\n", entry->theme, entry->nb);
#endif
char *theme = entry->theme;
themeList_t* tmp = NULL;
tmp = entry;
entry = entry->next;
free(theme);
free(tmp);
}
}
static int randomTheme(char *dirspec, const char **theme) {
long ret, flags, time;
long long index;
int sta = 1;
const char * name;
index = 0;
uint8_t i=0;
char *list[MAX_tHEME];
#ifdef EMBED_THEME
list[i] = "";
add_theme("", i);
i++;
#endif
while (i < MAX_tHEME) {
while (i < MAX_THEMES) {
ret = GetDirEntry(dirspec, &index, &name, &flags, &time);
if (ret == -1) break;
// Make sure this is a directory.
if ((flags & kFileTypeMask) != kFileTypeDirectory) continue;
if ((unsigned)(strlen(name) + 34) > 256) continue;
add_theme(name, i);
if ((list[i] = (char *)malloc(strlen(name))) == NULL) continue;
strcpy(list[i], name);
i++;
}
}
#if DEBUG_GUI
themeList_t* debugentry = themeList;
printf("theme list: \n");
while(debugentry)
{
printf("* %s (nb = %d)\n", debugentry->theme, debugentry->nb);
debugentry = debugentry->next;
}
printf("\n");
#endif
if (i) {
srand (time18());
*theme = list[(rand() % i)];
uint8_t choosen = rand() % i;
themeList_t* entry = themeList;
while(entry)
{
if (entry->nb == choosen) break;
entry = entry->next;
}
if (entry) {
#if DEBUG_GUI
printf("choosen theme %s (nb = %d)\n", entry->theme, entry->nb);
sleep(1);
#endif
*theme = entry->theme;
sta = startGUI();
}
#if DEBUG_GUI
else {
goto out;
}
#endif
int ret = startGUI();
free_theme_list();
uint8_t l=0;
#ifdef EMBED_THEME
l++;
#endif
while (l<i) {
free(list[l]);
l++;
}
}
#if DEBUG_GUI
else {
printf("No theme found !!\n");
return ret;
}
sleep(1);
}
#endif
return sta;
return 1;
#if DEBUG_GUI
out:
printf("random theme failed !!\n");
sleep(1);
#endif
return sta;
}
branches/cparm/i386/modules/GUI/gui.h
4949
5050
5151
52
53
54
55
56
57
5258
5359
5460
VerticalLayout= 1,
};
typedef struct themeList_t
{
char* theme;
unsigned char nb;
struct themeList_t* next;
} themeList_t;
/*
* Menu item structure.
branches/cparm/i386/libsa/prf.c
106106
107107
108108
109
109
110110
111111
112112
......
150150
151151
152152
153
153
154154
155155
156156
......
158158
159159
160160
161
161
162162
163163
164164
165165
166166
167167
168
168
169169
170170
171171
172172
173173
174174
175
175
176176
177177
178178
while ((c = *fmt++) != '%') {
if(c == '\0')
return len;
if (putfn_p && putfn_arg) {
if (putfn_p) {
(*putfn_p)(c, putfn_arg);
}
len++;
case 'o': case 'O':
b = 8;
number:
if (putfn_p && putfn_arg) {
if (putfn_p) {
printn((u_long)*adx, b, flag, minwidth, putfn_p, putfn_arg);
}
len++;
case 's':
s = (char *)*adx;
while ((c = *s++)) {
if (putfn_p && putfn_arg) {
if (putfn_p) {
(*putfn_p)(c, putfn_arg);
}
len++;
width++;
}
while (width++ < minwidth) {
if (putfn_p && putfn_arg) {
if (putfn_p) {
(*putfn_p)(' ', putfn_arg);
}
len++;
}
break;
case 'c':
if (putfn_p && putfn_arg) {
if (putfn_p) {
(*putfn_p)((char)*adx, putfn_arg);
}
len++;

Archive Download the corresponding diff file

Revision: 1810