From 05bf5e51de3729cd03a75bbd87fb0a8bb9b099a5 Mon Sep 17 00:00:00 2001 From: Leleat Date: Mon, 1 Feb 2021 22:13:50 +0100 Subject: [PATCH 1/2] add optional limit to appMenu width & tooltip onHover --- unite@hardpixel.eu/convenience.js | 12 +- unite@hardpixel.eu/panel.js | 91 ++++++ unite@hardpixel.eu/prefs.js | 6 + unite@hardpixel.eu/schemas/gschemas.compiled | Bin 2220 -> 2276 bytes ...g.gnome.shell.extensions.unite.gschema.xml | 5 + unite@hardpixel.eu/settings.ui | 289 ++++++++++-------- 6 files changed, 277 insertions(+), 126 deletions(-) diff --git a/unite@hardpixel.eu/convenience.js b/unite@hardpixel.eu/convenience.js index 9e701c83..79cded82 100644 --- a/unite@hardpixel.eu/convenience.js +++ b/unite@hardpixel.eu/convenience.js @@ -31,7 +31,8 @@ var SettingsManager = GObject.registerClass( 'hide-app-menu-arrow': 'boolean', 'hide-app-menu-icon': 'boolean', 'reduce-panel-spacing': 'boolean', - 'restrict-to-primary-screen': 'boolean' + 'restrict-to-primary-screen': 'boolean', + 'app-menu-max-width': 'int' } } @@ -50,8 +51,13 @@ var SettingsManager = GObject.registerClass( getSetting(key) { if (!this.exists(key)) return - let boolean = this.getSettingType(key) == 'boolean' - return boolean ? this.get_boolean(key) : this.get_string(key) + const settingsType = this.getSettingType(key) + if (settingsType === 'int') + return this.get_int(key) + else if (settingsType === 'boolean') + return this.get_boolean(key) + else + return this.get_string(key) } } ) diff --git a/unite@hardpixel.eu/panel.js b/unite@hardpixel.eu/panel.js index 458ccad8..c400f2cf 100644 --- a/unite@hardpixel.eu/panel.js +++ b/unite@hardpixel.eu/panel.js @@ -1,6 +1,8 @@ const Gi = imports._gi const System = imports.system const GObject = imports.gi.GObject +const GLib = imports.gi.GLib +const St = imports.gi.St const Clutter = imports.gi.Clutter const Shell = imports.gi.Shell const AppSystem = imports.gi.Shell.AppSystem.get_default() @@ -551,6 +553,92 @@ var PanelDoubleClick = GObject.registerClass( } ) +var AppMenuCustomizer = class AppMenuCustomizer extends PanelExtension { + constructor({ settings }) { + const active = val => val > 0 + super(settings, 'app-menu-max-width', active) + } + + _init() { + this.signals = new Handlers.Signals() + this.settings = new Handlers.Settings() + + this.signals.connect( + AppMenu, 'notify::hover', this._onAppMenuHover.bind(this) + ) + + this.signals.connect( + AppMenu, 'button-press-event', this._onAppMenuClicked.bind(this) + ) + + this.settings.connect( + 'app-menu-max-width', this._onMaxWidthChange.bind(this) + ) + + // tooltip label + this.tooltip = new St.Label({ + visible: false, + style: 'background-color: #212121; \ + border-radius: 6px; \ + border: 1px solid dimgray; \ + padding: 8px' + }); + Main.uiGroup.add_child(this.tooltip) + + this._onMaxWidthChange() + } + + get appMenuMaxWidth() { + return this.settings.get('app-menu-max-width') + } + + _onAppMenuHover(appMenu) { + if (!appMenu._label) + return + + this.isHovered = appMenu.get_hover() + if (!this.isHovered) + return this.tooltip.hide() + + GLib.timeout_add(GLib.PRIORITY_DEFAULT, 400, () => { + if (this.isHovered && !this.tooltip.visible) { + const [mouseX, mouseY] = global.get_pointer() + this.tooltip.set_position(mouseX + 20, mouseY) + this.tooltip.set_text(appMenu._label.get_text()) + this.tooltip.show() + } + + return GLib.SOURCE_REMOVE + }); + } + + _onAppMenuClicked() { + this.isHovered = false + this.tooltip.hide() + } + + _onMaxWidthChange() { + const label = AppMenu._label + if (!label) + return + + const maxWidth = this.appMenuMaxWidth + label.set_style('max-width' + (maxWidth ? `: ${maxWidth}px` : '')) + } + + _destroy() { + const label = AppMenu._label + if (label) { + label.set_style('max-width') + } + + this.tooltip.destroy() + + this.signals.disconnectAll() + this.settings.disconnectAll() + } +} + var PanelManager = GObject.registerClass( class UnitePanelManager extends GObject.Object { _init() { @@ -561,6 +649,7 @@ var PanelManager = GObject.registerClass( this.desktop = new DesktopName(this) this.tray = new TrayIcons(this) this.dblClick = new PanelDoubleClick() + this.appMCustom = new AppMenuCustomizer(this) } activate() { @@ -570,6 +659,7 @@ var PanelManager = GObject.registerClass( this.desktop.activate() this.tray.activate() this.dblClick.activate() + this.appMCustom.activate() } destroy() { @@ -579,6 +669,7 @@ var PanelManager = GObject.registerClass( this.desktop.destroy() this.tray.destroy() this.dblClick.destroy() + this.appMCustom.destroy() this.settings.disconnectAll() } diff --git a/unite@hardpixel.eu/prefs.js b/unite@hardpixel.eu/prefs.js index 643c98bf..a0097ca5 100644 --- a/unite@hardpixel.eu/prefs.js +++ b/unite@hardpixel.eu/prefs.js @@ -27,6 +27,7 @@ var PrefsWidget = GObject.registerClass( this._bindSelects() this._bindBooleans() this._bindEnumerations() + this._bindInts() } _getWidget(name) { @@ -67,6 +68,11 @@ var PrefsWidget = GObject.registerClass( let settings = this._settings.getTypeSettings('enum') settings.forEach(setting => { this._bindEnum(setting) }) } + + _bindInts() { + let settings = this._settings.getTypeSettings('int') + settings.forEach(setting => { this._bindInput(setting, 'value') }) + } } ) diff --git a/unite@hardpixel.eu/schemas/gschemas.compiled b/unite@hardpixel.eu/schemas/gschemas.compiled index 15db2e3b758c4d0f4fffba6b5915d8edd207dff7..6f458c2451ae02097af8ac6bb90bfbeb6f360039 100644 GIT binary patch literal 2276 zcmcIlO^6&t6t3uQjJwHZlii7b_NF907tFqe_1z5@PbNDaJrtXL#ZoqmlWF9EIZKG-Es{UrFe zA+G?}e*I#BJaum;5?!S6!;ME$ehy*<=v{~wTl z0e`-?6LB5tw0{|i(g3D8Nu4>_giL|+uROTJ@zfc&S0S0VM#oj8WuY>i%Cb;Vk_`@t zR1QrHe)?SK^aF=UtYvKS0!wC68Iy07^*&szpGQ?G!;VvaVDzMnREmXRl}sX7 z5thdvc4xUw`bnfL>rEDUnNag1OfneK6kU&Z5$x86EywzHsqUlSu^wF*><+`9)|)J`MsedHHM3^ z9ij(cD+!^m<7^X~PVL3WWRz^{7{jKV%k(B(2=?0~MQ5;of3QPI3D?WHgF~7Nr_wDo z@lkUNd;SFn28i!KSv}(hjq0^ScVv@I1XP!G0-#TbaPGITDRc-&wxbLjDJ!Qg) z?z?b{w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ensions.unite.gschema.xml index fbf6bbde..7aa2b73c 100644 --- a/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml +++ b/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml @@ -120,6 +120,11 @@ Hide app menu application icon. + + 0 + Limit the width of the app menu. 0 means no limit. + + true Reduce top bar items spacing. diff --git a/unite@hardpixel.eu/settings.ui b/unite@hardpixel.eu/settings.ui index e81d8ae5..324136db 100644 --- a/unite@hardpixel.eu/settings.ui +++ b/unite@hardpixel.eu/settings.ui @@ -1,34 +1,39 @@ - + + + 1000 + 1 + 10 + True - True + True True - False + False True True - False + False start - 20 - 20 - 20 - 20 + 20 + 20 + 20 + 20 vertical 15 True True - False + False 50 True - False + False center Extend top bar left box @@ -41,14 +46,14 @@ True - True + True center True False True - end + end 1 @@ -56,18 +61,18 @@ False True - 1 + 0 True - False + False 50 True - False + False center Auto focus new windows @@ -80,14 +85,14 @@ True - True + True center True False True - end + end 1 @@ -95,18 +100,18 @@ False True - 2 + 1 True - False + False 50 True - False + False center Show system tray in top bar @@ -119,14 +124,14 @@ True - True + True center True False True - end + end 1 @@ -134,18 +139,18 @@ False True - 3 + 2 True - False + False 50 True - False + False center Show desktop name in top bar @@ -158,14 +163,14 @@ True - True + True center True False True - end + end 1 @@ -173,18 +178,18 @@ False True - 5 + 3 True - False + False 50 True - False + False center Restrict functionalities to the primary screen @@ -197,14 +202,14 @@ True - True + True center True False True - end + end 1 @@ -212,18 +217,18 @@ False True - 6 + 4 True - False + False 50 True - False + False center Hide activities button @@ -235,10 +240,10 @@ - 170 + 170 True - False - 1 + False + 1 Never Auto @@ -248,7 +253,7 @@ False True - end + end 1 @@ -256,18 +261,18 @@ False True - 8 + 5 True - False + False 50 True - False + False center Hide window titlebars @@ -279,10 +284,10 @@ - 170 + 170 True - False - 2 + False + 2 Never Tiled @@ -294,7 +299,7 @@ False True - end + end 1 @@ -302,18 +307,18 @@ False True - 9 + 6 True - False + False 50 True - False + False center Show window title in app menu @@ -325,10 +330,10 @@ - 170 + 170 True - False - 2 + False + 2 Never Tiled @@ -340,7 +345,45 @@ False True - end + end + 1 + + + + + False + True + 7 + + + + + True + False + + + True + False + center + Max width for the app menu + + + False + True + 0 + + + + + 170 + True + True + maxwidth_appmenu_adjustment + + + False + True + end 1 @@ -354,12 +397,12 @@ True - False + False 50 True - False + False center Show window buttons in top bar @@ -371,10 +414,10 @@ - 170 + 170 True - False - 2 + False + 2 Never Tiled @@ -386,7 +429,7 @@ False True - end + end 1 @@ -400,12 +443,12 @@ True - False + False 50 True - False + False center Notification messages position @@ -417,10 +460,10 @@ - 170 + 170 True - False - 2 + False + 2 Center Left @@ -430,7 +473,7 @@ False True - end + end 1 @@ -443,40 +486,40 @@ - True + True True - False + False General - False + False True - False + False start - 20 - 20 - 20 - 20 + 20 + 20 + 20 + 20 vertical 15 True True - False + False 50 True - False + False center Apply system fonts to shell theme @@ -489,14 +532,14 @@ True - True + True center True False True - end + end 1 @@ -510,12 +553,12 @@ True - False + False 50 True - False + False center Convert tray icons to greyscale @@ -528,13 +571,13 @@ True - True + True center False True - end + end 1 @@ -548,12 +591,12 @@ True - False + False 50 True - False + False center Hide top bar dropdown arrows @@ -566,14 +609,14 @@ True - True + True center True False True - end + end 1 @@ -587,12 +630,12 @@ True - False + False 50 True - False + False center Hide aggregate menu dropdown arrow @@ -605,13 +648,13 @@ True - True + True center False True - end + end 1 @@ -625,12 +668,12 @@ True - False + False 50 True - False + False center Hide app menu dropdown arrow @@ -643,14 +686,14 @@ True - True + True center True False True - end + end 1 @@ -664,12 +707,12 @@ True - False + False 50 True - False + False center Hide app menu application icon @@ -682,14 +725,14 @@ True - True + True center True False True - end + end 1 @@ -703,12 +746,12 @@ True - False + False 50 True - False + False center Reduce top bar items spacing @@ -721,14 +764,14 @@ True - True + True center True False True - end + end 1 @@ -742,12 +785,12 @@ True - False + False 50 True - False + False center Top bar desktop name text @@ -759,15 +802,15 @@ - 170 + 170 True - True + True GNOME Desktop False True - end + end 1 @@ -781,13 +824,13 @@ True - False - True + False + True 50 True - False + False center Top bar window buttons position @@ -799,10 +842,10 @@ - 170 + 170 True - False - auto + False + auto Auto Left @@ -814,7 +857,7 @@ False True - end + end 1 @@ -828,13 +871,13 @@ True - False - True + False + True 50 True - False + False center Top bar window buttons theme @@ -846,10 +889,10 @@ - 170 + 170 True - False - 0 + False + 0 Default Dark Default Light @@ -877,7 +920,7 @@ False True - end + end 1 @@ -891,18 +934,18 @@ 1 - True + True True - False + False Appearance 1 - False + False From 021a01ff071a9a966b77aaca63fa60e1e1c0a1e0 Mon Sep 17 00:00:00 2001 From: Leleat Date: Tue, 2 Feb 2021 00:28:10 +0100 Subject: [PATCH 2/2] add setting to change appMenu's EllipsizeMode --- unite@hardpixel.eu/convenience.js | 3 +- unite@hardpixel.eu/panel.js | 31 ++++++++++++ unite@hardpixel.eu/schemas/gschemas.compiled | Bin 2276 -> 2404 bytes ...g.gnome.shell.extensions.unite.gschema.xml | 11 +++++ unite@hardpixel.eu/settings.ui | 45 +++++++++++++++++- 5 files changed, 88 insertions(+), 2 deletions(-) diff --git a/unite@hardpixel.eu/convenience.js b/unite@hardpixel.eu/convenience.js index 79cded82..fc24dc05 100644 --- a/unite@hardpixel.eu/convenience.js +++ b/unite@hardpixel.eu/convenience.js @@ -32,7 +32,8 @@ var SettingsManager = GObject.registerClass( 'hide-app-menu-icon': 'boolean', 'reduce-panel-spacing': 'boolean', 'restrict-to-primary-screen': 'boolean', - 'app-menu-max-width': 'int' + 'app-menu-max-width': 'int', + 'app-menu-ellipsize-mode': 'enum' } } diff --git a/unite@hardpixel.eu/panel.js b/unite@hardpixel.eu/panel.js index c400f2cf..f29baaa2 100644 --- a/unite@hardpixel.eu/panel.js +++ b/unite@hardpixel.eu/panel.js @@ -3,6 +3,7 @@ const System = imports.system const GObject = imports.gi.GObject const GLib = imports.gi.GLib const St = imports.gi.St +const Pango = imports.gi.Pango const Clutter = imports.gi.Clutter const Shell = imports.gi.Shell const AppSystem = imports.gi.Shell.AppSystem.get_default() @@ -575,6 +576,10 @@ var AppMenuCustomizer = class AppMenuCustomizer extends PanelExtension { 'app-menu-max-width', this._onMaxWidthChange.bind(this) ) + this.settings.connect( + 'app-menu-ellipsize-mode', this._onEllipsizeModeChange.bind(this) + ) + // tooltip label this.tooltip = new St.Label({ visible: false, @@ -592,6 +597,10 @@ var AppMenuCustomizer = class AppMenuCustomizer extends PanelExtension { return this.settings.get('app-menu-max-width') } + get ellipsizeMode() { + return this.settings.get('app-menu-ellipsize-mode') + } + _onAppMenuHover(appMenu) { if (!appMenu._label) return @@ -624,11 +633,33 @@ var AppMenuCustomizer = class AppMenuCustomizer extends PanelExtension { const maxWidth = this.appMenuMaxWidth label.set_style('max-width' + (maxWidth ? `: ${maxWidth}px` : '')) + + this._onEllipsizeModeChange() + } + + _onEllipsizeModeChange() { + const label = AppMenu._label + if (!label) + return + + switch (this.ellipsizeMode) { + case "start": + label.get_clutter_text().set_ellipsize(Pango.EllipsizeMode.START) + break; + + case "middle": + label.get_clutter_text().set_ellipsize(Pango.EllipsizeMode.MIDDLE) + break; + + case "end": + label.get_clutter_text().set_ellipsize(Pango.EllipsizeMode.END) + } } _destroy() { const label = AppMenu._label if (label) { + label.get_clutter_text().set_ellipsize(Pango.EllipsizeMode.END) label.set_style('max-width') } diff --git a/unite@hardpixel.eu/schemas/gschemas.compiled b/unite@hardpixel.eu/schemas/gschemas.compiled index 6f458c2451ae02097af8ac6bb90bfbeb6f360039..7a5fd6ea8485194e6b692460da6ce2c4d468ad27 100644 GIT binary patch literal 2404 zcmcImO^6&t6t2XbBMG0Nu|4M}T?YC~yo|02Tp+ zA(nv?0R7fz{_^?l8O#~$BVtpWf?Na6y#MKlJoU%GUxL)YKR0(G^3;!mA46US8sGnw zk*7{SA47gZzS=)^?*AI(J>Z)+U-*so)Q`blVA24dc<1yhq4T z0KRx~CM8dO0sJ+{&wyWdR<4t$z5@OhPNw!f;d@tJp>u%yS$;$Zh60LJIl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! z-6=Y*oYco`%jF6$Rn_6sqA|0Qa^AEMPIgjx&~A~=tj378 z)OJ5_FZEtvlXyv=GY7*hR#Q8Wj~e`1u+ AS^xk5 diff --git a/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml b/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml index 7aa2b73c..ddc461e3 100644 --- a/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml +++ b/unite@hardpixel.eu/schemas/org.gnome.shell.extensions.unite.gschema.xml @@ -59,6 +59,12 @@ + + + + + + true @@ -125,6 +131,11 @@ Limit the width of the app menu. 0 means no limit. + + "end" + The place where characters will be omitted when the max width of the app menu is reached. + + true Reduce top bar items spacing. diff --git a/unite@hardpixel.eu/settings.ui b/unite@hardpixel.eu/settings.ui index 324136db..1a727b6d 100644 --- a/unite@hardpixel.eu/settings.ui +++ b/unite@hardpixel.eu/settings.ui @@ -391,7 +391,50 @@ False True - 10 + 8 + + + + + True + False + + + True + False + center + Ellipsis mode for app menu + + + False + True + 0 + + + + + 170 + True + False + 2 + + Start + Middle + End + + + + False + True + end + 1 + + + + + False + True + 9