add panel indicator and prefs to disable osd notifications and indicator
This commit is contained in:
parent
14205295fc
commit
d2c285154b
2
draw.js
2
draw.js
|
|
@ -506,7 +506,6 @@ var DrawingArea = new Lang.Class({
|
||||||
this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
|
this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this));
|
||||||
this._onKeyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
|
this._onKeyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this));
|
||||||
this.scrollHandler = this.connect('scroll-event', this._onScroll.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.get_parent().set_background_color(this.hasBackground ? this.activeBackgroundColor : null);
|
||||||
this._updateStyle();
|
this._updateStyle();
|
||||||
},
|
},
|
||||||
|
|
@ -542,6 +541,7 @@ var DrawingArea = new Lang.Class({
|
||||||
|
|
||||||
this.currentElement = null;
|
this.currentElement = null;
|
||||||
this._stopCursorTimeout();
|
this._stopCursorTimeout();
|
||||||
|
this.currentShape = Shapes.NONE;
|
||||||
this.dashedLine = false;
|
this.dashedLine = false;
|
||||||
this.fill = false;
|
this.fill = false;
|
||||||
this._redisplay();
|
this._redisplay();
|
||||||
|
|
|
||||||
68
extension.js
68
extension.js
|
|
@ -25,8 +25,11 @@ const Lang = imports.lang;
|
||||||
const Meta = imports.gi.Meta;
|
const Meta = imports.gi.Meta;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const OsdWindow = imports.ui.osdWindow;
|
const OsdWindow = imports.ui.osdWindow;
|
||||||
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
|
|
||||||
const Extension = imports.misc.extensionUtils.getCurrentExtension();
|
const Extension = imports.misc.extensionUtils.getCurrentExtension();
|
||||||
const Convenience = Extension.imports.convenience;
|
const Convenience = Extension.imports.convenience;
|
||||||
const Draw = Extension.imports.draw;
|
const Draw = Extension.imports.draw;
|
||||||
|
|
@ -78,6 +81,9 @@ var AreaManager = new Lang.Class({
|
||||||
this.updateAreas();
|
this.updateAreas();
|
||||||
this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
|
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.desktopSettingHandler = this.settings.connect('changed::drawing-on-desktop', this.onDesktopSettingChanged.bind(this));
|
||||||
this.persistentSettingHandler = this.settings.connect('changed::persistent-drawing', this.onPersistentSettingChanged.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();
|
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() {
|
updateAreas: function() {
|
||||||
if (this.activeArea)
|
if (this.activeArea)
|
||||||
this.toggleDrawing();
|
this.toggleDrawing();
|
||||||
|
|
@ -264,8 +279,8 @@ var AreaManager = new Lang.Class({
|
||||||
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
global.display.set_cursor(Meta.Cursor.DEFAULT);
|
||||||
else if (global.screen && global.screen.set_cursor)
|
else if (global.screen && global.screen.set_cursor)
|
||||||
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
global.screen.set_cursor(Meta.Cursor.DEFAULT);
|
||||||
|
if (!this.osdDisabled)
|
||||||
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
|
Main.osdWindowManager.show(activeIndex, this.leaveGicon, _("Leaving drawing mode"), null);
|
||||||
} else {
|
} else {
|
||||||
// avoid to deal with Meta changes (global.display/global.screen)
|
// avoid to deal with Meta changes (global.display/global.screen)
|
||||||
let currentIndex = Main.layoutManager.monitors.indexOf(Main.layoutManager.currentMonitor);
|
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);
|
global.display.set_cursor(Meta.Cursor.POINTING_HAND);
|
||||||
else if (global.screen && global.screen.set_cursor)
|
else if (global.screen && global.screen.set_cursor)
|
||||||
global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
|
global.screen.set_cursor(Meta.Cursor.POINTING_HAND);
|
||||||
|
|
||||||
// increase OSD display time
|
this.osdDisabled = this.settings.get_boolean('osd-disabled');
|
||||||
let hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
|
if (!this.osdDisabled) {
|
||||||
OsdWindow.HIDE_TIMEOUT = 2000;
|
// increase OSD display time
|
||||||
Main.osdWindowManager.show(currentIndex, this.enterGicon, _("Press Ctrl + F1 for help") + "\n\n" + _("Entering drawing mode"), null);
|
let hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
|
||||||
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
|
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) {
|
showOsd: function(emitter, label, level, maxLevel) {
|
||||||
|
if (this.osdDisabled)
|
||||||
|
return;
|
||||||
let activeIndex = this.areas.indexOf(this.activeArea);
|
let activeIndex = this.areas.indexOf(this.activeArea);
|
||||||
if (activeIndex != -1) {
|
if (activeIndex != -1) {
|
||||||
Main.osdWindowManager.show(activeIndex, this.enterGicon, label, level, maxLevel);
|
Main.osdWindowManager.show(activeIndex, this.enterGicon, label, level, maxLevel);
|
||||||
|
|
@ -326,6 +349,10 @@ var AreaManager = new Lang.Class({
|
||||||
Main.layoutManager.disconnect(this.monitorChangedHandler);
|
Main.layoutManager.disconnect(this.monitorChangedHandler);
|
||||||
this.monitorChangedHandler = null;
|
this.monitorChangedHandler = null;
|
||||||
}
|
}
|
||||||
|
if (this.indicatorSettingHandler) {
|
||||||
|
this.settings.disconnect(this.indicatorSettingHandler);
|
||||||
|
this.indicatorSettingHandler = null;
|
||||||
|
}
|
||||||
if (this.desktopSettingHandler) {
|
if (this.desktopSettingHandler) {
|
||||||
this.settings.disconnect(this.desktopSettingHandler);
|
this.settings.disconnect(this.desktopSettingHandler);
|
||||||
this.desktopSettingHandler = null;
|
this.desktopSettingHandler = null;
|
||||||
|
|
@ -340,6 +367,31 @@ var AreaManager = new Lang.Class({
|
||||||
Main.wm.removeKeybinding('toggle-drawing');
|
Main.wm.removeKeybinding('toggle-drawing');
|
||||||
Main.wm.removeKeybinding('erase-drawing');
|
Main.wm.removeKeybinding('erase-drawing');
|
||||||
this.removeAreas();
|
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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,12 @@ msgstr ""
|
||||||
msgid "Persistent drawing through session restart"
|
msgid "Persistent drawing through session restart"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Disable on-screen notifications"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Disable panel indicator"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Internal"
|
msgid "Internal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
||||||
30
prefs.js
30
prefs.js
|
|
@ -109,7 +109,7 @@ function buildPrefsWidget() {
|
||||||
return topStack;
|
return topStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TopStack = new GObject.Class({
|
var TopStack = new GObject.Class({
|
||||||
Name: 'DrawOnYourScreenTopStack',
|
Name: 'DrawOnYourScreenTopStack',
|
||||||
GTypeName: 'DrawOnYourScreenTopStack',
|
GTypeName: 'DrawOnYourScreenTopStack',
|
||||||
Extends: Gtk.Stack,
|
Extends: Gtk.Stack,
|
||||||
|
|
@ -123,7 +123,7 @@ const TopStack = new GObject.Class({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const AboutPage = new GObject.Class({
|
var AboutPage = new GObject.Class({
|
||||||
Name: 'DrawOnYourScreenAboutPage',
|
Name: 'DrawOnYourScreenAboutPage',
|
||||||
GTypeName: 'DrawOnYourScreenAboutPage',
|
GTypeName: 'DrawOnYourScreenAboutPage',
|
||||||
Extends: Gtk.ScrolledWindow,
|
Extends: Gtk.ScrolledWindow,
|
||||||
|
|
@ -170,7 +170,7 @@ const AboutPage = new GObject.Class({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const PrefsPage = new GObject.Class({
|
var PrefsPage = new GObject.Class({
|
||||||
Name: 'DrawOnYourScreenPrefsPage',
|
Name: 'DrawOnYourScreenPrefsPage',
|
||||||
GTypeName: 'DrawOnYourScreenPrefsPage',
|
GTypeName: 'DrawOnYourScreenPrefsPage',
|
||||||
Extends: Gtk.ScrolledWindow,
|
Extends: Gtk.ScrolledWindow,
|
||||||
|
|
@ -226,6 +226,28 @@ const PrefsPage = new GObject.Class({
|
||||||
persistentBox.pack_start(persistentLabelBox, true, true, 4);
|
persistentBox.pack_start(persistentLabelBox, true, true, 4);
|
||||||
persistentBox.pack_start(persistentSwitch, false, false, 4);
|
persistentBox.pack_start(persistentSwitch, false, false, 4);
|
||||||
listBox.add(persistentBox);
|
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);
|
this.addSeparator(listBox);
|
||||||
|
|
||||||
let internalTitleBox = new Gtk.Box({ margin: MARGIN });
|
let internalTitleBox = new Gtk.Box({ margin: MARGIN });
|
||||||
|
|
@ -313,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/
|
// 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',
|
Name: 'DrawOnYourScreenKeybindings.Widget',
|
||||||
GTypeName: 'DrawOnYourScreenKeybindingsWidget',
|
GTypeName: 'DrawOnYourScreenKeybindingsWidget',
|
||||||
Extends: Gtk.Box,
|
Extends: Gtk.Box,
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -16,6 +16,16 @@
|
||||||
<summary>persistent drawing</summary>
|
<summary>persistent drawing</summary>
|
||||||
<description>persistent drawing</description>
|
<description>persistent drawing</description>
|
||||||
</key>
|
</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">
|
<key type="as" name="toggle-drawing">
|
||||||
<default>["<Alt><Super>d"]</default>
|
<default>["<Alt><Super>d"]</default>
|
||||||
<summary>toggle drawing</summary>
|
<summary>toggle drawing</summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue