Back to index

easystroke  0.5.5.1
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
PrefDB Class Reference

#include <prefdb.h>

Inheritance diagram for PrefDB:
Inheritance graph
[legend]
Collaboration diagram for PrefDB:
Collaboration graph
[legend]

List of all members.

Classes

struct  PrefSource

Public Member Functions

 PrefDB ()
void init ()
virtual void timeout ()
virtual void notify ()
void execute_now ()
template<class T >
void watch (Out< T > &v)

Public Attributes

PrefSource< std::map
< std::string, RButtonInfo > > 
exceptions
PrefSource< ButtonInfobutton
PrefSource< TraceTypetrace
PrefSource< bool > advanced_ignore
PrefSource< bool > pressure_abort
PrefSource< int > pressure_threshold
PrefSource< bool > proximity
PrefSource< bool > feedback
PrefSource< bool > left_handed
PrefSource< int > init_timeout
PrefSource< int > final_timeout
PrefSource< TimeoutTypetimeout_profile
PrefSource< bool > timeout_gestures
PrefSource< bool > tray_icon
PrefSource< std::set
< std::string > > 
excluded_devices
PrefSource< RGBAcolor
PrefSource< int > trace_width
PrefSource< std::vector
< ButtonInfo > > 
extra_buttons
PrefSource< bool > advanced_popups
PrefSource< bool > scroll_invert
PrefSource< double > scroll_speed
PrefSource< bool > tray_feedback
PrefSource< bool > show_osd
PrefSource< bool > move_back
PrefSource< std::map
< std::string, TimeoutType > > 
device_timeout

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)

Private Attributes

bool good_state

Friends

class boost::serialization::access

Detailed Description

Definition at line 101 of file prefdb.h.


Constructor & Destructor Documentation


Member Function Documentation

void TimeoutWatcher::execute_now ( ) [inline, inherited]

