1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-29 05:12:41 +00:00

convert mpd objects to callbacks.free

This commit is contained in:
Phil Sutter 2009-11-29 20:58:37 +01:00
parent 4c4a7c4096
commit 6fb5302778
3 changed files with 21 additions and 23 deletions

View File

@ -1177,61 +1177,78 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
mpd_set_maxlen(mpd_artist); mpd_set_maxlen(mpd_artist);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_artist; obj->callbacks.print = &print_mpd_artist;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_title, &update_mpd) END OBJ(mpd_title, &update_mpd)
mpd_set_maxlen(mpd_title); mpd_set_maxlen(mpd_title);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_title; obj->callbacks.print = &print_mpd_title;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_random, &update_mpd) END OBJ(mpd_random, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_random; obj->callbacks.print = &print_mpd_random;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_repeat, &update_mpd) END OBJ(mpd_repeat, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_repeat; obj->callbacks.print = &print_mpd_repeat;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_elapsed, &update_mpd) END OBJ(mpd_elapsed, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_elapsed; obj->callbacks.print = &print_mpd_elapsed;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_length, &update_mpd) END OBJ(mpd_length, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_length; obj->callbacks.print = &print_mpd_length;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_track, &update_mpd) END OBJ(mpd_track, &update_mpd)
mpd_set_maxlen(mpd_track); mpd_set_maxlen(mpd_track);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_track; obj->callbacks.print = &print_mpd_track;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_name, &update_mpd) END OBJ(mpd_name, &update_mpd)
mpd_set_maxlen(mpd_name); mpd_set_maxlen(mpd_name);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_name; obj->callbacks.print = &print_mpd_name;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_file, &update_mpd) END OBJ(mpd_file, &update_mpd)
mpd_set_maxlen(mpd_file); mpd_set_maxlen(mpd_file);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_file; obj->callbacks.print = &print_mpd_file;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_percent, &update_mpd) END OBJ(mpd_percent, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.percentage = &mpd_percentage; obj->callbacks.percentage = &mpd_percentage;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_album, &update_mpd) END OBJ(mpd_album, &update_mpd)
mpd_set_maxlen(mpd_album); mpd_set_maxlen(mpd_album);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_album; obj->callbacks.print = &print_mpd_album;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_vol, &update_mpd) END OBJ(mpd_vol, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_vol; obj->callbacks.print = &print_mpd_vol;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_bitrate, &update_mpd) END OBJ(mpd_bitrate, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_bitrate; obj->callbacks.print = &print_mpd_bitrate;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_status, &update_mpd) END OBJ(mpd_status, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_status; obj->callbacks.print = &print_mpd_status;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_bar, &update_mpd) END OBJ(mpd_bar, &update_mpd)
scan_bar(obj, arg); scan_bar(obj, arg);
init_mpd(); init_mpd();
obj->callbacks.barval = &mpd_barval; obj->callbacks.barval = &mpd_barval;
obj->callbacks.free = &free_mpd;
END OBJ(mpd_smart, &update_mpd) END OBJ(mpd_smart, &update_mpd)
mpd_set_maxlen(mpd_smart); mpd_set_maxlen(mpd_smart);
init_mpd(); init_mpd();
obj->callbacks.print = &print_mpd_smart; obj->callbacks.print = &print_mpd_smart;
obj->callbacks.free = &free_mpd;
END OBJ_IF(if_mpd_playing, &update_mpd) END OBJ_IF(if_mpd_playing, &update_mpd)
init_mpd(); init_mpd();
obj->callbacks.iftest = &check_mpd_playing; obj->callbacks.iftest = &check_mpd_playing;
obj->callbacks.free = &free_mpd;
#undef mpd_set_maxlen #undef mpd_set_maxlen
#endif /* MPD */ #endif /* MPD */
#ifdef MOC #ifdef MOC
@ -1859,27 +1876,6 @@ void free_text_objects(struct text_object *root, int internal)
free_top(obj, internal); free_top(obj, internal);
break; break;
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef MPD
case OBJ_mpd_title:
case OBJ_mpd_artist:
case OBJ_mpd_album:
case OBJ_mpd_random:
case OBJ_mpd_repeat:
case OBJ_mpd_vol:
case OBJ_mpd_bitrate:
case OBJ_mpd_status:
case OBJ_mpd_bar:
case OBJ_mpd_elapsed:
case OBJ_mpd_length:
case OBJ_mpd_track:
case OBJ_mpd_name:
case OBJ_mpd_file:
case OBJ_mpd_percent:
case OBJ_mpd_smart:
case OBJ_if_mpd_playing:
free_mpd();
break;
#endif /* MPD */
#ifdef X11 #ifdef X11
case OBJ_desktop: case OBJ_desktop:
case OBJ_desktop_number: case OBJ_desktop_number:

View File

@ -118,8 +118,10 @@ static void clear_mpd(void)
memset(&mpd_info, 0, sizeof(mpd_info)); memset(&mpd_info, 0, sizeof(mpd_info));
} }
void free_mpd(void) void free_mpd(struct text_object *obj)
{ {
(void)obj;
if (!(--refcount)) /* last client */ if (!(--refcount)) /* last client */
clear_mpd(); clear_mpd();
} }

View File

@ -11,7 +11,7 @@ int mpd_set_port(const char *);
/* text object functions */ /* text object functions */
void init_mpd(void); void init_mpd(void);
void free_mpd(void); void free_mpd(struct text_object *);
void update_mpd(void); void update_mpd(void);
void print_mpd_elapsed(struct text_object *, char *, int); void print_mpd_elapsed(struct text_object *, char *, int);