Back to index

easystroke  0.5.5.1
Classes | Public Member Functions | Private Member Functions | Private Attributes
Prefs Class Reference

#include <prefs.h>

Collaboration diagram for Prefs:
Collaboration graph
[legend]

List of all members.

Classes

class  DeviceColumns
class  ExceptionColumns
class  ExtraColumns
class  Single

Public Member Functions

 Prefs ()
virtual ~Prefs ()
void update_device_list ()
void update_extra_buttons ()

Private Member Functions

void set_button_label ()
void on_add ()
void on_remove ()
void on_add_extra ()
void on_edit_extra ()
void on_remove_extra ()
void on_select_button ()
void on_button_editing_started (Gtk::CellEditable *editable, const Glib::ustring &path)
void on_device_toggled (const Gtk::TreeModel::Path &path, const Gtk::TreeModel::iterator &iter)
void on_device_timeout_changed (const Glib::ustring &path, const Glib::ustring &new_text)
bool select_row (const Gtk::TreeModel::Path &path, const Gtk::TreeModel::iterator &iter, std::string name)

Private Attributes

ExceptionColumns cols
Glib::RefPtr< Gtk::ListStore > tm
Gtk::TreeView * tv
Single timeout_columns
DeviceColumns dcs
Gtk::TreeView * dtv
Glib::RefPtr< Gtk::ListStore > dtm
ExtraColumns ecs
Gtk::TreeView * etv
Glib::RefPtr< Gtk::ListStore > etm
Gtk::SpinButton * spin_radius
Gtk::Label * blabel
bool ignore_device_toggled

Detailed Description

Definition at line 22 of file prefs.h.


Constructor & Destructor Documentation

