gboolean logview_log_get_has_days (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->has_days; }
char * logview_log_get_uri (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return g_file_get_uri (log->priv->file); }
GFile * logview_log_get_gfile (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return g_object_ref (log->priv->file); }
GSList * logview_log_get_days_for_cached_lines (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->days; }
gboolean logview_log_has_new_lines (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->has_new_lines; }
guint logview_log_get_cached_lines_number (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->lines_no; }
goffset logview_log_get_file_size (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->file_size; }
time_t logview_log_get_timestamp (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->file_time; }
const char * logview_log_get_display_name (LogviewLog *log) { g_assert (LOGVIEW_IS_LOG (log)); return log->priv->display_name; }
static gboolean do_read_new_lines (GIOSchedulerJob *io_job, GCancellable *cancellable, gpointer user_data) { /* this runs in a separate thread */ NewLinesJob *job = user_data; LogviewLog *log = job->log; char *line; GError *err = NULL; GPtrArray *lines; g_assert (LOGVIEW_IS_LOG (log)); g_assert (log->priv->stream != NULL); if (!log->priv->lines) { log->priv->lines = g_ptr_array_new (); g_ptr_array_add (log->priv->lines, NULL); } lines = log->priv->lines; /* remove the NULL-terminator */ g_ptr_array_remove_index (lines, lines->len - 1); while ((line = g_data_input_stream_read_line (log->priv->stream, NULL, NULL, &err)) != NULL) { g_ptr_array_add (lines, (gpointer) line); } if (err) { job->err = err; goto out; } /* NULL-terminate the array again */ g_ptr_array_add (lines, NULL); log->priv->has_new_lines = FALSE; /* we'll return only the new lines in the callback */ line = g_ptr_array_index (lines, log->priv->lines_no); job->lines = (const char **) lines->pdata + log->priv->lines_no; /* save the new number of days and lines */ job->new_days = add_new_days_to_cache (log, job->lines, log->priv->lines_no); log->priv->lines_no = (lines->len - 1); out: g_io_scheduler_job_send_to_mainloop_async (io_job, new_lines_job_done, job, NULL); return FALSE; }
void logview_loglist_update_lines (LogviewLoglist *loglist, LogviewLog *log) { GSList *days; GtkTreeIter *parent; g_assert (LOGVIEW_IS_LOGLIST (loglist)); g_assert (LOGVIEW_IS_LOG (log)); days = logview_log_get_days_for_cached_lines (log); parent = logview_loglist_find_log (loglist, log); update_days_and_lines_for_log (loglist, parent, days); gtk_tree_iter_free (parent); }