[gnome-logs/wip/async-journal: 2/2] Port GlEventViewList to use gl_journal_query_async
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs/wip/async-journal: 2/2] Port GlEventViewList to use gl_journal_query_async
- Date: Thu, 15 Jan 2015 15:40:08 +0000 (UTC)
commit 3bb398db4e9d3378eba4c313749ae9004702a33d
Author: David King <davidk gnome org>
Date: Thu Jan 15 15:28:02 2015 +0000
Port GlEventViewList to use gl_journal_query_async
src/gl-eventviewlist.c | 141 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 120 insertions(+), 21 deletions(-)
---
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 9f7f529..6dabc33 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -362,17 +362,28 @@ insert_devices_idle (GlEventViewList *view)
}
static void
-insert_journal_query_devices (GlEventViewList *view,
- const GlJournalQuery *query,
- GtkListBox *listbox)
+query_devices_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ GlEventViewList *view;
GlEventViewListPrivate *priv;
+ GlJournal *journal;
+ GError *error = NULL;
GList *l;
gsize n_results;
+ view = GL_EVENT_VIEW_LIST (user_data);
priv = gl_event_view_list_get_instance_private (view);
- priv->results = gl_journal_query (priv->journal, query);
- priv->results_listbox = listbox;
+ journal = GL_JOURNAL (source_object);
+
+ priv->results = gl_journal_query_finish (journal, res, &error);
+
+ if (!priv->results)
+ {
+ /* TODO: Check for error. */
+ g_error_free (error);
+ }
n_results = g_list_length (priv->results);
@@ -393,6 +404,20 @@ insert_journal_query_devices (GlEventViewList *view,
g_source_set_name_by_id (priv->insert_idle_id, G_STRFUNC);
}
+static void
+insert_journal_query_devices (GlEventViewList *view,
+ const GlJournalQuery *query,
+ GtkListBox *listbox)
+{
+ GlEventViewListPrivate *priv;
+
+ priv = gl_event_view_list_get_instance_private (view);
+
+ priv->results_listbox = listbox;
+ gl_journal_query_async (priv->journal, query, NULL, query_devices_ready,
+ view);
+}
+
static gboolean
insert_security_idle (GlEventViewList *view)
{
@@ -447,17 +472,28 @@ insert_security_idle (GlEventViewList *view)
}
static void
-insert_journal_query_security (GlEventViewList *view,
- const GlJournalQuery *query,
- GtkListBox *listbox)
+query_security_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ GlEventViewList *view;
GlEventViewListPrivate *priv;
+ GlJournal *journal;
+ GError *error = NULL;
GList *l;
- gsize n_results;
+ guint n_results;
+ view = GL_EVENT_VIEW_LIST (user_data);
priv = gl_event_view_list_get_instance_private (view);
- priv->results = gl_journal_query (priv->journal, query);
- priv->results_listbox = listbox;
+ journal = GL_JOURNAL (source_object);
+
+ priv->results = gl_journal_query_finish (journal, res, &error);
+
+ if (!priv->results)
+ {
+ /* TODO: Check for error. */
+ g_error_free (error);
+ }
n_results = g_list_length (priv->results);
@@ -478,6 +514,20 @@ insert_journal_query_security (GlEventViewList *view,
g_source_set_name_by_id (priv->insert_idle_id, G_STRFUNC);
}
+static void
+insert_journal_query_security (GlEventViewList *view,
+ const GlJournalQuery *query,
+ GtkListBox *listbox)
+{
+ GlEventViewListPrivate *priv;
+
+ priv = gl_event_view_list_get_instance_private (view);
+
+ priv->results_listbox = listbox;
+ gl_journal_query_async (priv->journal, query, NULL, query_security_ready,
+ view);
+}
+
static gboolean
insert_simple_idle (GlEventViewList *view)
{
@@ -527,17 +577,28 @@ insert_simple_idle (GlEventViewList *view)
}
static void
-insert_journal_query_simple (GlEventViewList *view,
- const GlJournalQuery *query,
- GtkListBox *listbox)
+query_simple_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ GlEventViewList *view;
GlEventViewListPrivate *priv;
+ GlJournal *journal;
+ GError *error = NULL;
GList *l;
gsize n_results;
+ view = GL_EVENT_VIEW_LIST (user_data);
priv = gl_event_view_list_get_instance_private (view);
- priv->results = gl_journal_query (priv->journal, query);
- priv->results_listbox = listbox;
+ journal = GL_JOURNAL (source_object);
+
+ priv->results = gl_journal_query_finish (journal, res, &error);
+
+ if (!priv->results)
+ {
+ /* TODO: Check for error. */
+ g_error_free (error);
+ }
n_results = g_list_length (priv->results);
@@ -547,6 +608,7 @@ insert_journal_query_simple (GlEventViewList *view,
}
priv->pending_results = g_queue_new ();
+
for (l = priv->results; l != NULL; l = g_list_next (l))
{
g_queue_push_tail (priv->pending_results, l->data);
@@ -556,6 +618,19 @@ insert_journal_query_simple (GlEventViewList *view,
g_source_set_name_by_id (priv->insert_idle_id, G_STRFUNC);
}
+static void
+insert_journal_query_simple (GlEventViewList *view,
+ const GlJournalQuery *query,
+ GtkListBox *listbox)
+{
+ GlEventViewListPrivate *priv;
+
+ priv = gl_event_view_list_get_instance_private (view);
+ priv->results_listbox = listbox;
+ gl_journal_query_async (priv->journal, query, NULL, query_simple_ready,
+ view);
+}
+
static gboolean
insert_cmdline_idle (GlEventViewList *view)
{
@@ -605,17 +680,28 @@ insert_cmdline_idle (GlEventViewList *view)
}
static void
-insert_journal_query_cmdline (GlEventViewList *view,
- const GlJournalQuery *query,
- GtkListBox *listbox)
+query_cmdline_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ GlEventViewList *view;
GlEventViewListPrivate *priv;
+ GlJournal *journal;
+ GError *error = NULL;
GList *l;
gsize n_results;
+ view = GL_EVENT_VIEW_LIST (user_data);
priv = gl_event_view_list_get_instance_private (view);
- priv->results = gl_journal_query (priv->journal, query);
- priv->results_listbox = listbox;
+ journal = GL_JOURNAL (source_object);
+
+ priv->results = gl_journal_query_finish (journal, res, &error);
+
+ if (!priv->results)
+ {
+ /* TODO: Check for error. */
+ g_error_free (error);
+ }
n_results = g_list_length (priv->results);
@@ -637,6 +723,19 @@ insert_journal_query_cmdline (GlEventViewList *view,
}
static void
+insert_journal_query_cmdline (GlEventViewList *view,
+ const GlJournalQuery *query,
+ GtkListBox *listbox)
+{
+ GlEventViewListPrivate *priv;
+
+ priv = gl_event_view_list_get_instance_private (view);
+ priv->results_listbox = listbox;
+ gl_journal_query_async (priv->journal, query, NULL, query_cmdline_ready,
+ view);
+}
+
+static void
gl_event_view_list_add_listbox_important (GlEventViewList *view)
{
/* Alert or emergency priority. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]