1 /* 2 3 This file is from Nitrogen, an X11 background setter. 4 Copyright (C) 2006 Dave Foster & Javeed Shaikh 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 20 */ 21 22 #ifndef _CONFIG_H_ 23 #define _CONFIG_H_ 24 25 #include <glib.h> 26 #include "SetBG.h" 27 #include <vector> 28 #include "Thumbview.h" 29 30 /** 31 * Static class that interfaces with the configuration. 32 * 33 * @author Dave Foster <daf@minuslab.net> 34 * @date 6 Sept 2005 35 */ 36 class Config { 37 private: 38 39 bool check_dir(); 40 41 bool recurse; 42 DisplayMode m_display_mode; 43 gint m_posx, m_posy; 44 guint m_sizex, m_sizey; 45 gboolean m_icon_captions; 46 VecStrs m_vec_dirs; 47 Thumbview::SortMode m_sort_mode; 48 get_bg_config_file()49 std::string get_bg_config_file() const { return get_file("bg-saved.cfg"); } get_config_file()50 std::string get_config_file() const { return get_file("nitrogen.cfg"); } 51 std::string get_file(const Glib::ustring filename) const; 52 53 public: 54 55 // instance getter 56 static Config* get_instance(); 57 58 Config(); 59 60 Config* clone(); 61 62 // get/set for bgs 63 bool get_bg(const Glib::ustring disp, Glib::ustring &file, SetBG::SetMode &mode, Gdk::Color &bgcolor); 64 bool set_bg(const Glib::ustring disp, const Glib::ustring file, const SetBG::SetMode mode, Gdk::Color bgcolor); 65 66 // get all groups (bg_saved.cfg) 67 bool get_bg_groups(std::vector<Glib::ustring> &groups); 68 get_recurse()69 bool get_recurse() { return recurse; } set_recurse(bool n)70 void set_recurse(bool n) { recurse = n; } get_display_mode()71 DisplayMode get_display_mode() { return m_display_mode; } set_display_mode(DisplayMode mode)72 void set_display_mode(DisplayMode mode) { m_display_mode = mode; } get_icon_captions()73 bool get_icon_captions() { return m_icon_captions; } set_icon_captions(gboolean caps)74 void set_icon_captions(gboolean caps) { m_icon_captions = caps; } 75 76 void get_pos(gint &x, gint &y); 77 void set_pos(gint x, gint y); 78 void get_size(guint &w, guint &h); 79 void set_size(guint w, guint h); 80 set_sort_mode(Thumbview::SortMode s)81 void set_sort_mode(Thumbview::SortMode s) { m_sort_mode = s; } get_sort_mode()82 Thumbview::SortMode get_sort_mode(){ return m_sort_mode; } 83 84 VecStrs get_dirs(); 85 void set_dirs(const VecStrs& new_dirs); 86 bool add_dir(const std::string& dir); 87 bool rm_dir(const std::string& dir); 88 89 bool save_cfg(); // save non bg related cfg info 90 bool load_cfg(); 91 }; 92 93 #endif 94