Skip to content

Commit

Permalink
Merge branch 'master' into user-applet-pf-picture
Browse files Browse the repository at this point in the history
  • Loading branch information
anaximeno committed Apr 7, 2024
2 parents e9cdd38 + 7fa70d0 commit b8918f1
Show file tree
Hide file tree
Showing 19 changed files with 878 additions and 409 deletions.
5 changes: 5 additions & 0 deletions data/theme/cinnamon.css
Original file line number Diff line number Diff line change
Expand Up @@ -2185,3 +2185,8 @@ StScrollBar StButton#vhandle:hover {
-pie-border-color: rgba(200, 200, 200, 0.8);
-pie-background-color: rgba(140, 140, 140, 0.6);;
}

.user-icon {
border: 2px solid #868686;
border-radius: 99px;
}
47 changes: 42 additions & 5 deletions files/usr/share/cinnamon/applets/inhibit@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,40 @@ const Util = imports.misc.util;
const INHIBIT_IDLE_FLAG = 8;
const INHIBIT_SLEEP_FLAG = 4;

class InhibitAppletIcon {
constructor(applet, notificationStatus, inhibitStatus) {
this._applet = applet;
this.icon_name = 'inhibit';
this.notificationStatus = notificationStatus;
this.inhibitStatus = inhibitStatus;
}

setAppletIcon() {
this._applet.set_applet_icon_symbolic_name(this.getAppletIcon());
}

getAppletIcon() {
let appletIcon = this.icon_name;
if (this.inhibitStatus) {
appletIcon += '-active';
}
if (this.notificationStatus) {
appletIcon += '-notifications-disabled';
}
return appletIcon;
}

toggleNotificationStatus() {
this.notificationStatus = !this.notificationStatus;
this.setAppletIcon();
}

toggleInhibitStatus(status) {
this.inhibitStatus = status;
this.setAppletIcon();
}
}

class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
constructor(applet) {
super();
Expand Down Expand Up @@ -80,10 +114,10 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {

if (current_state & INHIBIT_IDLE_FLAG ||
current_state & INHIBIT_SLEEP_FLAG) {
this._applet.set_applet_icon_symbolic_name('inhibit-active');
this._applet.icon.toggleInhibitStatus(true);
this._applet.set_applet_tooltip(_("Power management: inhibited"));
} else {
this._applet.set_applet_icon_symbolic_name('inhibit');
this._applet.icon.toggleInhibitStatus(false);
this._applet.set_applet_tooltip(_("Power management: active"));
}

Expand Down Expand Up @@ -214,7 +248,7 @@ class InhibitorMenuSection extends PopupMenu.PopupMenuSection {
}

resetInhibitors() {
// Abort any in-progress update or else it may continue to add menu items
// Abort any in-progress update or else it may continue to add menu items
// even after we've cleared them.
this._updateId++;

Expand All @@ -232,7 +266,7 @@ class InhibitorMenuSection extends PopupMenu.PopupMenuSection {
}

updateInhibitors(sessionProxy) {
// Grab a new ID for this update while at the same time aborting any other in-progress
// Grab a new ID for this update while at the same time aborting any other in-progress
// update. We don't want to end up with duplicate menu items!
let updateId = ++this._updateId;

Expand Down Expand Up @@ -358,17 +392,20 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
this.inhibitSwitch = new InhibitSwitch(this);
this.menu.addMenuItem(this.inhibitSwitch);

this.set_applet_icon_symbolic_name('inhibit');
this.set_applet_tooltip(_("Inhibit applet"));

this.notif_settings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.notifications" });
this.notificationsSwitch = new PopupMenu.PopupSwitchMenuItem(_("Notifications"), this.notif_settings.get_boolean("display-notifications"));

this.icon = new InhibitAppletIcon(this, !this.notificationsSwitch.state, !this.inhibitSwitch.state);
this.icon.setAppletIcon();

this.notif_settings.connect('changed::display-notifications', Lang.bind(this, function() {
this.notificationsSwitch.setToggleState(this.notif_settings.get_boolean("display-notifications"));
}));
this.notificationsSwitch.connect('toggled', Lang.bind(this, function() {
this.notif_settings.set_boolean("display-notifications", this.notificationsSwitch.state);
this.icon.toggleNotificationStatus();
}));

this.menu.addMenuItem(this.notificationsSwitch);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const St = imports.gi.St;
const Main = imports.ui.main;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
const Mainloop = imports.mainloop;
const Gio = imports.gi.Gio;
const Cairo = imports.cairo;
const Signals = imports.signals;
Expand Down Expand Up @@ -390,7 +389,7 @@ class CinnamonKeyboardApplet extends Applet.TextIconApplet {
this._setLayoutItems(layoutItems);
this._setLayoutIcons(layoutIcons);

Mainloop.idle_add(() => this._syncGroup());
this._syncGroup();
}

_syncGroup() {
Expand Down
24 changes: 9 additions & 15 deletions files/usr/share/cinnamon/applets/user@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const AccountsService = imports.gi.AccountsService;
const GnomeSession = imports.misc.gnomeSession;
const ScreenSaver = imports.misc.screenSaver;
const Settings = imports.ui.settings;
const UserWidget = imports.ui.userWidget;

const DIALOG_ICON_SIZE = 64;


const USER_DEFAULT_PIC_PATH = "/usr/share/cinnamon/faces/user-generic.png"
Expand All @@ -32,9 +35,13 @@ class CinnamonUserApplet extends Applet.TextIconApplet {
this._contentSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._contentSection);

this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._onUserChanged));
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._onUserChanged));

let userBox = new St.BoxLayout({ style_class: 'user-box', reactive: true, vertical: false });

this._userIcon = new St.Bin({ style_class: 'user-icon'});
this._userIcon = new UserWidget.Avatar(this._user, { iconSize: DIALOG_ICON_SIZE });

this.settings.bind("display-name", "disp_name", this._updateLabel);

Expand Down Expand Up @@ -130,10 +137,6 @@ class CinnamonUserApplet extends Applet.TextIconApplet {
}));
this.menu.addMenuItem(item);

this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._onUserChanged));
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._onUserChanged));

this._onUserChanged();
this.set_show_label_in_vertical_panels(false);
}
Expand All @@ -156,16 +159,7 @@ class CinnamonUserApplet extends Applet.TextIconApplet {
this.set_applet_tooltip(this._user.get_real_name());
this.userLabel.set_text (this._user.get_real_name());
if (this._userIcon) {
let iconFileName = this._user.get_icon_file();
let iconFile = Gio.file_new_for_path(iconFileName);
let icon;
if (iconFile.query_exists(null)) {
icon = new Gio.FileIcon({file: iconFile});
} else {
icon = new Gio.ThemedIcon({name: 'avatar-default'});
}
let img = St.TextureCache.get_default().load_gicon(null, icon, 48);
this._userIcon.set_child (img);
this._userIcon.update();
this._userIcon.show();
}
this._updateLabel();
Expand Down
Loading

0 comments on commit b8918f1

Please sign in to comment.