Skip to content

Commit

Permalink
Merge branch 'gnome-3-36' into ubuntu-dock
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Mar 18, 2020
2 parents f315e17 + 811c2a2 commit d322443
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 258 deletions.
36 changes: 25 additions & 11 deletions appIcons.js
Expand Up @@ -5,7 +5,6 @@ const GdkPixbuf = imports.gi.GdkPixbuf
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Signals = imports.signals;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
Expand Down Expand Up @@ -310,7 +309,7 @@ class MyAppIcon extends Dash.DashIcon {
position == St.Side.BOTTOM);
// If horizontal also remove the height of the dash
let fixedDock = Docking.DockManager.settings.get_boolean('dock-fixed');
let additional_margin = this._isHorizontal && !fixedDock ? Main.overview._dash.height : 0;
let additional_margin = this._isHorizontal && !fixedDock ? Main.overview.dash.height : 0;
let verticalMargins = this._menu.actor.margin_top + this._menu.actor.margin_bottom;
// Also set a max width to the menu, so long labels (long windows title) get truncated
this._menu.actor.style = ('max-height: ' + Math.round(workArea.height - additional_margin - verticalMargins) + 'px;' +
Expand Down Expand Up @@ -783,6 +782,11 @@ const MyAppIconMenu = class DashToDock_MyAppIconMenu extends AppDisplay.AppIconM
}

_redisplay() {
// This will be removed by 3.36.1
return this._rebuildMenu();
}

_rebuildMenu() {
this.removeAll();

if (Docking.DockManager.settings.get_boolean('show-windows-preview')) {
Expand Down Expand Up @@ -880,7 +884,10 @@ const MyAppIconMenu = class DashToDock_MyAppIconMenu extends AppDisplay.AppIconM
}

} else {
super._redisplay();
if (super._rebuildMenu)
super._rebuildMenu();
else
super._redisplay();
}

