Skip to content

Commit

Permalink
Changes for GNOME Shell 40
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRochet committed May 19, 2021
1 parent 5e631ca commit 2bce903
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 49 deletions.
18 changes: 4 additions & 14 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ let SLIDETIME = 15/100;
let HOVERDELAY = 300;
let HIDEDELAY = 500;
let TITLE = true;
let TITLE_FORCE = true;
let APPDESCRIPTION = true;
let GROUPAPPCOUNT = true;
let BORDERS = false;
Expand All @@ -36,7 +35,6 @@ let _labelShowing = false; // self explainatory

let _settings;
let _settingsConnectionId;
let _pageChangedConnectionId;
let _ovhidingConnectionId;

function init() {
Expand All @@ -56,11 +54,11 @@ function enable() {
_tooltips = new Array();

// Enabling tooltips for already loaded icons
_connectAll(Main.overview.viewSelector.appDisplay);
_connectAll(Main.overview._overview._controls._appDisplay);

// monkeypatching for future app icons
_old_addItem = imports.ui.iconGrid.IconGrid.prototype.addItem;
imports.ui.iconGrid.IconGrid.prototype.addItem = function(item, index){
imports.ui.iconGrid.IconGrid.prototype.addItem = function(item, page, index){
_connect(item);
// original part of the function I'm overwriting
_old_addItem.apply(this, arguments);
Expand All @@ -76,9 +74,6 @@ function enable() {
// apply new settings if changed
_settingsConnectionId = _settings.connect('changed', _applySettings);

// Hide tooltip if page changed
_pageChangedConnectionId = Main.overview.viewSelector.connect('page-changed', _onLeave);

// Hide tooltip if overview is hidden
_ovhidingConnectionId = Main.overview.connect('hiding', _onLeave);

Expand All @@ -89,7 +84,6 @@ function disable() {

// Disconnect from events
if (_ovhidingConnectionId > 0) _settings.disconnect(_ovhidingConnectionId);
if (_pageChangedConnectionId > 0) _settings.disconnect(_pageChangedConnectionId);

// disconnects settings
if (_settingsConnectionId > 0) _settings.disconnect(_settingsConnectionId);
Expand Down Expand Up @@ -117,7 +111,6 @@ function _applySettings() {
LABELHIDETIME = _settings.get_int("labelhidetime")/100 ;
HOVERDELAY = _settings.get_int("hoverdelay") ;
TITLE = _settings.get_boolean("title") ;
TITLE_FORCE = _settings.get_boolean("titlealways") ;
APPDESCRIPTION = _settings.get_boolean("appdescription") ;
GROUPAPPCOUNT = _settings.get_boolean("groupappcount") ;
BORDERS = _settings.get_boolean("borders");
Expand Down Expand Up @@ -211,7 +204,6 @@ function _showTooltip(actor) {
let icontext = '';
let titletext = '';
let detailtext = '';
let is_ellipsized = actor._delegate.icon.label.get_clutter_text().get_layout().is_ellipsized();
let should_display = false;

if (actor._delegate.app){
Expand Down Expand Up @@ -244,10 +236,8 @@ function _showTooltip(actor) {

// Decide wether to show title
if ( TITLE && icontext ) {
if ( TITLE_FORCE || is_ellipsized ) {
titletext = icontext;
should_display = true;
}
titletext = icontext;
should_display = true;
}

// If there's something to show ..
Expand Down
2 changes: 0 additions & 2 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ function buildPrefsWidget(){
settings.bind('groupappcount', buildable.get_object('field_groupappcount'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('borders', buildable.get_object('field_borders'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('title', buildable.get_object('field_title'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('titlealways', buildable.get_object('field_title_always'), 'active', Gio.SettingsBindFlags.DEFAULT);

box.show_all();
return box;
};
58 changes: 25 additions & 33 deletions prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
</object>

<object class="GtkNotebook" id="prefs_widget">
<property name="expand">true</property>

<child>
<object class="GtkGrid">
<property name="margin">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-top">18</property>
<property name="margin-bottom">18</property>
<property name="row-spacing">18</property>
<property name="row-homogeneous">false</property>
<property name="orientation">vertical</property>

<child>
<object class="GtkVBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>

<child>
Expand All @@ -46,7 +49,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Show in tooltip</property>
Expand All @@ -61,29 +64,12 @@
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Show even if the icon-label is not elipsized</property>
<property name="hexpand">true</property>
<property name="halign">1</property>
</object>
</child>
<child>
<object class="GtkSwitch" id="field_title_always">
<property name="active">true</property>
</object>
</child>
</object>
</child>

</object>
</child>
<child>
<object class="GtkVBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>

<child>
Expand All @@ -100,7 +86,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Show in tooltip</property>
Expand All @@ -119,7 +105,8 @@
</object>
</child>
<child>
<object class="GtkVBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>

<child>
Expand All @@ -136,7 +123,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Show in tooltip</property>
Expand All @@ -155,7 +142,8 @@
</object>
</child>
<child>
<object class="GtkVBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>

<child>
Expand All @@ -172,7 +160,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Draw borders</property>
Expand Down Expand Up @@ -202,13 +190,17 @@

<child>
<object class="GtkGrid">
<property name="margin">18</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-top">18</property>
<property name="margin-bottom">18</property>
<property name="row-spacing">18</property>
<property name="row-homogeneous">false</property>
<property name="orientation">vertical</property>

<child>
<object class="GtkVBox">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>

<child>
Expand All @@ -225,7 +217,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Hover time before the tooltip is displayed (in ms)</property>
Expand All @@ -245,7 +237,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Tooltip display animation duration (in ms)</property>
Expand All @@ -265,7 +257,7 @@
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<property name="margin-left">12</property>
<property name="margin-start">12</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Tooltip dismiss animation duration (in ms)</property>
Expand Down

0 comments on commit 2bce903

Please sign in to comment.