Skip to content

Commit

Permalink
Submit version 11
Browse files Browse the repository at this point in the history
GNOME Shell 46
  • Loading branch information
purejava committed Mar 17, 2024
1 parent 384a72c commit 4c8a1c2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 53 deletions.
78 changes: 46 additions & 32 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ let BOOT_WAIT = 15; // 15s
let CHECK_INTERVAL = 60*60; // 1h
let NOTIFY = false;
let HOWMUCH = 0;
let TRANSIENT = true;
let UPDATE_CMD = "gnome-terminal -- /bin/sh -c \"sudo dnf upgrade; echo Done - Press enter to exit; read _\" ";
let CHECK_CMD = "/bin/bash -c \"/usr/bin/dnf check-update --refresh -yq | tail -n +2 | grep -E 'x86_64|i686|noarch|aarch64' | awk '{print $1,$2}'\"";
let MANAGER_CMD = "";
Expand Down Expand Up @@ -127,13 +126,13 @@ class FedoraUpdateIndicator extends Button {
x_expand: true
});
cancelButton.set_x_align(Clutter.ActorAlign.END);
this.checkingMenuItem.actor.add_actor( checkingLabel );
this.checkingMenuItem.actor.add_actor( cancelButton );
this.checkingMenuItem.add_child( checkingLabel );
this.checkingMenuItem.add_child( cancelButton );

// A little trick on "check now" menuitem to keep menu opened
this.checkNowMenuItem = new PopupMenu.PopupMenuItem( _('Check now') );
this.checkNowMenuContainer = new PopupMenu.PopupMenuSection();
this.checkNowMenuContainer.actor.add_actor(this.checkNowMenuItem.actor);
this.checkNowMenuContainer.box.add_child(this.checkNowMenuItem.actor);

