move all externs to global.h

This commit is contained in:
Andrzej Rybczak
2009-02-11 09:45:23 +01:00
parent cecb11c3d8
commit 29301aefd5
13 changed files with 204 additions and 158 deletions

View File

@@ -9,6 +9,6 @@ INCLUDES= $(all_includes)
# the library search path.
ncmpcpp_LDFLAGS = $(all_libraries)
noinst_HEADERS = browser.h charset.h clock.h display.h help.h helpers.h \
lyrics.h menu.h mpdpp.h scrollpad.h search_engine.h settings.h song.h \
noinst_HEADERS = browser.h charset.h clock.h display.h global.h help.h \
helpers.h lyrics.h menu.h mpdpp.h scrollpad.h search_engine.h settings.h song.h \
status_checker.h tag_editor.h window.h

View File

@@ -25,28 +25,17 @@
#include "browser.h"
#include "charset.h"
#include "display.h"
#include "global.h"
#include "helpers.h"
#include "settings.h"
#ifdef HAVE_TAGLIB_H
# include "tag_editor.h"
#endif // HAVE_TAGLIB_H
using namespace Global;
using namespace MPD;
using std::string;
extern Connection *Mpd;
extern ncmpcpp_config Config;
extern Menu<Song> *mPlaylist;
extern Menu<Item> *mBrowser;
extern NcmpcppScreen current_screen;
extern string browsed_dir;
extern int browsed_dir_scroll_begin;
namespace
{
const char *supported_extensions[] = { "wma", "asf", "rm", "mp1", "mp2", "mp3", "mp4", "m4a", "flac", "ogg", "wav", "au", "aiff", "aif", "ac3", "aac", "mpc", "it", "mod", "s3m", "xm", "wv", 0 };

View File

@@ -22,6 +22,7 @@
#include "clock.h"
#include "display.h"
#include "global.h"
#ifdef ENABLE_CLOCK
@@ -71,9 +72,9 @@ void Display::Clock(Window &w, const tm *time)
char buf[54];
strftime(buf, 64, "%x", time);
attron(COLOR_PAIR(Config.main_color));
attron(COLOR_PAIR(Global::Config.main_color));
mvprintw(w.GetStartY()+w.GetHeight(), w.GetStartX()+(w.GetWidth()-strlen(buf))/2, "%s", buf);
attroff(COLOR_PAIR(Config.main_color));
attroff(COLOR_PAIR(Global::Config.main_color));
refresh();
for (int k = 0; k < 6; k++)
@@ -97,7 +98,7 @@ void Display::Clock(Window &w, const tm *time)
{
w.GotoXY(2*j+2, i);
}
if (Config.clock_display_seconds || j < 18)
if (Global::Config.clock_display_seconds || j < 18)
w << " ";
}
}

View File

