X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Ficontheme.c;h=28643aedb1dca8ac50d1cb00c4ea526ba808cfa2;hp=bcf79601485d2e824e159eaa1fd1a6572600729a;hb=5d2d3f4eea91c74af93c735bff7ad9955b466181;hpb=9f8e0bd23ce7dde31156b634f3a66bf234b11927 diff --git a/webcit/icontheme.c b/webcit/icontheme.c index bcf796014..28643aedb 100644 --- a/webcit/icontheme.c +++ b/webcit/icontheme.c @@ -1,4 +1,3 @@ - /* * Displays and customizes the iconbar. * @@ -29,53 +28,61 @@ HashList *AvailableThemes = NULL; const StrBuf *DefaultTheme = NULL; -void LoadIconthemeSettings(StrBuf * icontheme, long lvalue) { +void LoadIconthemeSettings(StrBuf *icontheme, long lvalue) +{ wcsession *WCC = WC; void *vTheme; const StrBuf *theme; if (GetHash(AvailableThemes, SKEY(icontheme), &vTheme)) - theme = (StrBuf *) vTheme; + theme = (StrBuf*)vTheme; else theme = DefaultTheme; - if (WCC->IconTheme != NULL) + if (WCC->IconTheme != NULL) StrBufPlain(WCC->IconTheme, SKEY(theme)); else WCC->IconTheme = NewStrBufDup(theme); } -void tmplput_icontheme(StrBuf * Target, WCTemplputParams * TP) { +void tmplput_icontheme(StrBuf *Target, WCTemplputParams *TP) +{ wcsession *WCC = WC; - if ((WCC != NULL) && (WCC->IconTheme != NULL)) { - StrBufAppendTemplate(Target, TP, WCC->IconTheme, 0); + if ( (WCC != NULL) && + (WCC->IconTheme != NULL)) + { + StrBufAppendTemplate(Target, TP, WCC->IconTheme, 0); } - else { - StrBufAppendTemplate(Target, TP, DefaultTheme, 0); + else + { + StrBufAppendTemplate(Target, TP, DefaultTheme, 0); } } -int LoadThemeDir(const char *DirName) { +int LoadThemeDir(const char *DirName) +{ StrBuf *Dir = NULL; DIR *filedir = NULL; struct dirent *d; struct dirent *filedir_entry; int d_type = 0; - int d_namelen; - - filedir = opendir(DirName); + int d_namelen; + + filedir = opendir (DirName); if (filedir == NULL) { return 0; } - d = (struct dirent *) malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); + d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1); if (d == NULL) { return 0; } - while ((readdir_r(filedir, d, &filedir_entry) == 0) && (filedir_entry != NULL)) { + while ((readdir_r(filedir, d, &filedir_entry) == 0) && + (filedir_entry != NULL)) + { #ifdef _DIRENT_HAVE_D_NAMELEN d_namelen = filedir_entry->d_namlen; d_type = filedir_entry->d_type; @@ -94,31 +101,37 @@ int LoadThemeDir(const char *DirName) { d_type = DT_UNKNOWN; #endif if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~') - continue; /* Ignore backup files... */ + continue; /* Ignore backup files... */ - if ((d_namelen == 1) && (filedir_entry->d_name[0] == '.')) + if ((d_namelen == 1) && + (filedir_entry->d_name[0] == '.')) continue; - if ((d_namelen == 2) && (filedir_entry->d_name[0] == '.') && (filedir_entry->d_name[1] == '.')) + if ((d_namelen == 2) && + (filedir_entry->d_name[0] == '.') && + (filedir_entry->d_name[1] == '.')) continue; if (d_type == DT_UNKNOWN) { struct stat s; char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%s", DirName, filedir_entry->d_name); + snprintf(path, PATH_MAX, "%s/%s", + DirName, filedir_entry->d_name); if (stat(path, &s) == 0) { d_type = IFTODT(s.st_mode); } } - switch (d_type) { - case DT_LNK: /* TODO: check whether its a file or a directory */ + switch (d_type) + { + case DT_LNK: /* TODO: check whether its a file or a directory */ case DT_DIR: /* Skip directories we are not interested in... */ - if ((strcmp(filedir_entry->d_name, ".svn") == 0) || (strcmp(filedir_entry->d_name, "t") == 0)) + if ((strcmp(filedir_entry->d_name, ".svn") == 0) || + (strcmp(filedir_entry->d_name, "t") == 0)) break; - - Dir = NewStrBufPlain(filedir_entry->d_name, d_namelen); + + Dir = NewStrBufPlain (filedir_entry->d_name, d_namelen); if (DefaultTheme == NULL) DefaultTheme = Dir; Put(AvailableThemes, SKEY(Dir), Dir, HFreeStrBuf); @@ -136,15 +149,20 @@ int LoadThemeDir(const char *DirName) { return 1; } -HashList *GetValidThemeHash(StrBuf * Target, WCTemplputParams * TP) { +HashList *GetValidThemeHash(StrBuf *Target, WCTemplputParams *TP) +{ return AvailableThemes; } - -void ServerStartModule_ICONTHEME(void) { +void +ServerStartModule_ICONTHEME +(void) +{ AvailableThemes = NewHash(1, NULL); } - -void InitModule_ICONTHEME(void) { +void +InitModule_ICONTHEME +(void) +{ StrBuf *Themes = NewStrBufPlain(static_dirs[0], -1); StrBufAppendBufPlain(Themes, HKEY("/"), 0); @@ -155,13 +173,21 @@ void InitModule_ICONTHEME(void) { RegisterPreference("icontheme", _("Icon Theme"), PRF_STRING, LoadIconthemeSettings); RegisterNamespace("ICONTHEME", 0, 0, tmplput_icontheme, NULL, CTX_NONE); - RegisterIterator("PREF:VALID:THEME", 0, NULL, GetValidThemeHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG); + RegisterIterator("PREF:VALID:THEME", 0, NULL, + GetValidThemeHash, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG); } -void ServerShutdownModule_ICONTHEME(void) { +void +ServerShutdownModule_ICONTHEME +(void) +{ DeleteHash(&AvailableThemes); } -void SessionDestroyModule_ICONTHEME(wcsession * sess) { +void +SessionDestroyModule_ICONTHEME +(wcsession *sess) +{ FreeStrBuf(&sess->IconTheme); } +