Skip to content

Commit

Permalink
Gnome 3.36 Support (#778)
Browse files Browse the repository at this point in the history
* Extension: derive ServiceIndicator from GObject based class

* Extension: remove DoNotDisturb

As of gnome-shell 3.36, there is a built-in do not disturb feature so
there is no reason for us to duplicate this feature. Additionally, this
often caused confusion as many users believed this controlled their
phone's dnd state.

* Extension: fix two minor changes in notification sources

The signal ::acknowledged-changed has been replaced with a proper
GObject property.

NotificationSource.notify() has been renamed showNotification()

* Extension: remove dnd styles

* Extension: update Notification classes to derive from GObject

* Extension: update notificationDaemon methods

* correct some arg names

* Extension Menu: replace removed style class with custom CSS

* Extension: refactor notification banner

* Extension: revert type guard for notification callback

* Extension: misc cleanup to shell/notification.js

* Extension: update PanelMenu.SystemIndicator usage

* GMenu: remove extraneous popup-sub-menu classes

* _gsconnect: misc cleanup

* Remote: avoid a spurious ::g-properties-changed emission after disposal

We do a force disposal when dropping device proxies, but GDBusProxy will
synthesize an emission when the name owner disappears.

This seems to happen after we've disposed it, so add a guard clause to
prevent touching a finalized object.

* Extension: stop pollutiing the global searchPath

We've been polluting the global import searchPath by injecting our
imports into it. Up until now we've just been lucky, but we can just use
the provided Extension object for this.

* metadata.json: bump gnome-shell version to 3.36
  • Loading branch information
andyholmes authored Mar 8, 2020
1 parent 49e5fdd commit 2ed8d53
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 522 deletions.
2 changes: 1 addition & 1 deletion data/metadata.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "GSConnect",
"description": "GSConnect is a complete implementation of KDE Connect especially for GNOME Shell with Nautilus, Chrome and Firefox integration. It does not rely on the KDE Connect desktop application and will not work with it installed.\n\nKDE Connect allows devices to securely share content like notifications or files and other features like SMS messaging and remote control. The KDE Connect team has applications for Linux, BSD, Android, Sailfish and Windows.\n\nKDE Connect Indicator can support Gtk desktops other than GNOME Shell.\n\nPlease report issues on Github!",
"version": @VERSION@,
"shell-version": [ "3.34" ],
"shell-version": [ "3.36" ],
"url": "https://github.com/andyholmes/gnome-shell-extension-gsconnect/wiki",
"libdir": "@GNOME_SHELL_LIBDIR@",
"localedir": "@LOCALEDIR@",
Expand Down
3 changes: 0 additions & 3 deletions data/org.gnome.Shell.Extensions.GSConnect.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
<key name="devices" type="as">
<default>[]</default>
</key>
<key name="donotdisturb" type="i">
<default>0</default>
</key>
<key name="debug" type="b">
<default>false</default>
</key>
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ src/service/ui/messaging.js
src/service/ui/service.js
src/service/ui/telephony.js
src/shell/device.js
src/shell/donotdisturb.js
src/shell/notification.js
webextension/gettext.js
8 changes: 8 additions & 0 deletions src/_gsconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const GIRepository = imports.gi.GIRepository;
const GLib = imports.gi.GLib;


// Bootstrap the global object
if (!window.gsconnect) {
window.gsconnect = {};
let m = /@(.+):\d+/.exec((new Error()).stack.split('\n')[1]);
gsconnect.extdatadir = Gio.File.new_for_path(m[1]).get_parent().get_path();
}


/**
* String.format API supporting %s, %d, %x and %f. Used exclusively for gettext.
* See: https://github.com/GNOME/gjs/blob/master/modules/format.js
Expand Down
40 changes: 18 additions & 22 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;

const Main = imports.ui.main;
Expand All @@ -10,20 +11,16 @@ const PopupMenu = imports.ui.popupMenu;
const AggregateMenu = Main.panel.statusArea.aggregateMenu;

// Bootstrap
window.gsconnect = {
extdatadir: imports.misc.extensionUtils.getCurrentExtension().path
};
imports.searchPath.unshift(gsconnect.extdatadir);
imports._gsconnect;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
Extension.imports._gsconnect;

// eslint-disable-next-line no-redeclare
const _ = gsconnect._;
const Clipboard = imports.shell.clipboard;
const Device = imports.shell.device;
const DoNotDisturb = imports.shell.donotdisturb;
const Keybindings = imports.shell.keybindings;
const Notification = imports.shell.notification;
const Remote = imports.shell.remote;
const Clipboard = Extension.imports.shell.clipboard;
const Device = Extension.imports.shell.device;
const Keybindings = Extension.imports.shell.keybindings;
const Notification = Extension.imports.shell.notification;
const Remote = Extension.imports.shell.remote;


/**
Expand Down Expand Up @@ -82,10 +79,12 @@ gsconnect.getIcon = function(name) {
* A System Indicator used as the hub for spawning device indicators and
* indicating that the extension is active when there are none.
*/
class ServiceIndicator extends PanelMenu.SystemIndicator {
const ServiceIndicator = GObject.registerClass({
GTypeName: 'GSConnectServiceIndicator'
}, class ServiceIndicator extends PanelMenu.SystemIndicator {

constructor() {
super();
_init() {
super._init();

this._menus = {};

Expand Down Expand Up @@ -135,7 +134,7 @@ class ServiceIndicator extends PanelMenu.SystemIndicator {
);
this._indicator.visible = false;

AggregateMenu._indicators.insert_child_at_index(this.indicators, 0);
AggregateMenu._indicators.insert_child_at_index(this, 0);
AggregateMenu._gsconnect = this;

// Service Menu
Expand All @@ -160,10 +159,6 @@ class ServiceIndicator extends PanelMenu.SystemIndicator {
// Service Menu -> Separator
this._item.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

// Service Menu -> "Do Not Disturb"
let dndItem = new DoNotDisturb.createMenuItem(this.settings);
this._item.menu.addMenuItem(dndItem);

// Service Menu -> "Turn On/Off"
this._enableItem = this._item.menu.addAction(
_('Turn On'),
Expand Down Expand Up @@ -441,12 +436,13 @@ class ServiceIndicator extends PanelMenu.SystemIndicator {
this.settings.run_dispose();

// Destroy the PanelMenu.SystemIndicator actors
delete AggregateMenu._gsconnect;
this.indicators.destroy();
this._item.destroy();
this.menu.destroy();

delete AggregateMenu._gsconnect;
super.destroy();
}
}
});


var serviceIndicator = null;
Expand Down
15 changes: 4 additions & 11 deletions src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;

// Find the root datadir of the extension
function get_datadir() {
let m = /@(.+):\d+/.exec((new Error()).stack.split('\n')[1]);
return Gio.File.new_for_path(m[1]).get_parent().get_path();
}

// Local Imports
window.gsconnect = {extdatadir: get_datadir()};
imports.searchPath.unshift(gsconnect.extdatadir);
imports._gsconnect;
// Bootstrap
const Extension = imports.misc.extensionUtils.getCurrentExtension();
Extension.imports._gsconnect;


function init() {
Expand All @@ -31,7 +24,7 @@ function buildPrefsWidget() {

// Exec `gsconnect-preferences
let proc = new Gio.Subprocess({
argv: [gsconnect.extdatadir + '/gsconnect-preferences']
argv: [Extension.path + '/gsconnect-preferences']
});
proc.init(null);
proc.wait_async(null, null);
Expand Down
21 changes: 0 additions & 21 deletions src/service/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,27 +503,6 @@ const Service = GObject.registerClass({
}
}

/**
* Override Gio.Application.send_notification() to respect donotdisturb
*/
send_notification(id, notification) {
if (!this._notificationSettings) {
this._notificationSettings = new Gio.Settings({
schema_id: 'org.gnome.desktop.notifications.application',
path: '/org/gnome/desktop/notifications/application/org-gnome-shell-extensions-gsconnect/'
});
}

let now = GLib.DateTime.new_now_local().to_unix();
let dnd = (this.settings.get_int('donotdisturb') <= now);

// TODO: Maybe the 'enable-sound-alerts' should be left alone/queried
this._notificationSettings.set_boolean('enable-sound-alerts', dnd);
this._notificationSettings.set_boolean('show-banners', dnd);

super.send_notification(id, notification);
}

/**
* Remove a local libnotify or Gtk notification.
*
Expand Down
6 changes: 4 additions & 2 deletions src/shell/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const St = imports.gi.St;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;

const Extension = imports.misc.extensionUtils.getCurrentExtension();

// eslint-disable-next-line no-redeclare
const _ = gsconnect._;
const GMenu = imports.shell.gmenu;
const Tooltip = imports.shell.tooltip;
const GMenu = Extension.imports.shell.gmenu;
const Tooltip = Extension.imports.shell.tooltip;


/**
Expand Down
Loading

0 comments on commit 2ed8d53

Please sign in to comment.