Skip to content

Commit

Permalink
add scaleSize helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Mar 31, 2018
1 parent afcfd3c commit c31d54c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 8 additions & 0 deletions [email protected]/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Config = imports.misc.config;
const Gio = imports.gi.Gio;
const St = imports.gi.St;
const Main = imports.ui.main;
const Meta = imports.gi.Meta;

Expand Down Expand Up @@ -134,3 +135,10 @@ function getVersion() {
let version = Config.PACKAGE_VERSION.match(/\d+.\d+/);
return parseFloat(version);
}

function scaleSize(initial_size) {
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let size = initial_size * scale;

return size;
}
6 changes: 3 additions & 3 deletions [email protected]/modules/messageTray.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const Lang = imports.lang;
const Main = imports.ui.main;
const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const MessageBanner = Main.messageTray._bannerBin;
const ExtensionUtils = imports.misc.extensionUtils;
const Unite = ExtensionUtils.getCurrentExtension();
const Helpers = Unite.imports.helpers;
const Convenience = Unite.imports.convenience;

var MessageTray = new Lang.Class({
Expand Down Expand Up @@ -34,8 +34,8 @@ var MessageTray = new Lang.Class({
},

_updateWidth: function () {
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
MessageBanner.set_width(390 * scale);
let width = Helpers.scaleSize(390);
MessageBanner.set_width(width);
},

_resetWidth: function () {
Expand Down
9 changes: 4 additions & 5 deletions [email protected]/modules/topIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const PanelMenu = imports.ui.panelMenu;
const Panel = Main.panel;
const ExtensionUtils = imports.misc.extensionUtils;
const Unite = ExtensionUtils.getCurrentExtension();
const Helpers = Unite.imports.helpers;
const Convenience = Unite.imports.convenience;

var TopIcons = new Lang.Class({
Expand Down Expand Up @@ -140,6 +141,7 @@ var TopIcons = new Lang.Class({

let buttonMask = St.ButtonMask.ONE | St.ButtonMask.TWO | St.ButtonMask.THREE;
let iconContainer = new St.Button({ child: icon, button_mask: buttonMask });
let iconSize = Helpers.scaleSize(18);

icon.connect('destroy', function() {
icon.clear_effects();
Expand All @@ -154,12 +156,9 @@ var TopIcons = new Lang.Class({
this._iconsContainer.container.show();
this._iconsBoxLayout.insert_child_at_index(iconContainer, 0);

let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let size = 18 * scale;

icon.reactive = true;
icon.get_parent().set_size(size, size);
icon.set_size(size, size);
icon.get_parent().set_size(iconSize, iconSize);
icon.set_size(iconSize, iconSize);
},

_removeTrayIcon: function (o, icon) {
Expand Down

0 comments on commit c31d54c

Please sign in to comment.