[gtksourceview] CompletionModel: fix provider visibility update
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] CompletionModel: fix provider visibility update
- Date: Tue, 10 Apr 2012 15:04:02 +0000 (UTC)
commit 34fd522b9fbb57e429084d486a68d9e97f27e34b
Author: SÃbastien Wilmet <sebastien wilmet gmail com>
Date: Mon Apr 9 00:08:35 2012 +0200
CompletionModel: fix provider visibility update
Take into account the fact that the nodes can be filtered (e.g. the
header if 'show-headers' is false).
To make the code easier to understand, split the function in two:
_show() and _hide().
gtksourceview/gtksourcecompletionmodel.c | 92 ++++++++++++++++++++++++------
1 files changed, 75 insertions(+), 17 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletionmodel.c b/gtksourceview/gtksourcecompletionmodel.c
index b552437..dd63e4e 100644
--- a/gtksourceview/gtksourcecompletionmodel.c
+++ b/gtksourceview/gtksourcecompletionmodel.c
@@ -880,36 +880,89 @@ update_header_visibility (GtkSourceCompletionModel *model)
}
static void
-update_provider_visibility_show_hide (GtkSourceCompletionModel *model,
- ProviderInfo *info,
- gboolean show)
+update_provider_visibility_show (GtkSourceCompletionModel *model,
+ ProviderInfo *info)
{
GList *item;
GtkTreePath *path = NULL;
- item = info->first;
- info->filtered = !show;
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (info->first != NULL);
- while (item)
+ if (info->filtered == FALSE)
{
- ProposalNode *node = (ProposalNode *)item->data;
+ return;
+ }
- node->filtered = !show;
+ info->filtered = FALSE;
- if (path == NULL)
+ for (item = info->first; item != NULL; item = g_list_next (item))
+ {
+ ProposalNode *node = (ProposalNode *)item->data;
+
+ /* Check whether the header should be displayed */
+ if (item == info->first && !model->priv->show_headers)
{
- path = path_from_list (model, item);
+ node->filtered = TRUE;
}
-
- if (show)
+ else
{
- ++model->priv->num;
+ node->filtered = FALSE;
+
+ if (path == NULL)
+ {
+ path = path_from_list (model, item);
+ }
+ ++model->priv->num;
handle_row_inserted (model, item, &path);
gtk_tree_path_next (path);
}
- else
+
+ if (item == info->last)
{
+ break;
+ }
+ }
+
+ if (path != NULL)
+ {
+ gtk_tree_path_free (path);
+ }
+}
+
+static void
+update_provider_visibility_hide (GtkSourceCompletionModel *model,
+ ProviderInfo *info)
+{
+ GList *item;
+ GtkTreePath *path = NULL;
+
+ g_return_if_fail (info != NULL);
+ g_return_if_fail (info->first != NULL);
+
+ if (info->filtered == TRUE)
+ {
+ return;
+ }
+
+ info->filtered = TRUE;
+
+ for (item = info->first; item != NULL; item = g_list_next (item))
+ {
+ ProposalNode *node = (ProposalNode *)item->data;
+
+ /* Hide only the nodes that are not already filtered.
+ * For example, the header can be hidden. */
+ if (!node->filtered)
+ {
+ node->filtered = TRUE;
+
+ if (path == NULL)
+ {
+ path = path_from_list (model, item);
+ }
+
--model->priv->num;
handle_row_deleted (model, item, &path);
}
@@ -918,8 +971,6 @@ update_provider_visibility_show_hide (GtkSourceCompletionModel *model,
{
break;
}
-
- item = g_list_next (item);
}
if (path != NULL)
@@ -939,7 +990,14 @@ update_provider_visibility_each (GtkSourceCompletionProvider *provider,
return;
}
- update_provider_visibility_show_hide (model, info, info->filtered);
+ if (info->filtered)
+ {
+ update_provider_visibility_show (model, info);
+ }
+ else
+ {
+ update_provider_visibility_hide (model, info);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]