Commit Graph

412 Commits

Author SHA1 Message Date
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Nikita Churaev
92f1aec3dd appDisplay: Fix small app folder icons when using HIDPI
While the scale factor is taken into account for app icons, we set
an explicit size when combining the into a folder icon - unless we
take the factor into account, the result will be too small on HiDPI
displays.

https://bugzilla.gnome.org/show_bug.cgi?id=792259
2018-02-10 00:40:48 +00:00
Marco Trevisan (Treviño)
35eac697c1 appDisplay: don't try to close the popup menu that is already destroyed
This would lead to a JS error otherwise, as we might end up
in deleting actors that have been already destructed.

https://bugzilla.gnome.org/show_bug.cgi?id=791233
2018-01-17 13:04:41 -05:00
Rares Visalom
52f604757c appDisplay: Include system actions in search results
The way system actions are displayed in the search
results is by appending them at the end of the list
returned by the ApplicationProvider.

https://bugzilla.gnome.org/show_bug.cgi?id=691900
2017-08-22 13:02:58 +02:00
Mario Sanchez Prada
d903978937 Explicitly set the width and height for subicons' containers in folders
Otherwise the smaller icons will try to take too much space since the
texture rendering the icons will be scaled up on HiDPI displays according
to the scale factor, which will push the size of the StBin containing the
texture up, causing them to completely fill the folder's total space.

Explicitly setting the size of the StBin container in this case, in a
similar fashion to what we do when creating the empty placeholders (in
case where there are less than 4 apps in a folder), ensures that each
"cell" of the grid-like widget representing the folder does not take
too much space.

https://bugzilla.gnome.org/show_bug.cgi?id=786145
2017-08-11 12:47:45 +02:00
Florian Müllner
c67eabaf62 appDisplay: Use ::paint handler to set up spring animation
The animation needs the icons' final positions, so we currently defer
it to a ::notify::allocation handler; however as starting the animation
during an allocation cycle would trigger a Clutter warning, it is
further deferred to a MetaLater. While this usually works, it is possible
that the allocation is already valid when we connect the signal, in which
case the animation is triggered at a later unexpected time. Switch to
a more robust ::paint handler instead, which also allows us to get rid
of the double-delay.

https://bugzilla.gnome.org/show_bug.cgi?id=736148
2017-07-19 10:49:54 +02:00
Florian Müllner
033277b68f Define externally accessible contants with 'var' instead of 'const'
Just as we did with classes, define other constants that are (or
may be) used from other modules with 'var' to cut down on warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
6a2af25d48 appDisplay: Define constant before using it
This is now a fatal error with current gjs, however I wonder: Did this
ever work?

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
358133e82f Initialize properties in _init()
While we've always considered it good style to initialize JS properties,
some code that relies on uninitialized properties having an implicit
value of 'undefined' has slipped in over time. The updated SpiderMonkey
version used by gjs now warns when accessing those properties, so we
should make sure that they are properly initialized to avoid log spam,
even though all warnings addressed here occur in conditionals that
produce the correct result with 'undefined'.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-13 17:23:54 +02:00
Mario Sanchez Prada
d8e7fc403b appDisplay: Add a null-check for the scrollview's fade ClutterEffect
This effect will only be created when the StScrollView actor has either
a non-zero vertical or horizontal fade offset defined, so we need to
add a null-check in these two cases before assuming it's there.

https://bugzilla.gnome.org/show_bug.cgi?id=783823
2017-06-15 15:01:51 +01:00
Florian Müllner
e08f2a4a04 Don't mix GJS and GObject signal systems
GJS implements a basic signal system that allows monkey-patching
JS objects with signal methods resembling the GObject ones. However
it's clearly not a good idea to replace the actual GObject methods,
so use the proper GObject facilities when inheriting from GObject.

https://bugzilla.gnome.org/show_bug.cgi?id=778660
2017-02-15 23:20:14 +01:00
Xiaoguang Wang
09e6bb5d56 appDisplay: Fix completion handler for empty animations
If an onComplete handler is passed to animate(), it is set to run at
the end of the animation via the icon grid's ::animation-done signal.
Currently the signal is connected after starting the animation, with
the result that the handler doesn't run when the animation completes
immediately (because there are no icons to animate). Fix this by only
starting the animation after connecting the signal.

