Skip to content

Commit

Permalink
Redesign, begin implementing device list
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeger committed Oct 11, 2008
1 parent 6ecde98 commit e587bf8
Show file tree
Hide file tree
Showing 7 changed files with 501 additions and 327 deletions.
1 change: 1 addition & 0 deletions grabber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ bool Grabber::init_xi() {
delete xi_dev;
continue;
}
xi_dev->name = dev->name;

DeviceButtonPress(xi_dev->dev, xi_dev->event_type[DOWN], xi_dev->events[DOWN]);
DeviceButtonRelease(xi_dev->dev, xi_dev->event_type[UP], xi_dev->events[UP]);
Expand Down
6 changes: 4 additions & 2 deletions grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Grabber {
void select_proximity(bool);

struct XiDevice {
std::string name;
XDevice *dev;
XEventClass events[6];
int event_type[6];
Expand All @@ -76,10 +77,11 @@ class Grabber {
XiDevice *get_xi_dev(XID id);
int event_presence;
XEventClass presence_class;
private:
int button_events_n;

XiDevice **xi_devs;
int xi_devs_n;
private:
int button_events_n;
bool init_xi();

State current, grabbed;
Expand Down
779 changes: 456 additions & 323 deletions gui.glade

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions prefdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void PrefDB::init() {
watchValue(timeout_profile);
watchValue(timeout_gestures);
watchValue(tray_icon);
watchValue(excluded_devices);
}

PrefDB prefs;
5 changes: 4 additions & 1 deletion prefdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class PrefDB : public TimeoutWatcher {
if (version < 9) return;
ar & timeout_gestures.unsafe_ref();
ar & tray_icon.unsafe_ref();
if (version < 10) return;
ar & excluded_devices.unsafe_ref();
}
public:
PrefDB();
Expand All @@ -120,12 +122,13 @@ class PrefDB : public TimeoutWatcher {
Source<int> timeout_profile;
Source<bool> timeout_gestures;
Source<bool> tray_icon;
Source<std::set<std::string> > excluded_devices;

void init();
virtual void timeout();
};

BOOST_CLASS_VERSION(PrefDB, 9)
BOOST_CLASS_VERSION(PrefDB, 10)

extern PrefDB prefs;
#endif
24 changes: 24 additions & 0 deletions prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Prefs::Prefs() {
widgets->get_widget("button_remove_exception", remove_exception);
widgets->get_widget("label_button", blabel);
widgets->get_widget("treeview_exceptions", tv);
widgets->get_widget("treeview_devices", dtv);
widgets->get_widget("scale_p", scale_p);

new Sensitive(xinput_v, "check_timing_workaround");
Expand All @@ -207,6 +208,18 @@ Prefs::Prefs() {
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);
dtv->append_column("Device", dcs.name);
for (int i = 0; i < grabber->xi_devs_n; i++) {
std::string name = grabber->xi_devs[i]->name;
Gtk::TreeModel::Row row = *(dtm->append());
row[dcs.enabled] = !prefs.excluded_devices.get().count(name);
row[dcs.name] = name;
}
dtm->signal_row_changed().connect(sigc::mem_fun(*this, &Prefs::on_device_toggled));

double p = prefs.p.get();
scale_p->set_value(p);
scale_p->signal_value_changed().connect(sigc::mem_fun(*this, &Prefs::on_p_changed));
Expand Down Expand Up @@ -374,6 +387,17 @@ void Prefs::on_remove() {
}
}


void Prefs::on_device_toggled(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter) {
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);
}

void Prefs::set_button_label() {
blabel->set_text(prefs.button.ref().get_button_text());
}
12 changes: 11 additions & 1 deletion prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Prefs {
void on_p_changed();
void on_p_default();
void on_select_button();
void on_device_toggled(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);

struct SelectRow;

Expand All @@ -41,10 +42,19 @@ class Prefs {
Gtk::TreeModelColumn<Glib::ustring> col;
};
SingleColumn cols;

Glib::RefPtr<Gtk::ListStore> tm;
Gtk::TreeView* tv;

class DeviceColumns : public Gtk::TreeModel::ColumnRecord {
public:
DeviceColumns() { add(enabled); add(name); }
Gtk::TreeModelColumn<bool> enabled;
Gtk::TreeModelColumn<Glib::ustring> name;
};
DeviceColumns dcs;
Gtk::TreeView* dtv;
Glib::RefPtr<Gtk::ListStore> dtm;

Gtk::HScale* scale_p;
Gtk::SpinButton *spin_radius;
Gtk::Label* blabel;
Expand Down

0 comments on commit e587bf8

Please sign in to comment.