Merge branch 'dev' into 'master'

Dev

See merge request abakkk/DrawOnYourScreen!2
This commit is contained in:
abakkk 2019-03-28 22:26:42 +01:00
commit 26d27a6048
6 changed files with 292 additions and 78 deletions

53
draw.js
View File

@ -52,6 +52,7 @@ const LINECAP_ICON_PATH = Extension.dir.get_child('icons').get_child('linecap-sy
const DASHED_LINE_ICON_PATH = Extension.dir.get_child('icons').get_child('dashed-line-symbolic.svg').get_path();
var Shapes = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4 };
var TextState = { DRAWING: 0, WRITING: 1 };
var ShapeNames = { 0: "Free drawing", 1: "Line", 2: "Ellipse", 3: "Rectangle", 4: "Text" };
var LineCapNames = { 0: 'Butt', 1: 'Round', 2: 'Square' };
var LineJoinNames = { 0: 'Miter', 1: 'Round', 2: 'Bevel' };
@ -159,12 +160,12 @@ var DrawingArea = new Lang.Class({
let shiftPressed = event.has_shift_modifier();
// stop writing
if (this.currentElement && this.currentElement.shape == Shapes.TEXT) {
if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING ) {
this._stopWriting();
}
// hide helper
if (this.helper.visible && button != 2) {
if (this.helper.visible) {
this.helper.hideHelp();
return Clutter.EVENT_STOP;
}
@ -173,7 +174,7 @@ var DrawingArea = new Lang.Class({
this._startDrawing(x, y, shiftPressed);
return Clutter.EVENT_STOP;
} else if (button == 2) {
this.toggleShape();
this.toggleFill();
} else if (button == 3) {
this._stopDrawing();
this.menu.open(x, y);
@ -196,7 +197,7 @@ var DrawingArea = new Lang.Class({
this.emitter.emit('stop-drawing');
return Clutter.EVENT_STOP;
} else if (this.currentElement && this.currentElement.shape == Shapes.TEXT) {
} else if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING) {
if (event.get_key_symbol() == Clutter.KEY_BackSpace) {
this.currentElement.text = this.currentElement.text.slice(0, -1);
this._updateCursorTimeout();
@ -251,7 +252,7 @@ var DrawingArea = new Lang.Class({
this.smoothedStroke = this.settings.get_boolean('smoothed-stroke');
this.currentElement = new DrawingElement ({
shape: this.currentShape == Shapes.TEXT ? Shapes.RECTANGLE : this.currentShape,
shape: this.currentShape,
color: this.currentColor.to_string(),
line: { lineWidth: this.currentLineWidth, lineJoin: this.currentLineJoin, lineCap: this.currentLineCap },
dash: { array: this.dashedLine ? this.dashArray : [0, 0] , offset: this.dashedLine ? this.dashOffset : 0 },
@ -263,6 +264,14 @@ var DrawingArea = new Lang.Class({
points: [[startX, startY]]
});
if (this.currentShape == Shapes.TEXT) {
this.currentElement.line = { lineWidth: 1, lineJoin: 0, lineCap: 0 };
this.currentElement.dash = { array: [1, 1] , offset: 0 };
this.currentElement.fill = false;
this.currentElement.text = _("Text");
this.currentElement.state = TextState.DRAWING;
}
this.motionHandler = this.connect('motion-event', (actor, event) => {
let coords = event.get_coords();
let [s, x, y] = this.transform_stage_point(coords[0], coords[1]);
@ -289,11 +298,12 @@ var DrawingArea = new Lang.Class({
Math.hypot(this.currentElement.points[1][0] - this.currentElement.points[0][0], this.currentElement.points[1][1] - this.currentElement.points[0][1]) > 3)) {
// start writing
if (this.currentShape == Shapes.TEXT) {
this.currentElement.shape = Shapes.TEXT;
if (this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.DRAWING) {
this.currentElement.state = TextState.WRITING;
this.currentElement.text = '';
this.emitter.emit('show-osd', _("Type your text\nand press Enter"), null);
this._updateCursorTimeout();
this.textHasCursor = true;
this._redisplay();
return;
}
@ -310,7 +320,7 @@ var DrawingArea = new Lang.Class({
return;
if (this.currentElement.shape == Shapes.NONE)
this.currentElement.addPoint(x, y, this.smoothedStroke);
else if (this.currentElement.shape == Shapes.RECTANGLE && (controlPressed || this.currentElement.transform.active))
else if ((this.currentElement.shape == Shapes.RECTANGLE || this.currentElement.shape == Shapes.TEXT) && (controlPressed || this.currentElement.transform.active))
this.currentElement.transformRectangle(x, y);
else if (this.currentElement.shape == Shapes.ELLIPSE && (controlPressed || this.currentElement.transform.active))
this.currentElement.transformEllipse(x, y);
@ -427,10 +437,6 @@ var DrawingArea = new Lang.Class({
this.emitter.emit('show-osd', _(ShapeNames[shape]), null);
},
toggleShape: function() {
this.selectShape((this.currentShape == Object.keys(Shapes).length - 1) ? 0 : this.currentShape + 1);
},
toggleFill: function() {
this.fill = !this.fill;
this.emitter.emit('show-osd', this.fill ? _("Fill") : _("Stroke"), null);
@ -443,17 +449,17 @@ var DrawingArea = new Lang.Class({
incrementLineWidth: function(increment) {
this.currentLineWidth = Math.max(this.currentLineWidth + increment, 1);
this.emitter.emit('show-osd', this.currentLineWidth + "px", this.currentLineWidth);
this.emitter.emit('show-osd', this.currentLineWidth + " " + _("px"), this.currentLineWidth);
},
toggleLineJoin: function() {
this.currentLineJoin = this.currentLineJoin == 2 ? 0 : this.currentLineJoin + 1;
this.emitter.emit('show-osd', LineJoinNames[this.currentLineJoin], null);
this.emitter.emit('show-osd', _(LineJoinNames[this.currentLineJoin]), null);
},
toggleLineCap: function() {
this.currentLineCap = this.currentLineCap == 2 ? 0 : this.currentLineCap + 1;
this.emitter.emit('show-osd', LineCapNames[this.currentLineCap], null);
this.emitter.emit('show-osd', _(LineCapNames[this.currentLineCap]), null);
},
toggleFontWeight: function() {
@ -462,7 +468,7 @@ var DrawingArea = new Lang.Class({
this.currentElement.font.weight = this.currentFontWeight;
this._redisplay();
}
this.emitter.emit('show-osd', `<span font_weight="${FontWeightNames[this.currentFontWeight].toLowerCase()}">${FontWeightNames[this.currentFontWeight]}</span>`, null);
this.emitter.emit('show-osd', `<span font_weight="${FontWeightNames[this.currentFontWeight].toLowerCase()}">${_(FontWeightNames[this.currentFontWeight])}</span>`, null);
},
toggleFontStyle: function() {
@ -471,7 +477,7 @@ var DrawingArea = new Lang.Class({
this.currentElement.font.style = this.currentFontStyle;
this._redisplay();
}
this.emitter.emit('show-osd', `<span font_style="${FontStyleNames[this.currentFontStyle].toLowerCase()}">${FontStyleNames[this.currentFontStyle]}</span>`, null);
this.emitter.emit('show-osd', `<span font_style="${FontStyleNames[this.currentFontStyle].toLowerCase()}">${_(FontStyleNames[this.currentFontStyle])}</span>`, null);
},
toggleFontFamily: function() {
@ -481,7 +487,7 @@ var DrawingArea = new Lang.Class({
this.currentElement.font.family = currentFontFamily;
this._redisplay();
}
this.emitter.emit('show-osd', `<span font_family="${currentFontFamily}">${currentFontFamily}</span>`, null);
this.emitter.emit('show-osd', `<span font_family="${currentFontFamily}">${_(currentFontFamily)}</span>`, null);
},
toggleHelp: function() {
@ -496,7 +502,6 @@ var DrawingArea = new Lang.Class({
this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
this._onKeyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this));
this.selectShape(Shapes.NONE);
this.get_parent().set_background_color(this.hasBackground ? this.activeBackgroundColor : null);
this._updateStyle();
},
@ -532,6 +537,7 @@ var DrawingArea = new Lang.Class({
this.currentElement = null;
this._stopCursorTimeout();
this.currentShape = Shapes.NONE;
this.dashedLine = false;
this.fill = false;
this._redisplay();
@ -543,9 +549,9 @@ var DrawingArea = new Lang.Class({
saveAsSvg: function() {
// stop drawing or writing
if (this.currentElement && this.currentElement.shape == Shapes.TEXT) {
if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING) {
this._stopWriting();
} else if (this.currentElement && this.currentShape != Shapes.TEXT) {
} else if (this.currentElement && this.currentElement.shape != Shapes.TEXT) {
this._stopDrawing();
}
@ -706,6 +712,8 @@ var DrawingElement = new Lang.Class({
} else if (shape == Shapes.TEXT && points.length == 2) {
this.rotate(cr, trans.angle, trans.center[0], trans.center[1]);
if (this.state == TextState.DRAWING)
cr.rectangle(points[0][0], points[0][1], points[1][0] - points[0][0], points[1][1] - points[0][1]);
cr.selectFontFace(this.font.family, this.font.style, this.font.weight);
cr.setFontSize(Math.abs(points[1][1] - points[0][1]));
cr.moveTo(Math.min(points[0][0], points[1][0]), Math.max(points[0][1], points[1][1]));
@ -1063,6 +1071,7 @@ var DrawingMenu = new Lang.Class({
this._addSwitchItem(lineSection, _("Dashed"), dashedLineIcon, this.area, 'dashedLine');
this._addSeparator(lineSection);
this.menu.addMenuItem(lineSection);
lineSection.itemActivated = () => {};
this.lineSection = lineSection;
let fontSection = new PopupMenu.PopupMenuSection();
@ -1128,7 +1137,7 @@ var DrawingMenu = new Lang.Class({
_addSliderItem: function(menu, target, targetProperty) {
let item = new PopupMenu.PopupBaseMenuItem({ activate: false });
let label = new St.Label({ text: target[targetProperty] + " px", style_class: 'draw-on-your-screen-menu-slider-label' });
let label = new St.Label({ text: target[targetProperty] + " " + _("px"), style_class: 'draw-on-your-screen-menu-slider-label' });
let slider = new Slider.Slider(target[targetProperty] / 50);
slider.connect('value-changed', (slider, value, property) => {

View File

@ -25,8 +25,11 @@ const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Main = imports.ui.main;
const OsdWindow = imports.ui.osdWindow;
const PanelMenu = imports.ui.panelMenu;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Extension.imports.convenience;
const Draw = Extension.imports.draw;
@ -78,6 +81,9 @@ var AreaManager = new Lang.Class({
this.updateAreas();
this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
this.updateIndicator();
this.indicatorSettingHandler = this.settings.connect('changed::indicator-disabled', this.updateIndicator.bind(this));
this.desktopSettingHandler = this.settings.connect('changed::drawing-on-desktop', this.onDesktopSettingChanged.bind(this));
this.persistentSettingHandler = this.settings.connect('changed::persistent-drawing', this.onPersistentSettingChanged.bind(this));
@ -105,6 +111,15 @@ var AreaManager = new Lang.Class({
this.areas[Main.layoutManager.primaryIndex].saveAsJson();
},
updateIndicator: function() {
if (this.indicator) {
this.indicator.disable();
this.indicator = null;
}
if (!this.settings.get_boolean('indicator-disabled'))
this.indicator = new DrawingIndicator();
},
updateAreas: function() {
if (this.activeArea)
this.toggleDrawing();
@ -264,8 +279,8 @@ var AreaManager = new Lang.Class({
global.display.set_cursor(Meta.Cursor.DEFAULT);
else if (global.screen && global.screen.set_cursor)
global.screen.set_cursor(Meta.Cursor.DEFAULT);
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
if (!this.osdDisabled)
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
} else {
// avoid to deal with Meta changes (global.display/global.screen)
let currentIndex = Main.layoutManager.monitors.indexOf(Main.layoutManager.currentMonitor);
@ -287,16 +302,24 @@ var AreaManager = new Lang.Class({
global.display.set_cursor(Meta.Cursor.POINTING_HAND);
else if (global.screen && global.screen.set_cursor)
global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
// increase OSD display time
let hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
OsdWindow.HIDE_TIMEOUT = 2000;
Main.osdWindowManager.show(currentIndex, this.enterGicon, _("Press Ctrl + F1 for help") + "\n\n" + _("Entering drawing mode"), null);
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
this.osdDisabled = this.settings.get_boolean('osd-disabled');
if (!this.osdDisabled) {
// increase OSD display time
let hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
OsdWindow.HIDE_TIMEOUT = 2000;
Main.osdWindowManager.show(currentIndex, this.enterGicon, _("Press Ctrl + F1 for help") + "\n\n" + _("Entering drawing mode"), null);
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
}
}
if (this.indicator)
this.indicator.sync(this.activeArea != null);
},
showOsd: function(emitter, label, level, maxLevel) {
if (this.osdDisabled)
return;
let activeIndex = this.areas.indexOf(this.activeArea);
if (activeIndex != -1) {
Main.osdWindowManager.show(activeIndex, this.enterGicon, label, level, maxLevel);
@ -326,6 +349,10 @@ var AreaManager = new Lang.Class({
Main.layoutManager.disconnect(this.monitorChangedHandler);
this.monitorChangedHandler = null;
}
if (this.indicatorSettingHandler) {
this.settings.disconnect(this.indicatorSettingHandler);
this.indicatorSettingHandler = null;
}
if (this.desktopSettingHandler) {
this.settings.disconnect(this.desktopSettingHandler);
this.desktopSettingHandler = null;
@ -340,6 +367,31 @@ var AreaManager = new Lang.Class({
Main.wm.removeKeybinding('toggle-drawing');
Main.wm.removeKeybinding('erase-drawing');
this.removeAreas();
if (this.indicator)
this.indicator.disable();
}
});
var DrawingIndicator = new Lang.Class({
Name: 'DrawOnYourScreenIndicator',
_init: function() {
let [menuAlignment, dontCreateMenu] = [0, true];
this.button = new PanelMenu.Button(menuAlignment, "Drawing Indicator", dontCreateMenu);
Main.panel.addToStatusArea('draw-on-your-screen-indicator', this.button);
this.icon = new St.Icon({ icon_name: 'applications-graphics-symbolic',
style_class: 'system-status-icon screencast-indicator' });
this.button.actor.add_child(this.icon);
this.button.actor.visible = false;
},
sync: function(visible) {
this.button.actor.visible = visible;
},
disable: function() {
this.button.destroy();
}
});

View File

@ -17,6 +17,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
# add your name here, for example:
# "Aïssata\n"
# "<a href=\"mailto:ali@mail.org\">Ali</a>\n"
# "<a href=\"https://...\">丽</a>"
# It will be displayed in About page
msgid "Translators"
msgstr ""
#: extension.js
msgid "Leaving drawing mode"
msgstr ""
@ -90,8 +98,17 @@ msgstr ""
msgid "Dashed"
msgstr ""
msgid "Color"
msgstr ""
#: prefs.js
msgid "Preferences"
msgstr ""
msgid "About"
msgstr ""
# GLOBAL_KEYBINDINGS
msgid "Enter/leave drawing mode"
@ -189,13 +206,13 @@ msgstr ""
msgid "Left click"
msgstr ""
msgid "Draw by filling in"
msgid "Menu"
msgstr ""
msgid "Right click"
msgstr ""
msgid "Toggle shape"
msgid "Toggle fill/stroke"
msgstr ""
msgid "Center click"
@ -231,13 +248,20 @@ msgstr ""
msgid "Escape key"
msgstr ""
#
# About page
msgid ""
"Start drawing with Super+Alt+D\n"
"Then save your beautiful work by taking a screenshot"
# you are free to translate the extension name
#msgid "Draw On You Screen"
#msgstr ""
msgid "Version %s"
msgstr ""
msgid "Start drawing with Super+Alt+D and save your beautiful work by taking a screenshot"
msgstr ""
# Prefs page
msgid "Global"
msgstr ""
@ -253,6 +277,12 @@ msgstr ""
msgid "Persistent drawing through session restart"
msgstr ""
msgid "Disable on-screen notifications"
msgstr ""
msgid "Disable panel indicator"
msgstr ""
msgid "Internal"
msgstr ""
@ -269,7 +299,7 @@ msgstr ""
msgid "Smooth stroke during the drawing process"
msgstr ""
msgid "You can smooth the stroke afterward\nSee"
msgid "You can also smooth the stroke afterward\nSee"
msgstr ""
msgid "Change the style"
@ -284,11 +314,52 @@ msgid ""
"(See \"Add a drawing background\" or edit the SVG file afterwards)"
msgstr ""
msgid ""
"<span size=\"small\">This program comes with ABSOLUTELY NO WARRANTY.\n"
"See the <a href=\"https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
"\">GNU General Public License, version 2 or later</a> for details.</span>"
msgstr ""
msgid "Author"
msgstr ""
# The following words refer to SVG attributes.
# You have the choice to translate or not
#msgid "Butt"
#msgstr ""
#msgid "Round"
#msgstr ""
#msgid "Square"
#msgstr ""
#msgid "Miter"
#msgstr ""
#msgid "Bevel"
#msgstr ""
#msgid "Normal"
#msgstr ""
#msgid "Bold"
#msgstr ""
#msgid "Italic"
#msgstr ""
#msgid "Oblique"
#msgstr ""
#msgid "Sans-Serif"
#msgstr ""
#msgid "Serif"
#msgstr ""
#msgid "Monospace"
#msgstr ""
#msgid "Cursive"
#msgstr ""
#msgid "Fantasy"
#msgstr ""
#msgid "px"
#msgstr ""

140
prefs.js
View File

@ -23,12 +23,14 @@
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();
const Convenience = Extension.imports.convenience;
const Metadata = Extension.metadata;
const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext;
const _GTK = imports.gettext.domain('gtk30').gettext;
const MARGIN = 10;
@ -73,8 +75,8 @@ var INTERNAL_KEYBINDINGS = {
var OTHER_SHORTCUTS = [
{ desc: "Draw", shortcut: "Left click" },
{ desc: "Draw by filling in", shortcut: "Right click" },
{ desc: "Toggle shape", shortcut: "Center click" },
{ desc: "Menu", shortcut: "Right click" },
{ desc: "Toggle fill/stroke", shortcut: "Center click" },
{ desc: "Transform shape (when drawing)", shortcut: "Ctrl key" },
{ desc: "Increment/decrement line width", shortcut: "Scroll" },
{ desc: "Select color", shortcut: "Ctrl+1...9" },
@ -92,7 +94,83 @@ function buildPrefsWidget() {
return prefsPage;
}
const PrefsPage = new GObject.Class({
function buildPrefsWidget() {
let topStack = new TopStack();
let switcher = new Gtk.StackSwitcher({halign: Gtk.Align.CENTER, visible: true, stack: topStack});
Mainloop.timeout_add(0, () => {
let window = topStack.get_toplevel();
window.resize(720,500);
let headerBar = window.get_titlebar();
headerBar.custom_title = switcher;
return false;
});
topStack.show_all();
return topStack;
}
var TopStack = new GObject.Class({
Name: 'DrawOnYourScreenTopStack',
GTypeName: 'DrawOnYourScreenTopStack',
Extends: Gtk.Stack,
_init: function(params) {
this.parent({ transition_type: 1, transition_duration: 500, expand: true });
this.prefsPage = new PrefsPage();
this.add_titled(this.prefsPage, 'prefs', _("Preferences"));
this.aboutPage = new AboutPage();
this.add_titled(this.aboutPage, 'about', _("About"));
}
});
var AboutPage = new GObject.Class({
Name: 'DrawOnYourScreenAboutPage',
GTypeName: 'DrawOnYourScreenAboutPage',
Extends: Gtk.ScrolledWindow,
_init: function(params) {
this.parent();
let vbox= new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 });
this.add(vbox);
let name = "<b> " + _(Metadata.name) + "</b>";
let version = _("Version %s").format(Metadata.version.toString());
let description = _(Metadata.description);
let link = "<span><a href=\"" + Metadata.url + "\">" + Metadata.url + "</a></span>";
let licenceName = _GTK("GNU General Public License, version 2 or later");
let licenceLink = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html";
let licence = "<small>" + _GTK("This program comes with absolutely no warranty.\nSee the <a href=\"%s\">%s</a> for details.").format(licenceLink, licenceName) + "</small>";
let aboutLabel = new Gtk.Label({ wrap: true, justify: 2, use_markup: true, label:
name + "\n\n" + version + "\n\n" + description + "\n\n" + link + "\n\n" + licence + "\n" });
vbox.add(aboutLabel);
let creditBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, margin: 2*MARGIN });
let leftBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let rightBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let leftLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 2, justify: 1, use_markup: true, label: "<small>" + _GTK("Created by") + "</small>" });
let rightLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 1, justify: 0, use_markup: true, label: "<small><a href=\"https://framagit.org/abakkk\">Abakkk</a></small>" });
leftBox.pack_start(leftLabel, true, true, 0);
rightBox.pack_start(rightLabel, true, true, 0);
creditBox.pack_start(leftBox, true, true, 5);
creditBox.pack_start(rightBox, true, true, 5);
vbox.add(creditBox);
if (_("Translators") != "Translators") {
leftBox.pack_start(new Gtk.Label(), true, true, 0);
rightBox.pack_start(new Gtk.Label(), true, true, 0);
leftLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 2, justify: 1, use_markup: true, label: "<small>" + _GTK("Translated by") + "</small>" });
rightLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 1, justify: 0, use_markup: true, label: "<small>" + _("Translators") + "</small>" });
leftBox.pack_start(leftLabel, true, true, 0);
rightBox.pack_start(rightLabel, true, true, 0);
}
}
});
var PrefsPage = new GObject.Class({
Name: 'DrawOnYourScreenPrefsPage',
GTypeName: 'DrawOnYourScreenPrefsPage',
Extends: Gtk.ScrolledWindow,
@ -105,13 +183,7 @@ const PrefsPage = new GObject.Class({
let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 });
this.add(box);
let textBox1 = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN });
let text1 = new Gtk.Label({ wrap: true, justify: 2, use_markup: true,
label: "<big> " + _("Start drawing with Super+Alt+D\nThen save your beautiful work by taking a screenshot") + "</big>" });
textBox1.pack_start(text1, false, false, 0);
box.add(textBox1);
let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true, margin_top: 2*MARGIN, margin_bottom: 2*MARGIN });
let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true });
box.add(listBox);
let styleContext = listBox.get_style_context();
@ -154,6 +226,28 @@ const PrefsPage = new GObject.Class({
persistentBox.pack_start(persistentLabelBox, true, true, 4);
persistentBox.pack_start(persistentSwitch, false, false, 4);
listBox.add(persistentBox);
let osdBox = new Gtk.Box({ margin: MARGIN });
let osdLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let osdLabel1 = new Gtk.Label({label: _("Disable on-screen notifications")});
osdLabel1.set_halign(1);
osdLabelBox.pack_start(osdLabel1, true, true, 0);
let osdSwitch = new Gtk.Switch({valign: 3});
this.settings.bind("osd-disabled", osdSwitch, "active", 0);
osdBox.pack_start(osdLabelBox, true, true, 4);
osdBox.pack_start(osdSwitch, false, false, 4);
listBox.add(osdBox);
let indicatorBox = new Gtk.Box({ margin: MARGIN });
let indicatorLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let indicatorLabel1 = new Gtk.Label({label: _("Disable panel indicator")});
indicatorLabel1.set_halign(1);
indicatorLabelBox.pack_start(indicatorLabel1, true, true, 0);
let indicatorSwitch = new Gtk.Switch({valign: 3});
this.settings.bind("indicator-disabled", indicatorSwitch, "active", 0);
indicatorBox.pack_start(indicatorLabelBox, true, true, 4);
indicatorBox.pack_start(indicatorSwitch, false, false, 4);
listBox.add(indicatorBox);
this.addSeparator(listBox);
let internalTitleBox = new Gtk.Box({ margin: MARGIN });
@ -193,7 +287,7 @@ const PrefsPage = new GObject.Class({
let smoothBox = new Gtk.Box({ margin: MARGIN });
let smoothLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let smoothLabel1 = new Gtk.Label({label: _("Smooth stroke during the drawing process")});
let smoothLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "<small>" + _("You can smooth the stroke afterward\nSee") + " \"" + _("Smooth last brushstroke") + "\"</small>" });
let smoothLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "<small>" + _("You can also smooth the stroke afterward\nSee") + " \"" + _("Smooth last brushstroke") + "\"</small>" });
smoothLabel1.set_halign(1);
smoothLabel2.get_style_context().add_class("dim-label");
smoothLabelBox.pack_start(smoothLabel1, true, true, 0);
@ -226,28 +320,6 @@ const PrefsPage = new GObject.Class({
noteBox.pack_start(noteLabel, true, true, 4);
listBox.add(noteBox);
this.addSeparator(listBox);
let licence = _("<span size=\"small\">This program comes with ABSOLUTELY NO WARRANTY.\nSee the <a href=\"https://www.gnu.org/licenses/old-licenses/gpl-2.0.html\">GNU General Public License, version 2 or later</a> for details.</span>");
let textBox2 = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let text2 = new Gtk.Label({ wrap: true, justify: 2, use_markup: true,
label: "<small>Version" + " " + Metadata.version +"</small>\n\n" + "<span><a href=\"" + Metadata.url + "\">" + Metadata.url + "</a></span>" + "\n\n" + licence + "\n" });
textBox2.pack_start(text2, false, false, 0);
let creditBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
let leftBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let rightBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let leftLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 2, justify: 1, use_markup: true, label: "<small><u>" + _("Author") + ":</u></small>" });
let rightLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 1, justify: 0, use_markup: true, label: "<small>Abakkk</small>" });
leftBox.pack_start(leftLabel, true, true, 0);
rightBox.pack_start(rightLabel, true, true, 0);
creditBox.pack_start(leftBox, true, true, 5);
creditBox.pack_start(rightBox, true, true, 5);
textBox2.pack_start(creditBox, false, false, 0);
box.add(textBox2);
let children = listBox.get_children();
for (let i = 0; i < children.length; i++) {
if (children[i].activatable)
@ -263,7 +335,7 @@ const PrefsPage = new GObject.Class({
});
// this code comes from Sticky Notes View by Sam Bull, https://extensions.gnome.org/extension/568/notes/
const KeybindingsWidget = new GObject.Class({
var KeybindingsWidget = new GObject.Class({
Name: 'DrawOnYourScreenKeybindings.Widget',
GTypeName: 'DrawOnYourScreenKeybindingsWidget',
Extends: Gtk.Box,

Binary file not shown.

View File

@ -16,6 +16,16 @@
<summary>persistent drawing</summary>
<description>persistent drawing</description>
</key>
<key type="b" name="osd-disabled">
<default>false</default>
<summary>disable OSD notifications</summary>
<description>disable on-screen notifications</description>
</key>
<key type="b" name="indicator-disabled">
<default>false</default>
<summary>disable panel indicator</summary>
<description>disable panel indicator</description>
</key>
<key type="as" name="toggle-drawing">
<default>["&lt;Alt&gt;&lt;Super&gt;d"]</default>
<summary>toggle drawing</summary>