https://bugzilla.gnome.org/show_bug.cgi?id=774381
2016-11-23 22:11:00 +01:00
Florian Müllner
e661d904de appDisplay: Use correct view for animation
We currently assume that the current view matches the 'app-picker-view'
setting. While that is usually the case, there is one notable exception:
While there isn't sufficient usage data (yet), we show all applications
instead of an empty frequent view regardless of the setting. We should
animate the actually visible icons in that case, not the (non-existent)
ones from the hidden frequent view.

https://bugzilla.gnome.org/show_bug.cgi?id=774381
2016-11-23 22:11:00 +01:00
Bastien Nocera
009d021e4f appDisplay: Add a menu item to launch on the discrete GPU
It will only show up when a discrete GPU is available (detected through
the switcheroo-control D-Bus service), and the application hasn't
alreayd been launched.

Note that this will not currently work for D-Bus activated applications,
eg. the menu item will be available, but the environment variable will
not be passed through to D-Bus to use when launching the application.

https://bugzilla.gnome.org/show_bug.cgi?id=773117
2016-10-21 19:26:49 +02:00
Michele Gaio
1545596c7e AppIconMenu: properly destroy on source destroy.
If the source actor is destroyed while the popupMenu is shown -- this
can happen if a non favorite application was closing or crashes -- the
menu actor is improperly destroyed.

This makes the popupMenu close first and does a clean ungrab instead.

https://bugzilla.gnome.org/show_bug.cgi?id=757556
2016-05-27 01:03:25 +02:00
Florian Müllner
fed79ce4e6 appDisplay: Handle non-UTF8 filename encodings more gracefully
It may be 2015, but users still stumble upon the occasional .desktop
file that uses a filename encoding other than UTF-8. We currently
fail quite spectacularly in that case by not displaying any apps at
all - handle this case more gracefully, by only filtering out the
offending apps.

https://bugzilla.gnome.org/show_bug.cgi?id=651503
2015-07-31 16:52:42 +02:00
Rui Matos
7bdd1c625c AllView: prevent accessing a NULL effect
In some cases we might be allocated a size such that
this._grid.topPadding and this._grid.bottomPadding are both 0 which
means that the ScrollView fade effect gets removed. In that case don't
try to access the effect since it will be NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=750714
2015-06-26 18:09:17 +02:00
Giovanni Campagna
1f2e53dd15 AppDisplay: use global settings object
We don't need a different GSettings object for each app or
favorite item.

While it practice it does not change much (AddMatch is still
obviously sent out), it minimally reduces the overhead on
changes, and makes for cleaner code.

https://bugzilla.gnome.org/show_bug.cgi?id=746509
2015-03-27 13:11:22 -07:00
Rui Matos
4ff489d24b appDisplay: Don't call a non-existent onComplete
Follow up to commit 6bb905895c .

https://bugzilla.gnome.org/show_bug.cgi?id=745627
2015-03-04 19:01:41 +01:00
Florian Müllner
6bb905895c appDisplay: Disable scrolling during animations
Currently scroll events during the swarm animation will make the
grid appear immediately in addition to the animating clones, and
there'll be a mismatch with the icon at the target position. This
badly breaks the illusion of launchers emerging from the dash and
positioning themselves in a grid - as scrolling icons "mid-air"
before they form a paginated grid doesn't make much sense anyway,
fix this issue by ignoring scroll events for the duration of the
animation.

https://bugzilla.gnome.org/show_bug.cgi?id=745574
2015-03-04 13:45:26 +01:00
Michele
99af774c98 appDisplay: Fix leaking signal connections
The overview has a longer life-time than dash items, so we are leaking a
signal connection each time an item is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=745570
2015-03-04 12:56:35 +01:00
Jakub Steiner
48cfd35b65 theme: a button is a button is a button
https://bugzilla.gnome.org/show_bug.cgi?id=737785
2015-02-20 15:16:06 +01:00
Carlos Soriano
6cf53a8d1c appDisplay: Show a dot when application is running
Show a dot in the icon of running applications.
Design request.

https://bugzilla.gnome.org/show_bug.cgi?id=744680
2015-02-20 15:14:42 +01:00
Florian Müllner
12cb023050 appDisplay: Do not duplicate "New Window" action
We assume that applications that export a 'new-window' action can open
a new window, so we add an appropriate entry to the context menu.
However this duplicates functionality if the application already
exposes the action via the desktop file - don't add our own entry
in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=744446
2015-02-13 23:27:44 +01:00
Murray Cumming
1da9546c40 App Picker: Prevent drag if favorite-apps is locked.
Because there's nothing (in single-monitor setups) that could
take the drop in this case.

