Back to index

unity  6.0.0
DevicesSettings.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Andrea Azzarone <aazzarone@hotmail.it>
00018  */
00019 
00020 #ifndef DEVICES_SETTINGS_H
00021 #define DEVICES_SETTINGS_H
00022 
00023 #include <list>
00024 #include <string>
00025 
00026 #include <gio/gio.h>
00027 #include <boost/utility.hpp>
00028 #include <sigc++/sigc++.h>
00029 #include <UnityCore/GLibWrapper.h>
00030 
00031 namespace unity {
00032 
00033 typedef std::list<std::string> DeviceList;
00034 
00035 class DevicesSettings : boost::noncopyable
00036 {
00037 public:
00038   typedef enum
00039   {
00040     NEVER = 0,
00041     ONLY_MOUNTED,
00042     ALWAYS
00043 
00044   } DevicesOption;
00045 
00046   DevicesSettings();
00047   
00048   static DevicesSettings& GetDefault();
00049 
00050   void SetDevicesOption(DevicesOption devices_option);
00051   DevicesOption GetDevicesOption() { return devices_option_; };
00052 
00053   DeviceList const& GetFavorites() { return favorites_; };
00054   void AddFavorite(std::string const& uuid);
00055   void RemoveFavorite(std::string const& uuid);
00056 
00057   void Changed(std::string const& key);
00058   
00059   // Signals
00060   sigc::signal<void> changed;
00061   
00062 private:
00063   void Refresh();
00064   void SaveFavorites(DeviceList const& favorites);
00065 
00066   glib::Object<GSettings> settings_;
00067   DeviceList favorites_;
00068   bool ignore_signals_;
00069   DevicesOption devices_option_;
00070 };
00071 
00072 } // namespace unity
00073 
00074 #endif // DEVICES_SETTINGS_H