From 03be7e88ac6275e42526ae581d1d621d8ffea5f7 Mon Sep 17 00:00:00 2001 From: David Kettler Date: Fri, 16 Jan 2009 17:13:33 +1030 Subject: [PATCH] mode-line: provide a widget to show count of buffers currently loading This provides a count like (2 loading) in the mode-line. When no buffers are being loaded, the widget is blank. This is useful as a notifier when a buffer is visiting a web page that loads slowly. I enable this and the buffer count with: add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true); add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true); --- modules/mode-line.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/mode-line.js b/modules/mode-line.js index f07a8fa..74a4b27 100644 --- a/modules/mode-line.js +++ b/modules/mode-line.js @@ -206,6 +206,24 @@ buffer_count_widget.prototype.update = function () { this.window.buffers.count + "]"); }; +function loading_count_widget(window) { + this.name = "loading-count-widget"; + text_widget.call(this, window); + var obj = this; + this.add_hook("content_buffer_started_loading_hook"); + this.add_hook("content_buffer_finished_loading_hook"); + this.add_hook("kill_buffer_hook"); +} +loading_count_widget.prototype.__proto__ = text_widget.prototype; +loading_count_widget.prototype.update = function () { + var count = 0; + for_each_buffer(function(b) {if (b.loading) count++;}); + if (count) + this.view.text = "(" + count + " loading)"; + else + this.view.text = ""; +}; + function mode_line_adder(widget_constructor) { if (!('mode_line_adder' in widget_constructor)) widget_constructor.mode_line_adder = function (window) { -- 2.11.4.GIT