Definition at line 152 of file var.h.

                          {
              if (remove_timeout())
                     timeout();
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void PrefDB::init ( )

Definition at line 172 of file prefdb.cc.

                  {
       std::string filename = config_dir+"preferences";
       for (const char **v = prefs_versions; *v; v++) {
              if (is_file(filename + *v)) {
                     filename += *v;
                     try {
                            std::ifstream ifs(filename.c_str(), std::ios::binary);
                            if (!ifs.fail()) {
                                   boost::archive::text_iarchive ia(ifs);
                                   ia >> *this;
                                   if (verbosity >= 2)
                                          std::cout << "Loaded preferences." << std::endl;
                            }
                     } catch (...) {
                            printf(_("Error: Couldn't read preferences.\n"));
                     }
                     break;
              }
       }
       std::map<std::string, RButtonInfo>::iterator i = exceptions.unsafe_ref().find("(window manager frame)");
       if (i != exceptions.unsafe_ref().end()) {
              RButtonInfo bi = i->second;
              exceptions.unsafe_ref().erase(i);
              exceptions.unsafe_ref()[""] = bi;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void TimeoutWatcher::notify ( ) [inline, virtual, inherited]

Implements Base.

Definition at line 151 of file var.h.

Here is the call graph for this function:

template<class Archive >
void PrefDB::serialize ( Archive &  ar,
const unsigned int  version 
) [private]

Definition at line 60 of file prefdb.cc.

                                                                                       {
       if (version < 11) {
              std::set<std::string> old;
              ar & old;
              for (std::set<std::string>::iterator i = old.begin(); i != old.end(); i++)
                     exceptions.unsafe_ref()[*i] = RButtonInfo();
       } else ar & exceptions.unsafe_ref();
       if (version < 14) {
              double p = 0.5;
              ar & p;
       }
       ar & button.unsafe_ref();
       if (version < 2) {
              bool help;
              ar & help;
       }
       ar & trace.unsafe_ref();
       if (trace.get() == TraceShape)
              trace.unsafe_ref() = TraceDefault;
       if (version < 3) {
              int delay;
              ar & delay;
       }
       if (version == 1) {
              ButtonInfo foo;
              ar & foo;
              ar & foo;
              return;
       }
       if (version < 2) return;
       if (version != 6)
              ar & advanced_ignore.unsafe_ref();
       int radius = 16;
       ar & radius;
       if (version < 4) return;
       bool ignore_grab = false;
       ar & ignore_grab;
       bool timing_workaround = false;
       ar & timing_workaround;
       bool show_clicks = false;
       ar & show_clicks;
       ar & pressure_abort.unsafe_ref();
       ar & pressure_threshold.unsafe_ref();
       ar & proximity.unsafe_ref();
       if (version < 5) return;
       ar & feedback.unsafe_ref();
       ar & left_handed.unsafe_ref();
       ar & init_timeout.unsafe_ref();
       ar & final_timeout.unsafe_ref();
       if (version < 8) return;
       ar & timeout_profile.unsafe_ref();
       if (version < 9) return;
       ar & timeout_gestures.unsafe_ref();
       ar & tray_icon.unsafe_ref();
       if (version < 10) return;
       ar & excluded_devices.unsafe_ref();
       if (version < 12) {
              unsigned long c = 0;
              ar & c;
              color.unsafe_ref().color.set_rgb(257*(c >> 16), 257*((c >> 8) % 256), 257*(c % 256));
              return;
       } else {
              ar & color.unsafe_ref();
       }
       ar & trace_width.unsafe_ref();
       if (version < 13) return;
       ar & extra_buttons.unsafe_ref();
       ar & advanced_popups.unsafe_ref();
       ar & scroll_invert.unsafe_ref();
       ar & scroll_speed.unsafe_ref();
       ar & tray_feedback.unsafe_ref();
       ar & show_osd.unsafe_ref();
       if (version < 16) return;
       ar & move_back.unsafe_ref();
       if (version < 17) return;
       ar & device_timeout.unsafe_ref();
}

Here is the call graph for this function:

void PrefDB::timeout ( ) [virtual]

Implements Timeout.

Definition at line 138 of file prefdb.cc.

                     {
       std::string filename = config_dir+"preferences"+prefs_versions[0];
       std::string tmp = filename + ".tmp";
       try {
              std::ofstream ofs(tmp.c_str());
              boost::archive::text_oarchive oa(ofs);
              const PrefDB *me = this;
              oa << *me;
              ofs.close();
              if (rename(tmp.c_str(), filename.c_str()))
                     throw std::runtime_error("rename() failed");
              if (verbosity >= 2)
                     printf("Saved preferences.\n");
       } catch (std::exception &e) {
              printf(_("Error: Couldn't save preferences: %s.\n"), e.what());
              if (!good_state)
                     return;
              good_state = false;
              error_dialog(Glib::ustring::compose(_( "Couldn't save %1.  Your changes will be lost.  "
                            "Make sure that \"%2\" is a directory and that you have write access to it.  "
                            "You can change the configuration directory "
                            "using the -c or --config-dir command line options."), _("preferences"), config_dir));
       }
}

Here is the call graph for this function:

template<class T >
void Watcher::watch ( Out< T > &  v) [inline, inherited]

Definition at line 144 of file var.h.

{ v.connect(this); }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class boost::serialization::access [friend]

Definition at line 102 of file prefdb.h.


Member Data Documentation

Definition at line 116 of file prefdb.h.

Definition at line 131 of file prefdb.h.

Definition at line 114 of file prefdb.h.

Definition at line 128 of file prefdb.h.

PrefSource<std::map<std::string, TimeoutType> > PrefDB::device_timeout

Definition at line 137 of file prefdb.h.

PrefSource<std::map<std::string, RButtonInfo> > PrefDB::exceptions

Definition at line 113 of file prefdb.h.

PrefSource<std::set<std::string> > PrefDB::excluded_devices

Definition at line 127 of file prefdb.h.

Definition at line 130 of file prefdb.h.

Definition at line 120 of file prefdb.h.

Definition at line 123 of file prefdb.h.

bool PrefDB::good_state [private]

Definition at line 103 of file prefdb.h.

Definition at line 122 of file prefdb.h.

Definition at line 121 of file prefdb.h.

Definition at line 136 of file prefdb.h.

Definition at line 117 of file prefdb.h.

Definition at line 118 of file prefdb.h.

Definition at line 119 of file prefdb.h.

Definition at line 132 of file prefdb.h.

Definition at line 133 of file prefdb.h.

Definition at line 135 of file prefdb.h.

Definition at line 125 of file prefdb.h.

Definition at line 124 of file prefdb.h.

Definition at line 115 of file prefdb.h.

Definition at line 129 of file prefdb.h.

Definition at line 134 of file prefdb.h.

Definition at line 126 of file prefdb.h.


The documentation for this class was generated from the following files: