/* $Id$ */ /* * Cantus Tag Editor * Copyright © 2002-2004 by Samuel Abels * Copyright © 2007 by Tim Huetz * * 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 3 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, see **/ #ifdef HAVE_CONFIG_H # include #endif #ifndef HAVE_PREFERENCES_H #define HAVE_PREFERENCES_H #include #include #include #include #include #include class Preferences : public sigc::trackable { protected: // Prevent copys. Preferences(Preferences &p) { g_assert_not_reached(); } // Prevent assignments. Preferences& operator=(Preferences &p) { g_assert_not_reached(); } public: Preferences(void); ~Preferences(void); /* Triggered whenever something has been changed. */ SigC::Signal1 signal_changed; /* Tests all edited preferences for sanity. */ bool check_commit(void); /* Tests the preference with the given key for sanity. */ bool check_commit(std::string key); /* Confirms all preferences. This also triggers a Preferences:Changed event. */ bool commit(void); /* Confirms the preference with the given key. This also triggers a * Preferences:Changed event. */ bool commit(std::string key); /* Set one preference value. Returns always TRUE. */ bool set(std::string key, int type, void *value); /* Set one preference value (integer). */ void set_int(std::string key, int value); /* Get one preference value (int). */ int get_int(std::string key); /* Set one preference value (boolean). */ void set_bool(std::string key, bool value); /* Get one preference value (char). */ bool get_bool(std::string key); /* Set one preference value (char). */ void set_char(std::string key, std::string value); /* Get one preference value (char). */ std::string get_char(std::string key); /* Walks through all preferences calling the given slot. * Args passed to the slot are: The preference name, type (e.g. G_TYPE_INT) * and its value. * If the slot returns FALSE, list evaluation will be stopped. */ void foreach(SigC::Slot3 slot); protected: std::map prefs; std::map editedprefs; }; #endif