protected override bool OnButtonPressEvent (Gdk.EventButton press)
{
TreePath path;
TreeViewColumn column;
if (press.Button == 1) {
ResetHighlight ();
}
// If there is not a row at the click position let the base handler take care of the press
if (!GetPathAtPos ((int)press.X, (int)press.Y, out path, out column)) {
return base.OnButtonPressEvent (press);
}
Source source = store.GetSource (path);
if (source == null || source is SourceManager.GroupSource) {
return false;
}
// From F-Spot's SaneTreeView class
if (source_renderer.InExpander ((int)press.X)) {
if (!source.Expanded) {
ExpandRow (path, false);
} else {
CollapseRow (path);
}
// If the active source is a child of this source, and we are about to collapse it, switch
// the active source to the parent.
if (source == ServiceManager.SourceManager.ActiveSource.Parent && GetRowExpanded (path)) {
ServiceManager.SourceManager.SetActiveSource (source);
}
return true;
}
// For Sources that can't be activated, when they're clicked just
// expand or collapse them and return.
if (press.Button == 1 && !source.CanActivate) {
if (!source.Expanded) {
ExpandRow (path, false);
} else {
CollapseRow (path);
}
return false;
}
if (press.Button == 3) {
TreeIter iter;
if (Model.GetIter (out iter, path)) {
HighlightIter (iter);
OnPopupMenu ();
return true;
}
}
if (!source.CanActivate) {
return false;
}
if (press.Button == 1) {
if (ServiceManager.SourceManager.ActiveSource != source) {
ServiceManager.SourceManager.SetActiveSource (source);
}
}
if ((press.State & Gdk.ModifierType.ControlMask) != 0) {
if (press.Type == Gdk.EventType.TwoButtonPress && press.Button == 1) {
ActivateRow (path, null);
}
return true;
}
return base.OnButtonPressEvent (press);
}