[gnome-builder/wip/slaf/pack] xml-pack: add comments for signals and properties completion
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/pack] xml-pack: add comments for signals and properties completion
- Date: Sat, 21 Jul 2018 18:37:35 +0000 (UTC)
commit 397aca0172c4ed899063c10c443fdebfe9856c77
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sat Jul 21 16:39:49 2018 +0200
xml-pack: add comments for signals and properties completion
"comment" is the text field at the bottom of
the completion window.
src/plugins/xml-pack/ide-xml-completion-provider.c | 44 +++++++++++++++++++++-
src/plugins/xml-pack/ide-xml-proposal.c | 17 +++++++++
src/plugins/xml-pack/ide-xml-proposal.h | 2 +
3 files changed, 62 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/xml-pack/ide-xml-completion-provider.c
b/src/plugins/xml-pack/ide-xml-completion-provider.c
index f2d4eebd7..27a678c6a 100644
--- a/src/plugins/xml-pack/ide-xml-completion-provider.c
+++ b/src/plugins/xml-pack/ide-xml-completion-provider.c
@@ -837,7 +837,14 @@ get_element_proposals (IdeXmlPosition *position,
else
continue;
- item = ide_xml_proposal_new (string->str, NULL, label, prefix, pos, kind,
IDE_XML_COMPLETION_TYPE_ELEMENT);
+ item = ide_xml_proposal_new (string->str,
+ NULL,
+ label,
+ prefix,
+ NULL,
+ pos,
+ kind,
+ IDE_XML_COMPLETION_TYPE_ELEMENT);
results = g_list_prepend (results, item);
}
@@ -876,6 +883,7 @@ get_attributes_proposals (IdeXmlPosition *position,
match_item->is_optional ? "optional" : NULL,
name,
detail->prefix,
+ NULL,
pos,
kind,
IDE_XML_COMPLETION_TYPE_ATTRIBUTE);
@@ -934,6 +942,7 @@ get_values_proposals (IdeXmlPosition *position,
NULL,
value_match_item->name,
detail->prefix,
+ NULL,
-1,
kind,
IDE_XML_COMPLETION_TYPE_VALUE));
@@ -995,6 +1004,7 @@ try_get_gtype_proposals (IdeXmlCompletionProvider *self,
namespace,
src_item->word,
detail->value,
+ NULL,
-1,
kind,
IDE_XML_COMPLETION_TYPE_UI_GTYPE);
@@ -1046,6 +1056,7 @@ append_object_properties (IdeGiBase *object,
NULL,
name,
word,
+ g_steal_pointer (&prop),
-1,
kind,
IDE_XML_COMPLETION_TYPE_UI_PROPERTY));
@@ -1170,6 +1181,7 @@ append_object_signals (IdeGiBase *object,
NULL,
name,
word,
+ g_steal_pointer (&signal),
-1,
kind,
IDE_XML_COMPLETION_TYPE_UI_SIGNAL);
@@ -1308,6 +1320,7 @@ try_get_requires_lib_proposals (IdeXmlCompletionProvider *self,
NULL,
prefix_item->word,
detail->prefix,
+ NULL,
-1,
kind,
IDE_XML_COMPLETION_TYPE_UI_PACKAGE);
@@ -1698,6 +1711,33 @@ ide_xml_completion_provider_activate_proposal (IdeCompletionProvider *provider,
}
}
+static gchar *
+ide_xml_completion_provider_get_comment (IdeCompletionProvider *provider,
+ IdeCompletionProposal *proposal)
+{
+ IdeXmlProposal *item = (IdeXmlProposal *)proposal;
+ IdeXmlCompletionType type;
+ g_autoptr(IdeGiDoc) doc = NULL;
+ gpointer data;
+
+ type = ide_xml_proposal_get_completion_type (item);
+ if (type == IDE_XML_COMPLETION_TYPE_UI_PROPERTY ||
+ type == IDE_XML_COMPLETION_TYPE_UI_SIGNAL)
+ {
+ data = ide_xml_proposal_get_data (item);
+ if ((doc = ide_gi_base_get_doc ((IdeGiBase *)data)))
+ return g_strdup (ide_gi_doc_get_doc (doc));
+ }
+
+ return NULL;
+}
+
+static gchar *
+ide_xml_completion_provider_get_title (IdeCompletionProvider *provider)
+{
+ return g_strdup ("Xml Completion");
+}
+
static void
ide_xml_completion_provider_finalize (GObject *object)
{
@@ -1724,6 +1764,8 @@ completion_provider_init (IdeCompletionProviderInterface *iface)
iface->display_proposal = ide_xml_completion_provider_display_proposal;
iface->populate_async = ide_xml_completion_provider_populate_async;
iface->populate_finish = ide_xml_completion_provider_populate_finish;
+ iface->get_comment = ide_xml_completion_provider_get_comment;
+ iface->get_title = ide_xml_completion_provider_get_title;
/* We don't use refilter currently because we don't get a good 'begin'
* bound, so the searched word, so refilter triggering.
*/
diff --git a/src/plugins/xml-pack/ide-xml-proposal.c b/src/plugins/xml-pack/ide-xml-proposal.c
index d739b0448..71b5bff0c 100644
--- a/src/plugins/xml-pack/ide-xml-proposal.c
+++ b/src/plugins/xml-pack/ide-xml-proposal.c
@@ -22,6 +22,8 @@
#include <ide.h>
+#include "../gi/ide-gi-objects.h"
+
#include "ide-xml-proposal.h"
struct _IdeXmlProposal
@@ -31,6 +33,7 @@ struct _IdeXmlProposal
gchar *label;
gchar *text;
gchar *prefix;
+ gpointer data;
gint insert_position;
IdeXmlCompletionType completion_type;
IdeXmlPositionKind kind;
@@ -44,6 +47,12 @@ ide_xml_proposal_finalize (GObject *object)
{
IdeXmlProposal *self = (IdeXmlProposal *)object;
+ if (self->completion_type == IDE_XML_COMPLETION_TYPE_UI_PROPERTY ||
+ self->completion_type == IDE_XML_COMPLETION_TYPE_UI_SIGNAL)
+ {
+ dzl_clear_pointer (&self->data, ide_gi_base_unref);
+ }
+
dzl_clear_pointer (&self->header, g_free);
dzl_clear_pointer (&self->label, g_free);
dzl_clear_pointer (&self->text, g_free);
@@ -70,6 +79,7 @@ ide_xml_proposal_new (const gchar *text,
const gchar *header,
const gchar *label,
const gchar *prefix,
+ gpointer data,
gint insert_position,
IdeXmlPositionKind kind,
IdeXmlCompletionType completion_type)
@@ -81,6 +91,7 @@ ide_xml_proposal_new (const gchar *text,
self->header = g_strdup (header);
self->label = g_strdup (label);
self->prefix = g_strdup (prefix);
+ self->data = data;
self->insert_position = insert_position;
self->completion_type = completion_type;
self->kind = kind;
@@ -94,6 +105,12 @@ ide_xml_proposal_get_header (IdeXmlProposal *self)
return self->header;
}
+gpointer
+ide_xml_proposal_get_data (IdeXmlProposal *self)
+{
+ return self->data;
+}
+
const gchar *
ide_xml_proposal_get_label (IdeXmlProposal *self)
{
diff --git a/src/plugins/xml-pack/ide-xml-proposal.h b/src/plugins/xml-pack/ide-xml-proposal.h
index 08f35d82f..1cdd1c915 100644
--- a/src/plugins/xml-pack/ide-xml-proposal.h
+++ b/src/plugins/xml-pack/ide-xml-proposal.h
@@ -32,9 +32,11 @@ IdeXmlProposal *ide_xml_proposal_new (const gchar
const gchar *header,
const gchar *label,
const gchar *prefix,
+ gpointer data,
gint insert_position,
IdeXmlPositionKind kind,
IdeXmlCompletionType completion_type);
+gpointer ide_xml_proposal_get_data (IdeXmlProposal *self);
const gchar *ide_xml_proposal_get_header (IdeXmlProposal *self);
gint ide_xml_proposal_get_insert_position (IdeXmlProposal *self);
IdeXmlPositionKind ide_xml_proposal_get_kind (IdeXmlProposal *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]