summaryrefslogtreecommitdiffstats
path: root/src/widgets/gradient-selector.cpp
diff options
context:
space:
mode:
authorNathan Lee <2431820-nathanal@users.noreply.gitlab.com>2019-07-17 13:53:53 +0000
committerNathan Lee <2431820-nathanal@users.noreply.gitlab.com>2019-07-17 14:37:37 +0000
commit38bde4dc227c01dea1c7843529d4f1c6e507314b (patch)
tree6ee904039f99ef51e3285c8cbde14beebd54b20a /src/widgets/gradient-selector.cpp
parentUpdate hr.po with current pot file (diff)
downloadinkscape-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.cpp40
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;
}