St: drop StClickable, add some functionality to StButton
For historical reasons, we had both StClickable and StButton, which were nearly identical. StButton was more widely-used, so keep that and port all StClickable users to that. https://bugzilla.gnome.org/show_bug.cgi?id=640583
This commit is contained in:
@ -593,8 +593,8 @@ SwitcherList.prototype = {
|
||||
},
|
||||
|
||||
addItem : function(item) {
|
||||
let bbox = new St.Clickable({ style_class: 'item-box',
|
||||
reactive: true });
|
||||
let bbox = new St.Button({ style_class: 'item-box',
|
||||
reactive: true });
|
||||
|
||||
bbox.set_child(item);
|
||||
this._list.add_actor(bbox);
|
||||
|
@ -319,10 +319,11 @@ function AppWellIcon(app, iconParams) {
|
||||
AppWellIcon.prototype = {
|
||||
_init : function(app, iconParams) {
|
||||
this.app = app;
|
||||
this.actor = new St.Clickable({ style_class: 'app-well-app',
|
||||
reactive: true,
|
||||
x_fill: true,
|
||||
y_fill: true });
|
||||
this.actor = new St.Button({ style_class: 'app-well-app',
|
||||
reactive: true,
|
||||
button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO,
|
||||
x_fill: true,
|
||||
y_fill: true });
|
||||
this.actor._delegate = this;
|
||||
|
||||
this.icon = new AppIcon(app, iconParams);
|
||||
@ -390,12 +391,11 @@ AppWellIcon.prototype = {
|
||||
return false;
|
||||
},
|
||||
|
||||
_onClicked: function(actor, event) {
|
||||
_onClicked: function(actor, button) {
|
||||
this._removeMenuTimeout();
|
||||
|
||||
let button = event.get_button();
|
||||
if (button == 1) {
|
||||
this._onActivate(event);
|
||||
this._onActivate(Clutter.get_current_event());
|
||||
} else if (button == 2) {
|
||||
let newWorkspace = Main.overview.workspaces.addWorkspace();
|
||||
if (newWorkspace != null) {
|
||||
|
10
js/ui/dnd.js
10
js/ui/dnd.js
@ -112,11 +112,11 @@ _Draggable.prototype = {
|
||||
return false;
|
||||
|
||||
this._buttonDown = true;
|
||||
// special case St.Clickable: grabbing the pointer would mess up the
|
||||
// special case St.Button: grabbing the pointer would mess up the
|
||||
// internal state, so we start the drag manually on hover change
|
||||
if (this.actor instanceof St.Clickable)
|
||||
if (this.actor instanceof St.Button)
|
||||
this.actor.connect('notify::hover',
|
||||
Lang.bind(this, this._onClickableHoverChanged));
|
||||
Lang.bind(this, this._onButtonHoverChanged));
|
||||
else
|
||||
this._grabActor();
|
||||
|
||||
@ -127,8 +127,8 @@ _Draggable.prototype = {
|
||||
return false;
|
||||
},
|
||||
|
||||
_onClickableHoverChanged: function(button) {
|
||||
if (button.hover || !button.held)
|
||||
_onButtonHoverChanged: function(button) {
|
||||
if (button.hover || !button.pressed)
|
||||
return;
|
||||
|
||||
button.fake_release();
|
||||
|
@ -137,12 +137,12 @@ ListItem.prototype = {
|
||||
|
||||
let layout = new St.BoxLayout({ vertical: false});
|
||||
|
||||
this.actor = new St.Clickable({ style_class: 'end-session-dialog-app-list-item',
|
||||
can_focus: true,
|
||||
child: layout,
|
||||
reactive: true,
|
||||
x_align: St.Align.START,
|
||||
x_fill: true });
|
||||
this.actor = new St.Button({ style_class: 'end-session-dialog-app-list-item',
|
||||
can_focus: true,
|
||||
child: layout,
|
||||
reactive: true,
|
||||
x_align: St.Align.START,
|
||||
x_fill: true });
|
||||
|
||||
this._icon = this._app.create_icon_texture(_ITEM_ICON_SIZE);
|
||||
|
||||
|
@ -612,10 +612,10 @@ Panel.prototype = {
|
||||
/* Button on the left side of the panel. */
|
||||
/* Translators: If there is no suitable word for "Activities" in your language, you can use the word for "Overview". */
|
||||
let label = new St.Label({ text: _("Activities") });
|
||||
this.button = new St.Clickable({ name: 'panelActivities',
|
||||
style_class: 'panel-button',
|
||||
reactive: true,
|
||||
can_focus: true });
|
||||
this.button = new St.Button({ name: 'panelActivities',
|
||||
style_class: 'panel-button',
|
||||
reactive: true,
|
||||
can_focus: true });
|
||||
this.button.set_child(label);
|
||||
this.button._delegate = this.button;
|
||||
this.button._xdndTimeOut = 0;
|
||||
@ -712,7 +712,7 @@ Panel.prototype = {
|
||||
// We get into the Overview mode on button-press-event as opposed to button-release-event because eventually we'll probably
|
||||
// have the Overview act like a menu that allows the user to release the mouse on the activity the user wants
|
||||
// to switch to.
|
||||
this.button.connect('clicked', Lang.bind(this, function(b, event) {
|
||||
this.button.connect('clicked', Lang.bind(this, function(b) {
|
||||
if (!Main.overview.animationInProgress) {
|
||||
this._maybeToggleOverviewOnClick();
|
||||
return true;
|
||||
@ -724,10 +724,10 @@ Panel.prototype = {
|
||||
// pressing the System key, Alt+F1 or Esc. We want the button to be pressed in when the Overview is entered
|
||||
// and to be released when it is exited regardless of how it was triggered.
|
||||
Main.overview.connect('showing', Lang.bind(this, function() {
|
||||
this.button.active = true;
|
||||
this.button.checked = true;
|
||||
}));
|
||||
Main.overview.connect('hiding', Lang.bind(this, function() {
|
||||
this.button.active = false;
|
||||
this.button.checked = false;
|
||||
}));
|
||||
|
||||
Main.chrome.addActor(this.actor, { visibleInOverview: true });
|
||||
|
@ -24,10 +24,10 @@ SearchResult.prototype = {
|
||||
_init: function(provider, metaInfo, terms) {
|
||||
this.provider = provider;
|
||||
this.metaInfo = metaInfo;
|
||||
this.actor = new St.Clickable({ style_class: 'search-result',
|
||||
reactive: true,
|
||||
x_align: St.Align.START,
|
||||
y_fill: true });
|
||||
this.actor = new St.Button({ style_class: 'search-result',
|
||||
reactive: true,
|
||||
x_align: St.Align.START,
|
||||
y_fill: true });
|
||||
this.actor._delegate = this;
|
||||
|
||||
let content = provider.createResultActor(metaInfo, terms);
|
||||
@ -69,7 +69,7 @@ SearchResult.prototype = {
|
||||
Main.overview.toggle();
|
||||
},
|
||||
|
||||
_onResultClicked: function(actor, event) {
|
||||
_onResultClicked: function(actor) {
|
||||
this.activate();
|
||||
},
|
||||
|
||||
@ -221,23 +221,23 @@ SearchResults.prototype = {
|
||||
},
|
||||
|
||||
_createOpenSearchProviderButton: function(provider) {
|
||||
let clickable = new St.Clickable({ style_class: 'dash-search-button',
|
||||
reactive: true,
|
||||
x_fill: true,
|
||||
y_align: St.Align.MIDDLE });
|
||||
let button = new St.Button({ style_class: 'dash-search-button',
|
||||
reactive: true,
|
||||
x_fill: true,
|
||||
y_align: St.Align.MIDDLE });
|
||||
let bin = new St.Bin({ x_fill: false,
|
||||
x_align:St.Align.MIDDLE });
|
||||
clickable.connect('clicked', Lang.bind(this, function() {
|
||||
button.connect('clicked', Lang.bind(this, function() {
|
||||
this._openSearchSystem.activateResult(provider.id);
|
||||
}));
|
||||
let title = new St.Label({ text: provider.name,
|
||||
style_class: 'dash-search-button-label' });
|
||||
|
||||
bin.set_child(title);
|
||||
clickable.set_child(bin);
|
||||
provider.actor = clickable;
|
||||
button.set_child(bin);
|
||||
provider.actor = button;
|
||||
|
||||
this._searchProvidersBox.add(clickable);
|
||||
this._searchProvidersBox.add(button);
|
||||
},
|
||||
|
||||
createProviderMeta: function(provider) {
|
||||
|
Reference in New Issue
Block a user