diff --git a/draw.js b/draw.js index ae5d198..77d6ac1 100644 --- a/draw.js +++ b/draw.js @@ -70,7 +70,7 @@ var FontFamilyNames = { 0: 'Default', 1: 'Sans-Serif', 2: 'Serif', 3: 'Monospac var DrawingArea = new Lang.Class({ Name: 'DrawOnYourScreenDrawingArea', Extends: St.DrawingArea, - Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, + Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, 'stop-drawing': {} }, _init: function(params, monitor, helper, loadJson) { @@ -322,7 +322,7 @@ var DrawingArea = new Lang.Class({ if (this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.DRAWING) { this.currentElement.state = TextState.WRITING; this.currentElement.text = ''; - this.emit('show-osd', _("Type your text\nand press Enter"), -1); + this.emit('show-osd', null, _("Type your text\nand press Enter"), -1); this._updateCursorTimeout(); this.textHasCursor = true; this._redisplay(); @@ -468,38 +468,38 @@ var DrawingArea = new Lang.Class({ this.currentElement.color = this.currentColor.to_string(); this._redisplay(); } - this.emit('show-osd', `${this.currentColor.to_string()}`, -1); + this.emit('show-osd', null, `${this.currentColor.to_string()}`, -1); }, selectShape: function(shape) { this.currentShape = shape; - this.emit('show-osd', _(ShapeNames[shape]), -1); + this.emit('show-osd', null, _(ShapeNames[shape]), -1); this.updatePointerCursor(); }, toggleFill: function() { this.fill = !this.fill; - this.emit('show-osd', this.fill ? _("Fill") : _("Stroke"), -1); + this.emit('show-osd', null, this.fill ? _("Fill") : _("Stroke"), -1); }, toggleDash: function() { this.dashedLine = !this.dashedLine; - this.emit('show-osd', this.dashedLine ? _("Dashed line") : _("Full line"), -1); + this.emit('show-osd', null, this.dashedLine ? _("Dashed line") : _("Full line"), -1); }, incrementLineWidth: function(increment) { this.currentLineWidth = Math.max(this.currentLineWidth + increment, 0); - this.emit('show-osd', this.currentLineWidth + " " + _("px"), 2 * this.currentLineWidth); + this.emit('show-osd', null, this.currentLineWidth + " " + _("px"), 2 * this.currentLineWidth); }, toggleLineJoin: function() { this.currentLineJoin = this.currentLineJoin == 2 ? 0 : this.currentLineJoin + 1; - this.emit('show-osd', _(LineJoinNames[this.currentLineJoin]), -1); + this.emit('show-osd', null, _(LineJoinNames[this.currentLineJoin]), -1); }, toggleLineCap: function() { this.currentLineCap = this.currentLineCap == 2 ? 0 : this.currentLineCap + 1; - this.emit('show-osd', _(LineCapNames[this.currentLineCap]), -1); + this.emit('show-osd', null, _(LineCapNames[this.currentLineCap]), -1); }, toggleFontWeight: function() { @@ -508,7 +508,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.weight = this.currentFontWeight; this._redisplay(); } - this.emit('show-osd', `${_(FontWeightNames[this.currentFontWeight])}`, -1); + this.emit('show-osd', null, `${_(FontWeightNames[this.currentFontWeight])}`, -1); }, toggleFontStyle: function() { @@ -517,7 +517,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.style = this.currentFontStyle; this._redisplay(); } - this.emit('show-osd', `${_(FontStyleNames[this.currentFontStyle])}`, -1); + this.emit('show-osd', null, `${_(FontStyleNames[this.currentFontStyle])}`, -1); }, toggleFontFamily: function() { @@ -527,7 +527,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.family = currentFontFamily; this._redisplay(); } - this.emit('show-osd', `${_(currentFontFamily)}`, -1); + this.emit('show-osd', null, `${_(currentFontFamily)}`, -1); }, toggleHelp: function() { diff --git a/extension.js b/extension.js index 6491dfb..635c99a 100644 --- a/extension.js +++ b/extension.js @@ -315,11 +315,12 @@ var AreaManager = new Lang.Class({ }, // use level -1 to set no level (null) - showOsd: function(emitter, label, level, maxLevel) { + showOsd: function(emitter, iconName, label, level) { if (this.osdDisabled) return; let activeIndex = this.areas.indexOf(this.activeArea); if (activeIndex != -1) { + let maxLevel; if (level == -1) level = null; else if (level > 100) @@ -329,7 +330,9 @@ var AreaManager = new Lang.Class({ // GS 3.34+ : bar from 0 to 1 if (level && GS_VERSION > '3.33.0') level = level / 100; - Main.osdWindowManager.show(activeIndex, this.enterGicon, label, level, maxLevel); + + let icon = iconName && new Gio.ThemedIcon({ name: iconName }); + Main.osdWindowManager.show(activeIndex, icon || this.enterGicon, label, level, maxLevel); Main.osdWindowManager._osdWindows[activeIndex]._label.get_clutter_text().set_use_markup(true); if (level === 0) {