Single-click on sidebar containers opens them: Closes #4985

This commit is contained in:
Avi Levy 2013-05-31 15:31:59 -07:00 committed by Jim Nelson
parent b77766c8d7
commit cbd5eea573
2 changed files with 32 additions and 12 deletions

1
THANKS
View file

@ -16,6 +16,7 @@ Michael George <mdgeorge@cs.cornell.edu>
Sven Hagemann <sven@rednose.nl> Sven Hagemann <sven@rednose.nl>
Mathias Hasselmann <mathias@openismus.com> Mathias Hasselmann <mathias@openismus.com>
Timo Kluck <tkluck@infty.nl> Timo Kluck <tkluck@infty.nl>
Avi Levy <avi.w.levy@gmail.com>
Kai Mast <mail@kai-mast.de> Kai Mast <mail@kai-mast.de>
Thomas Moschny <thomas.moschny@gmx.de> Thomas Moschny <thomas.moschny@gmx.de>
Tom Most <twm@freecog.net> Tom Most <twm@freecog.net>

View file

@ -75,6 +75,7 @@ public class Sidebar.Tree : Gtk.TreeView {
private bool mask_entry_selected_signal = false; private bool mask_entry_selected_signal = false;
private weak EntryWrapper? selected_wrapper = null; private weak EntryWrapper? selected_wrapper = null;
private Gtk.Menu? default_context_menu = null; private Gtk.Menu? default_context_menu = null;
private bool is_expander_arrow_action_enabled = true;
private bool is_internal_drag_in_progress = false; private bool is_internal_drag_in_progress = false;
private Sidebar.Entry? internal_drag_source_entry = null; private Sidebar.Entry? internal_drag_source_entry = null;
private Gtk.TreeRowReference? old_path_ref = null; private Gtk.TreeRowReference? old_path_ref = null;
@ -883,8 +884,20 @@ public class Sidebar.Tree : Gtk.TreeView {
return true; return true;
} }
public override bool button_release_event(Gdk.EventButton event) {
// see bug 4985
if (event.button == 1 && event.type == Gdk.EventType.BUTTON_RELEASE) {
if (!is_expander_arrow_action_enabled) {
is_expander_arrow_action_enabled = true;
return false;
}
}
return base.button_release_event(event);
}
public override bool button_press_event(Gdk.EventButton event) { public override bool button_press_event(Gdk.EventButton event) {
Gtk.TreePath? path = get_path_from_event(event); Gtk.TreePath? path = get_path_from_event(event);
EntryWrapper? wrapper = get_wrapper_at_path(path);
if (event.button == 3 && event.type == Gdk.EventType.BUTTON_PRESS) { if (event.button == 3 && event.type == Gdk.EventType.BUTTON_PRESS) {
// single right click // single right click
@ -892,17 +905,23 @@ public class Sidebar.Tree : Gtk.TreeView {
popup_context_menu(path, event); popup_context_menu(path, event);
else else
popup_default_context_menu(event); popup_default_context_menu(event);
} else if (event.button == 1 && event.type == Gdk.EventType.2BUTTON_PRESS) {
// double left click
if (path != null) {
toggle_branch_expansion(path, false);
if (can_rename_path(path))
return false;
}
} else if (event.button == 1 && event.type == Gdk.EventType.BUTTON_PRESS) { } else if (event.button == 1 && event.type == Gdk.EventType.BUTTON_PRESS) {
if (path == null) {
old_path_ref = null;
return base.button_press_event(event);
}
// Enable single click to toggle tree entries (bug 4985)
is_expander_arrow_action_enabled = true;
if (wrapper.entry is Sidebar.ExpandableEntry
|| wrapper.entry is Sidebar.InternalDropTargetEntry) {
// all labels are InternalDropTargetEntries
is_expander_arrow_action_enabled = false;
toggle_branch_expansion(path, false);
}
// Is this a click on an already-highlighted tree item? // Is this a click on an already-highlighted tree item?
if (path != null && (old_path_ref != null) && (old_path_ref.get_path() != null) if ((old_path_ref != null) && (old_path_ref.get_path() != null)
&& (old_path_ref.get_path().compare(path) == 0)) { && (old_path_ref.get_path().compare(path) == 0)) {
// yes, don't allow single-click editing, but // yes, don't allow single-click editing, but
// pass the event on for dragging. // pass the event on for dragging.
@ -912,13 +931,13 @@ public class Sidebar.Tree : Gtk.TreeView {
// Got click on different tree item, make sure it is editable // Got click on different tree item, make sure it is editable
// if it needs to be. // if it needs to be.
if (path != null && get_wrapper_at_path(path).entry is Sidebar.RenameableEntry && if (wrapper.entry is Sidebar.RenameableEntry &&
((Sidebar.RenameableEntry) get_wrapper_at_path(path).entry).is_user_renameable()) { ((Sidebar.RenameableEntry) wrapper.entry).is_user_renameable()) {
text_renderer.editable = true; text_renderer.editable = true;
} }
// Remember what tree item is highlighted for next time. // Remember what tree item is highlighted for next time.
old_path_ref = (path != null) ? new Gtk.TreeRowReference(store, path) : null; old_path_ref = new Gtk.TreeRowReference(store, path);
} }
return base.button_press_event(event); return base.button_press_event(event);