summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9e8806d)
raw | patch | inline | side by side (parent: 9e8806d)
author | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 12:27:31 +0000 (13:27 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 7 Nov 2008 12:27:31 +0000 (13:27 +0100) |
Disable lots of smaller features which don't have a separate configure
option:
- xterm title
- screen list
- horizontal scrolling
- MPD version number check
- key binding checks
- character set conversion
- bitrate display
- highlighting in the file browser
- completion / history
option:
- xterm title
- screen list
- horizontal scrolling
- MPD version number check
- key binding checks
- character set conversion
- bitrate display
- highlighting in the file browser
- completion / history
16 files changed:
src/Makefile.am | patch | blob | history | |
src/charset.c | patch | blob | history | |
src/charset.h | patch | blob | history | |
src/i18n.h | patch | blob | history | |
src/main.c | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen.c | patch | blob | history | |
src/screen_browser.c | patch | blob | history | |
src/screen_browser.h | patch | blob | history | |
src/screen_file.c | patch | blob | history | |
src/screen_play.c | patch | blob | history | |
src/screen_utils.c | patch | blob | history | |
src/screen_utils.h | patch | blob | history | |
src/wreadln.c | patch | blob | history | |
src/wreadln.h | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index e03f645f80ca6d4e812686725e8ae962e405614e..2c0d63d802c0798c5f8e74548dcad938e67f6085 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
playlist.c \
filelist.c \
options.c\
- conf.c\
command.c\
ncu.c \
screen.c\
utils.c\
str_pool.c
+if NCMPC_MINI
+else
+ncmpc_SOURCES += conf.c
+endif
+
if ENABLE_HELP_SCREEN
ncmpc_SOURCES += screen_help.c
endif
diff --git a/src/charset.c b/src/charset.c
index a0e8bbda4dca3fb07ff55f05d622274502361f6a..69e15eb6e042b6047ac52bbec4be8a6f8041e51a 100644 (file)
--- a/src/charset.c
+++ b/src/charset.c
#include <string.h>
#include <glib.h>
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
static bool noconvert = true;
static const char *charset;
char *
utf8_to_locale(const char *utf8str)
{
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
gchar *str;
assert(utf8str != NULL);
char *
locale_to_utf8(const char *localestr)
{
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
gchar *str;
assert(localestr != NULL);
diff --git a/src/charset.h b/src/charset.h
index 0cb69d135bece726bb9077d3e10f862b65843016..4dfe13f3f19f28b490cf73cb8aeba9aa03886c5a 100644 (file)
--- a/src/charset.h
+++ b/src/charset.h
#include <stdbool.h>
#include <stddef.h>
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
const char *
charset_init(void);
#endif
diff --git a/src/i18n.h b/src/i18n.h
index f99505ed1a052d4dd659fd244b5881967e30e0bf..64484834a67847a4adc27d7861e2815f6e4f9241 100644 (file)
--- a/src/i18n.h
+++ b/src/i18n.h
#include "config.h"
/* i18n */
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
#include <locale.h>
#endif
#ifdef ENABLE_NLS
diff --git a/src/main.c b/src/main.c
index 49c813a7a49d83523b3b5012a14aee3b46136fca..6a0336349b14408d3a3a912003c364f267f1097d 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "mpdclient.h"
#include "charset.h"
#include "options.h"
-#include "conf.h"
#include "command.h"
#include "ncu.h"
#include "screen.h"
#include "i18n.h"
#include "gcc.h"
+#ifndef NCMPC_MINI
+#include "conf.h"
+#endif
+
#ifdef ENABLE_LYRICS_SCREEN
#include "lyrics.h"
#endif
}
}
+#ifndef NCMPC_MINI
static void
update_xterm_title(void)
{
set_xterm_title("%s", title);
}
}
+#endif
static void
exit_and_cleanup(void)
{
screen_exit();
+#ifndef NCMPC_MINI
set_xterm_title("");
+#endif
printf("\n");
if (mpd) {
g_free(options.password);
g_free(options.list_format);
g_free(options.status_format);
+#ifndef NCMPC_MINI
g_free(options.scroll_sep);
+#endif
}
static void
return FALSE;
}
+#ifndef NCMPC_MINI
/* quit if mpd is pre 0.11.0 - song id not supported by mpd */
if (MPD_VERSION_LT(mpd, 0, 11, 0)) {
screen_status_printf(_("Error: MPD version %d.%d.%d is to old (0.11.0 needed).\n"),
g_timeout_add(30000, timer_reconnect, NULL);
return FALSE;
}
+#endif
screen_status_printf(_("Connected to %s!"), options.host);
doupdate();
reconnect_source_id = g_timeout_add(1000, timer_reconnect,
NULL);
+#ifndef NCMPC_MINI
if (options.enable_xterm_title)
update_xterm_title();
+#endif
screen_update(mpd);
}
#endif
+#ifndef NCMPC_MINI
/**
* Check the configured key bindings for errors, and display a status
* message every 10 seconds.
doupdate();
return TRUE;
}
+#endif
int
main(int argc, const char *argv[])
{
struct sigaction act;
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
const char *charset = NULL;
#endif
GIOChannel *keyboard_channel;
GIOChannel *lirc_channel = NULL;
#endif
-#ifdef HAVE_LOCALE_H
+#if defined(HAVE_LOCALE_H) && !defined(NCMPC_MINI)
/* time and date formatting */
setlocale(LC_TIME,"");
/* care about sorting order etc */
options_parse(argc, argv);
/* read configuration */
+#ifndef NCMPC_MINI
read_configuration();
+#endif
/* check key bindings */
check_key_bindings(NULL, NULL, 0);
update_source_id = g_timeout_add(update_interval,
timer_mpd_update,
GINT_TO_POINTER(TRUE));
+#ifndef NCMPC_MINI
g_timeout_add(10000, timer_check_key_bindings, NULL);
+#endif
idle_source_id = g_timeout_add(idle_interval, timer_idle, NULL);
screen_paint(mpd);
diff --git a/src/options.c b/src/options.c
index 3c39bdaf6ff4aae9aa49e67d7153e2b9c43abdf6..b6a49e3c68204d7cdef42abb9271c5c8d0e73145 100644 (file)
--- a/src/options.c
+++ b/src/options.c
.find_wrap = true,
.wide_cursor = true,
.audible_bell = true,
+#ifndef NCMPC_MINI
.scroll = DEFAULT_SCROLL,
.welcome_screen_list = true,
+#endif
};
static const arg_opt_t option_table[] = {
options.status_format = g_strdup(DEFAULT_STATUS_FORMAT);
options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
options.timedisplay_type = g_strdup(DEFAULT_TIMEDISPLAY_TYPE);
+#ifndef NCMPC_MINI
options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
+#endif
}
diff --git a/src/options.h b/src/options.h
index 5496e78ca468a82db9517bb26754d7139a7dd357..98ad3156ecbfd91482667d63e10e8c7c7af9c927 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *key_file;
char *list_format;
char *status_format;
+#ifndef NCMPC_MINI
char *xterm_title_format;
char *scroll_sep;
+#endif
char **screen_list;
char *timedisplay_type;
int port;
#endif
bool audible_bell;
bool visible_bell;
+#ifndef NCMPC_MINI
bool enable_xterm_title;
+#endif
#ifdef HAVE_GETMOUSE
bool enable_mouse;
#endif
+#ifndef NCMPC_MINI
bool scroll;
bool visible_bitrate;
bool welcome_screen_list;
+#endif
} options_t;
extern options_t options;
diff --git a/src/screen.c b/src/screen.c
index c333529fd21afd9a6a91b196e054b6cef7673c9f..17641df997a2bfb5fc3efdebd16d431c30e8884c 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#include <time.h>
#include <locale.h>
+#ifndef NCMPC_MINI
/** welcome message time [s] */
static const GTime SCREEN_WELCOME_TIME = 10;
+#endif
/** status message time [s] */
static const GTime SCREEN_STATUS_MESSAGE_TIME = 3;
/* screens */
+#ifndef NCMPC_MINI
static gboolean welcome = TRUE;
+#endif
+
struct screen screen;
static const struct screen_functions *mode_fn = &screen_playlist;
static int seek_id = -1;
if (header[0]) {
colors_use(w, COLOR_TITLE_BOLD);
mvwaddstr(w, 0, 0, header);
+#ifndef NCMPC_MINI
} else {
colors_use(w, COLOR_TITLE_BOLD);
waddstr(w, get_key_names(CMD_SCREEN_HELP, FALSE));
waddstr(w, get_key_names(CMD_SCREEN_LYRICS, FALSE));
colors_use(w, COLOR_TITLE);
waddstr(w, _(":Lyrics "));
+#endif
#endif
}
+
if (c->status == NULL || c->status->volume == MPD_STATUS_NO_VOLUME) {
g_snprintf(buf, 32, _("Volume n/a "));
} else {
mpd_Status *status = c->status;
mpd_Song *song = c->song;
int elapsedTime = 0;
+#ifdef NCMPC_MINI
+ static char bitrate[1];
+#else
char bitrate[16];
+#endif
const char *str = NULL;
int x = 0;
elapsedTime = seek_target_time;
/* display bitrate if visible-bitrate is true */
+#ifndef NCMPC_MINI
if (options.visible_bitrate) {
g_snprintf(bitrate, 16,
" [%d kbps]", status->bitRate);
} else {
bitrate[0] = '\0';
}
+#endif
/*write out the time, using hours if time over 60 minutes*/
if (c->status->totalTime > 3600) {
bitrate, elapsedTime/60, elapsedTime%60,
status->totalTime/60, status->totalTime%60 );
}
+#ifndef NCMPC_MINI
} else {
g_snprintf(screen.buf, screen.buf_size,
" [%d kbps]", status->bitRate );
+#endif
}
+#ifndef NCMPC_MINI
} else {
time_t timep;
time(&timep);
strftime(screen.buf, screen.buf_size, "%X ",localtime(&timep));
+#endif
}
/* display song */
if (status != NULL && (IS_PLAYING(status->state) ||
IS_PAUSED(status->state))) {
char songname[MAX_SONGNAME_LENGTH];
+#ifndef NCMPC_MINI
int width = COLS - x - utf8_width(screen.buf);
+#endif
if (song)
strfsong(songname, MAX_SONGNAME_LENGTH,
colors_use(w, COLOR_STATUS);
/* scroll if the song name is to long */
+#ifndef NCMPC_MINI
if (options.scroll && utf8_width(songname) > (unsigned)width) {
static scroll_state_t st = { 0, 0 };
char *tmp = strscroll(songname, options.scroll_sep, width, &st);
g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH);
g_free(tmp);
}
+#endif
//mvwaddnstr(w, 0, x, songname, width);
mvwaddstr(w, 0, x, songname);
}
void
screen_update(mpdclient_t *c)
{
+#ifndef NCMPC_MINI
static int repeat = -1;
static int random_enabled = -1;
static int crossfade = -1;
screen.last_cmd==CMD_NONE &&
time(NULL)-screen.start_timestamp <= SCREEN_WELCOME_TIME)
paint_top_window("", c, 0);
- else if (mode_fn->get_title != NULL) {
+ else
+#endif
+ if (mode_fn->get_title != NULL) {
paint_top_window(mode_fn->get_title(screen.buf,screen.buf_size), c, 0);
+#ifndef NCMPC_MINI
welcome = FALSE;
+#endif
} else
paint_top_window("", c, 0);
screen_cmd(mpdclient_t *c, command_t cmd)
{
screen.last_cmd = cmd;
+#ifndef NCMPC_MINI
welcome = FALSE;
+#endif
if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd))
return;
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 5bea9e49075158a5eb37a1d2f38e957ddd10c2ca..26dca5285ac533d1f730bb389a3dbe6fed4b3a06 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
#define BUFSIZE 1024
+#ifndef NCMPC_MINI
#define HIGHLIGHT (0x01)
+#endif
static const char playlist_format[] = "*%s*";
+#ifndef NCMPC_MINI
+
/* clear the highlight flag for all items in the filelist */
static void
clear_highlights(mpdclient_filelist_t *fl)
}
}
+#endif
+
/* list_window callback */
const char *
browser_lw_callback(unsigned idx, int *highlight, void *data)
assert(entry != NULL);
entity = entry->entity;
+#ifndef NCMPC_MINI
*highlight = (entry->flags & HIGHLIGHT);
+#else
+ *highlight = false;
+#endif
if( entity == NULL )
return "[..]";
filelist_free(browser->filelist);
browser->filelist = mpdclient_filelist_get(c, path);
+#ifndef NCMPC_MINI
sync_highlights(c, browser->filelist);
+#endif
idx = filelist_find_directory(browser->filelist, old_path);
g_free(old_path);
mpd_InfoEntity *entity = entry->entity;
mpd_Song *song = entity->info.song;
+#ifndef NCMPC_MINI
if (!(entry->flags & HIGHLIGHT)) {
+#endif
if (mpdclient_cmd_add(c, song) == 0) {
char buf[BUFSIZE];
+#ifndef NCMPC_MINI
entry->flags |= HIGHLIGHT;
+#endif
strfsong(buf, BUFSIZE, options.list_format, song);
screen_status_printf(_("Adding \'%s\' to playlist\n"), buf);
mpdclient_update(c); /* get song id */
} else
return -1;
+#ifndef NCMPC_MINI
}
+#endif
idx = playlist_get_index_from_file(c, song->file);
mpdclient_cmd_play(c, idx);
static int
browser_select_entry(mpdclient_t *c, filelist_entry_t *entry,
- gboolean toggle)
+ mpd_unused gboolean toggle)
{
assert(entry != NULL);
assert(entry->entity != NULL);
assert(entry->entity->info.song != NULL);
- if (!toggle || (entry->flags & HIGHLIGHT) == 0) {
+#ifndef NCMPC_MINI
+ if (!toggle || (entry->flags & HIGHLIGHT) == 0)
+#endif
+ {
mpd_Song *song = entry->entity->info.song;
+#ifndef NCMPC_MINI
entry->flags |= HIGHLIGHT;
+#endif
if (mpdclient_cmd_add(c, song) == 0) {
char buf[BUFSIZE];
strfsong(buf, BUFSIZE, options.list_format, song);
screen_status_printf(_("Adding \'%s\' to playlist\n"), buf);
}
+#ifndef NCMPC_MINI
} else {
/* remove song from playlist */
mpd_Song *song = entry->entity->info.song;
while ((idx = playlist_get_index_from_file(c, song->file)) >=0)
mpdclient_cmd_delete(c, idx);
+#endif
}
return 0;
diff --git a/src/screen_browser.h b/src/screen_browser.h
index 802886aa0b75b8e167c9b222a9245782a6ecbe3c..57564f1c948e956f112f91963fd66a0cb996ccf5 100644 (file)
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
mpdclient_filelist_t *filelist;
};
+#ifndef NCMPC_MINI
+
void
sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl);
browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c,
int event, gpointer data);
+#endif
+
const char *browser_lw_callback(unsigned index, int *highlight, void *filelist);
int
diff --git a/src/screen_file.c b/src/screen_file.c
index b14b3b10495aac68bd14ad75792ffe45162f1bac..5a81e8fb8c0eccaeaf79f83acfee22d2736da4a4 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
mpd_unused gpointer data)
{
browser.filelist = mpdclient_filelist_update(c, browser.filelist);
+#ifndef NCMPC_MINI
sync_highlights(c, browser.filelist);
+#endif
list_window_check_selected(browser.lw, filelist_length(browser.filelist));
file_repaint_if_active();
}
+#ifndef NCMPC_MINI
/* the playlist have been updated -> fix highlights */
static void
playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
file_repaint_if_active();
}
+#endif
static int
handle_save(mpdclient_t *c)
{
if (browser.filelist == NULL) {
browser.filelist = mpdclient_filelist_get(c, "");
+#ifndef NCMPC_MINI
mpdclient_install_playlist_callback(c, playlist_changed_callback);
+#endif
mpdclient_install_browse_callback(c, file_changed_callback);
}
}
break;
case CMD_SCREEN_UPDATE:
browser.filelist = mpdclient_filelist_update(c, browser.filelist);
+#ifndef NCMPC_MINI
sync_highlights(c, browser.filelist);
+#endif
list_window_check_selected(browser.lw,
filelist_length(browser.filelist));
file_repaint();
diff --git a/src/screen_play.c b/src/screen_play.c
index 90b06aa0eb730d3ef2ee8749a681e7e6dbd05db5..58bf65a545c988d1df68412fa644df30b2c51d8a 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
#define MAX_SONG_LENGTH 512
+#ifndef NCMPC_MINI
typedef struct
{
GList **list;
GList **dir_list;
mpdclient_t *c;
} completion_callback_data_t;
+#endif
static struct mpdclient_playlist *playlist;
static int current_song_id = -1;
list_window_check_selected(lw, length);
}
+#ifndef NCMPC_MINI
static void
save_pre_completion_cb(GCompletion *gcmp, mpd_unused gchar *line, void *data)
{
if (g_list_length(items) >= 1)
screen_display_completion_list(items);
}
+#endif
int
playlist_save(mpdclient_t *c, char *name, char *defaultname)
{
gchar *filename;
gint error;
+#ifndef NCMPC_MINI
GCompletion *gcmp;
GList *list = NULL;
completion_callback_data_t data;
+#endif
+
+#ifdef NCMPC_MINI
+ (void)defaultname;
+#endif
+#ifndef NCMPC_MINI
if (name == NULL) {
/* initialize completion support */
gcmp = g_completion_new(NULL);
if( filename )
filename=g_strstrip(filename);
} else
+#endif
filename=g_strdup(name);
if (filename == NULL || filename[0] == '\0')
return 0;
}
+#ifndef NCMPC_MINI
static void add_dir(GCompletion *gcmp, gchar *dir, GList **dir_list,
GList **list, mpdclient_t *c)
{
add_dir(gcmp, line, dir_list, list, c);
}
}
+#endif
static int
handle_add_to_playlist(mpdclient_t *c)
{
gchar *path;
+#ifndef NCMPC_MINI
GCompletion *gcmp;
GList *list = NULL;
GList *dir_list = NULL;
wrln_completion_callback_data = &data;
wrln_pre_completion_callback = add_pre_completion_cb;
wrln_post_completion_callback = add_post_completion_cb;
+#endif
/* get path */
path = screen_readln(screen.status_window.w,
_("Add: "),
NULL,
NULL,
- gcmp);
+#ifdef NCMPC_MINI
+ NULL
+#else
+ gcmp
+#endif
+ );
/* destroy completion data */
+#ifndef NCMPC_MINI
wrln_completion_callback_data = NULL;
wrln_pre_completion_callback = NULL;
wrln_post_completion_callback = NULL;
g_completion_free(gcmp);
string_list_free(list);
string_list_free(dir_list);
+#endif
/* add the path to the playlist */
if (path && path[0])
diff --git a/src/screen_utils.c b/src/screen_utils.c
index fc8fa90b323303ba0b9a0d20ff73ce9953417f5c..e44d8eb67cc03e442ef803af0f1da86a15eca39b 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
colors_use(w, COLOR_LIST);
}
+#ifndef NCMPC_MINI
void
set_xterm_title(const char *format, ...)
{
options.enable_xterm_title = FALSE;
}
}
+#endif
diff --git a/src/screen_utils.h b/src/screen_utils.h
index 335faceb2b40b0183b6e0dd6e45245deff45a7cb..8e0f86d588533f89b1f594e802f6d74509cd48da 100644 (file)
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
void screen_display_completion_list(GList *list);
+#ifndef NCMPC_MINI
void set_xterm_title(const char *format, ...);
+#endif
#endif
diff --git a/src/wreadln.c b/src/wreadln.c
index 7abfc4ac203a65270f65c0176b812d336ca64d43..df5b55e8c97a9d7ae2477a8363de70fdaab9f1f6 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
/** max items stored in the history list */
static const guint wrln_max_history_length = 32;
+#ifndef NCMPC_MINI
void *wrln_completion_callback_data = NULL;
wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL;
wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
+#endif
/** converts a byte position to a screen column */
static unsigned
gint key = 0;
size_t i;
+#ifdef NCMPC_MINI
+ (void)gcmp;
+#endif
+
/* turn off echo */
noecho();
/* make shure the cursor is visible */
break;
case TAB:
+#ifndef NCMPC_MINI
if (gcmp) {
char *prefix = NULL;
GList *list;
wrln_post_completion_callback(gcmp, wr.line, list,
wrln_completion_callback_data);
}
+#endif
break;
case KEY_CTRL_G:
diff --git a/src/wreadln.h b/src/wreadln.h
index e1ac67318cde15e724ba51ec94867c87f4d1e47d..e745025d347431657c3f7d3313514def1d76b91d 100644 (file)
--- a/src/wreadln.h
+++ b/src/wreadln.h
#include <ncurses.h>
#endif
+#ifndef NCMPC_MINI
+
/* completion callback data */
extern void *wrln_completion_callback_data;
void *data);
extern wrln_gcmp_post_cb_t wrln_post_completion_callback;
+#endif
+
/* Note, wreadln calls curs_set() and noecho(), to enable cursor and
* disable echo. wreadln will not restore these settings when exiting! */
gchar *wreadln(WINDOW *w, /* the curses window to use */