[gnome-builder/wip/uajain/word-completion: 2/7] Add IdeWordCompletionResults



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

    Add IdeWordCompletionResults
    
    results : fixed

 libide/sourceview/ide-word-completion-results.c |   67 +++++++++++++++++++++++
 libide/sourceview/ide-word-completion-results.h |   36 ++++++++++++
 2 files changed, 103 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..f728182
--- /dev/null
+++ b/libide/sourceview/ide-word-completion-results.c
@@ -0,0 +1,67 @@
+/* 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..8b02463
--- /dev/null
+++ b/libide/sourceview/ide-word-completion-results.h
@@ -0,0 +1,36 @@
+/* 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())
+
+G_DECLARE_FINAL_TYPE (IdeWordCompletionResults, ide_word_completion_results, IDE, WORD_COMPLETION_RESULTS, 
IdeCompletionResults)
+
+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]