.pot rework

* .pot file can be generated automaticaly from new locale/POTFILES.in.
* move shortcuts key and strings to new shortcut.js
This commit is contained in:
abakkk 2020-09-08 20:11:57 +02:00
parent 2dd900bddf
commit 03b73862cc
9 changed files with 714 additions and 569 deletions

View File

@ -42,6 +42,7 @@ const Elements = Me.imports.elements;
const Files = Me.imports.files;
const Menu = Me.imports.menu;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const pgettext = imports.gettext.domain(Me.metadata['gettext-domain']).pgettext;
const CAIRO_DEBUG_EXTENDS = false;
const SVG_DEBUG_EXTENDS = false;
@ -392,6 +393,7 @@ var DrawingArea = new Lang.Class({
event.get_key_symbol() == Clutter.KEY_KP_Enter ||
event.get_key_symbol() == Clutter.KEY_Control_L) {
if (this.currentElement.points.length == 2)
// Translators: %s is a key label
this.emit('show-osd', null, _("Press <i>%s</i> to get\na fourth control point")
.format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1, true);
this.currentElement.addPoint();
@ -594,7 +596,8 @@ var DrawingArea = new Lang.Class({
color: this.currentColor.to_string(),
eraser: eraser,
font: this.currentFont.to_string(),
text: _("Text"),
// Translators: initial content of the text area
text: pgettext("text-area-content", "Text"),
textRightAligned: this.currentTextRightAligned,
points: []
});
@ -626,6 +629,7 @@ var DrawingArea = new Lang.Class({
this.currentElement.startDrawing(startX, startY);
if (this.currentTool == Shapes.POLYGON || this.currentTool == Shapes.POLYLINE)
// Translators: %s is a key label
this.emit('show-osd', null, _("Press <i>%s</i> to mark vertices")
.format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1, true);
@ -687,6 +691,7 @@ var DrawingArea = new Lang.Class({
let [x, y] = [this.currentElement.x, this.currentElement.y];
this.currentElement.text = '';
this.currentElement.cursorPosition = 0;
// Translators: %s is a key label
this.emit('show-osd', null, _("Type your text and press <i>%s</i>")
.format(Gtk.accelerator_get_label(Clutter.KEY_Escape, 0)), "", -1, true);
this._updateTextCursorTimeout();

View File

@ -342,6 +342,7 @@ const AreaManager = new Lang.Class({
if (Main._findModal(this.activeArea) != -1) {
Main.popModal(this.activeArea);
if (source && source == global.display)
// Translators: "released" as the opposite of "grabbed"
this.showOsd(null, 'touchpad-disabled-symbolic', _("Keyboard and pointer released"), null, null, false);
this.setCursor('DEFAULT');
this.activeArea.reactive = false;
@ -388,7 +389,8 @@ const AreaManager = new Lang.Class({
this.activeArea.enterDrawingMode();
this.osdDisabled = Me.settings.get_boolean('osd-disabled');
let label = _("<small>Press <i>%s</i> for help</small>").format(this.activeArea.helper.helpKeyLabel) + "\n\n" + _("Entering drawing mode");
// Translators: %s is a key label
let label = "<small>" + _("Press <i>%s</i> for help").format(this.activeArea.helper.helpKeyLabel) + "</small>\n\n" + _("Entering drawing mode");
this.showOsd(null, this.enterGicon, label, null, null, true);
}

View File

@ -31,7 +31,7 @@ const Tweener = imports.ui.tweener;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = ExtensionUtils.getSettings ? ExtensionUtils : Me.imports.convenience;
const Prefs = Me.imports.prefs;
const Shortcuts = Me.imports.shortcuts.Shortcuts;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const GS_VERSION = Config.PACKAGE_VERSION;
@ -87,49 +87,54 @@ var DrawingHelper = new Lang.Class({
this.add_actor(this.vbox);
this.vbox.add_child(new St.Label({ text: _("Global") }));
for (let settingKey of Prefs.GLOBAL_KEYBINDINGS) {
if (!Me.settings.get_strv(settingKey)[0])
continue;
Shortcuts.GLOBAL_KEYBINDINGS.forEach((settingKeys, index) => {
if (index)
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
let hbox = new St.BoxLayout({ vertical: false });
let [keyval, mods] = Gtk.accelerator_parse(Me.settings.get_strv(settingKey)[0]);
hbox.add_child(new St.Label({ text: Me.settings.settings_schema.get_key(settingKey).get_summary() }));
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
this.vbox.add_child(hbox);
}
settingKeys.forEach(settingKey => {
if (!Me.settings.get_strv(settingKey)[0])
return;
let hbox = new St.BoxLayout({ vertical: false });
let [keyval, mods] = Gtk.accelerator_parse(Me.settings.get_strv(settingKey)[0]);
hbox.add_child(new St.Label({ text: Me.settings.settings_schema.get_key(settingKey).get_summary() }));
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
this.vbox.add_child(hbox);
});
});
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
this.vbox.add_child(new St.Label({ text: _("Internal") }));
Prefs.OTHER_SHORTCUTS.forEach((object, index) => {
Shortcuts.OTHERS.forEach((pairs, index) => {
if (index)
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
for (let key in object) {
pairs.forEach(pair => {
let hbox = new St.BoxLayout({ vertical: false });
hbox.add_child(new St.Label({ text: _(key) }));
hbox.add_child(new St.Label({ text: object[key], x_expand: true }));
hbox.add_child(new St.Label({ text: pair[0] }));
hbox.add_child(new St.Label({ text: pair[1], x_expand: true }));
hbox.get_children()[0].get_clutter_text().set_use_markup(true);
this.vbox.add_child(hbox);
}
});
});
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
Prefs.INTERNAL_KEYBINDINGS.forEach((object, index) => {
Shortcuts.INTERNAL_KEYBINDINGS.forEach((settingKeys, index) => {
if (index)
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
for (let settingKey of object) {
settingKeys.forEach(settingKey => {
if (!Me.internalShortcutSettings.get_strv(settingKey)[0])
continue;
return;
let hbox = new St.BoxLayout({ vertical: false });
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv(settingKey)[0]);
hbox.add_child(new St.Label({ text: Me.internalShortcutSettings.settings_schema.get_key(settingKey).get_summary() }));
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
this.vbox.add_child(hbox);
}
});
});
let mediaKeysSettings;

8
locale/POTFILES.in Normal file
View File

@ -0,0 +1,8 @@
# xgettext --from-code=UTF-8 --add-comments="Translators: " --no-location --package-name="Draw On Your Screen" --msgid-bugs-address="https://framagit.org/abakkk/DrawOnYourScreen/issues" -f locale/POTFILES.in
area.js
extension.js
helper.js
menu.js
prefs.js
shortcuts.js
schemas/org.gnome.shell.extensions.draw-on-your-screen.gschema.xml

View File

@ -8,9 +8,9 @@
# You are free to translate them or not.
msgid ""
msgstr ""
"Project-Id-Version: Draw On Your Screen VERSION\n"
"Project-Id-Version: Draw On Your Screen\n"
"Report-Msgid-Bugs-To: https://framagit.org/abakkk/DrawOnYourScreen/issues\n"
"POT-Creation-Date: 2019-03-04 16:40+0100\n"
"POT-Creation-Date: 2020-09-09 08:40+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -19,177 +19,338 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "About"
#. Translators: %s is a key label
#, javascript-format
msgid ""
"Press <i>%s</i> to get\n"
"a fourth control point"
msgstr ""
# You are free to translate the extension name, that is displayed in About page, or not.
msgid "Draw On You Screen"
msgid "Mark a point of symmetry"
msgstr ""
msgid "Version %d"
msgid "Draw a line of symmetry"
msgstr ""
msgid "Start drawing with Super+Alt+D and save your beautiful work by taking a screenshot"
#. Translators: initial content of the text area
msgctxt "text-area-content"
msgid "Text"
msgstr ""
# Add your name here, for example:
# (add "\n" as separator if there is many translators)
# msgid "translator-credits"
# msgstr "Me"
# or, with mail:
# msgid "translator-credits"
# msgstr "<a href=\"mailto:me@mail.org\">Me</a>"
# or, with page:
# msgid "translator-credits"
# msgstr "<a href=\"https://...\">Me</a>"
# else keep it empty.
# It will be displayed in about page
msgid "translator-credits"
#. Translators: %s is a key label
#, javascript-format
msgid "Press <i>%s</i> to mark vertices"
msgstr ""
msgid "Drawing"
#. Translators: %s is a key label
#, javascript-format
msgid "Type your text and press <i>%s</i>"
msgstr ""
msgid "Palettes"
#. Translators: "released" as the opposite of "grabbed"
msgid "Keyboard and pointer released"
msgstr ""
msgid "Color palettes"
msgid "Keyboard and pointer grabbed"
msgstr ""
msgid "The palettes of drawing colors"
msgid "Leaving drawing mode"
msgstr ""
#. Translators: %s is a key label
#, javascript-format
msgid "Press <i>%s</i> for help"
msgstr ""
msgid "Entering drawing mode"
msgstr ""
msgid "Global"
msgstr ""
msgid "Internal"
msgstr ""
msgid "System"
msgstr ""
msgid "Dashed line"
msgstr ""
#. Translators: as the alternative to "Dashed line"
msgid "Full line"
msgstr ""
msgid "Fill"
msgstr ""
#. Translators: as the alternative to "Fill"
msgid "Outline"
msgstr ""
#. Translators: fill-rule SVG attribute
msgid "Nonzero"
msgstr ""
msgid "Evenodd"
msgstr ""
#. Translators: generic font-family SVG attribute
msgctxt "font-family"
msgid "Sans-Serif"
msgstr ""
msgctxt "font-family"
msgid "Serif"
msgstr ""
msgctxt "font-family"
msgid "Monospace"
msgstr ""
msgctxt "font-family"
msgid "Cursive"
msgstr ""
msgctxt "font-family"
msgid "Fantasy"
msgstr ""
#. Translators: font-style SVG attribute
msgctxt "font-style"
msgid "Normal"
msgstr ""
msgctxt "font-style"
msgid "Oblique"
msgstr ""
msgctxt "font-style"
msgid "Italic"
msgstr ""
#. Translators: font-weight SVG attribute
msgctxt "font-weight"
msgid "Thin"
msgstr ""
msgctxt "font-weight"
msgid "Ultra Light"
msgstr ""
msgctxt "font-weight"
msgid "Light"
msgstr ""
msgctxt "font-weight"
msgid "Semi Light"
msgstr ""
msgctxt "font-weight"
msgid "Book"
msgstr ""
msgctxt "font-weight"
msgid "Normal"
msgstr ""
msgctxt "font-weight"
msgid "Medium"
msgstr ""
msgctxt "font-weight"
msgid "Semi Bold"
msgstr ""
msgctxt "font-weight"
msgid "Bold"
msgstr ""
msgctxt "font-weight"
msgid "Ultra Bold"
msgstr ""
msgctxt "font-weight"
msgid "Heavy"
msgstr ""
msgctxt "font-weight"
msgid "Ultra Heavy"
msgstr ""
#. Translators: stroke-linecap SVG attribute
msgctxt "stroke-linecap"
msgid "Butt"
msgstr ""
msgctxt "stroke-linecap"
msgid "Round"
msgstr ""
msgctxt "stroke-linecap"
msgid "Square"
msgstr ""
#. Translators: stroke-linejoin SVG attribute
msgctxt "stroke-linejoin"
msgid "Miter"
msgstr ""
msgctxt "stroke-linejoin"
msgid "Round"
msgstr ""
msgctxt "stroke-linejoin"
msgid "Bevel"
msgstr ""
#. Translators: value in pixel unit (e.g. "5 px")
#, javascript-format
msgid "%f px"
msgstr ""
#. Translators: text alignment
msgid "Right aligned"
msgstr ""
msgid "Left aligned"
msgstr ""
msgctxt "drawing-tool"
msgid "Free drawing"
msgstr ""
msgctxt "drawing-tool"
msgid "Line"
msgstr ""
msgctxt "drawing-tool"
msgid "Ellipse"
msgstr ""
msgctxt "drawing-tool"
msgid "Rectangle"
msgstr ""
msgctxt "drawing-tool"
msgid "Text"
msgstr ""
msgctxt "drawing-tool"
msgid "Polygon"
msgstr ""
msgctxt "drawing-tool"
msgid "Polyline"
msgstr ""
msgctxt "drawing-tool"
msgid "Image"
msgstr ""
msgctxt "drawing-tool"
msgid "Move"
msgstr ""
msgctxt "drawing-tool"
msgid "Resize"
msgstr ""
msgctxt "drawing-tool"
msgid "Mirror"
msgstr ""
msgid "Undo"
msgstr ""
msgid "Redo"
msgstr ""
msgid "Erase"
msgstr ""
msgid "Smooth"
msgstr ""
msgid "Palette"
msgstr ""
msgid "Color"
msgstr ""
msgid "Open drawing"
msgstr ""
#. Translators: "Preferences" page in preferences
msgid "Preferences"
msgstr ""
#. Translators: "Drawing" page in preferences
msgid "Drawing"
msgstr ""
#. Translators: "About" page in preferences
msgid "About"
msgstr ""
#. Translators: you are free to translate the extension name, that is displayed in About page, or not
msgid "Draw On You Screen"
msgstr ""
#. Translators: version number in "About" page
#, javascript-format
msgid "Version %d"
msgstr ""
#. Translators: you are free to translate the extension description, that is displayed in About page, or not
msgid ""
"Start drawing with Super+Alt+D and save your beautiful work by taking a "
"screenshot"
msgstr ""
#. Translators: add your name here or keep it empty, it will be displayed in about page, e.g.
#. msgstr ""
#. "translator1\n"
#. "<a href=\"mailto:translator2@mail.org\">translator2</a>\n"
#. "<a href=\"https://...\">translator3</a>"
msgid "translator-credits"
msgstr ""
msgid "Palettes"
msgstr ""
msgid "Add a new palette"
msgstr ""
msgid "New palette"
msgstr ""
msgid "Rename the palette"
msgstr ""
msgid "Remove the palette"
msgstr ""
msgid "Auto"
msgstr ""
msgid "Area"
msgstr ""
msgid "Square area size"
msgstr ""
msgid "Automatic square area size"
msgstr ""
msgid "Compute the size of the square area from the screen size"
msgstr ""
msgid "The size of the square area in pixels"
msgstr ""
msgid "Background color"
msgstr ""
msgid "The color of the drawing area background"
msgid "Auto"
msgstr ""
msgid "Grid overlay line"
msgstr ""
msgid "Automatic grid overlay line"
msgstr ""
msgid "Compute the lengths from the screen size"
msgstr ""
msgid "Grid overlay line spacing"
msgstr ""
msgid "The line width in pixels"
msgstr ""
msgid "Grid overlay line width"
msgstr ""
msgid "The gap between lines in pixels"
msgstr ""
msgid "Grid overlay color"
msgstr ""
msgid "The color of the lines"
msgstr ""
msgid "Tools"
msgstr ""
msgid "Dash array"
msgstr ""
msgid "Automatic dash array"
msgstr ""
msgid "Compute the lengths from the line width"
msgstr ""
msgid "Dash array on"
msgstr ""
msgid "The dash length in pixels"
msgstr ""
msgid "Dash array off"
msgstr ""
msgid "The gap between the dashes in pixels"
msgstr ""
msgid "Dash offset"
msgstr ""
msgid "The dash offset in pixels"
msgstr ""
msgid "Reset settings"
msgstr ""
msgid "Preferences"
msgid "Rename the palette"
msgstr ""
msgid "Global"
msgid "Remove the palette"
msgstr ""
msgid "Enter/leave drawing mode"
#. Translators: default name of a new palette
msgid "New palette"
msgstr ""
# There is a similar text in GNOME Boxes (https://gitlab.gnome.org/GNOME/gnome-boxes/tree/master/po)
msgid "Grab/ungrab keyboard and pointer"
msgstr ""
msgid "Erase all drawings"
msgstr ""
msgid "Persistent"
msgstr ""
msgid "Persistent drawing through session restart"
msgstr ""
msgid "Drawing on the desktop"
msgstr ""
msgid "<i>Draw On Your Screen</i> becomes <i>Draw On Your Desktop</i>"
msgstr ""
msgid "Disable on-screen notifications"
msgstr ""
msgid "Disable panel indicator"
msgid "In drawing mode"
msgstr ""
msgid "Draw"
@ -213,17 +374,19 @@ msgstr ""
msgid "Scroll"
msgstr ""
#. Translators: %s are key labels (Ctrl+F1 and Ctrl+F9)
msgid "Select color"
msgstr ""
# %s are key labels (Ctrl+F1 and Ctrl+F9)
#, javascript-format
msgid "%s … %s"
msgstr ""
#. Translators: %s is a key label
msgid "Ignore pointer movement"
msgstr ""
# %s is a key label
#, javascript-format
msgid "%s held"
msgstr ""
@ -257,22 +420,137 @@ msgstr ""
msgid "Inverse <span alpha=\"50%\">(while mirroring)</span>"
msgstr ""
msgid "Internal"
msgid "Drawing on the desktop"
msgstr ""
msgid "In drawing mode"
msgid "<i>Draw On Your Screen</i> becomes <i>Draw On Your Desktop</i>"
msgstr ""
msgid "Undo last brushstroke"
msgid "Erase all drawings"
msgstr ""
msgid "Redo last brushstroke"
msgid "Disable panel indicator"
msgstr ""
msgid "Disable on-screen notifications"
msgstr ""
msgid "Persistent"
msgstr ""
msgid "Persistent drawing through session restart"
msgstr ""
msgid "Enter/leave drawing mode"
msgstr ""
#. Translators: there is a similar text in GNOME Boxes (https://gitlab.gnome.org/GNOME/gnome-boxes/tree/master/po)
msgid "Grab/ungrab keyboard and pointer"
msgstr ""
msgid "Background color"
msgstr ""
msgid "The color of the drawing area background"
msgstr ""
msgid "Automatic dash array"
msgstr ""
msgid "Compute the lengths from the line width"
msgstr ""
msgid "Dash array on"
msgstr ""
msgid "The dash length in pixels"
msgstr ""
msgid "Dash array off"
msgstr ""
msgid "The gap between the dashes in pixels"
msgstr ""
msgid "Dash offset"
msgstr ""
msgid "The dash offset in pixels"
msgstr ""
msgid "Grid overlay color"
msgstr ""
msgid "The color of the lines"
msgstr ""
msgid "Automatic grid overlay line"
msgstr ""
msgid "Compute the lengths from the screen size"
msgstr ""
msgid "Grid overlay line spacing"
msgstr ""
msgid "The gap between lines in pixels"
msgstr ""
msgid "Grid overlay line width"
msgstr ""
msgid "The line width in pixels"
msgstr ""
msgid "Color palettes"
msgstr ""
msgid "The palettes of drawing colors"
msgstr ""
msgid "Automatic square area size"
msgstr ""
msgid "Compute the size of the square area from the screen size"
msgstr ""
msgid "Square area size"
msgstr ""
msgid "The size of the square area in pixels"
msgstr ""
msgid "Decrement line width"
msgstr ""
msgid "Decrement line width even more"
msgstr ""
msgid "Erase last brushstroke"
msgstr ""
msgid "Smooth last brushstroke"
msgid "Increment line width"
msgstr ""
msgid "Increment line width even more"
msgstr ""
msgid "Open next drawing"
msgstr ""
msgid "Open preferences"
msgstr ""
msgid "Open previous drawing"
msgstr ""
msgid "Redo last brushstroke"
msgstr ""
msgid "Save drawing"
msgstr ""
msgid "Save drawing as a SVG file"
msgstr ""
msgid "Select color 1"
@ -317,6 +595,9 @@ msgstr ""
msgid "Select move tool"
msgstr ""
msgid "Select free drawing"
msgstr ""
msgid "Select polygon tool"
msgstr ""
@ -332,10 +613,7 @@ msgstr ""
msgid "Select text tool"
msgstr ""
msgid "Toggle fill/outline"
msgstr ""
msgid "Toggle fill rule"
msgid "Smooth last brushstroke"
msgstr ""
msgid "Change color palette"
@ -344,22 +622,10 @@ msgstr ""
msgid "Change color palette (reverse)"
msgstr ""
msgid "Increment line width"
msgid "Toggle fill/outline"
msgstr ""
msgid "Decrement line width"
msgstr ""
msgid "Increment line width even more"
msgstr ""
msgid "Decrement line width even more"
msgstr ""
msgid "Change linejoin"
msgstr ""
msgid "Change linecap"
msgid "Toggle fill rule"
msgstr ""
msgid "Change font family"
@ -368,19 +634,22 @@ msgstr ""
msgid "Change font family (reverse)"
msgstr ""
msgid "Change font weight"
msgstr ""
msgid "Change font style"
msgstr ""
msgid "Toggle text alignment"
msgid "Change font weight"
msgstr ""
msgid "Change image file"
msgstr ""
msgid "Hide panel and dock"
msgid "Change linecap"
msgstr ""
msgid "Change linejoin"
msgstr ""
msgid "Toggle text alignment"
msgstr ""
msgid "Add a drawing background"
@ -389,251 +658,14 @@ msgstr ""
msgid "Add a grid overlay"
msgstr ""
msgid "Square drawing area"
msgstr ""
msgid "Open previous drawing"
msgstr ""
msgid "Open next drawing"
msgstr ""
msgid "Save drawing as a SVG file"
msgstr ""
msgid "Open preferences"
msgstr ""
msgid "Show help"
msgstr ""
msgid "Screenshot"
msgid "Hide panel and dock"
msgstr ""
msgid "Screenshot to clipboard"
msgid "Square drawing area"
msgstr ""
msgid "Area screenshot"
msgid "Undo last brushstroke"
msgstr ""
msgid "Area screenshot to clipboard"
msgstr ""
msgid "System"
msgstr ""
msgid "Undo"
msgstr ""
msgid "Redo"
msgstr ""
msgid "Erase"
msgstr ""
msgid "Smooth"
msgstr ""
msgid "Free drawing"
msgstr ""
msgid "Line"
msgstr ""
msgid "Ellipse"
msgstr ""
msgid "Rectangle"
msgstr ""
msgid "Text"
msgstr ""
msgid "Polygon"
msgstr ""
msgid "Polyline"
msgstr ""
msgid "Image"
msgstr ""
msgid "Move"
msgstr ""
msgid "Resize"
msgstr ""
msgid "Mirror"
msgstr ""
msgid "Color"
msgstr ""
msgid "Fill"
msgstr ""
# fill-rule SVG attribute
msgid "Evenodd"
msgstr ""
msgid "%d px"
msgstr ""
# stroke-linejoin SVG attribute
msgid "Miter"
msgstr ""
# stroke-linejoin and stroke-linecap SVG attribute
msgid "Round"
msgstr ""
# stroke-linejoin SVG attribute
msgid "Bevel"
msgstr ""
# stroke-linecap SVG attribute
msgid "Butt"
msgstr ""
# stroke-linecap SVG attribute
msgid "Square"
msgstr ""
# generic font-family SVG attribute
msgid "Sans-Serif"
msgstr ""
# generic font-family SVG attribute
msgid "Serif"
msgstr ""
# generic font-family SVG attribute
msgid "Monospace"
msgstr ""
# generic font-family SVG attribute
msgid "Cursive"
msgstr ""
# generic font-family SVG attribute
msgid "Fantasy"
msgstr ""
# font-weight SVG attribute
msgid "Thin"
msgstr ""
# font-weight SVG attribute
msgid "Ultra-light"
msgstr ""
# font-weight SVG attribute
msgid "Light"
msgstr ""
# font-weight SVG attribute
msgid "Semi-light"
msgstr ""
# font-weight SVG attribute
msgid "Book"
msgstr ""
# font-weight and font-style SVG attribute
msgid "Normal"
msgstr ""
# font-weight SVG attribute
msgid "Medium"
msgstr ""
# font-weight SVG attribute
msgid "Semi-bold"
msgstr ""
# font-weight SVG attribute
msgid "Bold"
msgstr ""
# font-weight SVG attribute
msgid "Ultra-bold"
msgstr ""
# font-weight SVG attribute
msgid "Heavy"
msgstr ""
# font-style SVG attribute
msgid "Italic"
msgstr ""
# font-style SVG attribute
msgid "Oblique"
msgstr ""
msgid "Right aligned"
msgstr ""
msgid "Open drawing"
msgstr ""
msgid "Save drawing"
msgstr ""
msgid "Leaving drawing mode"
msgstr ""
# %s is a key label
msgid "<small>Press <i>%s</i> for help</small>"
msgstr ""
msgid "Entering drawing mode"
msgstr ""
# "released" as the opposite of "grabbed"
msgid "Keyboard and pointer released"
msgstr ""
msgid "Keyboard and pointer grabbed"
msgstr ""
# %s is a key label
msgid ""
"Press <i>%s</i> to get\n"
"a fourth control point"
msgstr ""
msgid "Mark a point of symmetry"
msgstr ""
msgid "Draw a line of symmetry"
msgstr ""
# %s is a key label
msgid ""
"Press <i>%s</i> to mark vertices"
msgstr ""
# %s is a key label
msgid ""
"Type your text and press <i>%s</i>"
msgstr ""
# as the alternative to "Fill"
msgid "Outline"
msgstr ""
msgid "Dashed line"
msgstr ""
msgid "Full line"
msgstr ""
msgid "Left aligned"
msgstr ""
msgid "Nonzero"
msgstr ""

44
menu.js
View File

@ -39,6 +39,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Files = Me.imports.files;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const pgettext = imports.gettext.domain(Me.metadata['gettext-domain']).pgettext;
const GS_VERSION = Config.PACKAGE_VERSION;
@ -71,29 +72,37 @@ const getSummary = function(settingKey) {
// Used by both menu and osd notifications.
var DisplayStrings = {
getDashedLine: function(dashed) {
return dashed ? _("Dashed line") : _("Full line");
return dashed ? _("Dashed line") :
// Translators: as the alternative to "Dashed line"
_("Full line");
},
getFill: function(fill) {
return fill ? _("Fill") : _("Outline");
return fill ? _("Fill") :
// Translators: as the alternative to "Fill"
_("Outline");
},
get FillRule() {
if (!this._fillRules)
// Translators: fill-rule SVG attribute
this._fillRules = { 0: _("Nonzero"), 1: _("Evenodd") };
return this._fillRules;
},
getFontFamily: function(family) {
if (!this._fontGenericFamilies)
this._fontGenericFamilies = { 'Sans-Serif': _("Sans-Serif"), 'Serif': _("Serif"), 'Monospace': _("Monospace"),
'Cursive': _("Cursive"), 'Fantasy': _("Fantasy") };
// Translators: generic font-family SVG attribute
this._fontGenericFamilies = { 'Sans-Serif': pgettext("font-family", "Sans-Serif"), 'Serif': pgettext("font-family", "Serif"),
'Monospace': pgettext("font-family", "Monospace"), 'Cursive': pgettext("font-family", "Cursive"),
'Fantasy': pgettext("font-family", "Fantasy") };
return this._fontGenericFamilies[family] || family;
},
get FontStyle() {
if (!this._fontStyles)
this._fontStyles = { 0: _("Normal"), 1: _("Oblique"), 2: _("Italic") };
// Translators: font-style SVG attribute
this._fontStyles = { 0: pgettext("font-style", "Normal"), 1: pgettext("font-style", "Oblique"), 2: pgettext("font-style", "Italic") };
return this._fontStyles;
},
@ -101,37 +110,44 @@ var DisplayStrings = {
get FontWeight() {
if (!this._fontWeights)
this._fontWeights = { 100: _("Thin"), 200: _("Ultra Light"), 300: _("Light"), 350: _("Semi Light"),
380: _("Book"), 400: _("Normal"), 500: _("Medium"), 600: _("Semi Bold"),
700: _("Bold"), 800: _("Ultra Bold"), 900: _("Heavy"), 1000:_("Ultra Heavy") };
// Translators: font-weight SVG attribute
this._fontWeights = { 100: pgettext("font-weight", "Thin"), 200: pgettext("font-weight", "Ultra Light"), 300: pgettext("font-weight", "Light"),
350: pgettext("font-weight", "Semi Light"), 380: pgettext("font-weight", "Book"), 400: pgettext("font-weight", "Normal"),
500: pgettext("font-weight", "Medium"), 600: pgettext("font-weight", "Semi Bold"), 700: pgettext("font-weight", "Bold"),
800: pgettext("font-weight", "Ultra Bold"), 900: pgettext("font-weight", "Heavy"), 1000: pgettext("font-weight", "Ultra Heavy") };
return this._fontWeights;
},
get LineCap() {
if (!this._lineCaps)
this._lineCaps = { 0: _("Butt"), 1: _("Round"), 2: _("Square") };
// Translators: stroke-linecap SVG attribute
this._lineCaps = { 0: pgettext("stroke-linecap", "Butt"), 1: pgettext("stroke-linecap", "Round"), 2: pgettext("stroke-linecap", "Square") };
return this._lineCaps;
},
get LineJoin() {
if (!this._lineJoins)
this._lineJoins = { 0: _("Miter"), 1: _("Round"), 2: _("Bevel") };
// Translators: stroke-linejoin SVG attribute
this._lineJoins = { 0: pgettext("stroke-linejoin", "Miter"), 1: pgettext("stroke-linejoin", "Round"), 2: pgettext("stroke-linejoin", "Bevel") };
return this._lineJoins;
},
getPixels(value) {
return _("%d px").format(value);
// Translators: value in pixel unit (e.g. "5 px")
return _("%f px").format(value);
},
getTextAlignment: function(rightAligned) {
// Translators: text alignment
return rightAligned ? _("Right aligned") : _("Left aligned");
},
get Tool() {
if (!this._tools)
this._tools = { 0: _("Free drawing"), 1: _("Line"), 2: _("Ellipse"), 3: _("Rectangle"),
4: _("Text"), 5: _("Polygon"), 6: _("Polyline"), 7: _("Image"),
100: _("Move"), 101: _("Resize"), 102: _("Mirror") };
this._tools = { 0: pgettext("drawing-tool", "Free drawing"), 1: pgettext("drawing-tool", "Line"), 2: pgettext("drawing-tool", "Ellipse"),
3: pgettext("drawing-tool", "Rectangle"), 4: pgettext("drawing-tool", "Text"), 5: pgettext("drawing-tool", "Polygon"),
6: pgettext("drawing-tool", "Polyline"), 7: pgettext("drawing-tool", "Image"),
100: pgettext("drawing-tool", "Move"), 101: pgettext("drawing-tool", "Resize"), 102: pgettext("drawing-tool", "Mirror") };
return this._tools;
}
};

106
prefs.js
View File

@ -1,5 +1,5 @@
/* jslint esversion: 6 */
/* exported GLOBAL_KEYBINDINGS, INTERNAL_KEYBINDINGS, OTHER_SHORTCUTS, init, buildPrefsWidget */
/* exported init, buildPrefsWidget */
/*
* Copyright 2019 Abakkk
@ -27,10 +27,10 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
const Shortcuts = Me.imports.shortcuts.Shortcuts;
const gettext = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const _ = function(string) {
if (!string)
@ -39,51 +39,9 @@ const _ = function(string) {
};
const _GTK = imports.gettext.domain('gtk30').gettext;
const GS_VERSION = Config.PACKAGE_VERSION;
const MARGIN = 10;
const ROWBOX_MARGIN_PARAMS = { margin_top: MARGIN / 2, margin_bottom: MARGIN / 2, margin_left: MARGIN, margin_right: MARGIN };
var GLOBAL_KEYBINDINGS = ['toggle-drawing', 'toggle-modal', 'erase-drawings'];
var INTERNAL_KEYBINDINGS = [
['undo', 'redo', 'delete-last-element', 'smooth-last-element'],
['select-none-shape', 'select-line-shape', 'select-ellipse-shape', 'select-rectangle-shape', 'select-polygon-shape', 'select-polyline-shape',
'select-text-shape', 'select-image-shape', 'select-move-tool', 'select-resize-tool', 'select-mirror-tool'],
['switch-fill', 'switch-fill-rule', 'switch-color-palette', 'switch-color-palette-reverse'],
['increment-line-width', 'increment-line-width-more', 'decrement-line-width', 'decrement-line-width-more',
'switch-linejoin', 'switch-linecap', 'switch-dash'],
['switch-font-family', 'switch-font-family-reverse', 'switch-font-weight', 'switch-font-style', 'switch-text-alignment', 'switch-image-file'],
['toggle-panel-and-dock-visibility', 'toggle-background', 'toggle-grid', 'toggle-square-area'],
['open-next-json', 'open-previous-json', 'save-as-json', 'save-as-svg', 'open-preferences', 'toggle-help']
];
if (GS_VERSION < '3.36')
delete INTERNAL_KEYBINDINGS[INTERNAL_KEYBINDINGS.length - 1]['open-preferences'];
const getKeyLabel = function(accel) {
let [keyval, mods] = Gtk.accelerator_parse(accel);
return Gtk.accelerator_get_label(keyval, mods);
};
var OTHER_SHORTCUTS = [{
get "Draw"() { return _("Left click"); },
get "Menu"() { return _("Right click"); },
get "Toggle fill/outline"() { return _("Center click"); },
get "Increment/decrement line width"() { return _("Scroll"); },
get "Select color"() { return _("%s … %s").format(getKeyLabel('<Primary>1'), getKeyLabel('<Primary>9')); },
get "Ignore pointer movement"() { return _("%s held").format(getKeyLabel('space')); },
"Leave": getKeyLabel('Escape'),
}, {
"Select eraser <span alpha=\"50%\">(while starting drawing)</span>": getKeyLabel('<Shift>'),
"Duplicate <span alpha=\"50%\">(while starting handling)</span>": getKeyLabel('<Shift>'),
"Rotate rectangle, polygon, polyline": getKeyLabel('<Primary>'),
"Extend circle to ellipse": getKeyLabel('<Primary>'),
"Curve line": getKeyLabel('<Primary>'),
"Smooth free drawing outline": getKeyLabel('<Primary>'),
"Rotate <span alpha=\"50%\">(while moving)</span>": getKeyLabel('<Primary>'),
"Stretch <span alpha=\"50%\">(while resizing)</span>": getKeyLabel('<Primary>'),
"Inverse <span alpha=\"50%\">(while mirroring)</span>": getKeyLabel('<Primary>'),
}];
function init() {
Convenience.initTranslations();
}
@ -110,10 +68,13 @@ const TopStack = new GObject.Class({
_init: function(params) {
this.parent({ transition_type: 1, transition_duration: 500, expand: true });
this.prefsPage = new PrefsPage();
// Translators: "Preferences" page in preferences
this.add_titled(this.prefsPage, 'prefs', _("Preferences"));
this.drawingPage = new DrawingPage();
// Translators: "Drawing" page in preferences
this.add_titled(this.drawingPage, 'drawing', _("Drawing"));
this.aboutPage = new AboutPage();
// Translators: "About" page in preferences
this.add_titled(this.aboutPage, 'about', _("About"));
}
});
@ -129,9 +90,12 @@ const AboutPage = new GObject.Class({
let vbox= new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN * 3 });
this.add(vbox);
let name = "<b> " + _(Me.metadata.name) + "</b>";
// Translators: you are free to translate the extension name, that is displayed in About page, or not
let name = "<b> " + _("Draw On You Screen") + "</b>";
// Translators: version number in "About" page
let version = _("Version %d").format(Me.metadata.version);
let description = _(Me.metadata.description);
// Translators: you are free to translate the extension description, that is displayed in About page, or not
let description = _("Start drawing with Super+Alt+D and save your beautiful work by taking a screenshot");
let link = "<span><a href=\"" + Me.metadata.url + "\">" + Me.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";
@ -153,6 +117,11 @@ const AboutPage = new GObject.Class({
creditBox.pack_start(rightBox, true, true, 5);
vbox.add(creditBox);
// Translators: add your name here or keep it empty, it will be displayed in about page, e.g.
// msgstr ""
// "translator1\n"
// "<a href=\"mailto:translator2@mail.org\">translator2</a>\n"
// "<a href=\"https://...\">translator3</a>"
if (_("translator-credits") != "translator-credits" && _("translator-credits") != "") {
leftBox.pack_start(new Gtk.Label(), false, false, 0);
rightBox.pack_start(new Gtk.Label(), false, false, 0);
@ -162,7 +131,6 @@ const AboutPage = new GObject.Class({
rightBox.pack_start(rightLabel, false, false, 0);
}
}
});
const DrawingPage = new GObject.Class({
@ -375,6 +343,7 @@ const DrawingPage = new GObject.Class({
_addNewPalette: function() {
let colors = Array(9).fill('Black');
// Translators: default name of a new palette
this.palettes.push([_("New palette"), colors]);
this._savePalettes();
},
@ -407,10 +376,15 @@ const PrefsPage = new GObject.Class({
listBox.get_style_context().add_class('background');
globalFrame.add(listBox);
let globalKeybindingsRow = new Gtk.ListBoxRow({ activatable: false });
let globalKeybindingsWidget = new KeybindingsWidget(GLOBAL_KEYBINDINGS, settings);
globalKeybindingsRow.add(globalKeybindingsWidget);
listBox.add(globalKeybindingsRow);
Shortcuts.GLOBAL_KEYBINDINGS.forEach((settingKeys, index) => {
if (index)
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
let globalKeybindingsRow = new Gtk.ListBoxRow({ activatable: false });
let globalKeybindingsWidget = new KeybindingsWidget(settingKeys, settings);
globalKeybindingsRow.add(globalKeybindingsWidget);
listBox.add(globalKeybindingsRow);
});
let persistentKey = schema.get_key('persistent-drawing');
let persistentRow = new PrefRow({ label: persistentKey.get_summary(), desc: persistentKey.get_description() });
@ -447,28 +421,28 @@ const PrefsPage = new GObject.Class({
listBox.get_style_context().add_class('background');
internalFrame.add(listBox);
OTHER_SHORTCUTS.forEach((object, index) => {
Shortcuts.OTHERS.forEach((pairs, index) => {
if (index)
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
for (let key in object) {
pairs.forEach(pair => {
let otherBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN });
let otherLabel = new Gtk.Label({ label: _(key), use_markup: true });
let otherLabel = new Gtk.Label({ label: pair[0], use_markup: true });
otherLabel.set_halign(1);
let otherLabel2 = new Gtk.Label({ label: object[key] });
let otherLabel2 = new Gtk.Label({ label: pair[1] });
otherBox.pack_start(otherLabel, true, true, 4);
otherBox.pack_start(otherLabel2, false, false, 4);
listBox.add(otherBox);
}
});
});
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
INTERNAL_KEYBINDINGS.forEach((array, index) => {
Shortcuts.INTERNAL_KEYBINDINGS.forEach((settingKeys, index) => {
if (index)
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
let internalKeybindingsWidget = new KeybindingsWidget(array, internalShortcutSettings);
let internalKeybindingsWidget = new KeybindingsWidget(settingKeys, internalShortcutSettings);
listBox.add(internalKeybindingsWidget);
});
@ -552,7 +526,7 @@ const PixelSpinButton = new GObject.Class({
// Add 'px' unit.
vfunc_output: function() {
this.text = _("%d px").format(Math.round(this.value * 100) / 100);
this.text = _("%f px").format(Number(this.value).toFixed(2));
return true;
},
@ -603,11 +577,11 @@ const KeybindingsWidget = new GObject.Class({
GTypeName: 'DrawOnYourScreenKeybindingsWidget',
Extends: Gtk.Box,
_init: function(keybindings, settings) {
_init: function(settingKeys, settings) {
this.parent(ROWBOX_MARGIN_PARAMS);
this.set_orientation(Gtk.Orientation.VERTICAL);
this._keybindings = keybindings;
this._settingKeys = settingKeys;
this._settings = settings;
this._columns = {
@ -706,9 +680,9 @@ const KeybindingsWidget = new GObject.Class({
_refresh: function() {
this._store.clear();
for(let settings_key of this._keybindings) {
this._settingKeys.forEach(settingKey => {
let [key, mods] = Gtk.accelerator_parse(
this._settings.get_strv(settings_key)[0]
this._settings.get_strv(settingKey)[0]
);
let iter = this._store.append();
@ -720,12 +694,12 @@ const KeybindingsWidget = new GObject.Class({
this._columns.KEY
],
[
settings_key,
this._settings.settings_schema.get_key(settings_key).get_summary(),
settingKey,
this._settings.settings_schema.get_key(settingKey).get_summary(),
mods,
key
]
);
}
});
}
});

View File

@ -31,10 +31,82 @@
</key>
<key type="as" name="toggle-modal">
<default>["&lt;Primary&gt;&lt;Alt&gt;&lt;Super&gt;d"]</default>
<!-- Translators: there is a similar text in GNOME Boxes (https://gitlab.gnome.org/GNOME/gnome-boxes/tree/master/po) -->
<summary>Grab/ungrab keyboard and pointer</summary>
<description></description>
</key>
</schema>
<schema path="/org/gnome/shell/extensions/draw-on-your-screen/drawing/" id="org.gnome.shell.extensions.draw-on-your-screen.drawing">
<key type="s" name="background-color">
<default>"#2e2e2e"</default>
<summary>Background color</summary>
<description>The color of the drawing area background</description>
</key>
<key type="b" name="dash-array-auto">
<default>true</default>
<summary>Automatic dash array</summary>
<description>Compute the lengths from the line width</description>
</key>
<key type="d" name="dash-array-on">
<default>5</default>
<summary>Dash array on</summary>
<description>The dash length in pixels</description>
</key>
<key type="d" name="dash-array-off">
<default>15</default>
<summary>Dash array off</summary>
<description>The gap between the dashes in pixels</description>
</key>
<key type="d" name="dash-offset">
<default>0</default>
<summary>Dash offset</summary>
<description>The dash offset in pixels</description>
</key>
<key type="s" name="grid-color">
<default>"Gray"</default>
<summary>Grid overlay color</summary>
<description>The color of the lines</description>
</key>
<key type="b" name="grid-line-auto">
<default>true</default>
<summary>Automatic grid overlay line</summary>
<description>Compute the lengths from the screen size</description>
</key>
<key type="u" name="grid-line-spacing">
<default>10</default>
<summary>Grid overlay line spacing</summary>
<description>The gap between lines in pixels</description>
</key>
<key type="d" name="grid-line-width">
<default>0.5</default>
<summary>Grid overlay line width</summary>
<description>The line width in pixels</description>
</key>
<key type="a(sas)" name="palettes">
<default>
[
("Palette", ["HotPink","Cyan","yellow","Orangered","Chartreuse","DarkViolet","White","Gray","Black"]),
("GNOME HIG lighter", ["rgb(153,193,241)","rgb(143,240,164)","rgb(249,240,107)","rgb(255,190,111)","rgb(246,97,81)","rgb(220,138,221)","rgb(205,171,143)","rgb(255,255,255)","rgb(119,118,123)"]),
("GNOME HIG light", ["rgb(98,160,241)","rgb(87,227,137)","rgb(248,228,92)","rgb(255,163,72)","rgb(237,51,59)","rgb(192,97,203)","rgb(181,131,90)","rgb(246,245,244)","rgb(94,92,100)"]),
("GNOME HIG normal", ["rgb(53,132,228)","rgb(51,209,122)","rgb(246,211,45)","rgb(255,120,0)","rgb(224,27,36)","rgb(145,65,172)","rgb(152,106,68)","rgb(222,221,218)","rgb(61,56,70)"]),
("GNOME HIG dark", ["rgb(28,113,216)","rgb(46,194,126)","rgb(245,194,17)","rgb(230,97,0)","rgb(192,28,40)","rgb(129,61,156)","rgb(134,94,60)","rgb(192,191,188)","rgb(36,31,49)"]),
("GNOME HIG darker", ["rgb(26,095,180)","rgb(38,162,105)","rgb(229,165,10)","rgb(198,70,0)","rgb(165,29,45)","rgb(97,53,131)","rgb(99,69,44)","rgb(154,153,150)","rgb(0,0,0)"])
]
</default>
<summary>Color palettes</summary>
<description>The palettes of drawing colors</description>
</key>
<key type="b" name="square-area-auto">
<default>true</default>
<summary>Automatic square area size</summary>
<description>Compute the size of the square area from the screen size</description>
</key>
<key type="u" name="square-area-size">
<default>512</default>
<summary>Square area size</summary>
<description>The size of the square area in pixels</description>
</key>
</schema>
<schema path="/org/gnome/shell/extensions/draw-on-your-screen/internal-shortcuts/" id="org.gnome.shell.extensions.draw-on-your-screen.internal-shortcuts">
<key type="as" name="decrement-line-width">
<default><![CDATA[['<Primary>KP_Subtract','<Primary>minus','<Primary><Shift>minus']]]></default>
@ -139,7 +211,7 @@
</key>
<key type="as" name="select-none-shape">
<default>["&lt;Primary&gt;p"]</default>
<summary>Free drawing</summary>
<summary>Select free drawing</summary>
</key>
<key type="as" name="select-polygon-shape">
<default>["&lt;Primary&gt;y"]</default>
@ -242,75 +314,4 @@
<summary>Undo last brushstroke</summary>
</key>
</schema>
<schema path="/org/gnome/shell/extensions/draw-on-your-screen/drawing/" id="org.gnome.shell.extensions.draw-on-your-screen.drawing">
<key type="s" name="background-color">
<default>"#2e2e2e"</default>
<summary>Background color</summary>
<description>The color of the drawing area background</description>
</key>
<key type="b" name="dash-array-auto">
<default>true</default>
<summary>Automatic dash array</summary>
<description>Compute the lengths from the line width</description>
</key>
<key type="d" name="dash-array-on">
<default>5</default>
<summary>Dash array on</summary>
<description>The dash length in pixels</description>
</key>
<key type="d" name="dash-array-off">
<default>15</default>
<summary>Dash array off</summary>
<description>The gap between the dashes in pixels</description>
</key>
<key type="d" name="dash-offset">
<default>0</default>
<summary>Dash offset</summary>
<description>The dash offset in pixels</description>
</key>
<key type="s" name="grid-color">
<default>"Gray"</default>
<summary>Grid overlay color</summary>
<description>The color of the lines</description>
</key>
<key type="b" name="grid-line-auto">
<default>true</default>
<summary>Automatic grid overlay line</summary>
<description>Compute the lengths from the screen size</description>
</key>
<key type="u" name="grid-line-spacing">
<default>10</default>
<summary>Grid overlay line spacing</summary>
<description>The gap between lines in pixels</description>
</key>
<key type="d" name="grid-line-width">
<default>0.5</default>
<summary>Grid overlay line width</summary>
<description>The line width in pixels</description>
</key>
<key type="a(sas)" name="palettes">
<default>
[
("Palette", ["HotPink","Cyan","yellow","Orangered","Chartreuse","DarkViolet","White","Gray","Black"]),
("GNOME HIG lighter", ["rgb(153,193,241)","rgb(143,240,164)","rgb(249,240,107)","rgb(255,190,111)","rgb(246,97,81)","rgb(220,138,221)","rgb(205,171,143)","rgb(255,255,255)","rgb(119,118,123)"]),
("GNOME HIG light", ["rgb(98,160,241)","rgb(87,227,137)","rgb(248,228,92)","rgb(255,163,72)","rgb(237,51,59)","rgb(192,97,203)","rgb(181,131,90)","rgb(246,245,244)","rgb(94,92,100)"]),
("GNOME HIG normal", ["rgb(53,132,228)","rgb(51,209,122)","rgb(246,211,45)","rgb(255,120,0)","rgb(224,27,36)","rgb(145,65,172)","rgb(152,106,68)","rgb(222,221,218)","rgb(61,56,70)"]),
("GNOME HIG dark", ["rgb(28,113,216)","rgb(46,194,126)","rgb(245,194,17)","rgb(230,97,0)","rgb(192,28,40)","rgb(129,61,156)","rgb(134,94,60)","rgb(192,191,188)","rgb(36,31,49)"]),
("GNOME HIG darker", ["rgb(26,095,180)","rgb(38,162,105)","rgb(229,165,10)","rgb(198,70,0)","rgb(165,29,45)","rgb(97,53,131)","rgb(99,69,44)","rgb(154,153,150)","rgb(0,0,0)"])
]
</default>
<summary>Color palettes</summary>
<description>The palettes of drawing colors</description>
</key>
<key type="b" name="square-area-auto">
<default>true</default>
<summary>Automatic square area size</summary>
<description>Compute the size of the square area from the screen size</description>
</key>
<key type="u" name="square-area-size">
<default>512</default>
<summary>Square area size</summary>
<description>The size of the square area in pixels</description>
</key>
</schema>
</schemalist>

102
shortcuts.js Normal file
View File

@ -0,0 +1,102 @@
/* jslint esversion: 6 */
/* exported Shortcuts */
/*
* Copyright 2019 Abakkk
*
* This file is part of DrawOnYourScreen, a drawing extension for GNOME Shell.
* https://framagit.org/abakkk/DrawOnYourScreen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const Gtk = imports.gi.Gtk;
const GS_VERSION = imports.misc.config.PACKAGE_VERSION;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const internalShortcutsSchema = Convenience.getSettings(Me.metadata['settings-schema'] + '.internal-shortcuts').settings_schema;
const getKeyLabel = function(accel) {
let [keyval, mods] = Gtk.accelerator_parse(accel);
return Gtk.accelerator_get_label(keyval, mods);
};
// It is used by helper and prefs.
var Shortcuts = {
// The setting keys of the "org.gnome.shell.extensions.draw-on-your-screen" schema.
GLOBAL_KEYBINDINGS: [
['toggle-drawing', 'toggle-modal', 'erase-drawings']
],
// The setting keys of the "org.gnome.shell.extensions.draw-on-your-screen.internal-shortcuts" schema.
INTERNAL_KEYBINDINGS: [
['undo', 'redo', 'delete-last-element', 'smooth-last-element'],
['select-none-shape', 'select-line-shape', 'select-ellipse-shape', 'select-rectangle-shape', 'select-polygon-shape', 'select-polyline-shape',
'select-text-shape', 'select-image-shape', 'select-move-tool', 'select-resize-tool', 'select-mirror-tool'],
['switch-fill', 'switch-fill-rule', 'switch-color-palette', 'switch-color-palette-reverse'],
['increment-line-width', 'increment-line-width-more', 'decrement-line-width', 'decrement-line-width-more',
'switch-linejoin', 'switch-linecap', 'switch-dash'],
['switch-font-family', 'switch-font-family-reverse', 'switch-font-weight', 'switch-font-style', 'switch-text-alignment', 'switch-image-file'],
['toggle-panel-and-dock-visibility', 'toggle-background', 'toggle-grid', 'toggle-square-area'],
['open-next-json', 'open-previous-json', 'save-as-json', 'save-as-svg', 'open-preferences', 'toggle-help']
],
// Use functions to get the translations "at runtime".
_otherFunctions: [[
() => [_("Draw"), _("Left click")],
() => [_("Menu"), _("Right click")],
() => [internalShortcutsSchema.get_key('switch-fill').get_summary(), _("Center click")],
() => [_("Increment/decrement line width"), _("Scroll")],
// Translators: %s are key labels (Ctrl+F1 and Ctrl+F9)
() => [_("Select color"), _("%s … %s").format(getKeyLabel('<Primary>1'), getKeyLabel('<Primary>9'))],
// Translators: %s is a key label
() => [_("Ignore pointer movement"), _("%s held").format(getKeyLabel('space'))],
() => [_("Leave"), getKeyLabel('Escape')],
], [
() => [_("Select eraser <span alpha=\"50%\">(while starting drawing)</span>"), getKeyLabel('<Shift>')],
() => [_("Duplicate <span alpha=\"50%\">(while starting handling)</span>"), getKeyLabel('<Shift>')],
() => [_("Rotate rectangle, polygon, polyline"), getKeyLabel('<Primary>')],
() => [_("Extend circle to ellipse"), getKeyLabel('<Primary>')],
() => [_("Curve line"), getKeyLabel('<Primary>')],
() => [_("Smooth free drawing outline"), getKeyLabel('<Primary>')],
() => [_("Rotate <span alpha=\"50%\">(while moving)</span>"), getKeyLabel('<Primary>')],
() => [_("Stretch <span alpha=\"50%\">(while resizing)</span>"), getKeyLabel('<Primary>')],
() => [_("Inverse <span alpha=\"50%\">(while mirroring)</span>"), getKeyLabel('<Primary>')],
]],
get OTHERS() {
if (!this._others) {
this._others = [];
this._otherFunctions.forEach(getPairFunctions => {
let pairs = [];
getPairFunctions.forEach(getPairFunction => pairs.push(getPairFunction()));
this._others.push(pairs);
});
}
return this._others;
}
};
if (GS_VERSION < '3.36')
// Remove 'open-preferences' keybinding.
Shortcuts.INTERNAL_KEYBINDINGS.forEach(settingKeys => {
let index = settingKeys.indexOf('open-preferences');
if (index != -1)
settingKeys.splice(index, 1);
});