* js/ui/appDisplay.js:
  AllView._loadApps(), FrequentView._loadApps(): Pass
  an isDraggable parameter when creating the AppIcons,
  depending on whether the favorite-apps key is locked.
  AppIcon._init(): Check for isDraggable in the params and
  do not create _draggable if it was specified, to prevent a
  drag from starting.
  AppIcon.popupMenu(): Check _draggable before trying to call
  fakeRelease on it.
* js/ui/dash.js: Dash._createAppItem(): Check AppIcon._draggable
  before trying to connect to its signals.

https://bugzilla.gnome.org/show_bug.cgi?id=741325
2015-01-28 14:15:51 +01:00
David King
e69cc20fc7 dash: Improve feedback when favorite-apps key is locked
In a lockdown scenario, where the favorite-apps GSettings key is not
writable, hide the menu items for adding and removing favorites from the
dash menu. Additionally, reject drops to the dash for DND.

https://bugzilla.gnome.org/show_bug.cgi?id=741325
2015-01-28 14:15:51 +01:00
Yuki
24c0a1a1d4 Move style updates in AppIcon._onStateChanged out
There is currently no simple way to inject into AppIcon's state change,
so an extension that wants to do this has to destroy/remove/update all
icons in the Shell (i.e. in the Dash, AllView, FrequentView) on enable()
and disable() after updating AppIcon.prototype._onStateChange, or the
extension must require a restart of the Shell.

To solve this issue, we rename _onStateChanged to _updateRunningStyle,
and connect the notify::state signal with an anonymous function that
calls _updateRunningStyle.
This extra function call should allow extensions to just extend the
updateRunningStyle function in the prototype.

https://bugzilla.gnome.org/show_bug.cgi?id=739497
2014-11-06 21:22:33 +01:00
Florian Müllner
5180ab262c appDisplay: Use EXTERNAL scroll policy
Now that we support the new policy type, we can just use it instead
of hiding the scrollbar.

https://bugzilla.gnome.org/show_bug.cgi?id=739379
2014-10-30 00:37:55 +01:00
Florian Müllner
3ae45bddad appDisplay: Hide empty app folders
Trying to open an empty folder currently leaves the parent view in a
rather confused state. While we should look into fixing this in the
future, empty folders are not useful at all to begin with, so hide them.

https://bugzilla.gnome.org/show_bug.cgi?id=736910
2014-09-19 15:12:03 +02:00
Florian Müllner
491100c7ee appDisplay: Only allow ctrl-click for apps that can open new windows
Trust the heuristics in shell_app_can_open_new_window() to get it right
more often than not, and add an appropriate check in activate(). This
makes the behavior consistent with the dash, e.g. we will try to open
a new window (and show the corresponding animation) for apps that don't
have a "New window" item in their dash context menu.

https://bugzilla.gnome.org/show_bug.cgi?id=736329
2014-09-09 15:57:15 +02:00
Florian Müllner
3981b27d8f search: Remove DND code from GridSearchResult
Providers that need drag-and-drop behavior can implement this via the
createResultObject() hook (as the app search provider already does), no
need to duplicate that code in the generic result objects
(ListSearchResult already does not implement DND).

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Carlos Soriano
62786c09a8 appDisplay: Animate appIcon for new window of apps
Following design mockups, animate the icons on AllView, FrequentView,
Dash and Search to zoom out when opening a new window of the app or when
the app is not running and the user execute it.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Florian Müllner
67c216a6fe search: Allow providers to return the complete result object
This makes the existing createResultObject() match its name better
 and avoids oddities like nested StButtons in app search results.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-02 00:07:32 +02:00
Carlos Soriano
75d5e84a4b appDisplay: Animate indicators out
Given that we animate indicator in, it makes sense to animate them out
as well.
Also make possible animating indicators between view changes as well.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-01 22:34:51 +02:00
Carlos Soriano
f160dda187 appDisplay: Animate AllView and FrequentView
Following design decision, we want to animate AllView and FrequentView
when opening and closing with a swarm spring form.

This involves a few changes needed to allow that, since from some time
now, we are animating page changes in viewSelector, using only a fade
transition. However now we want to let appDisplay and iconGrid apply its
own animation.