// Assemble all menu items into the popup menu
this.menu.addMenuItem(this.menuExpander);
Expand Down Expand Up @@ -193,7 +192,7 @@ class FedoraUpdateIndicator extends Button {

_positionChanged(){
if (this._settings.get_boolean('enable-positioning')) {
this.container.get_parent().remove_actor(this.container);
this.container.get_parent().remove_child(this.container);
let boxes = {
0: Main.panel._leftBox,
1: Main.panel._centerBox,
Expand Down Expand Up @@ -225,7 +224,6 @@ class FedoraUpdateIndicator extends Button {
CHECK_INTERVAL = 60 * this._settings.get_int('check-interval');
NOTIFY = this._settings.get_boolean('notify');
HOWMUCH = this._settings.get_int('howmuch');
TRANSIENT = this._settings.get_boolean('transient');
UPDATE_CMD = this._settings.get_string('update-cmd');
CHECK_CMD = this._settings.get_string('check-cmd');
DISABLE_PARSING = this._settings.get_boolean('disable-parsing');
Expand All @@ -235,7 +233,7 @@ class FedoraUpdateIndicator extends Button {
STRIP_VERSIONS_N = this._settings.get_boolean('strip-versions-in-notification');
AUTO_EXPAND_LIST = this._settings.get_int('auto-expand-list');
PACKAGE_INFO_CMD = this._settings.get_string('package-info-cmd');
this.managerMenuItem.actor.visible = ( MANAGER_CMD != "" );
this.managerMenuItem.visible = ( MANAGER_CMD != "" );
this._checkShowHide();
this._updateStatus();
this._startFolderMonitor();
Expand Down Expand Up @@ -339,11 +337,11 @@ class FedoraUpdateIndicator extends Button {
_showChecking(isChecking) {
if (isChecking == true) {
this.updateIcon.set_gicon( this._getCustIcon('fedora-unknown-symbolic') );
this.checkNowMenuContainer.actor.visible = false;
this.checkNowMenuContainer.visible = false;
this.checkingMenuItem.actor.visible = true;;
} else {
this.checkNowMenuContainer.actor.visible = true;;
this.checkingMenuItem.actor.visible = false;;
this.checkNowMenuContainer.visible = true;;
this.checkingMenuItem.visible = false;;
}
}

Expand Down Expand Up @@ -421,13 +419,13 @@ class FedoraUpdateIndicator extends Button {
this.menuExpander.menu.box.destroy_all_children();
if (label == "") {
// No text, hide the menuitem
this.menuExpander.actor.visible = false;
this.menuExpander.visible = false;
} else {
// We make our expander look like a regular menu label if disabled
this.menuExpander.actor.reactive = enabled;
this.menuExpander.reactive = enabled;
this.menuExpander._triangle.visible = enabled;
this.menuExpander.label.set_text(label);
this.menuExpander.actor.visible = true;
this.menuExpander.visible = true;
if (enabled && this._updateList.length > 0) {
this._updateList.forEach( item => {
if(DISABLE_PARSING) {
Expand Down Expand Up @@ -457,14 +455,26 @@ class FedoraUpdateIndicator extends Button {
}
}
// 'Update now' visibility is linked so let's save a few lines and set it here
this.updateNowMenuItem.actor.reactive = enabled;
this.updateNowMenuItem.reactive = enabled;
// Seems that's not done anymore by PopupBaseMenuItem after init, so let's update inactive styling
if ( this.updateNowMenuItem.reactive ) {
this.updateNowMenuItem.remove_style_class_name('popup-inactive-menu-item');
} else {
this.updateNowMenuItem.add_style_class_name('popup-inactive-menu-item');
}
if ( this.menuExpander.reactive ) {
this.menuExpander.remove_style_class_name('popup-inactive-menu-item');
} else {
this.menuExpander.add_style_class_name('popup-inactive-menu-item');
}
}

_createPackageLabel(name) {
if (PACKAGE_INFO_CMD) {
let label = new St.Label({
text: name,
track_hover: true,
x_expand: true,
reactive: true,
style_class: 'fedora-updates-update-name-link'
});
Expand All @@ -484,6 +494,7 @@ class FedoraUpdateIndicator extends Button {
}

_packageInfo(item) {
this.menu.close();
let proc = this.launcher.spawnv(['dnf', 'info', item]);
proc.communicate_utf8_async(null, null, (proc, res) => {
let name = "NAME";
Expand Down Expand Up @@ -563,29 +574,32 @@ class FedoraUpdateIndicator extends Button {
}

_showNotification(title, message) {
// Destroy previous notification if still there
if (this._notification) {
this._notification.destroy(MessageTray.NotificationDestroyedReason.REPLACED);
}
// Prepare a notification Source with our name and icon
// It looks like notification Sources are destroyed when empty so we check every time
if (this._notifSource == null) {
// We have to prepare this only once
this._notifSource = new MessageTray.SystemNotificationSource();
let gicon = Gio.icon_new_for_string( this._extension.dir.get_child('icons').get_path() + "/fedora-updates-logo.svg" );
this._notifSource.createIcon = function() {
return new St.Icon({ gicon: gicon });
};
// Take care of note leaving unneeded sources
this._notifSource = new MessageTray.Source({
title: this._extension.metadata.name.toString(),
icon: this._getCustIcon("fedora-lit-symbolic"),
});
// Take care of not leaving unneeded sources
this._notifSource.connect('destroy', ()=>{this._notifSource = null;});
Main.messageTray.add(this._notifSource);
}
let notification = null;
// We do not want to have multiple notifications stacked
// instead we will update previous
if (this._notifSource.notifications.length == 0) {
notification = new MessageTray.Notification(this._notifSource, title, message);
notification.addAction( _('Update now') , ()=>{this._updateNow();} );
} else {
notification = this._notifSource.notifications[0];
notification.update( title, message, { clear: true });
}
notification.setTransient(TRANSIENT);
this._notifSource.showNotification(notification);
// Creates a new notification
this._notification = new MessageTray.Notification({
source: this._notifSource,
title: title,
body: message
});
this._notification.gicon = this._getCustIcon("fedora-updates-symbolic");
this._notification.addAction( _('Update now') , ()=>{this._updateNow();} );
this._notification.connect('destroy', ()=>{this._notification = null;});
this._notifSource.addNotification(this._notification);
}

});
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"description": "GNOME Shell update indicator for Fedora Linux.\n This is based on Arch Linux Updates Indicator by Raphaël Rochet.\n This extension is not affiliated, funded, or in any way associated with Fedora brand and Red Hat Software.",
"name": "Fedora Linux Update Indicator",
"shell-version": [ "45" ],
"shell-version": [ "46" ],
"url": "https://github.com/purejava/fedora-update",
"uuid": "[email protected]",
"gettext-domain": "[email protected]",
"settings-schema": "org.gnome.shell.extensions.fedora-update",
"version": 10
"version": 11
}
1 change: 0 additions & 1 deletion prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default class FedoraUpdatePreferences extends ExtensionPreferences {
settings.bind('show-count' , buildable.get_object('field_count') , 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('notify' , buildable.get_object('field_notify') , 'active' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('howmuch', buildable.get_object('field_howmuch'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('transient', buildable.get_object('field_transient'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('strip-versions' , buildable.get_object('field_stripversions') , 'active' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('strip-versions-in-notification' , buildable.get_object('field_stripversionsnotifications') , 'active' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('check-cmd' , buildable.get_object('field_checkcmd') , 'text' , Gio.SettingsBindFlags.DEFAULT);
Expand Down
12 changes: 0 additions & 12 deletions prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,6 @@
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property translatable="yes" name="title">Use transient notifications (auto dismiss)</property>
<property name="activatable-widget">field_transient</property>
<child>
<object class="GtkSwitch" id="field_transient">
<property name="valign">3</property>
<property name="active">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property translatable="yes" name="title">How much information to show on notifications</property>
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
6 changes: 0 additions & 6 deletions schemas/org.gnome.shell.extensions.fedora-update.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
<description>0:count, 1:list</description>
</key>

<key name="transient" type="b">
<default>true</default>
<summary>Use transient notifications (auto dismiss)</summary>
<description></description>
</key>

<key name="check-cmd" type="s">
<default>"/bin/bash -c \"/usr/bin/dnf check-update --refresh -yq | tail -n +2 | grep -E 'x86_64|i686|noarch|aarch64' | awk '{print $1,$2}'\""</default>
<summary>Command to run to check for updated packages.</summary>
Expand Down

0 comments on commit 4c8a1c2

Please sign in to comment.