diff options
| author | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-07-17 13:53:53 +0000 |
|---|---|---|
| committer | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-07-17 14:37:37 +0000 |
| commit | 38bde4dc227c01dea1c7843529d4f1c6e507314b (patch) | |
| tree | 6ee904039f99ef51e3285c8cbde14beebd54b20a /src/widgets/gradient-selector.cpp | |
| parent | Update hr.po with current pot file (diff) | |
| download | inkscape-38bde4dc227c01dea1c7843529d4f1c6e507314b.tar.gz inkscape-38bde4dc227c01dea1c7843529d4f1c6e507314b.zip | |
Stop End button selecting first swatch in list
Fix gitlab.com/inkscape/inbox/issues/659
Diffstat (limited to 'src/widgets/gradient-selector.cpp')
| -rw-r--r-- | src/widgets/gradient-selector.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 19dc184eb..cb0ce09f2 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -336,21 +336,31 @@ void SPGradientSelector::onTreeCountColClick() { column->set_sort_column(columns->refcount); } -void SPGradientSelector::moveSelection(int amount) +void SPGradientSelector::moveSelection(int amount, bool down, bool toEnd) { Glib::RefPtr<Gtk::TreeSelection> select = treeview->get_selection(); auto iter = select->get_selected(); - auto canary = iter; - for (--canary; amount < 0 && canary; ++amount) { - --canary; - --iter; + if (amount < 0) { + down = !down; + amount = -amount; } - canary = iter; - for (++canary; amount > 0 && canary; --amount) { + auto canary = iter; + if (down) { ++canary; - ++iter; + } else { + --canary; + } + while (canary && (toEnd || amount > 0)) { + --amount; + if (down) { + ++canary; + ++iter; + } else { + --canary; + --iter; + } } select->select(iter); @@ -393,6 +403,20 @@ bool SPGradientSelector::onKeyPressEvent(GdkEventKey *event) consume = true; break; } + + case GDK_KEY_End: + case GDK_KEY_KP_End: { + moveSelection(0, true, true); + consume = true; + break; + } + + case GDK_KEY_Home: + case GDK_KEY_KP_Home: { + moveSelection(0, false, true); + consume = true; + break; + } } return consume; } |
