[gnome-logs] Define GlRowEntry object and it's API



commit 08a5624b1eb28d8419637a1b655dfe192b71473e
Author: Pranav Ganorkar <pranavg189 gmail com>
Date:   Fri Jun 9 14:42:57 2017 +0530

    Define GlRowEntry object and it's API
    
    The GlRowEntry object includes flags/variables to store information
    about the compression of journal entries and pass it on from the
    model to view.
    
    There are three types of row entries: uncompressed, compressed, header.
    
    If a row entry is a header, then it also stores the compressed
    journal entries which are represented by the header.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709294

 src/gl-journal-model.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/gl-journal-model.h |   19 +++++++++++++
 2 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/src/gl-journal-model.c b/src/gl-journal-model.c
index 4eb745b..802fc4a 100644
--- a/src/gl-journal-model.c
+++ b/src/gl-journal-model.c
@@ -27,6 +27,19 @@ typedef struct GlQueryItem
     GlQuerySearchType search_type;
 } GlQueryItem;
 
+struct _GlRowEntry
+{
+    GObject parent_instance;
+
+    GlJournalEntry *journal_entry;
+    GlRowEntryType row_type;
+
+    /* Number of compressed entries represented by
+     * a compressed entries header
+     */
+    guint compressed_entries;
+};
+
 struct _GlJournalModel
 {
     GObject parent_instance;
@@ -49,6 +62,8 @@ static GPtrArray *tokenize_search_string (gchar *search_text);
 static gboolean search_in_entry (GlJournalEntry *entry, GlJournalModel *model);
 static gboolean gl_query_check_journal_end (GlQuery *query, GlJournalEntry *entry);
 
+G_DEFINE_TYPE (GlRowEntry, gl_row_entry, G_TYPE_OBJECT);
+
 G_DEFINE_TYPE_WITH_CODE (GlJournalModel, gl_journal_model, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gl_journal_model_interface_init))
 
@@ -1044,3 +1059,55 @@ gl_journal_model_fetch_more_entries (GlJournalModel *model,
         g_object_notify_by_pspec (G_OBJECT (model), properties[PROP_LOADING]);
     }
 }
+
+GlRowEntry *
+gl_row_entry_new (void)
+{
+    return g_object_new (GL_TYPE_ROW_ENTRY, NULL);
+}
+
+GlJournalEntry *
+gl_row_entry_get_journal_entry (GlRowEntry *entry)
+{
+    g_return_val_if_fail (GL_IS_ROW_ENTRY (entry), NULL);
+
+    return entry->journal_entry;
+}
+
+GlRowEntryType
+gl_row_entry_get_row_type (GlRowEntry *entry)
+{
+    return entry->row_type;
+}
+
+guint
+gl_row_entry_get_compressed_entries (GlRowEntry *entry)
+{
+    return entry->compressed_entries;
+}
+
+static void
+gl_row_entry_init (GlRowEntry *entry)
+{
+    entry->journal_entry = NULL;
+    entry->row_type = GL_ROW_ENTRY_TYPE_UNCOMPRESSED;
+    entry->compressed_entries = 0;
+}
+
+static void
+gl_row_entry_finalize (GObject *object)
+{
+  GlRowEntry *row_entry = GL_ROW_ENTRY (object);
+
+  g_clear_object (&row_entry->journal_entry);
+
+  G_OBJECT_CLASS (gl_row_entry_parent_class)->finalize (object);
+}
+
+static void
+gl_row_entry_class_init (GlRowEntryClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = gl_row_entry_finalize;
+}
diff --git a/src/gl-journal-model.h b/src/gl-journal-model.h
index 5a6c1ce..49818b8 100644
--- a/src/gl-journal-model.h
+++ b/src/gl-journal-model.h
@@ -22,6 +22,7 @@
 #include <gio/gio.h>
 
 #include "gl-application.h"
+#include "gl-journal.h"
 
 typedef enum
 {
@@ -29,6 +30,13 @@ typedef enum
     GL_QUERY_SEARCH_TYPE_EXACT
 } GlQuerySearchType;
 
+typedef enum
+{
+    GL_ROW_ENTRY_TYPE_UNCOMPRESSED,
+    GL_ROW_ENTRY_TYPE_COMPRESSED,
+    GL_ROW_ENTRY_TYPE_HEADER
+} GlRowEntryType;
+
 /* Resultant query passed to journal model from eventviewlist */
 typedef struct GlQuery
 {
@@ -39,6 +47,9 @@ typedef struct GlQuery
     guint64 end_timestamp;
 } GlQuery;
 
+#define GL_TYPE_ROW_ENTRY gl_row_entry_get_type()
+G_DECLARE_FINAL_TYPE (GlRowEntry, gl_row_entry, GL, ROW_ENTRY, GObject)
+
 #define GL_TYPE_JOURNAL_MODEL gl_journal_model_get_type()
 G_DECLARE_FINAL_TYPE (GlJournalModel, gl_journal_model, GL, JOURNAL_MODEL, GObject)
 
@@ -46,6 +57,8 @@ GlJournalModel *        gl_journal_model_new                            (void);
 
 GlQuery *               gl_query_new                                    (void);
 
+GlRowEntry *            gl_row_entry_new                                (void);
+
 void                    gl_journal_model_take_query                     (GlJournalModel *model,
                                                                          GlQuery *query);
 
@@ -77,4 +90,10 @@ void                    gl_query_set_search_type                        (GlQuery
 void                    gl_query_set_sort_order                         (GlQuery *query,
                                                                          GlSortOrder order);
 
+GlJournalEntry *        gl_row_entry_get_journal_entry                  (GlRowEntry *entry);
+
+GlRowEntryType          gl_row_entry_get_row_type                       (GlRowEntry *entry);
+
+guint                   gl_row_entry_get_compressed_entries             (GlRowEntry *entry);
+
 #endif


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