1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 02:25:09 +00:00

okay, i think it's fairly stable now

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@14 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-07-25 01:13:26 +00:00
parent 8da5fae3d6
commit cea3453824
2 changed files with 23 additions and 9 deletions

23
conky.c
View File

@ -86,6 +86,10 @@ int no_buffers;
/* pad percentages to decimals? */ /* pad percentages to decimals? */
static int pad_percents = 0; static int pad_percents = 0;
/* UTF-8 */
int utf8_mode = 0;
/* Text that is shown */ /* Text that is shown */
static char original_text[] = static char original_text[] =
"$nodename - $sysname $kernel on $machine\n" "$nodename - $sysname $kernel on $machine\n"
@ -162,7 +166,12 @@ static inline int calc_text_width(const char *s, unsigned int l)
#ifdef XFT #ifdef XFT
if (use_xft) { if (use_xft) {
XGlyphInfo gi; XGlyphInfo gi;
XftTextExtentsUtf8(display, xftfont, s, l, &gi); if(utf8_mode) {
XftTextExtentsUtf8(display, xftfont, s, l, &gi);
}
else {
XftTextExtents8(display, xftfont, s, l, &gi);
}
return gi.xOff; return gi.xOff;
} else } else
#endif #endif
@ -2181,7 +2190,6 @@ static void draw_string(const char *s)
char space[2]; char space[2];
snprintf(space, 2, " "); snprintf(space, 2, " ");
max = ((text_width-width_of_s)/get_string_width(space)); max = ((text_width-width_of_s)/get_string_width(space));
//printf("width: %i, length: %i, max: %i space: %i\n", text_width, width_of_s, max, get_string_width(space));
/* /*
* This code looks for tabs in the text and coverts them to spaces. * This code looks for tabs in the text and coverts them to spaces.
* The trick is getting the correct number of spaces, * The trick is getting the correct number of spaces,
@ -2221,8 +2229,14 @@ static void draw_string(const char *s)
c2.color.green = c.green; c2.color.green = c.green;
c2.color.blue = c.blue; c2.color.blue = c.blue;
c2.color.alpha = font_alpha; c2.color.alpha = font_alpha;
XftDrawStringUtf8(window.xftdraw, &c2, xftfont, if(utf8_mode) {
cur_x, cur_y, (XftChar8 *) s, strlen(s)); XftDrawStringUtf8(window.xftdraw, &c2, xftfont,
cur_x, cur_y, (XftChar8 *) s, strlen(s));
}
else {
XftDrawString8(window.xftdraw, &c2, xftfont,
cur_x, cur_y, (XftChar8 *) s, strlen(s));
}
} else } else
#endif #endif
{ {
@ -3430,7 +3444,6 @@ else
int main(int argc, char **argv) { int main(int argc, char **argv) {
/* handle command line parameters that don't change configs */ /* handle command line parameters that don't change configs */
char *s; char *s;
int utf8_mode = 0;
if (((s = getenv("LC_ALL")) && *s) || if (((s = getenv("LC_ALL")) && *s) ||
((s = getenv("LC_CTYPE")) && *s) || ((s = getenv("LC_CTYPE")) && *s) ||

View File

@ -90,7 +90,7 @@ void *fetch_ftp( ) {
tries++; tries++;
if ( strlen(metar_station) != 8 ){ if ( strlen(metar_station) != 8 ){
fprintf(stderr,"You didn't supply a valid station code\n"); fprintf(stderr,"You didn't supply a valid station code\n");
return; return NULL;
} }
if (metar_server == NULL) if (metar_server == NULL)
metar_server = strdup("weather.noaa.gov"); metar_server = strdup("weather.noaa.gov");
@ -102,18 +102,18 @@ void *fetch_ftp( ) {
res = connectFtp(metar_server, 0); res = connectFtp(metar_server, 0);
if (res < 0) { if (res < 0) {
fprintf(stderr, "Couldn't connect to %s\n", metar_server); fprintf(stderr, "Couldn't connect to %s\n", metar_server);
return; return NULL;
} }
res = changeFtpDirectory(metar_path); res = changeFtpDirectory(metar_path);
if (res < 0) { if (res < 0) {
fprintf(stderr, "Metar update failed (couldn't CWD to %s)\n", metar_path); fprintf(stderr, "Metar update failed (couldn't CWD to %s)\n", metar_path);
disconnectFtp(); disconnectFtp();
return; return NULL;
} }
if (res == 0) { if (res == 0) {
fprintf(stderr, fprintf(stderr,
"Metar update failed\n"); "Metar update failed\n");
return; return NULL;
} }
if (getFtp(ftpData, NULL, metar_station) < 0) { if (getFtp(ftpData, NULL, metar_station) < 0) {
fprintf(stderr, "Failed to get file %s\n", metar_station); fprintf(stderr, "Failed to get file %s\n", metar_station);
@ -133,6 +133,7 @@ void *fetch_ftp( ) {
} while (ftp_ok == 0 && tries < 3); } while (ftp_ok == 0 && tries < 3);
status = 1; status = 1;
return NULL;
} }
static pthread_t thread1; static pthread_t thread1;