code style, indent with tabs XII
Follow the same code style als MPD itself.
Follow the same code style als MPD itself.
removed my_wgetch(), switch to wgetch()
There are no special cases left for my_wgetch() to handle. We can
remove it and use the original wgetch() instead.
There are no special cases left for my_wgetch() to handle. We can
remove it and use the original wgetch() instead.
disable ncurses raw mode
We're better off doing our own signal handling, instead of switching
ncurses to raw mode. Anyway, it was commented out and didn't work...
We're better off doing our own signal handling, instead of switching
ncurses to raw mode. Anyway, it was commented out and didn't work...
wreadln: removed the disabled ncursesw code
The wide character version of wreadln() is currently a non-functional
mess. Remove it for now, I will reimplement that later.
The wide character version of wreadln() is currently a non-functional
mess. Remove it for now, I will reimplement that later.
screen: declare time constants as GTime
Variables which store integer seconds should be declared as GTime.
This fixes a gcc warning.
Variables which store integer seconds should be declared as GTime.
This fixes a gcc warning.
Do not include libgen.h, it is unneeded after commit 44ecb.
use g_basename() instead of basename()
Another occurence of the non-portable basename() wasn't converted to
glib yet.
Another occurence of the non-portable basename() wasn't converted to
glib yet.
store MPD_UPDATE_TIME as guint
The glib function g_timeout_add() wants the interval as guint in
milliseconds. Store the update interval in this form, instead of
having to multiply MPD_UPDATE_TIME with 1000.
The glib function g_timeout_add() wants the interval as guint in
milliseconds. Store the update interval in this form, instead of
having to multiply MPD_UPDATE_TIME with 1000.
don't initialize sigaction struct twice
Don't reset sa_mask and sa_flags after every sigaction() call. Do it
once.
Don't reset sa_mask and sa_flags after every sigaction() call. Do it
once.
restart system call after SIGWINCH
Set option SA_RESTART for the SIGWINCH handler. The screen resizer
function is called by the glib main loop anyway, no need to interrupt
any random system call here.
Set option SA_RESTART for the SIGWINCH handler. The screen resizer
function is called by the glib main loop anyway, no need to interrupt
any random system call here.
typo: ignore SIGPIPE instead of SIGWINCH
Somehow the "ignore SIGPIPE" patch had a fatal typo: instead of
ignoring SIGPIPE, it ignored SIGWINCH. Somehow ncurses managed to
hide the bug's symptoms, but a recent patch finally broke it. Repair
the typo.
Somehow the "ignore SIGPIPE" patch had a fatal typo: instead of
ignoring SIGPIPE, it ignored SIGWINCH. Somehow ncurses managed to
hide the bug's symptoms, but a recent patch finally broke it. Repair
the typo.
screen: export the global variable "screen"
screen_t is a singleton. We do not have to pass it around
everywhere. Export the one global variable.
screen_t is a singleton. We do not have to pass it around
everywhere. Export the one global variable.
screen: don't pass mpdclient pointer to method paint()
None of the paint() implementations acutally uses the mpdclient
pointer. Remove it from the method signature.
None of the paint() implementations acutally uses the mpdclient
pointer. Remove it from the method signature.
screen_play: remember playlist
Remove the last paint() dependency on the mpdclient pointer: remember
a pointer to the playlist object, and don't take it from mpdclient
every time we paint. Also add the variable "current_song_id" which is
calculated in update().
Remove the last paint() dependency on the mpdclient pointer: remember
a pointer to the playlist object, and don't take it from mpdclient
every time we paint. Also add the variable "current_song_id" which is
calculated in update().
screen: removed "painted" flag
Repaint immediately instead of setting "painted=0".
Repaint immediately instead of setting "painted=0".
removed KEY_RESIZE
Since we are handling SIGWINCH, we do not need to handle KEY_RESIZE
from ncurses. Remove it.
Since we are handling SIGWINCH, we do not need to handle KEY_RESIZE
from ncurses. Remove it.
screen_search: array index is tag id
Save some bytes again: remove search_tag.id, make the array index
equal to the tag id.
Save some bytes again: remove search_tag.id, make the array index
equal to the tag id.
don't import mpdclient_finish_command() twice
mpdclient_finish_command() is already imported by mpdclient.h, don't
do it again in the sources.
mpdclient_finish_command() is already imported by mpdclient.h, don't
do it again in the sources.
screen_search: removed the FUTURE macro
The future is now!
The future is now!
options: don't initialize with memset(0)
Global variables are already initialized with zero when the program
starts, don't memset(0) again.
Global variables are already initialized with zero when the program
starts, don't memset(0) again.
options: don't pass the "options" pointer around
Just make everybody use the global "options" variable. This
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.
Just make everybody use the global "options" variable. This
eliminates namespace confusion and the NO_GLOBAL_OPTIONS hack.
colors: make color support optional at compile time
Default is colors disabled. Those who love colorful terminals have
the option to enable it with --enable-colors.
Default is colors disabled. Those who love colorful terminals have
the option to enable it with --enable-colors.
options: print one big string in --version screen
Instead of calling printf() multiple times for every compile time
option, build the whole string at compile time and print it with
puts().
Instead of calling printf() multiple times for every compile time
option, build the whole string at compile time and print it with
puts().
colors: color id is the index of the "colors" array
The color ids are sequential, and we can save some bytes if we use it
for the array index.
The color ids are sequential, and we can save some bytes if we use it
for the array index.
colors: added enum color_t
Instead of declaring a bunch of CPP macros, use a C enum for
identifying colors.
Instead of declaring a bunch of CPP macros, use a C enum for
identifying colors.
code style, indent with tabs XI
Follow the same code style als MPD itself.
Follow the same code style als MPD itself.
screen_artist: better screen title
The artist screen shouldn't be marked "experimental" anymore.
Describe the current state of the screen in the title, instead of
always writing "Artist".
The artist screen shouldn't be marked "experimental" anymore.
Describe the current state of the screen in the title, instead of
always writing "Artist".
list_window: remove list_window_state_t
We do not need to save a stack of list window states. When we return
to a parent directory, we just have to find the directory which we
come from in the parent list. Note that this patch resets the cursor
when going to the root directory, but I think it's not that important,
and I will deal with that later.
We do not need to save a stack of list window states. When we return
to a parent directory, we just have to find the directory which we
come from in the parent list. Note that this patch resets the cursor
when going to the root directory, but I think it's not that important,
and I will deal with that later.
filelist: added filelist_find_directory()
The function filelist_find_directory() will be useful for the
following patch.
The function filelist_find_directory() will be useful for the
following patch.
screen_artist: fix reload in "All tracks"
The variable "album" was set to _("All tracks") when it was empty.
When reloading the songs, ncmpc was trying to find an album named "All
tracks", which didn't seem to work. Leave "album" in its canonical
form and generate the title text on demand.
The variable "album" was set to _("All tracks") when it was empty.
When reloading the songs, ncmpc was trying to find an album named "All
tracks", which didn't seem to work. Leave "album" in its canonical
form and generate the title text on demand.
charset: pass -1 instead of strlen()
The GTK charset functions accept "-1" if the parameter is null
terminated.
The GTK charset functions accept "-1" if the parameter is null
terminated.
support: removed unused function remove_trailing_slash()
use g_basename() instead of basename()
g_basename() is always available, no need to implement a fallback.
Also use g_path_get_dirname(), g_path_get_basename().
g_basename() is always available, no need to implement a fallback.
Also use g_path_get_dirname(), g_path_get_basename().
use g_ascii_isspace() instead of IS_WHITESPACE()
Don't duplicate code which is already provided by glib.
Don't duplicate code which is already provided by glib.
use g_ascii_strdown() instead of the custom lowerstr()
Don't duplicate code which is already provided by glib.
Don't duplicate code which is already provided by glib.
list_window: removed unused macro "LW_ROW"
screen_browser: added constant playlist_format
Moved the format string for playlist files to the constant
"playlist_format".
Moved the format string for playlist files to the constant
"playlist_format".
fix compiler errors without locale.h
The code did not compile when HAVE_LOCALE_H was not set. Also don't
compile all that code in charset.c, when there is no locale.h.
The code did not compile when HAVE_LOCALE_H was not set. Also don't
compile all that code in charset.c, when there is no locale.h.
screen_lyrics: character set conversion
Convert the lyrics to the current character set before displaying
them.
Convert the lyrics to the current character set before displaying
them.
charset: convert strings with fallback
Use g_convert_with_fallback() for charset conversion, and don't print
a status bar message on error.
Use g_convert_with_fallback() for charset conversion, and don't print
a status bar message on error.
charset: charset_init() returns character set
Don't pass "noconvert" to charset_init(). Let charset_init()
determine that with g_get_charset() and return its name.
Don't pass "noconvert" to charset_init(). Let charset_init()
determine that with g_get_charset() and return its name.
charset: renamed my_strlen() to utf8_width()
my_strlen() is a bad name for the function, since the return value is
not a length, but a visible width on the screen. Rename it to
utf8_width() and change its return type to "unsigned".
my_strlen() is a bad name for the function, since the return value is
not a length, but a visible width on the screen. Rename it to
utf8_width() and change its return type to "unsigned".
moved code to charset.c
Move everything which deals with UTF-8 strings and character set
conversion to charset.c, header charset.h.
Move everything which deals with UTF-8 strings and character set
conversion to charset.c, header charset.h.
moved macros from ncmpc.h to main.c and screen.c
Moved constants which are only used in one source file. Remove
several unused macros.
Moved constants which are only used in one source file. Remove
several unused macros.
removed LIST_FORMAT, STATUS_FORMAT
Use options.list_format and options.status_format directly instead of
these two macros.
Use options.list_format and options.status_format directly instead of
these two macros.
moved i18n macros to i18n.h
Don't make everybody include ncmpc.h just to have generic features.
Move generic i18n macros to a separate header.
Don't make everybody include ncmpc.h just to have generic features.
Move generic i18n macros to a separate header.
options: use stdbool
Use the standard "bool" type instead of glib's "gboolean". This way,
options.h doesn't have to include the fat glib.h.
Use the standard "bool" type instead of glib's "gboolean". This way,
options.h doesn't have to include the fat glib.h.
removed the deprecated easy_download library
This library isn't being used anymore, delete it.
This library isn't being used anymore, delete it.
moved default value macros to defaults.h
These macros are only used by options.c and conf.c. Move them to a
common internal header.
These macros are only used by options.c and conf.c. Move them to a
common internal header.
options: initialize options.list_format
Instead of checking whether options.list_format is set in the
LIST_FORMAT macro, initialize it once with options.list_format. Same
for options.status_format / STATUS_FORMAT.
Instead of checking whether options.list_format is set in the
LIST_FORMAT macro, initialize it once with options.list_format. Same
for options.status_format / STATUS_FORMAT.
removed the debugging function D()
gdb is for debugging. We don't need D() calls littered all over.
gdb is for debugging. We don't need D() calls littered all over.
screen_browser: unexport command implementations
When we created created browser_cmd(), several functions of the
screen_browser API weren't used by other sources anymore. We can now
unexport them.
When we created created browser_cmd(), several functions of the
screen_browser API weren't used by other sources anymore. We can now
unexport them.
screen_lyrics: add screen_lyrics_switch()
screen_lyrics_switch() opens the lyrics screen and displays the lyrics
of the specified song. This way, the user may view the lyrics of any
song in the database browser.
screen_lyrics_switch() opens the lyrics screen and displays the lyrics
of the specified song. This way, the user may view the lyrics of any
song in the database browser.
screen: export function screen_switch()
Provide an API for switching the currently displayed screen. Rename
switch_screen_mode() to screen_switch().
Provide an API for switching the currently displayed screen. Rename
switch_screen_mode() to screen_switch().
screen: no typedefs for methods
Since the method types are used only once, we do not need typedefs for
that. Declare the method types within struct screen_functions.
Since the method types are used only once, we do not need typedefs for
that. Declare the method types within struct screen_functions.
screen_browser: added browser_cmd()
Merge a lot of code from the 3 browser screen into browser_cmd().
Merge a lot of code from the 3 browser screen into browser_cmd().
screen_artist: call artist_lw_cmd() at the end of artist_cmd()
By calling artist_lw_cmd() after the big switch, we can override
behaviour, and we can modify the command.
By calling artist_lw_cmd() after the big switch, we can override
behaviour, and we can modify the command.
screen_artist: don't call wrefresh() twice
artist_repaint() calls wrefresh(), don't call it again after
that.
artist_repaint() calls wrefresh(), don't call it again after
that.
strfsong: constant pointers
Pass constant pointers to strfsong() and screen_lyrics_load().
Pass constant pointers to strfsong() and screen_lyrics_load().
screen: include config.h in screen.h
Since screen.h checks the macros from config.h, we have to include it.
Since screen.h checks the macros from config.h, we have to include it.
Makefile.am: don't use $(addprefix ...)
The function "addprefix" is a GNU extension, don't use it.
The function "addprefix" is a GNU extension, don't use it.
Makefile.am: don't declare $(lyrics_plugin_dir) twice
The variable $(lyrics_plugin_dir) was already declared in
configure.ac, don't declare it again in Makefile.am.
The variable $(lyrics_plugin_dir) was already declared in
configure.ac, don't declare it again in Makefile.am.
configure.ac: define ENABLE_x_SCREEN instead of DISABLE_x_SCREEN
Everybody who uses the ENABLE_ macros has to include ncmpc.h. We're
better off defining those in config.h via configure.ac.
Everybody who uses the ENABLE_ macros has to include ncmpc.h. We're
better off defining those in config.h via configure.ac.
screen_file: set highlights after screen update
Due to a missing sync_highlights() call, highlights were gone when the
user pressed the "update" hot key.
Due to a missing sync_highlights() call, highlights were gone when the
user pressed the "update" hot key.
screen_artist: separate artist and album lists
"metalist" can have different meanings, depending on the mode.
Replace it with two separate variables "artist_list" and "album_list".
This way, we can optimize screen updates later.
"metalist" can have different meanings, depending on the mode.
Replace it with two separate variables "artist_list" and "album_list".
This way, we can optimize screen updates later.
screen_artist: replaced update_metalist()
Replaced update_metalist() with three specialized functions for mode
switching.
Replaced update_metalist() with three specialized functions for mode
switching.
screen_artist: added reload_lists()
Some callers of update_metalist() want to reload the list contents.
Add an optimized function reload_lists() which does not modify the
global variables "mode", "artist", "album".
Some callers of update_metalist() want to reload the list contents.
Add an optimized function reload_lists() which does not modify the
global variables "mode", "artist", "album".
screen_artist: splitted update_metalist()
Moved special cases for loading artist, album, song lists to separate
functions.
Moved special cases for loading artist, album, song lists to separate
functions.
screen_artist: convert metalist to GPtrArray
A linked list is quite uncomfortable here because there is a lot of
indexed access to the list. Use a GPtrArray of strings instead.
Note that mpdclient_get_artists_utf8() and mpdclient_get_albums_utf8()
return a linked list, and sorting is also performed on the linked
list. This will be optimized later.
A linked list is quite uncomfortable here because there is a lot of
indexed access to the list. Use a GPtrArray of strings instead.
Note that mpdclient_get_artists_utf8() and mpdclient_get_albums_utf8()
return a linked list, and sorting is also performed on the linked
list. This will be optimized later.
screen_artist: don't insert ".." and "all albums" into list
Generate these special list entries on the fly.
Generate these special list entries on the fly.
screen_artist: moved code to artist_lw_cmd()
To unify the code, wrap list_window_cmd() in artist_lw_cmd(), which
properly checks the current mode.
To unify the code, wrap list_window_cmd() in artist_lw_cmd(), which
properly checks the current mode.
screen_play: no song means id=-1
"prev_song_id" and "current_song_id" had value 0 if MPD was not
playing at all. This way, ncmpc cannot see the difference between
"song 0 playing" and "not playing". Change "not playing" to -1.
"prev_song_id" and "current_song_id" had value 0 if MPD was not
playing at all. This way, ncmpc cannot see the difference between
"song 0 playing" and "not playing". Change "not playing" to -1.
screen_play: repaint highlight when mpd starts playing
When deciding whether to repaint the current highlight, test if MPD is
actually playing. If MPD starts playing, repaint.
When deciding whether to repaint the current highlight, test if MPD is
actually playing. If MPD starts playing, repaint.
screen_play: repaint if current song has changed
The play_update() function was reduced too much: it didn't repaint the
screen when the current song changed. Add check for that.
Don't repaint the screen in center_playing_item(), make the caller do
it.
The play_update() function was reduced too much: it didn't repaint the
screen when the current song changed. Add check for that.
Don't repaint the screen in center_playing_item(), make the caller do
it.
ignore SIGPIPE
Ignore SIGPIPE, and handle errno==EPIPE instead.
Ignore SIGPIPE, and handle errno==EPIPE instead.
don't call lyrics_init if plugin is disabled
If the lyrics screen is disabled at compile time, don't initialize the
lyrics library in main().
If the lyrics screen is disabled at compile time, don't initialize the
lyrics library in main().
screen_browser: added hotkey for adding song
CMD_ADD ('a') appends a song to the playlist, no matter if it is
already there, i.e. unlike CMD_SELECT, it does not toggle the song.
CMD_ADD ('a') appends a song to the playlist, no matter if it is
already there, i.e. unlike CMD_SELECT, it does not toggle the song.
fix miscellaneous sparse warnings
Static variables, pointers vs integers, void function returning, ...
Static variables, pointers vs integers, void function returning, ...
Makefile: added "sparse-check" target
screen: removed screen.mode
Everything is now managed with a pointer to the screen_functions
struct.
Everything is now managed with a pointer to the screen_functions
struct.
screen: removed screen ids
Finally remove all screen ids, they are not used anymore.
Finally remove all screen ids, they are not used anymore.
screen: pass screen_functions pointer to switch_screen_mode()
Trying to get rid of the screen ids. A pointer to screen_functions is
better for identifying a screen.
Trying to get rid of the screen ids. A pointer to screen_functions is
better for identifying a screen.
screen: replaced get_cur_mode_id() with screen_is_visible()
Screen code shouldn't know anything about the screen ids (which will
be eliminated completely later). Instead of comparing ids, compare
the screen_functions pointer.
Screen code shouldn't know anything about the screen ids (which will
be eliminated completely later). Instead of comparing ids, compare
the screen_functions pointer.
screen: moved code to screen_list.c
Move the hard-coded screen list and everything which works with this
array to screen_list.c.
Move the hard-coded screen list and everything which works with this
array to screen_list.c.
screen: don't compile disabled sources
Instead of evaluating macros from config.h in the disabled source,
don't start the compiler on it at all.
Instead of evaluating macros from config.h in the disabled source,
don't start the compiler on it at all.
screen_utils: don't call wmove() twice
The second wmove() is redundant, because the cursor is already there
after waddstr(). This also repairs wide characters in the prompt.
The second wmove() is redundant, because the cursor is already there
after waddstr(). This also repairs wide characters in the prompt.
filelist: removed attribute "updated"
Since all screen updating is now on demand, we don't need this flag
anymore.
Since all screen updating is now on demand, we don't need this flag
anymore.
screen: don't pass screen pointer to method update()
play_update() is the only update() implementation left, and it does
not use the screen pointer. Remove it from the method signature.
play_update() is the only update() implementation left, and it does
not use the screen pointer. Remove it from the method signature.
screen_play: hide cursor with a timer
Instead of hiding the cursor in the update() callback, hide it with a
glib main loop timeout.
Instead of hiding the cursor in the update() callback, hide it with a
glib main loop timeout.
screen_search: removed update() method
Repaint the search screen on demand. No need for the update() method
anymore.
Repaint the search screen on demand. No need for the update() method
anymore.
screen_search: removed version check from paint() method
The check wasn't actually doing anything, except leaking memory.
Remove it.
The check wasn't actually doing anything, except leaking memory.
Remove it.
configure: updated automake options
New automake options are "gnu 1.6 dist-bzip2". Sync with Makefile.am.
New automake options are "gnu 1.6 dist-bzip2". Sync with Makefile.am.
lyrics: replaced "hd.py" with "hd.sh"
Replace the "hd" plugin with a trivial shell script.
Replace the "hd" plugin with a trivial shell script.
screen_file: removed update() method
Repaint the file screen on demand. No need for the update() method
anymore.
Repaint the file screen on demand. No need for the update() method
anymore.
screen_artist: removed update() method
Repaint the artist screen on demand. No need for the update() method
anymore.
Repaint the artist screen on demand. No need for the update() method
anymore.
screen_playlist: don't repaint in update()
Repaint the playlist window on demand. Don't repaint it
unconditionally in play_update().
Repaint the playlist window on demand. Don't repaint it
unconditionally in play_update().
list_window: removed property "repaint"
The property "repaint" is never read, since all callers repaint the
list window on demand.
The property "repaint" is never read, since all callers repaint the
list window on demand.
screen_lyrics: removed the "update" method
Automatically redraw the screen on demand, whenever data has changed.
Automatically redraw the screen on demand, whenever data has changed.
screen_lyrics: added lyrics_repaint()
lyrics_repaint() or lyrics_repaint_if_active() are called after data
has changed, and the screen needs an update.
lyrics_repaint() or lyrics_repaint_if_active() are called after data
has changed, and the screen needs an update.
screen_keydef: removed the update() method
Automatically redraw the list on demand, whenever data has changed.
Automatically redraw the list on demand, whenever data has changed.