[gnome-logs/wip/empty-listbox] Show only user events in the applications category



commit 127a759856be6cf3db26c1ddf0374c8098ba3bae
Author: David King <davidk gnome org>
Date:   Mon Oct 28 13:30:49 2013 +0000

    Show only user events in the applications category
    
    Refine the query for applications to only show events from the same user
    that is running the application.

 src/gl-eventview.c |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/src/gl-eventview.c b/src/gl-eventview.c
index 1d351d0..cd41b10 100644
--- a/src/gl-eventview.c
+++ b/src/gl-eventview.c
@@ -898,25 +898,54 @@ static void
 gl_event_view_add_listbox_applications (GlEventView *view)
 {
     GlEventViewPrivate *priv;
-    /* Allow all _TRANSPORT != kernel. */
-    const GlJournalQuery query = { N_RESULTS,
-                                   (gchar *[4]){ "_TRANSPORT=journal",
-                                                 "_TRANSPORT=stdout",
-                                                 "_TRANSPORT=syslog", NULL } };
+    GCredentials *creds;
+    uid_t uid;
     GtkWidget *listbox;
     GtkWidget *scrolled;
 
     priv = gl_event_view_get_instance_private (view);
 
     listbox = gl_event_view_list_box_new (view);
+    creds = g_credentials_new ();
+    uid = g_credentials_get_unix_user (creds, NULL);
 
-    insert_journal_query_cmdline (priv->journal, &query,
-                                  GTK_LIST_BOX (listbox));
+    /* Allow all _TRANSPORT != kernel. Attempt to filter by only processes
+     * owned by the same UID. */
+    if (uid != -1)
+    {
+        gchar *uid_str;
+
+        uid_str = g_strdup_printf ("_UID=%d", uid);
+
+        {
+            GlJournalQuery query = { N_RESULTS,
+                                     (gchar *[5]){ "_TRANSPORT=journal",
+                                                   "_TRANSPORT=stdout",
+                                                   "_TRANSPORT=syslog",
+                                                   uid_str, NULL } };
+
+            insert_journal_query_cmdline (priv->journal, &query,
+                                          GTK_LIST_BOX (listbox));
+        }
+        g_free (uid_str);
+    }
+    else
+    {
+        GlJournalQuery query = { N_RESULTS,
+                                 (gchar *[4]){ "_TRANSPORT=journal",
+                                               "_TRANSPORT=stdout",
+                                               "_TRANSPORT=syslog", NULL } };
+
+        insert_journal_query_cmdline (priv->journal, &query,
+                                      GTK_LIST_BOX (listbox));
+    }
 
     scrolled = gtk_scrolled_window_new (NULL, NULL);
     gtk_container_add (GTK_CONTAINER (scrolled), listbox);
     gtk_widget_show_all (scrolled);
     gtk_stack_add_named (GTK_STACK (view), scrolled, "listbox-applications");
+
+    g_object_unref (creds);
 }
 
 static void


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