summaryrefslogtreecommitdiff
path: root/logview/logview-window.c
diff options
context:
space:
mode:
authorMonsta <[email protected]>2015-08-21 19:40:20 +0300
committerinfirit <[email protected]>2015-08-31 21:57:23 +0200
commit9064796891da2a4b83c4ccd53f7f1dc26b930768 (patch)
tree4b0b7030b6a61e47fbe43a0be92cfad347148f86 /logview/logview-window.c
parent3ccc6321cdb356a6ef00f3a16a76ea5a161c59b8 (diff)
downloadmate-utils-9064796891da2a4b83c4ccd53f7f1dc26b930768.tar.bz2
mate-utils-9064796891da2a4b83c4ccd53f7f1dc26b930768.tar.xz
logview: use a GCancellable when reading new lines from the log
from https://git.gnome.org/browse/gnome-system-log/commit/?id=0aeb30fae9b5855804240972790045074854f1aa
Diffstat (limited to 'logview/logview-window.c')
-rw-r--r--logview/logview-window.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/logview/logview-window.c b/logview/logview-window.c
index bc3f8a4e..3634e1d2 100644
--- a/logview/logview-window.c
+++ b/logview/logview-window.c
@@ -67,6 +67,8 @@ struct _LogviewWindowPrivate {
gulong monitor_id;
guint search_timeout_id;
+ GCancellable *read_cancellable;
+
guint filter_merge_id;
GList *active_filters;
gboolean matches_only;
@@ -919,12 +921,29 @@ loglist_day_cleared_cb (LogviewLoglist *loglist,
}
static void
+logview_window_schedule_log_read (LogviewWindow *window,
+ LogviewLog *log)
+{
+ if (window->priv->read_cancellable != NULL) {
+ g_cancellable_cancel (window->priv->read_cancellable);
+ g_clear_object (&window->priv->read_cancellable);
+ }
+
+ window->priv->read_cancellable = g_cancellable_new ();
+ logview_log_read_new_lines (log,
+ window->priv->read_cancellable,
+ (LogviewNewLinesCallback) read_new_lines_cb,
+ window);
+}
+
+static void
log_monitor_changed_cb (LogviewLog *log,
gpointer user_data)
{
+ LogviewWindow *window = user_data;
+
/* reschedule a read */
- logview_log_read_new_lines (log, (LogviewNewLinesCallback) read_new_lines_cb,
- user_data);
+ logview_window_schedule_log_read (window, log);
}
static void
@@ -960,10 +979,12 @@ read_new_lines_cb (LogviewLog *log,
gsize len;
if (error != NULL) {
- primary = g_strdup_printf (_("Can't read from \"%s\""),
- logview_log_get_display_name (log));
- logview_window_add_error (window, primary, error->message);
- g_free (primary);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ primary = g_strdup_printf (_("Can't read from \"%s\""),
+ logview_log_get_display_name (log));
+ logview_window_add_error (window, primary, error->message);
+ g_free (primary);
+ }
return;
}
@@ -1065,7 +1086,7 @@ active_log_changed_cb (LogviewManager *manager,
if (lines == NULL || logview_log_has_new_lines (log)) {
/* read the new lines */
- logview_log_read_new_lines (log, (LogviewNewLinesCallback) read_new_lines_cb, window);
+ logview_window_schedule_log_read (window, log);
} else {
/* start now monitoring the log for changes */
window->priv->monitor_id = g_signal_connect (log, "log-changed",
@@ -1237,6 +1258,11 @@ logview_window_finalize (GObject *object)
{
LogviewWindow *logview = LOGVIEW_WINDOW (object);
+ if (logview->priv->read_cancellable != NULL) {
+ g_cancellable_cancel (logview->priv->read_cancellable);
+ g_clear_object (&logview->priv->read_cancellable);
+ }
+
g_object_unref (logview->priv->ui_manager);
G_OBJECT_CLASS (logview_window_parent_class)->finalize (object);
}