Definition at line 234 of file prefs.cc.

             {
       new Check(prefs.advanced_ignore, "check_advanced_ignore");

       new Check(prefs.pressure_abort, "check_pressure_abort");
       new Adjustment<int>(prefs.pressure_threshold, "adjustment_pressure_threshold");
       new Sensitive(prefs.pressure_abort, "spin_pressure_threshold");
       new Sensitive(prefs.pressure_abort, "button_default_pressure_threshold");

       new Check(prefs.proximity, "check_proximity");

       new Check(prefs.feedback, "check_feedback");
       new Check(prefs.left_handed, "check_left_handed");
       new Sensitive(prefs.feedback, "check_left_handed");
       new Check(prefs.advanced_popups, "check_advanced_popups");
       new Sensitive(prefs.feedback, "check_advanced_popups");

       new Check(prefs.tray_icon, "check_tray_icon");
       new Sensitive(prefs.tray_icon, "check_tray_feedback");
       new Check(prefs.tray_feedback, "check_tray_feedback");

       new Check(autostart, "check_autostart");
       new Sensitive(autostart_ok, "check_autostart");

       new Adjustment<int>(prefs.init_timeout, "adjustment_init_timeout");
       new Adjustment<int>(prefs.final_timeout, "adjustment_final_timeout");

       new ButtonSet<int>(prefs.pressure_threshold, "button_default_pressure_threshold", default_pressure_threshold);

       new Combo<TraceType>(prefs.trace, "box_trace", trace_info);
       new Color(prefs.color, "button_color");
       new Adjustment<int>(prefs.trace_width, "adjustment_trace_width");
       new Combo<TimeoutType>(prefs.timeout_profile, "box_timeout", experimental ? timeout_info_exp : timeout_info);

       new Check(prefs.timeout_gestures, "check_timeout_gestures");

       new Check(prefs.scroll_invert, "check_scroll_invert");
       new Adjustment<double>(prefs.scroll_speed, "adjustment_scroll_speed");

       new Check(prefs.move_back, "check_move_back");

       new Check(prefs.show_osd, "check_osd");

       Gtk::Button *bbutton, *add_exception, *remove_exception, *add_extra, *edit_extra, *remove_extra;
       widgets->get_widget("button_add_exception", add_exception);
       widgets->get_widget("button_button", bbutton);
       widgets->get_widget("button_remove_exception", remove_exception);
       widgets->get_widget("label_button", blabel);
       widgets->get_widget("button_add_extra", add_extra);
       widgets->get_widget("button_edit_extra", edit_extra);
       widgets->get_widget("button_remove_extra", remove_extra);
       widgets->get_widget("treeview_exceptions", tv);
       widgets->get_widget("treeview_devices", dtv);
       widgets->get_widget("treeview_extra", etv);

       new Sensitive(*fun(&is_custom, prefs.timeout_profile), "hbox_timeout");
       /*
       new Sensitive(supports_pressure, "hbox_pressure");
       new Sensitive(supports_proximity, "check_proximity");
       */
       new Sensitive(*fun(&draw_trace, prefs.trace), "button_color");
       new Sensitive(*fun(&draw_trace, prefs.trace), "spin_trace_width");

       tm = Gtk::ListStore::create(cols);
       tv->set_model(tm);
       tv->append_column(_("Application (WM__CLASS)"), cols.user_app);
       tm->set_sort_column(cols.user_app, Gtk::SORT_ASCENDING);

       CellRendererTextish *button_renderer = Gtk::manage(new CellRendererTextish);
       button_renderer->mode = CellRendererTextish::POPUP;
       tv->append_column(_("Button"), *button_renderer);
       Gtk::TreeView::Column *col_button = tv->get_column(1);
       col_button->add_attribute(button_renderer->property_text(), cols.button);
       button_renderer->property_editable() = true;
       button_renderer->signal_editing_started().connect(sigc::mem_fun(*this, &Prefs::on_button_editing_started));

       bbutton->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_select_button));

       add_exception->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_add));
       remove_exception->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_remove));

       dtm = Gtk::ListStore::create(dcs);
       dtv->set_model(dtm);
       dtv->append_column_editable(_("Enabled"), dcs.enabled);
       int n = dtv->append_column(_("Device"), dcs.name);
       Gtk::TreeView::Column *col_device = dtv->get_column(n-1);
       col_device->set_expand();

       Glib::RefPtr<Gtk::ListStore> timeout_model = Gtk::ListStore::create(timeout_columns);
       {
              Gtk::TreeModel::Row row = *(timeout_model->append());
              row[timeout_columns.name] = _("<unchanged>");
       }
       for (const Combo<TimeoutType>::Info *i = timeout_info; i->name; i++) {
              Gtk::TreeModel::Row row = *(timeout_model->append());
              row[timeout_columns.name] = i->name;
       }

       Gtk::CellRendererCombo *timeout_renderer = Gtk::manage(new Gtk::CellRendererCombo);
       timeout_renderer->property_model() = timeout_model;
       timeout_renderer->property_editable() = true;
       timeout_renderer->property_text_column() = 0;
       timeout_renderer->property_has_entry() = false;
        timeout_renderer->signal_edited().connect(sigc::mem_fun(*this, &Prefs::on_device_timeout_changed));
       n = dtv->append_column(_("Timeout profile"), *timeout_renderer);
       Gtk::TreeView::Column *col_timeout = dtv->get_column(n-1);
       col_timeout->add_attribute(timeout_renderer->property_text(), dcs.timeout);

       dtm->signal_row_changed().connect(sigc::mem_fun(*this, &Prefs::on_device_toggled));
       update_device_list();

       add_extra->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_add_extra));
       edit_extra->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_edit_extra));
       remove_extra->signal_clicked().connect(sigc::mem_fun(*this, &Prefs::on_remove_extra));

       etm = Gtk::ListStore::create(ecs);
       etv->set_model(etm);
       etv->append_column(_("Button"), ecs.str);
       update_extra_buttons();

       if (!experimental) {
              Gtk::HBox *hbox;
              widgets->get_widget("hbox_timeout", hbox);
              hbox->hide();
       }
       set_button_label();

       const std::map<std::string, RButtonInfo> &exceptions = prefs.exceptions.ref();
       for (std::map<std::string, RButtonInfo>::const_iterator i = exceptions.begin(); i!=exceptions.end(); i++) {
              Gtk::TreeModel::Row row = *(tm->append());
              row[cols.app] = i->first;
              row[cols.user_app] = app_name_hr(i->first);
              row[cols.button] = i->second ? i->second->get_button_text() : _("<App disabled>");
       }
}

Here is the call graph for this function:

virtual Prefs::~Prefs ( ) [inline, virtual]

Definition at line 25 of file prefs.h.

{}

Member Function Documentation

void Prefs::on_add ( ) [private]

