1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2010 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "title_bar.h"
28 #include <mpd/client.h>
37 print_hotkey(WINDOW
*w
, command_t cmd
, const char *label
)
39 colors_use(w
, COLOR_TITLE_BOLD
);
40 waddstr(w
, get_key_names(cmd
, false));
41 colors_use(w
, COLOR_TITLE
);
50 get_volume(const struct mpd_status
*status
)
53 ? mpd_status_get_volume(status
)
58 title_bar_paint(const struct title_bar
*p
, const char *title
,
59 const struct mpd_status
*status
)
61 WINDOW
*w
= p
->window
.w
;
72 colors_use(w
, COLOR_TITLE_BOLD
);
73 mvwaddstr(w
, 0, 0, title
);
76 #ifdef ENABLE_HELP_SCREEN
77 print_hotkey(w
, CMD_SCREEN_HELP
, _("Help"));
79 print_hotkey(w
, CMD_SCREEN_PLAY
, _("Playlist"));
80 print_hotkey(w
, CMD_SCREEN_FILE
, _("Browse"));
81 #ifdef ENABLE_ARTIST_SCREEN
82 print_hotkey(w
, CMD_SCREEN_ARTIST
, _("Artist"));
84 #ifdef ENABLE_SEARCH_SCREEN
85 print_hotkey(w
, CMD_SCREEN_SEARCH
, _("Search"));
87 #ifdef ENABLE_LYRICS_SCREEN
88 print_hotkey(w
, CMD_SCREEN_LYRICS
, _("Lyrics"));
90 #ifdef ENABLE_OUTPUTS_SCREEN
91 print_hotkey(w
, CMD_SCREEN_OUTPUTS
, _("Outputs"));
93 #ifdef ENABLE_CHAT_SCREEN
94 print_hotkey(w
, CMD_SCREEN_CHAT
, _("Chat"));
99 volume
= get_volume(status
);
101 g_snprintf(buf
, 32, _("Volume n/a"));
103 g_snprintf(buf
, 32, _("Volume %d%%"), volume
);
105 colors_use(w
, COLOR_TITLE
);
106 mvwaddstr(w
, 0, p
->window
.cols
- utf8_width(buf
), buf
);
109 if (status
!= NULL
) {
110 if (mpd_status_get_repeat(status
))
111 g_strlcat(flags
, "r", sizeof(flags
));
112 if (mpd_status_get_random(status
))
113 g_strlcat(flags
, "z", sizeof(flags
));
114 if (mpd_status_get_single(status
))
115 g_strlcat(flags
, "s", sizeof(flags
));
116 if (mpd_status_get_consume(status
))
117 g_strlcat(flags
, "c", sizeof(flags
));
118 if (mpd_status_get_crossfade(status
))
119 g_strlcat(flags
, "x", sizeof(flags
));
120 if (mpd_status_get_update_id(status
) != 0)
121 g_strlcat(flags
, "U", sizeof(flags
));
124 colors_use(w
, COLOR_LINE
);
125 mvwhline(w
, 1, 0, ACS_HLINE
, p
->window
.cols
);
127 wmove(w
, 1, p
->window
.cols
- strlen(flags
) - 3);
129 colors_use(w
, COLOR_LINE_BOLD
);
131 colors_use(w
, COLOR_LINE
);
139 title_bar_resize(struct title_bar
*p
, unsigned width
)
143 p
->window
.cols
= width
;
144 wresize(p
->window
.w
, 2, width
);