[libdazzle] shortcuts: add helper to steal element from chord table



commit cce82ecf447908683022d3841c2648dcf8b931d4
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 12 18:48:33 2017 -0700

    shortcuts: add helper to steal element from chord table

 src/shortcuts/dzl-shortcut-chord.c   |   15 +++++++++++++++
 src/shortcuts/dzl-shortcut-private.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-chord.c b/src/shortcuts/dzl-shortcut-chord.c
index f626c5f..9e92f0e 100644
--- a/src/shortcuts/dzl-shortcut-chord.c
+++ b/src/shortcuts/dzl-shortcut-chord.c
@@ -643,6 +643,21 @@ _dzl_shortcut_chord_table_iter_next (DzlShortcutChordTableIter  *iter,
   return FALSE;
 }
 
+void
+_dzl_shortcut_chord_table_iter_steal (DzlShortcutChordTableIter  *iter)
+{
+  g_return_if_fail (iter != NULL);
+  g_return_if_fail (iter->table != NULL);
+
+  if (iter->position > 0 && iter->position < iter->table->len)
+    {
+      dzl_shortcut_chord_table_remove_index (iter->table, --iter->position);
+      return;
+    }
+
+  g_warning ("Attempt to steal item from table that does not exist");
+}
+
 gboolean
 dzl_shortcut_chord_has_modifier (const DzlShortcutChord *self)
 {
diff --git a/src/shortcuts/dzl-shortcut-private.h b/src/shortcuts/dzl-shortcut-private.h
index a8d946d..681d550 100644
--- a/src/shortcuts/dzl-shortcut-private.h
+++ b/src/shortcuts/dzl-shortcut-private.h
@@ -107,6 +107,7 @@ void                   _dzl_shortcut_chord_table_iter_init      (DzlShortcutChor
 gboolean               _dzl_shortcut_chord_table_iter_next      (DzlShortcutChordTableIter  *iter,
                                                                  const DzlShortcutChord    **chord,
                                                                  gpointer                   *value);
+void                   _dzl_shortcut_chord_table_iter_steal     (DzlShortcutChordTableIter  *iter);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]