// quit menu
Expand Down Expand Up @@ -1035,27 +1042,31 @@ var MyShowAppsIcon = GObject.registerClass({
this.toggleButton.connect('clicked',
this._removeMenuTimeout.bind(this));

this.reactive = true;
this.toggleButton.popupMenu = () => this.popupMenu.call(this);
this.toggleButton._removeMenuTimeout = () => this._removeMenuTimeout.call(this);

this._menu = null;
this._menuManager = new PopupMenu.PopupMenuManager(this);
this._menuTimeoutId = 0;
}

vfunc_leave_event(leaveEvent)
{
return AppDisplay.AppIcon.prototype.vfunc_leave_event.apply(this,
leaveEvent);
return AppDisplay.AppIcon.prototype.vfunc_leave_event.call(
this.toggleButton, leaveEvent);
}

vfunc_button_press_event(buttonPressEvent)
{
return AppDisplay.AppIcon.prototype.vfunc_button_press_event.apply(this,
buttonPressEvent);
return AppDisplay.AppIcon.prototype.vfunc_button_press_event.call(
this.toggleButton, buttonPressEvent);
}

vfunc_touch_event(touchEvent)
{
return AppDisplay.AppIcon.prototype.vfunc_touch_event.apply(this,
touchEvent);
return AppDisplay.AppIcon.prototype.vfunc_touch_event.call(
this.toggleButton, touchEvent);
}

showLabel() {
Expand All @@ -1075,8 +1086,6 @@ var MyShowAppsIcon = GObject.registerClass({
}

popupMenu() {
return false;

this._removeMenuTimeout();
this.toggleButton.fake_release();

Expand Down Expand Up @@ -1112,6 +1121,11 @@ var MyShowAppsIcon = GObject.registerClass({
*/
var MyShowAppsIconMenu = class DashToDock_MyShowAppsIconMenu extends MyAppIconMenu {
_redisplay() {
// This will be removed by 3.36.1
return this._rebuildMenu();
}

_rebuildMenu() {
this.removeAll();

/* Translators: %s is "Settings", which is automatically translated. You
Expand Down
58 changes: 23 additions & 35 deletions dash.js
Expand Up @@ -4,8 +4,6 @@ const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Signals = imports.signals;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
Expand Down Expand Up @@ -70,7 +68,11 @@ class DashToDock_MyDashActor extends St.Widget {
name: 'dash',
layout_manager: layout,
clip_to_allocation: true,
y_align: Clutter.ActorAlign.CENTER,
...(this._isHorizontal ? {
x_align: Clutter.ActorAlign.CENTER,
} : {
y_align: Clutter.ActorAlign.CENTER,
})
});

// Since we are usually visible but not usually changing, make sure
Expand All @@ -80,14 +82,15 @@ class DashToDock_MyDashActor extends St.Widget {
}

vfunc_allocate(box, flags) {
this.set_allocation(box, flags);
let contentBox = box;
let contentBox = this.get_theme_node().get_content_box(box);
let availWidth = contentBox.x2 - contentBox.x1;
let availHeight = contentBox.y2 - contentBox.y1;

this.set_allocation(box, flags);

let [appIcons, showAppsButton] = this.get_children();
let [showAppsMinHeight, showAppsNatHeight] = showAppsButton.get_preferred_height(availWidth);
let [showAppsMinWidth, showAppsNatWidth] = showAppsButton.get_preferred_width(availHeight);
let [, showAppsNatHeight] = showAppsButton.get_preferred_height(availWidth);
let [, showAppsNatWidth] = showAppsButton.get_preferred_width(availHeight);

let offset_x = this._isHorizontal?showAppsNatWidth:0;
let offset_y = this._isHorizontal?0:showAppsNatHeight;
Expand All @@ -108,8 +111,7 @@ class DashToDock_MyDashActor extends St.Widget {
childBox.x2 = contentBox.x1 + showAppsNatWidth;
childBox.y2 = contentBox.y1 + showAppsNatHeight;
showAppsButton.allocate(childBox, flags);
}
else {
} else {
childBox.x1 = contentBox.x1;
childBox.y1 = contentBox.y1;
childBox.x2 = contentBox.x2 - offset_x;
Expand All @@ -125,33 +127,24 @@ class DashToDock_MyDashActor extends St.Widget {
}

vfunc_get_preferred_width(forHeight) {
// We want to request the natural height of all our children
// as our natural height, so we chain up to StWidget (which
// We want to request the natural width of all our children
// as our natural width, so we chain up to StWidget (which
// then calls BoxLayout), but we only request the showApps
// button as the minimum size

let [, natWidth] = this.layout_manager.get_preferred_width(this, forHeight);
let [, natWidth] = super.vfunc_get_preferred_width(forHeight);

let themeNode = this.get_theme_node();
let adjustedForHeight = themeNode.adjust_for_height(forHeight);
let [, showAppsButton] = this.get_children();
let [minWidth, ] = showAppsButton.get_preferred_height(forHeight);
let [minWidth] = showAppsButton.get_preferred_width(adjustedForHeight);
[minWidth] = themeNode.adjust_preferred_width(minWidth, natWidth);

return [minWidth, natWidth];
}

vfunc_get_preferred_height(forWidth) {
// We want to request the natural height of all our children
// as our natural height, so we chain up to StWidget (which
// then calls BoxLayout), but we only request the showApps
// button as the minimum size

let [, natHeight] = this.layout_manager.get_preferred_height(this, forWidth);

let themeNode = this.get_theme_node();
let [, showAppsButton] = this.get_children();
let [minHeight, ] = showAppsButton.get_preferred_height(forWidth);

return [minHeight, natHeight];
return Dash.DashActor.prototype.vfunc_get_preferred_height.call(this, forWidth);
}
});

Expand Down Expand Up @@ -205,8 +198,8 @@ var MyDash = GObject.registerClass({
this._container = new MyDashActor();
this._scrollView = new St.ScrollView({
name: 'dashtodockDashScrollview',
hscrollbar_policy: Gtk.PolicyType.NEVER,
vscrollbar_policy: Gtk.PolicyType.NEVER,
hscrollbar_policy: St.PolicyType.NEVER,
vscrollbar_policy: St.PolicyType.NEVER,
enable_mouse_scrolling: false
});

Expand Down Expand Up @@ -543,17 +536,13 @@ var MyDash = GObject.registerClass({
let firstButton = iconChildren[0].child;
let firstIcon = firstButton.icon;

let minHeight, natHeight, minWidth, natWidth;

// Enforce the current icon size during the size request
firstIcon.setIconSize(this.iconSize);
[minHeight, natHeight] = firstButton.get_preferred_height(-1);
[minWidth, natWidth] = firstButton.get_preferred_width(-1);
let [, natHeight] = firstButton.get_preferred_height(-1);
let [, natWidth] = firstButton.get_preferred_width(-1);

let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let iconSizes = this._availableIconSizes.map(function(s) {
return s * scaleFactor;
});
let iconSizes = this._availableIconSizes.map(s => s * scaleFactor);

// Subtract icon padding and box spacing from the available height
if (this._isHorizontal)
Expand Down Expand Up @@ -601,7 +590,6 @@ var MyDash = GObject.registerClass({
icon.icon.set_size(icon.icon.width * scale,
icon.icon.height * scale);

icon.icon.remove_all_transitions();
icon.icon.ease({
width: targetWidth,
height: targetHeight,
Expand Down

0 comments on commit d322443

Please sign in to comment.