add iconName param to showOsd function
Prepare save and open drawing features.
This commit is contained in:
parent
6d27a37478
commit
f0ac2a21b0
24
draw.js
24
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', `<span foreground="${this.currentColor.to_string()}">${this.currentColor.to_string()}</span>`, -1);
|
||||
this.emit('show-osd', null, `<span foreground="${this.currentColor.to_string()}">${this.currentColor.to_string()}</span>`, -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', `<span font_weight="${FontWeightNames[this.currentFontWeight].toLowerCase()}">${_(FontWeightNames[this.currentFontWeight])}</span>`, -1);
|
||||
this.emit('show-osd', null, `<span font_weight="${FontWeightNames[this.currentFontWeight].toLowerCase()}">${_(FontWeightNames[this.currentFontWeight])}</span>`, -1);
|
||||
},
|
||||
|
||||
toggleFontStyle: function() {
|
||||
|
|
@ -517,7 +517,7 @@ var DrawingArea = new Lang.Class({
|
|||
this.currentElement.font.style = this.currentFontStyle;
|
||||
this._redisplay();
|
||||
}
|
||||
this.emit('show-osd', `<span font_style="${FontStyleNames[this.currentFontStyle].toLowerCase()}">${_(FontStyleNames[this.currentFontStyle])}</span>`, -1);
|
||||
this.emit('show-osd', null, `<span font_style="${FontStyleNames[this.currentFontStyle].toLowerCase()}">${_(FontStyleNames[this.currentFontStyle])}</span>`, -1);
|
||||
},
|
||||
|
||||
toggleFontFamily: function() {
|
||||
|
|
@ -527,7 +527,7 @@ var DrawingArea = new Lang.Class({
|
|||
this.currentElement.font.family = currentFontFamily;
|
||||
this._redisplay();
|
||||
}
|
||||
this.emit('show-osd', `<span font_family="${currentFontFamily}">${_(currentFontFamily)}</span>`, -1);
|
||||
this.emit('show-osd', null, `<span font_family="${currentFontFamily}">${_(currentFontFamily)}</span>`, -1);
|
||||
},
|
||||
|
||||
toggleHelp: function() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue