[gnome-builder/wip/uajain/word-completion: 3/6] Add IdeWordCompletionResults



commit fdb00e1e730ff0460584cee0f8bf93b4567ebda3
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Aug 25 01:11:32 2017 +0530

    Add IdeWordCompletionResults

 libide/sourceview/ide-word-completion-results.c |   68 +++++++++++++++++++++++
 libide/sourceview/ide-word-completion-results.h |   51 +++++++++++++++++
 2 files changed, 119 insertions(+), 0 deletions(-)
---
diff --git a/libide/sourceview/ide-word-completion-results.c b/libide/sourceview/ide-word-completion-results.c
new file mode 100644
index 0000000..84ee7ff
--- /dev/null
+++ b/libide/sourceview/ide-word-completion-results.c
@@ -0,0 +1,68 @@
+/* ide-word-completion-results.c
+ *
+ * Copyright (C) 2017 Umang Jain <mailumangjain gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-word-completion-results"
+
+#include "sourceview/ide-word-completion-results.h"
+#include "sourceview/ide-word-completion-item.h"
+
+struct _IdeWordCompletionResults
+{
+  IdeCompletionResults parent_instance;
+};
+
+
+G_DEFINE_TYPE (IdeWordCompletionResults,
+               ide_word_completion_results,
+               IDE_TYPE_COMPLETION_RESULTS)
+
+static gint
+ide_word_completion_results_compare (IdeCompletionResults *results,
+                                     IdeCompletionItem    *left,
+                                     IdeCompletionItem    *right)
+{
+  IdeWordCompletionItem *p1 = (IdeWordCompletionItem *) left;
+  IdeWordCompletionItem *p2 = (IdeWordCompletionItem *) right;
+
+  if (ide_word_completion_item_get_offset (p1) <
+      ide_word_completion_item_get_offset (p2))
+    return -1;
+  else
+    return 1;
+}
+
+static void
+ide_word_completion_results_init (IdeWordCompletionResults *self)
+{
+}
+
+static void
+ide_word_completion_results_class_init (IdeWordCompletionResultsClass *klass)
+{
+  IdeCompletionResultsClass *results_class = IDE_COMPLETION_RESULTS_CLASS (klass);
+
+  results_class->compare = ide_word_completion_results_compare;
+}
+
+IdeWordCompletionResults *
+ide_word_completion_results_new (const gchar *query)
+{
+  return g_object_new (IDE_TYPE_WORD_COMPLETION_RESULTS,
+                       "query", query,
+                       NULL);
+}
diff --git a/libide/sourceview/ide-word-completion-results.h b/libide/sourceview/ide-word-completion-results.h
new file mode 100644
index 0000000..a8b2275
--- /dev/null
+++ b/libide/sourceview/ide-word-completion-results.h
@@ -0,0 +1,51 @@
+/* ide-word-completion-results.h
+ *
+ * Copyright (C) 2017 Umang Jain <mailumangjain gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_WORD_COMPLETION_RESULTS_H
+#define IDE_WORD_COMPLETION_RESULTS_H
+
+#include <gtksourceview/gtksource.h>
+
+#include "sourceview/ide-completion-results.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_WORD_COMPLETION_RESULTS            (ide_word_completion_results_get_type())
+#define IDE_WORD_COMPLETION_RESULTS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
IDE_TYPE_WORD_COMPLETION_RESULTS, IdeWordCompletionResults))
+#define IDE_WORD_COMPLETION_RESULTS_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
IDE_TYPE_WORD_COMPLETION_RESULTS, IdeWordCompletionResults const))
+#define IDE_WORD_COMPLETION_RESULTS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
IDE_TYPE_WORD_COMPLETION_RESULTS, IdeWordCompletionResultsClass))
+#define IDE_IS_WORD_COMPLETION_RESULTS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
IDE_TYPE_WORD_COMPLETION_RESULTS))
+#define IDE_IS_WORD_COMPLETION_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
IDE_TYPE_WORD_COMPLETION_RESULTS))
+#define IDE_WORD_COMPLETION_RESULTS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
IDE_TYPE_WORD_COMPLETION_RESULTS, IdeWordCompletionResultsClass))
+
+
+typedef struct _IdeWordCompletionResults        IdeWordCompletionResults;
+typedef struct _IdeWordCompletionResultsClass   IdeWordCompletionResultsClass;
+
+struct _IdeWordCompletionResultsClass
+{
+  IdeCompletionResultsClass parent_class;
+};
+
+GType ide_word_completion_results_get_type (void);
+
+IdeWordCompletionResults* ide_word_completion_results_new (const gchar *query);
+
+G_END_DECLS
+
+#endif /* IDE_WORD_COMPLETION_RESULTS_H */


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