Simple GUI buttons are provided for controlling conkeror. They are
intended to be unobtrusive and to steal as little screen space as
possible. Clicking on them executes a conkeror command. Hovering
over them tells you the command and the corresponding keystroke.
Hopefully they are useful for novices and casual users.
They can be enabled with:
add_mode_line_buttons(standard_mode_line_buttons, true);
Problems:
- The icons used do not clearly indicate their function.
- The names of the commands are also probably unclear for novices.
- There are probably too many buttons. It might be better to have
just a few, together with a popup menu.
---
modules/mode-line.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/modules/mode-line.js b/modules/mode-line.js
index 72315f7..acb5e75 100644
--- a/modules/mode-line.js
+++ b/modules/mode-line.js
@@ -33,6 +33,9 @@ generic_element_widget_container.prototype = {
element.setAttribute("class", class_name);
if (crop)
element.setAttribute("crop", crop);
+ return this.add_widget(widget, element);
+ },
+ add_widget : function (widget, element) {
element.conkeror_widget = new generic_widget_element(element, widget);
this.container.appendChild(element);
return element.conkeror_widget;
@@ -224,6 +227,46 @@ loading_count_widget.prototype.update = function () {
this.view.text = "";
};
+function make_button_widget(command, attributes) {
+ var button_widget = function(window) {
+ this.class_name = "button-widget";
+ text_widget.call(this, window);
+ }
+ button_widget.prototype.__proto__ = text_widget.prototype;
+
+ button_widget.mode_line_adder = function (window) {
+ var widget = new button_widget(window);
+ var element = create_XUL(window, "image");
+
+ element.addEventListener("click", function (event) {
+ var ctx = { window: window, key_sequence: [], sticky_modifiers: 0 };
+ call_interactively(ctx, command);
+ }, false);
+
+ element.addEventListener("mouseover", function (event) {
+ var msg = "Button: " + command;
+ var list = find_command_in_keymap(window.buffers.current, command);
+ if (list.length)
+ msg += " (which is on key " + list.join(", ") + ")";
+ window.minibuffer.show(msg);
+ }, false);
+
+ element.addEventListener("mouseout", function (event) {
+ window.minibuffer.show("");
+ }, false);
+
+ element.setAttribute("id", "button-widget-" + command);
+ element.setAttribute("class", widget.class_name);
+ for (var a in attributes) {
+ element.setAttribute(a, attributes[a]);
+ }
+
+ window.mode_line.add_widget(widget, element);
+ };
+
+ return button_widget;
+}
+
function mode_line_adder(widget_constructor) {
if (!('mode_line_adder' in widget_constructor))
widget_constructor.mode_line_adder = function (window) {
@@ -232,6 +275,40 @@ function mode_line_adder(widget_constructor) {
return widget_constructor.mode_line_adder;
}
+function mode_line_button(command, attributes, prepend) {
+ add_hook("mode_line_hook", mode_line_adder(make_button_widget(command, attributes)), prepend);
+}
+
+function simple_mode_line_button(command, icon, prepend) {
+ var attributes;
+ if (typeof(icon) == "string")
+ attributes = {src: "moz-icon://stock/gtk-" + icon};
+ else
+ attributes = icon;
+ mode_line_button(command, attributes, prepend);
+}
+
+function add_mode_line_buttons(buttons, prepend) {
+ if (prepend)
+ for (var i = buttons.length-1; i >= 0; i--)
+ simple_mode_line_button(buttons[i][0], buttons[i][1], true);
+ else
+ for (var i = 0; i < buttons.length; i++)
+ simple_mode_line_button(buttons[i][0], buttons[i][1], false);
+}
+
+standard_mode_line_buttons = [
+ ["find-url", "open"],
+ ["find-url-new-buffer", "new"],
+ ["go-back", "go-back"],
+ ["go-forward", "go-forward"],
+ ["reload", "refresh"],
+ ["kill-current-buffer", "close"],
+ ["buffer-previous", "go-up"],
+ ["buffer-next", "go-down"],
+ ["help-page", "help"],
+];
+
add_hook("mode_line_hook", mode_line_adder(current_buffer_name_widget));
add_hook("mode_line_hook", mode_line_adder(clock_widget));
add_hook("mode_line_hook", mode_line_adder(current_buffer_scroll_position_widget));
--
1.6.2.1
_______________________________________________
Conkeror mailing list
Conkeror@...
https://www.mozdev.org/mailman/listinfo/conkeror