[gegl] gcut: limit tab index to max of completions
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gcut: limit tab index to max of completions
- Date: Sat, 15 Jul 2017 22:00:44 +0000 (UTC)
commit 855f5ab498257a51f1efa6b13563096bf124bdbb
Author: Øyvind Kolås <pippin gimp org>
Date: Sat Jul 15 15:53:26 2017 +0200
gcut: limit tab index to max of completions
gcut/gcut-ui.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/gcut/gcut-ui.c b/gcut/gcut-ui.c
index 1563163..ea8797e 100644
--- a/gcut/gcut-ui.c
+++ b/gcut/gcut-ui.c
@@ -2105,7 +2105,6 @@ static void update_ui_clip (Clip *clip, int clip_frame_no)
}
clip->filter_graph = serialized_filter;
g_free (old);
- fprintf (stderr, "{%s}\n", clip->filter_graph);
}
else
g_free (serialized_filter);
@@ -2240,18 +2239,30 @@ static char **gcut_get_completions (const char *filter_query)
return completions;
}
+static int strarray_count (gchar **strs)
+{
+ int i ;
+ for (i= 0; strs && strs[i]; i++);
+ return i;
+}
+
+int tab_index = 0;
+
static void complete_filter_query_edit (MrgEvent *e, void *data1, void *data2)
{
GeglNode *new = NULL;
GeglEDL *edl = data1;
gchar **completions = gcut_get_completions (filter_query);
+ int n_completions = strarray_count (completions);
if (!selected_node)
selected_node = filter_start;
+ if (tab_index > n_completions-1)
+ tab_index = 0;
if (!completions)
return;
- new = gegl_node_new_child (edl->gegl, "operation", completions[0], NULL);
+ new = gegl_node_new_child (edl->gegl, "operation", completions[tab_index], NULL);
if (filter_query)
g_free (filter_query);
filter_query = NULL;
@@ -2266,6 +2277,32 @@ static void complete_filter_query_edit (MrgEvent *e, void *data1, void *data2)
mrg_event_stop_propagate (e);
}
+
+static void filter_query_tab (MrgEvent *e, void *data1, void *data2)
+{
+ GeglEDL *edl = data1;
+ tab_index++;
+ mrg_event_stop_propagate (e);
+
+ ui_tweaks++;
+ gcut_cache_invalid (edl);
+ mrg_queue_draw (e->mrg, NULL);
+}
+
+
+static void filter_query_tab_reverse (MrgEvent *e, void *data1, void *data2)
+{
+ GeglEDL *edl = data1;
+ tab_index--;
+ if (tab_index <0)
+ tab_index = 0;
+ mrg_event_stop_propagate (e);
+
+ ui_tweaks++;
+ gcut_cache_invalid (edl);
+ mrg_queue_draw (e->mrg, NULL);
+}
+
static void end_filter_query_edit (MrgEvent *e, void *data1, void *data2)
{
GeglEDL *edl = data1;
@@ -2281,6 +2318,7 @@ static void end_filter_query_edit (MrgEvent *e, void *data1, void *data2)
static void update_filter_query (const char *new_string, void *user_data)
{
+ tab_index = 0;
if (filter_query)
g_free (filter_query);
filter_query = g_strdup (new_string);
@@ -2345,6 +2383,8 @@ static void gcut_draw (Mrg *mrg,
mrg_edit_end (mrg);
mrg_add_binding (mrg, "escape", NULL, "end edit", end_filter_query_edit, edl);
+ mrg_add_binding (mrg, "shift-tab", NULL, "end edit", filter_query_tab_reverse, edl);
+ mrg_add_binding (mrg, "tab", NULL, "end edit", filter_query_tab, edl);
mrg_add_binding (mrg, "return", NULL, "end edit", complete_filter_query_edit, edl);
// XXX: print completions that are clickable?
@@ -2357,6 +2397,9 @@ static void gcut_draw (Mrg *mrg,
gint matches=0;
for (int i = 0; operations[i] && matches < 40; i++)
{
+ if (i == tab_index)
+ mrg_printf (mrg, "[%s]", operations[i]);
+ else
mrg_printf (mrg, "%s", operations[i]);
mrg_printf (mrg, " ");
matches ++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]