remove several redunant externs and use static variables
This commit is contained in:
@@ -28,8 +28,6 @@ using namespace MPD;
|
|||||||
|
|
||||||
extern Connection *Mpd;
|
extern Connection *Mpd;
|
||||||
|
|
||||||
extern ncmpcpp_config Config;
|
|
||||||
|
|
||||||
extern Menu<Song> *mPlaylist;
|
extern Menu<Song> *mPlaylist;
|
||||||
extern Menu<MPD::Item> *mBrowser;
|
extern Menu<MPD::Item> *mBrowser;
|
||||||
extern Window *wFooter;
|
extern Window *wFooter;
|
||||||
@@ -48,8 +46,6 @@ extern bool allow_statusbar_unlock;
|
|||||||
extern bool search_case_sensitive;
|
extern bool search_case_sensitive;
|
||||||
extern bool search_match_to_pattern;
|
extern bool search_match_to_pattern;
|
||||||
|
|
||||||
extern bool redraw_screen;
|
|
||||||
|
|
||||||
extern string EMPTY_TAG;
|
extern string EMPTY_TAG;
|
||||||
extern string UNKNOWN_ARTIST;
|
extern string UNKNOWN_ARTIST;
|
||||||
extern string UNKNOWN_TITLE;
|
extern string UNKNOWN_TITLE;
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
extern ncmpcpp_config Config;
|
|
||||||
|
|
||||||
bool ConnectToMPD();
|
bool ConnectToMPD();
|
||||||
bool ParseArgv(int, char **);
|
bool ParseArgv(int, char **);
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
|
||||||
extern ncmpcpp_config Config;
|
|
||||||
|
|
||||||
const string artists_folder = home_folder + "/" + ".ncmpcpp/artists";
|
const string artists_folder = home_folder + "/" + ".ncmpcpp/artists";
|
||||||
const string lyrics_folder = home_folder + "/" + ".lyrics";
|
const string lyrics_folder = home_folder + "/" + ".lyrics";
|
||||||
|
|
||||||
|
|||||||
@@ -144,8 +144,6 @@ extern bool lyrics_ready;
|
|||||||
|
|
||||||
bool dont_change_now_playing = 0;
|
bool dont_change_now_playing = 0;
|
||||||
bool block_progressbar_update = 0;
|
bool block_progressbar_update = 0;
|
||||||
bool block_statusbar_update = 0;
|
|
||||||
bool allow_statusbar_unlock = 1;
|
|
||||||
bool block_playlist_update = 0;
|
bool block_playlist_update = 0;
|
||||||
bool block_item_list_update = 0;
|
bool block_item_list_update = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ struct ncmpcpp_config
|
|||||||
int message_delay_time;
|
int message_delay_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern ncmpcpp_config Config;
|
||||||
|
|
||||||
void CreateConfigDir();
|
void CreateConfigDir();
|
||||||
void DefaultKeys(ncmpcpp_keys &);
|
void DefaultKeys(ncmpcpp_keys &);
|
||||||
void DefaultConfiguration(ncmpcpp_config &);
|
void DefaultConfiguration(ncmpcpp_config &);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
using namespace MPD;
|
using namespace MPD;
|
||||||
|
|
||||||
extern Connection *Mpd;
|
extern Connection *Mpd;
|
||||||
extern ncmpcpp_config Config;
|
|
||||||
|
|
||||||
extern Menu<Song> *mPlaylist;
|
extern Menu<Song> *mPlaylist;
|
||||||
extern Menu<Item> *mBrowser;
|
extern Menu<Item> *mBrowser;
|
||||||
@@ -56,9 +55,7 @@ extern NcmpcppScreen current_screen;
|
|||||||
extern NcmpcppScreen prev_screen;
|
extern NcmpcppScreen prev_screen;
|
||||||
|
|
||||||
extern bool dont_change_now_playing;
|
extern bool dont_change_now_playing;
|
||||||
extern bool allow_statusbar_unlock;
|
|
||||||
extern bool block_progressbar_update;
|
extern bool block_progressbar_update;
|
||||||
extern bool block_statusbar_update;
|
|
||||||
extern bool block_playlist_update;
|
extern bool block_playlist_update;
|
||||||
extern bool block_item_list_update;
|
extern bool block_item_list_update;
|
||||||
|
|
||||||
@@ -66,64 +63,51 @@ extern bool redraw_screen;
|
|||||||
extern bool redraw_header;
|
extern bool redraw_header;
|
||||||
extern bool reload_lyrics;
|
extern bool reload_lyrics;
|
||||||
|
|
||||||
bool header_update_status = 0;
|
|
||||||
bool repeat_one_allowed = 0;
|
|
||||||
|
|
||||||
long long playlist_old_id = -1;
|
|
||||||
|
|
||||||
int old_playing;
|
int old_playing;
|
||||||
|
|
||||||
size_t playing_song_scroll_begin = 0;
|
|
||||||
|
|
||||||
time_t time_of_statusbar_lock;
|
time_t time_of_statusbar_lock;
|
||||||
time_t now;
|
|
||||||
|
|
||||||
string playlist_stats;
|
string playlist_stats;
|
||||||
string volume_state;
|
string volume_state;
|
||||||
string switch_state;
|
string switch_state;
|
||||||
string player_state;
|
|
||||||
|
|
||||||
string mpd_repeat;
|
bool block_statusbar_update = 0;
|
||||||
string mpd_random;
|
bool allow_statusbar_unlock = 1;
|
||||||
string mpd_crossfade;
|
bool header_update_status = 0;
|
||||||
string mpd_db_updating;
|
bool repeat_one_allowed = 0;
|
||||||
|
|
||||||
void TraceMpdStatus()
|
void TraceMpdStatus()
|
||||||
{
|
{
|
||||||
Mpd->UpdateStatus();
|
Mpd->UpdateStatus();
|
||||||
now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
if (now == timer+Config.playlist_disable_highlight_delay && current_screen == csPlaylist)
|
if (current_screen == csPlaylist && now == timer+Config.playlist_disable_highlight_delay)
|
||||||
mPlaylist->Highlighting(!Config.playlist_disable_highlight_delay);
|
mPlaylist->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||||
|
|
||||||
if (lock_statusbar_delay > 0)
|
if (lock_statusbar_delay > 0)
|
||||||
{
|
{
|
||||||
if (now >= time_of_statusbar_lock+lock_statusbar_delay)
|
if (now >= time_of_statusbar_lock+lock_statusbar_delay)
|
||||||
lock_statusbar_delay = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lock_statusbar_delay)
|
|
||||||
{
|
|
||||||
lock_statusbar_delay = -1;
|
|
||||||
|
|
||||||
if (Config.statusbar_visibility)
|
|
||||||
block_statusbar_update = !allow_statusbar_unlock;
|
|
||||||
else
|
|
||||||
block_progressbar_update = !allow_statusbar_unlock;
|
|
||||||
|
|
||||||
StatusChanges changes;
|
|
||||||
switch (Mpd->GetState())
|
|
||||||
{
|
{
|
||||||
case psStop:
|
if (Config.statusbar_visibility)
|
||||||
changes.PlayerState = 1;
|
block_statusbar_update = !allow_statusbar_unlock;
|
||||||
break;
|
else
|
||||||
case psPlay: case psPause:
|
block_progressbar_update = !allow_statusbar_unlock;
|
||||||
changes.ElapsedTime = 1; // restore status
|
|
||||||
break;
|
StatusChanges changes;
|
||||||
default:
|
switch (Mpd->GetState())
|
||||||
break;
|
{
|
||||||
|
case psStop:
|
||||||
|
changes.PlayerState = 1;
|
||||||
|
NcmpcppStatusChanged(Mpd, changes, NULL);
|
||||||
|
break;
|
||||||
|
case psPause:
|
||||||
|
changes.ElapsedTime = 1; // restore status
|
||||||
|
NcmpcppStatusChanged(Mpd, changes, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NcmpcppStatusChanged(Mpd, changes, NULL);
|
|
||||||
}
|
}
|
||||||
//wHeader->WriteXY(0,1, IntoStr(now_playing), 1);
|
//wHeader->WriteXY(0,1, IntoStr(now_playing), 1);
|
||||||
}
|
}
|
||||||
@@ -146,6 +130,9 @@ void NcmpcppErrorCallback(Connection *Mpd, int errorid, const char *msg, void *)
|
|||||||
|
|
||||||
void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
||||||
{
|
{
|
||||||
|
static size_t playing_song_scroll_begin = 0;
|
||||||
|
static string player_state;
|
||||||
|
|
||||||
int sx, sy;
|
int sx, sy;
|
||||||
wFooter->DisableBB();
|
wFooter->DisableBB();
|
||||||
wFooter->AutoRefresh(0);
|
wFooter->AutoRefresh(0);
|
||||||
@@ -162,8 +149,6 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
|
|
||||||
if (changed.Playlist)
|
if (changed.Playlist)
|
||||||
{
|
{
|
||||||
playlist_old_id = Mpd->GetOldPlaylistID();
|
|
||||||
|
|
||||||
if (!block_playlist_update)
|
if (!block_playlist_update)
|
||||||
{
|
{
|
||||||
SongList list;
|
SongList list;
|
||||||
@@ -176,7 +161,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
Mpd->GetPlaylistChanges(-1, list);
|
Mpd->GetPlaylistChanges(-1, list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Mpd->GetPlaylistChanges(playlist_old_id, list);
|
Mpd->GetPlaylistChanges(Mpd->GetOldPlaylistID(), list);
|
||||||
|
|
||||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
@@ -384,35 +369,49 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
wFooter->WriteXY(0, 1, "", 1);
|
wFooter->WriteXY(0, 1, "", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char mpd_repeat;
|
||||||
|
static char mpd_random;
|
||||||
|
static char mpd_crossfade;
|
||||||
|
static char mpd_db_updating;
|
||||||
|
|
||||||
if (changed.Repeat)
|
if (changed.Repeat)
|
||||||
{
|
{
|
||||||
mpd_repeat = (Mpd->GetRepeat() ? "r" : "");
|
mpd_repeat = Mpd->GetRepeat() ? 'r' : 0;
|
||||||
ShowMessage("Repeat is %s", mpd_repeat.empty() ? "off" : "on");
|
ShowMessage("Repeat is %s", !mpd_repeat ? "off" : "on");
|
||||||
header_update_status = 1;
|
header_update_status = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (changed.Random)
|
if (changed.Random)
|
||||||
{
|
{
|
||||||
mpd_random = Mpd->GetRandom() ? "z" : "";
|
mpd_random = Mpd->GetRandom() ? 'z' : 0;
|
||||||
ShowMessage("Random is %s", mpd_random.empty() ? "off" : "on");
|
ShowMessage("Random is %s", !mpd_random ? "off" : "on");
|
||||||
header_update_status = 1;
|
header_update_status = 1;
|
||||||
}
|
}
|
||||||
if (changed.Crossfade)
|
if (changed.Crossfade)
|
||||||
{
|
{
|
||||||
int crossfade = Mpd->GetCrossfade();
|
int crossfade = Mpd->GetCrossfade();
|
||||||
mpd_crossfade = crossfade ? "x" : "";
|
mpd_crossfade = crossfade ? 'x' : 0;
|
||||||
ShowMessage("Crossfade set to %d seconds", crossfade);
|
ShowMessage("Crossfade set to %d seconds", crossfade);
|
||||||
header_update_status = 1;
|
header_update_status = 1;
|
||||||
}
|
}
|
||||||
if (changed.DBUpdating)
|
if (changed.DBUpdating)
|
||||||
{
|
{
|
||||||
mpd_db_updating = Mpd->GetDBIsUpdating() ? "U" : "";
|
mpd_db_updating = Mpd->GetDBIsUpdating() ? 'U' : 0;
|
||||||
ShowMessage(mpd_db_updating.empty() ? "Database update finished!" : "Database update started!");
|
ShowMessage(!mpd_db_updating ? "Database update finished!" : "Database update started!");
|
||||||
header_update_status = 1;
|
header_update_status = 1;
|
||||||
}
|
}
|
||||||
if (header_update_status && Config.header_visibility)
|
if (header_update_status && Config.header_visibility)
|
||||||
{
|
{
|
||||||
switch_state = mpd_repeat + mpd_random + mpd_crossfade + mpd_db_updating;
|
switch_state.clear();
|
||||||
|
if (mpd_repeat)
|
||||||
|
switch_state += mpd_repeat;
|
||||||
|
if (mpd_random)
|
||||||
|
switch_state += mpd_random;
|
||||||
|
if (mpd_crossfade)
|
||||||
|
switch_state += mpd_crossfade;
|
||||||
|
if (mpd_db_updating)
|
||||||
|
switch_state += mpd_db_updating;
|
||||||
|
|
||||||
wHeader->DisableBB();
|
wHeader->DisableBB();
|
||||||
wHeader->Bold(1);
|
wHeader->Bold(1);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
using namespace MPD;
|
using namespace MPD;
|
||||||
|
|
||||||
extern ncmpcpp_config Config;
|
|
||||||
extern ncmpcpp_keys Key;
|
extern ncmpcpp_keys Key;
|
||||||
|
|
||||||
extern Connection *Mpd;
|
extern Connection *Mpd;
|
||||||
|
|||||||
Reference in New Issue
Block a user