Definition at line 614 of file prefs.cc.

                   {
       std::string str = select_window();
       bool is_new;
       {
              Atomic a;
              is_new = prefs.exceptions.write_ref(a).insert(
                            std::pair<std::string, RButtonInfo>(str, RButtonInfo())).second;
       }
       if (is_new) {
              Gtk::TreeModel::Row row = *(tm->append());
              row[cols.app] = str;
              row[cols.user_app] = app_name_hr(str);
              row[cols.button] = _("<App disabled>");
              Gtk::TreePath path = tm->get_path(row);
              tv->set_cursor(path);
       } else {
              tm->foreach(sigc::bind(sigc::mem_fun(*this, &Prefs::select_row), str));
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_add_extra ( ) [private]

Definition at line 403 of file prefs.cc.

                         {
       ButtonInfo bi;
       SelectButton sb(bi, true, true);
       if (!sb.run())
              return;
       Atomic a;
       std::vector<ButtonInfo> &extra = prefs.extra_buttons.write_ref(a);
       for (std::vector<ButtonInfo>::iterator i = extra.begin(); i != extra.end();)
              if (i->overlap(sb.event))
                     i = extra.erase(i);
              else
                     i++;
       extra.push_back(sb.event);
       stable_sort(extra.begin(), extra.end());
       update_extra_buttons();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_button_editing_started ( Gtk::CellEditable *  editable,
const Glib::ustring &  path 
) [private]

Definition at line 634 of file prefs.cc.

                                                                                        {
       Gtk::TreeRow row(*tm->get_iter(path));
       std::string app = row[cols.app];
       ButtonInfo bi;
       bi.button = 0;
       bi.state = 0;
       std::map<std::string, RButtonInfo>::const_iterator i = prefs.exceptions.ref().find(app);
       if (i != prefs.exceptions.ref().end() && i->second)
              bi = *i->second;
       SelectButton sb(bi, true, true);
       if (!sb.run())
              return;
       RButtonInfo bi2;
       if (sb.event.button)
              bi2.reset(new ButtonInfo(sb.event));
       row[cols.button] = bi2 ? bi2->get_button_text() : _("<App disabled>");
       Atomic a;
       prefs.exceptions.write_ref(a)[app] = bi2;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_device_timeout_changed ( const Glib::ustring &  path,
const Glib::ustring &  new_text 
) [private]

Definition at line 679 of file prefs.cc.

                                                                                          {
       Gtk::TreeRow row(*dtm->get_iter(path));
       row[dcs.timeout] = new_text;
       Glib::ustring device = row[dcs.name];
       Atomic a;

       for (const Combo<TimeoutType>::Info *i = timeout_info; i->name; i++) {
              if (Glib::ustring(i->name) == new_text) {
                     std::map<std::string, TimeoutType> &dt = prefs.device_timeout.write_ref(a);
                     dt[device] = i->value;
                     return;
              }
       }

       std::map<std::string, TimeoutType> &dt = prefs.device_timeout.write_ref(a);
       dt.erase(device);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_device_toggled ( const Gtk::TreeModel::Path &  path,
const Gtk::TreeModel::iterator &  iter 
) [private]

Definition at line 667 of file prefs.cc.

                                                                                            {
       if (ignore_device_toggled)
              return;
       Atomic a;
       std::set<std::string> &ex = prefs.excluded_devices.write_ref(a);
       Glib::ustring device = (*iter)[dcs.name];
       if ((*iter)[dcs.enabled])
              ex.erase(device);
       else
              ex.insert(device);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_edit_extra ( ) [private]

Definition at line 420 of file prefs.cc.

                          {
       Gtk::TreePath path;
       Gtk::TreeViewColumn *col;
       etv->get_cursor(path, col);
       if (!path.gobj())
              return;
       Gtk::TreeIter iter = *etm->get_iter(path);
       std::vector<ButtonInfo>::iterator i = (*iter)[ecs.i];
       SelectButton sb(*i, true, true);
       if (!sb.run())
              return;
       Atomic a;
       std::vector<ButtonInfo> &extra = prefs.extra_buttons.write_ref(a);
       for (std::vector<ButtonInfo>::iterator j = extra.begin(); j != extra.end();)
              if (j != i && j->overlap(sb.event))
                     j = extra.erase(j);
              else
                     j++;
       *i = sb.event;
       update_extra_buttons();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_remove ( ) [private]

Definition at line 655 of file prefs.cc.

                      {
       Gtk::TreePath path;
       Gtk::TreeViewColumn *col;
       tv->get_cursor(path, col);
       if (path.gobj() != 0) {
              Gtk::TreeIter iter = *tm->get_iter(path);
              Atomic a;
              prefs.exceptions.write_ref(a).erase((Glib::ustring)((*iter)[cols.app]));
              tm->erase(iter);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_remove_extra ( ) [private]

Definition at line 442 of file prefs.cc.

                            {
       Gtk::TreePath path;
       Gtk::TreeViewColumn *col;
       etv->get_cursor(path, col);
       if (!path.gobj())
              return;
       Gtk::TreeIter iter = *etm->get_iter(path);
       Atomic a;
       std::vector<ButtonInfo>::iterator i = (*iter)[ecs.i];
       prefs.extra_buttons.write_ref(a).erase(i);
       update_extra_buttons();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Prefs::on_select_button ( ) [private]

Definition at line 596 of file prefs.cc.

                             {
       Atomic a;
       ButtonInfo &bi = prefs.button.write_ref(a);
       SelectButton sb(bi, true, true);
       if (!sb.run())
              return;
       bi = sb.event.button ? sb.event : default_button;
       set_button_label();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Prefs::select_row ( const Gtk::TreeModel::Path &  path,
const Gtk::TreeModel::iterator &  iter,
std::string  name 
) [private]

Definition at line 606 of file prefs.cc.

                                                                                                     {
       if ((std::string)(*iter)[cols.app] == name) {
              tv->set_cursor(path);
              return true;
       }
       return false;
}

Here is the caller graph for this function:

void Prefs::set_button_label ( ) [private]

Definition at line 697 of file prefs.cc.

                             {
       blabel->set_text(prefs.button.ref().get_button_text());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 369 of file prefs.cc.

                               {
       ignore_device_toggled = true;
       dtm->clear();
       std::set<std::string> names;
       for (Grabber::DeviceMap::iterator i = grabber->xi_devs.begin(); i != grabber->xi_devs.end(); ++i) {
              std::string name = i->second->name;
              if (names.count(name))
                     continue;
              names.insert(name);
              Gtk::TreeModel::Row row = *(dtm->append());
              row[dcs.enabled] = !prefs.excluded_devices.get().count(name);
              row[dcs.name] = name;
              row[dcs.timeout] = _("<unchanged>");

              const std::map<std::string, TimeoutType> &dt = prefs.device_timeout.ref();
              std::map<std::string, TimeoutType>::const_iterator j = dt.find(name);
              if (j != dt.end())
                     for (const Combo<TimeoutType>::Info *i = timeout_info; i->name; i++)
                            if (j->second == i->value)
                                   row[dcs.timeout] = i->name;
       }
       ignore_device_toggled = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 393 of file prefs.cc.

                                 {
       etm->clear();
       std::vector<ButtonInfo> &extra = prefs.extra_buttons.unsafe_ref();
       for (std::vector<ButtonInfo>::iterator i = extra.begin(); i != extra.end(); i++) {
              Gtk::TreeModel::Row row = *(etm->append());
              row[ecs.str] = i->get_button_text();
              row[ecs.i] = i;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Gtk::Label* Prefs::blabel [private]

Definition at line 81 of file prefs.h.

Definition at line 48 of file prefs.h.

Definition at line 66 of file prefs.h.

Glib::RefPtr<Gtk::ListStore> Prefs::dtm [private]

Definition at line 68 of file prefs.h.

Gtk::TreeView* Prefs::dtv [private]

Definition at line 67 of file prefs.h.

Definition at line 76 of file prefs.h.

Glib::RefPtr<Gtk::ListStore> Prefs::etm [private]

Definition at line 78 of file prefs.h.

Gtk::TreeView* Prefs::etv [private]

Definition at line 77 of file prefs.h.

Definition at line 82 of file prefs.h.

Gtk::SpinButton* Prefs::spin_radius [private]

Definition at line 80 of file prefs.h.

Definition at line 57 of file prefs.h.

Glib::RefPtr<Gtk::ListStore> Prefs::tm [private]

Definition at line 49 of file prefs.h.

Gtk::TreeView* Prefs::tv [private]

Definition at line 50 of file prefs.h.


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