For that we special case the change to and from apps page on
viewSelector to let appDisplay to animate its own items, using and API
on appDisplay which at the same time uses an API on iconGrid.

Thanks Florian Müllner for the debugging work

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-01 22:34:51 +02:00
Carlos Soriano
9c474a635a appDisplay: Animate folder view items
Add a new animation  to folder view based on designers mockups that
emulates pulsating icons.
The code on iconGrid is though to work well for the upcoming patches to
animate AllView and FrequentView.

https://bugzilla.gnome.org/show_bug.cgi?id=734726
2014-09-01 22:33:42 +02:00
Carlos Soriano
d1a3a000af appDisplay: sync page when changing adjustment
We were setting the value of adjustment on size changes, but we weren't
changing the page value, so adjustment and page value was not in sync.

To fix it, make sure adjustment of the view is in sync with the page
value.

https://bugzilla.gnome.org/show_bug.cgi?id=734680
2014-08-15 23:07:25 +02:00
Florian Müllner
d836194e31 appDisplay: Remove pointless return value
StButton::clicked does not have a return type, so don't return anything.
2014-08-07 18:41:28 +02:00
Florian Müllner
fe60db64e0 appDisplay: Use Clutter.GridLayout
Clutter.TableLayout has been deprecated, so move to the recommended
replacement.
2014-08-06 15:23:21 +02:00
Carlos Soriano
84cbbafaae appDisplay: Don't grow indicators more than the parent
Currently the indicators are a BoxLayout inside a BinLayout in AllView.
BinLayout doesn't have any size constraint, so if the indicators request
a bigger size than AllView the entire overview is grown, causing the
overview to go crazy.

To avoid that, create an actor for the page indicators that request as
minimum size 0, and as a natural size, the sum of all indicators natural
sizes. Then we clip_to_allocation, so it doesn't grow more than the
parent.

https://bugzilla.gnome.org/show_bug.cgi?id=723496
2014-08-06 09:41:29 +02:00
Giovanni Campagna
3182aba744 AppDisplay: don't show a "New Window" menu item if not possible
If the application reports itself as single window (through
an explicit indication in the desktop file or some heuristics),
not show a "New window" item that doesn't actually open a new window.

https://bugzilla.gnome.org/show_bug.cgi?id=722554
2014-08-01 11:45:18 +02:00
Carlos Garnacho
f8899cf274 appDisplay: Allow clicks/long presses through touch events
The long press code has been refactored so it can be used on both pointer and
touch events, and the click gesture has been made to account for button=0.

https://bugzilla.gnome.org/show_bug.cgi?id=733633
2014-07-24 18:15:02 +02:00
Carlos Soriano
554001c0ed appDisplay: Move focus to popup only when necessary
Unlike for the main app view, where we only move the key focus once the
users starts navigating, the key focus is moved immediately when opening
a folder popup. This is unexpected, so make app folders consistent with
the main view.
As arrow keys will not work while the container itself has key focus, we
handle those explicitly by translating them to TAB_FORWARD and
TAB_BACKWARD respectively.

https://bugzilla.gnome.org/show_bug.cgi?id=731477
2014-07-17 20:41:24 +02:00
Florian Müllner
2bda6db30f appDisplay: Fix folder icons for RTL locales
Unlike StTable, ClutterTableLayout does not take the actor's text
direction into account, so mirror columns ourselves now.

https://bugzilla.gnome.org/show_bug.cgi?id=731923
2014-06-24 23:37:35 +02:00
Jasper St. Pierre
83cb26d70e js: Adapt to GSettings API change
The 'schema' property has been deprecated for a long time. Even though
this will likely be reverted in glib, let's stop using it.
2014-06-24 15:17:09 -04:00
Florian Müllner
9bbb3e9c85 appDisplay: Fix app folder "modal-ness"
Commit 5d00c1a5ee moved app folder popups to GrabHelper - for some
reason, the line that ensures the current behavior of only considering
events inside the app picker to dismiss popups got lost ...
2014-06-16 10:28:59 +02:00
Florian Müllner
5d00c1a5ee appDisplay: Use GrabHelper for folder popups
As clicks outside the app picker should still be handled normally
while clicks inside should dismiss the popup, we cannot make full
use of GrabHelper. However using it at least for focus handling
fixes some minor details we are getting wrong, for instance not
restoring the previous focus after dismissing a folder popup.
2014-06-11 23:24:30 +02:00