@@ -19,8 +19,11 @@
***************************************************************************/
#include "display.h"
#include "global.h"
#include "helpers.h"
using Global::Config;
using Global::mPlaylist;
using MPD::Song;
using std::string;
@@ -90,8 +93,6 @@ string Display::Columns(string st)
void Display::TotalPlaylistLength(Window &w)
{
extern Menu<MPD::Song> *mPlaylist;
const int MINUTE = 60;
const int HOUR = 60*MINUTE;
const int DAY = 24*HOUR;

119
src/global.h Normal file
View File

@@ -0,0 +1,119 @@
/***************************************************************************
* Copyright (C) 2008-2009 by Andrzej Rybczak *
* electricityispower@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _GLOBAL_H
#define _GLOBAL_H
#include "settings.h"
#include "ncmpcpp.h"
#include "mpdpp.h"
/// FIXME: this is absolutely shitty, I need to get rid of this.
namespace Global
{
extern ncmpcpp_config Config;
extern ncmpcpp_keys Key;
extern Window *wCurrent;
extern Window *wPrev;
extern Menu<MPD::Song> *mPlaylist;
extern Menu<MPD::Item> *mBrowser;
extern Menu< std::pair<Buffer *, MPD::Song *> > *mSearcher;
extern Window *wLibActiveCol;
extern Menu<std::string> *mLibArtists;
extern Menu<string_pair> *mLibAlbums;
extern Menu<MPD::Song> *mLibSongs;
# ifdef HAVE_TAGLIB_H
extern Window *wTagEditorActiveCol;
extern Menu<Buffer> *mTagEditor;
extern Menu<string_pair> *mEditorAlbums;
extern Menu<string_pair> *mEditorDirs;
# endif // HAVE_TAGLIB_H
// blah, I use below in conditionals.
extern Menu<string_pair> *mEditorLeftCol;
extern Menu<std::string> *mEditorTagTypes;
extern Menu<MPD::Song> *mEditorTags;
extern Window *wPlaylistEditorActiveCol;
extern Menu<std::string> *mPlaylistList;
extern Menu<MPD::Song> *mPlaylistEditor;
extern Scrollpad *sHelp;
extern Scrollpad *sLyrics;
extern Scrollpad *sInfo;
extern Window *wHeader;
extern Window *wFooter;
# ifdef ENABLE_CLOCK
extern Scrollpad *wClock;
# endif
extern MPD::Connection *Mpd;
extern int now_playing;
extern int lock_statusbar_delay;
extern size_t browsed_dir_scroll_begin;
extern time_t timer;
extern std::string browsed_dir;
extern std::string editor_browsed_dir;
extern std::string editor_highlighted_dir;
extern NcmpcppScreen current_screen;
extern NcmpcppScreen prev_screen;
# ifdef HAVE_CURL_CURL_H
extern pthread_t lyrics_downloader;
extern pthread_t artist_info_downloader;
extern bool lyrics_ready;
extern bool artist_info_ready;
# endif
extern bool dont_change_now_playing;
extern bool block_progressbar_update;
extern bool block_playlist_update;
extern bool block_item_list_update;
extern bool messages_allowed;
extern bool redraw_header;
extern bool reload_lyrics;
extern std::string volume_state;
extern bool header_update_status;
extern bool header_update_status;
extern bool search_case_sensitive;
extern bool search_match_to_pattern;
extern std::string volume_state;
extern const char *search_mode_normal;
extern const char *search_mode_strict;
}
#endif

View File

@@ -20,15 +20,14 @@
#include "mpdpp.h"
#include "global.h"
#include "help.h"
#include "settings.h"
using Global::Key;
using Global::Mpd;
using std::string;
extern MPD::Connection *Mpd;
extern ncmpcpp_keys Key;
namespace
{
string DisplayKeys(int *key, int size = 2)

View File

@@ -22,23 +22,17 @@
#include <iostream>
#include "charset.h"
#include "global.h"
#include "helpers.h"
#include "tag_editor.h"
using namespace MPD;
using Global::Config;
using Global::Mpd;
using Global::mPlaylist;
using Global::wFooter;
using std::string;
extern Connection *Mpd;
extern Menu<Song> *mPlaylist;
extern Menu<MPD::Item> *mBrowser;
extern Window *wFooter;
extern NcmpcppScreen current_screen;
extern bool search_case_sensitive;
extern bool search_match_to_pattern;
namespace
{
inline void remove_the_word(string &s)

View File

@@ -22,30 +22,25 @@
#include <fstream>
#include "charset.h"
#include "global.h"
#include "helpers.h"
#include "lyrics.h"
#include "settings.h"
#include "song.h"
using namespace Global;
using std::vector;
using std::string;
extern Window *wCurrent;
extern Scrollpad *sLyrics;
extern Scrollpad *sInfo;
const string artists_folder = home_folder + "/.ncmpcpp/artists";
const string lyrics_folder = home_folder + "/.lyrics";
#ifdef HAVE_CURL_CURL_H
extern pthread_t lyrics_downloader;
extern pthread_t artist_info_downloader;
extern bool lyrics_ready;
extern bool artist_info_ready;
pthread_mutex_t curl = PTHREAD_MUTEX_INITIALIZER;
namespace
{
pthread_mutex_t curl = PTHREAD_MUTEX_INITIALIZER;
size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
{
size_t result = size * nmemb;

View File

@@ -34,6 +34,7 @@
#include "charset.h"
#include "clock.h"
#include "display.h"
#include "global.h"
#include "help.h"
#include "helpers.h"
#include "lyrics.h"
@@ -88,93 +89,84 @@
vFoundPositions.clear(); \
} while (0)
using namespace Global;
using namespace MPD;
using std::make_pair;
using std::string;
using std::vector;
ncmpcpp_config Config;
ncmpcpp_keys Key;
ncmpcpp_config Global::Config;
ncmpcpp_keys Global::Key;
Window *wCurrent;
Window *wPrev;
Window *Global::wCurrent;
Window *Global::wPrev;
Menu<Song> *mPlaylist;
Menu<Item> *mBrowser;
Menu< std::pair<Buffer *, Song *> > *mSearcher;
Menu<Song> *Global::mPlaylist;
Menu<Item> *Global::mBrowser;
Menu< std::pair<Buffer *, Song *> > *Global::mSearcher;
Window *wLibActiveCol;
Menu<string> *mLibArtists;
Menu<string_pair> *mLibAlbums;
Menu<Song> *mLibSongs;
Window *Global::wLibActiveCol;
Menu<string> *Global::mLibArtists;
Menu<string_pair> *Global::mLibAlbums;
Menu<Song> *Global::mLibSongs;
#ifdef HAVE_TAGLIB_H
Window *wTagEditorActiveCol;
Menu<Buffer> *mTagEditor;
Menu<string_pair> *mEditorAlbums;
Menu<string_pair> *mEditorDirs;
Window *Global::wTagEditorActiveCol;
Menu<Buffer> *Global::mTagEditor;
Menu<string_pair> *Global::mEditorAlbums;
Menu<string_pair> *Global::mEditorDirs;
#endif // HAVE_TAGLIB_H
// blah, I use below in conditionals.
Menu<string_pair> *mEditorLeftCol;
Menu<string> *mEditorTagTypes;
Menu<Song> *mEditorTags;
Menu<string_pair> *Global::mEditorLeftCol;
Menu<string> *Global::mEditorTagTypes;
Menu<Song> *Global::mEditorTags;
Window *wPlaylistEditorActiveCol;
Menu<string> *mPlaylistList;
Menu<Song> *mPlaylistEditor;
Window *Global::wPlaylistEditorActiveCol;
Menu<string> *Global::mPlaylistList;
Menu<Song> *Global::mPlaylistEditor;
Scrollpad *sHelp;
Scrollpad *sLyrics;
Scrollpad *sInfo;
Scrollpad *Global::sHelp;
Scrollpad *Global::sLyrics;
Scrollpad *Global::sInfo;
Window *wHeader;
Window *wFooter;
Window *Global::wHeader;
Window *Global::wFooter;
#ifdef ENABLE_CLOCK
Scrollpad *wClock;
Scrollpad *Global::wClock;
#endif
Connection *Mpd;
Connection *Global::Mpd;
int now_playing = -1;
int lock_statusbar_delay = -1;
int Global::now_playing = -1;
int Global::lock_statusbar_delay = -1;
size_t browsed_dir_scroll_begin = 0;
size_t Global::browsed_dir_scroll_begin = 0;
time_t timer;
time_t Global::timer;
string browsed_dir = "/";
string editor_browsed_dir = "/";
string editor_highlighted_dir;
string Global::browsed_dir = "/";
string Global::editor_browsed_dir = "/";
string Global::editor_highlighted_dir;
NcmpcppScreen current_screen;
NcmpcppScreen prev_screen;
NcmpcppScreen Global::current_screen;
NcmpcppScreen Global::prev_screen;
#ifdef HAVE_CURL_CURL_H
pthread_t lyrics_downloader;
pthread_t artist_info_downloader;
bool lyrics_ready = 0;
bool artist_info_ready = 0;
pthread_t Global::lyrics_downloader;
pthread_t Global::artist_info_downloader;
bool Global::lyrics_ready = 0;
bool Global::artist_info_ready = 0;
#endif
bool dont_change_now_playing = 0;
bool block_progressbar_update = 0;
bool block_playlist_update = 0;
bool block_item_list_update = 0;
bool Global::dont_change_now_playing = 0;
bool Global::block_progressbar_update = 0;
bool Global::block_playlist_update = 0;
bool Global::block_item_list_update = 0;
bool messages_allowed = 0;
//bool redraw_screen = 0;
bool redraw_header = 1;
bool reload_lyrics = 0;
extern bool header_update_status;
extern bool search_case_sensitive;
extern bool search_match_to_pattern;
extern string volume_state;
extern const char *search_mode_normal;
extern const char *search_mode_strict;
bool Global::messages_allowed = 0;
bool Global::redraw_header = 1;
bool Global::reload_lyrics = 0;
const char *message_part_of_songs_added = "Only part of requested songs' list added to playlist!";

View File

@@ -19,22 +19,20 @@
***************************************************************************/
#include "display.h"
#include "global.h"
#include "helpers.h"
#include "search_engine.h"
#include "settings.h"
using namespace MPD;
using namespace Global;
using std::string;
extern Connection *Mpd;
extern Menu<Song> *mPlaylist;
extern Menu< std::pair<Buffer *, Song *> > *mSearcher;
bool Global::search_match_to_pattern = 1;
bool Global::search_case_sensitive = 0;
bool search_match_to_pattern = 1;
bool search_case_sensitive = 0;
const char *search_mode_normal = "Match if tag contains searched phrase";
const char *search_mode_strict = "Match only if both values are the same";
const char *Global::search_mode_normal = "Match if tag contains searched phrase";
const char *Global::search_mode_strict = "Match only if both values are the same";
void UpdateFoundList()
{

View File

@@ -162,8 +162,6 @@ struct ncmpcpp_config
int lyrics_db;
};
extern ncmpcpp_config Config;
void CreateConfigDir();
void DefaultKeys(ncmpcpp_keys &);
void DefaultConfiguration(ncmpcpp_config &);

View File

@@ -23,52 +23,19 @@
#include "browser.h"
#include "charset.h"
#include "global.h"
#include "helpers.h"
#include "search_engine.h"
#include "settings.h"
#include "status_checker.h"
using namespace Global;
using namespace MPD;
using std::string;
extern Connection *Mpd;
string Global::volume_state;
extern Menu<Song> *mPlaylist;
extern Menu<Item> *mBrowser;
extern Menu<string> *mLibArtists;
extern Menu<Song> *mLibSongs;
extern Menu<Song> *mPlaylistEditor;
#ifdef HAVE_TAGLIB_H
extern Menu<string> *mEditorAlbums;
extern Menu<string> *mEditorDirs;
#endif // HAVE_TAGLIB_H
extern Window *wHeader;
extern Window *wFooter;
extern time_t timer;
extern int now_playing;
extern int lock_statusbar_delay;
extern string browsed_dir;
extern NcmpcppScreen current_screen;
extern NcmpcppScreen prev_screen;
extern bool dont_change_now_playing;
extern bool block_progressbar_update;
extern bool block_playlist_update;
extern bool block_item_list_update;
extern bool messages_allowed;
extern bool redraw_header;
extern bool reload_lyrics;
string volume_state;
bool header_update_status = 0;
bool Global::header_update_status = 0;
namespace
{

View File

@@ -31,20 +31,13 @@
#include "charset.h"
#include "display.h"
#include "global.h"
#include "helpers.h"
#include "status_checker.h"
using namespace Global;
using namespace MPD;
extern ncmpcpp_keys Key;
extern Connection *Mpd;
extern Menu<Song> *mPlaylist;
extern Menu<Buffer> *mTagEditor;
extern Window *wFooter;
extern Window *wPrev;
namespace
{
const string patterns_list_file = config_dir + "patterns.list";