From 4cc28cf100abe06bf8b6bfa962964d101812e41a Mon Sep 17 00:00:00 2001 From: abakkk Date: Tue, 7 Jan 2020 22:15:18 +0100 Subject: [PATCH] small rework of prefs.js --- locale/draw-on-your-screen.pot | 20 +++---- prefs.js | 95 ++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index b6474ed..54d4974 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -285,18 +285,18 @@ msgstr "" msgid "Global" msgstr "" -msgid "Drawing on the desktop" -msgstr "" - -msgid "Draw On Your Screen becomes Draw On Your Desktop" -msgstr "" - msgid "Persistent" msgstr "" msgid "Persistent drawing through session restart" msgstr "" +msgid "Drawing on the desktop" +msgstr "" + +msgid "Draw On Your Screen becomes Draw On Your Desktop" +msgstr "" + msgid "Disable on-screen notifications" msgstr "" @@ -314,18 +314,18 @@ msgid "" " . rotate a rectangle or a text area\n" " . extend and rotate an ellipse\n" " . curve a line (cubic Bezier curve)\n" -" . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" +" . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" msgstr "" msgid "" -"Default drawing attributes (colors, font, line, dash) are defined in an editable css file.\n" +"Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" "See “%s”." msgstr "" msgid "" -"Note: When you save elements made with eraser in a SVG file,\n" +"Note: When you save elements made with eraser in a SVG file, " "they are colored with background color, transparent if it is disabled.\n" -"(See “%s” or edit the SVG file afterwards)" +"See “%s” or edit the SVG file afterwards." msgstr "" diff --git a/prefs.js b/prefs.js index e1fc815..78d387e 100644 --- a/prefs.js +++ b/prefs.js @@ -176,85 +176,88 @@ var PrefsPage = new GObject.Class({ this.settings = Convenience.getSettings(); - let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 }); + let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 }); this.add(box); - let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true }); - box.add(listBox); + let globalFrame = new Gtk.Frame({ label_yalign: 1.0 }); + globalFrame.set_label_widget(new Gtk.Label({ margin_bottom: MARGIN/2, use_markup: true, label: "" + _("Global") + "" })); + box.add(globalFrame); + + let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true, margin_top: MARGIN/2, margin_bottom: MARGIN/2 }); + globalFrame.add(listBox); let styleContext = listBox.get_style_context(); styleContext.add_class('background'); - let globalTitleBox = new Gtk.Box({ margin: MARGIN }); - let globalTitleLabel = new Gtk.Label({ use_markup: true, label: "" + _("Global") + " :" }); - globalTitleLabel.set_halign(1); - globalTitleBox.pack_start(globalTitleLabel, true, true, 4); - listBox.add(globalTitleBox); - let globalKeybindingsWidget = new KeybindingsWidget(GLOBAL_KEYBINDINGS, this.settings); globalKeybindingsWidget.margin = MARGIN; listBox.add(globalKeybindingsWidget); - let persistentBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let persistentBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let persistentLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let persistentLabel1 = new Gtk.Label({label: _("Persistent")}); - let persistentLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Persistent drawing through session restart") + "" }); + let persistentLabel2 = new Gtk.Label({ use_markup: true, halign: 1, wrap: true, xalign: 0, label: "" + _("Persistent drawing through session restart") + "" }); persistentLabel1.set_halign(1); - persistentLabel2.get_style_context().add_class("dim-label"); + persistentLabel2.get_style_context().add_class('dim-label'); persistentLabelBox.pack_start(persistentLabel1, true, true, 0); persistentLabelBox.pack_start(persistentLabel2, true, true, 0); let persistentSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("persistent-drawing", persistentSwitch, "active", 0); + this.settings.bind('persistent-drawing', persistentSwitch, 'active', 0); persistentBox.pack_start(persistentLabelBox, true, true, 4); persistentBox.pack_start(persistentSwitch, false, false, 4); listBox.add(persistentBox); - let desktopBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let desktopBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let desktopLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let desktopLabel1 = new Gtk.Label({label: _("Drawing on the desktop")}); - let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); + let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, wrap: true, xalign: 0, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); desktopLabel1.set_halign(1); - desktopLabel2.get_style_context().add_class("dim-label"); + desktopLabel2.get_style_context().add_class('dim-label'); desktopLabelBox.pack_start(desktopLabel1, true, true, 0); desktopLabelBox.pack_start(desktopLabel2, true, true, 0); let desktopSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("drawing-on-desktop", desktopSwitch, "active", 0); + this.settings.bind('drawing-on-desktop', desktopSwitch, 'active', 0); desktopBox.pack_start(desktopLabelBox, true, true, 4); desktopBox.pack_start(desktopSwitch, false, false, 4); listBox.add(desktopBox); - let osdBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let osdBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: 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); + 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_left: MARGIN, margin_right: MARGIN }); + let indicatorBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: 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); + 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); - listBox.add(new Gtk.Box({ margin_bottom: MARGIN, margin_left: MARGIN, margin_right: MARGIN })); - this.addSeparator(listBox); + let children = listBox.get_children(); + for (let i = 0; i < children.length; i++) { + if (children[i].activatable) + children[i].set_activatable(false); + } - let internalTitleBox = new Gtk.Box({ margin: MARGIN }); - let internalTitleLabel = new Gtk.Label({ use_markup: true, label: "" + _("Internal") + " " + _("(in drawing mode)") + " :" }); - internalTitleLabel.set_halign(1); - internalTitleBox.pack_start(internalTitleLabel, true, true, 4); - listBox.add(internalTitleBox); + let internalFrame = new Gtk.Frame({ margin_top: 3*MARGIN, label_yalign: 1.0 }); + internalFrame.set_label_widget(new Gtk.Label({ margin_bottom: MARGIN/2, use_markup: true, label: "" + _("Internal") + " " + _("(in drawing mode)") })); + box.add(internalFrame); - listBox.add(new Gtk.Box({ margin_top: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN })); + listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true, margin_top: MARGIN }); + internalFrame.add(listBox); + + styleContext = listBox.get_style_context(); + styleContext.add_class('background'); for (let i = 0; i < OTHER_SHORTCUTS.length; i++) { if (OTHER_SHORTCUTS[i].desc.indexOf('-separator-') != -1) { @@ -270,19 +273,19 @@ var PrefsPage = new GObject.Class({ listBox.add(otherBox); } - listBox.add(new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN })); - - let controlBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let controlBox = new Gtk.Box({ margin: MARGIN, margin_top: 2*MARGIN }); let controlLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, label: _("By pressing Ctrl key during the drawing process, you can:\n" + " . rotate a rectangle or a text area\n" + " . extend and rotate an ellipse\n" + " . curve a line (cubic Bezier curve)\n" + - " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)").format(_("Smooth last brushstroke")) + " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)").format(_("Smooth last brushstroke")) }); controlLabel.set_halign(1); - controlLabel.get_style_context().add_class("dim-label"); + controlLabel.get_style_context().add_class('dim-label'); controlBox.pack_start(controlLabel, true, true, 4); listBox.add(controlBox); @@ -290,38 +293,38 @@ var PrefsPage = new GObject.Class({ internalKeybindingsWidget.margin = MARGIN; listBox.add(internalKeybindingsWidget); - let styleBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let styleBox = new Gtk.Box({ margin: MARGIN }); let styleLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, label: _("Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" + "See “%s”.").format(_("Open user.css")) }); styleLabel.set_halign(1); - styleLabel.get_style_context().add_class("dim-label"); + styleLabel.get_style_context().add_class('dim-label'); styleBox.pack_start(styleLabel, true, true, 4); listBox.add(styleBox); - let noteBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let noteBox = new Gtk.Box({ margin: MARGIN }); let noteLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, - label: _("Note: When you save elements made with eraser in a SVG file,\nthey are colored with background color, transparent if it is disabled.\n(See “%s” or edit the SVG file afterwards)").format(_("Add a drawing background")) + label: _("Note: When you save elements made with eraser in a SVG file, " + + "they are colored with background color, transparent if it is disabled.\n" + + "See “%s” or edit the SVG file afterwards.").format(_("Add a drawing background")) }); noteLabel.set_halign(1); - noteLabel.get_style_context().add_class("dim-label"); + noteLabel.get_style_context().add_class('dim-label'); noteBox.pack_start(noteLabel, true, true, 4); listBox.add(noteBox); - let children = listBox.get_children(); + children = listBox.get_children(); for (let i = 0; i < children.length; i++) { if (children[i].activatable) children[i].set_activatable(false); } - }, - - addSeparator: function(container) { - let separatorRow = new Gtk.ListBoxRow({sensitive: false}); - separatorRow.add(new Gtk.Separator({ margin: MARGIN })); - container.add(separatorRow); } });