[gnome-logs] eventviewlist: simplify applications query logic



commit 18c496728c2467e5a5f6749d035d2175da075218
Author: Lars Uebernickel <lars uebernic de>
Date:   Sat Feb 14 19:42:07 2015 +0100

    eventviewlist: simplify applications query logic

 src/gl-eventviewlist.c |   52 +++++++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 27 deletions(-)
---
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 15cafc9..3b5c4c2 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -415,47 +415,45 @@ gl_event_view_list_add_listbox_all (GlEventViewList *view)
     gl_journal_query_async (priv->journal, query, NULL, query_ready, view);
 }
 
-static void
-gl_event_view_list_add_listbox_applications (GlEventViewList *view)
+static gchar *
+create_uid_match_string (void)
 {
     GCredentials *creds;
     uid_t uid;
-    GlEventViewListPrivate *priv;
+    gchar *str = NULL;
 
-    priv = gl_event_view_list_get_instance_private (view);
-    priv->current_row_style = GL_EVENT_VIEW_ROW_STYLE_CMDLINE;
     creds = g_credentials_new ();
     uid = g_credentials_get_unix_user (creds, NULL);
 
-    /* Allow all _TRANSPORT != kernel. Attempt to filter by only processes
-     * owned by the same UID. */
     if (uid != -1)
-    {
-        gchar *uid_str;
+        str = g_strdup_printf ("_UID=%d", uid);
 
-        uid_str = g_strdup_printf ("_UID=%d", uid);
+    g_object_unref (creds);
+    return str;
+}
 
-        {
-            const gchar *query[] = { "_TRANSPORT=journal",
-                                     "_TRANSPORT=stdout",
-                                     "_TRANSPORT=syslog",
-                                     uid_str, NULL };
+/* Allow all _TRANSPORT != kernel. Attempt to filter by only processes
+ * owned by the same UID. */
+static void
+gl_event_view_list_add_listbox_applications (GlEventViewList *view)
+{
+    GlEventViewListPrivate *priv;
+    gchar *uid_str = NULL;
+    const gchar *query[] = { "_TRANSPORT=journal",
+                             "_TRANSPORT=stdout",
+                             "_TRANSPORT=syslog",
+                             NULL,
+                             NULL };
 
-            gl_journal_query_async (priv->journal, query, NULL, query_ready, view);
-        }
+    priv = gl_event_view_list_get_instance_private (view);
+    priv->current_row_style = GL_EVENT_VIEW_ROW_STYLE_CMDLINE;
 
-        g_free (uid_str);
-    }
-    else
-    {
-        const gchar *query[] = { "_TRANSPORT=journal",
-                                 "_TRANSPORT=stdout",
-                                 "_TRANSPORT=syslog", NULL };
+    uid_str = create_uid_match_string ();
+    query[3] = uid_str;
 
-        gl_journal_query_async (priv->journal, query, NULL, query_ready, view);
-    }
+    gl_journal_query_async (priv->journal, query, NULL, query_ready, view);
 
-    g_object_unref (creds);
+    g_free (uid_str);
 }
 
 static void


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