Commit Graph

78 Commits

Author SHA1 Message Date
Florian Müllner
a32c4f30d1 style: Allow lonely ifs where appropriate
We now have a lint rule to disallow lonely ifs, however there are
cases where the "lonely" part mirrors code from the preceding if
clause. Opt out of the lint rule in those cases.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/818
2019-11-11 23:51:17 +00:00
Florian Müllner
e44adb92cf cleanup: Avoid unnecessary parentheses
Extra parentheses usually add noise rather than clarity, so avoid
them.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
ebf77748a8 cleanup: Require "dangling" commas
Since ES5, trailing commas in arrays and object literals are valid.
We generally haven't used them so far, but they are actually a good
idea, as they make additions and removals in diffs much cleaner.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
07cc84f632 cleanup: Only omit braces for single-line blocks
Braces can be avoided when a block consists of a single statement,
but readability suffers when the statement spans more than a single
line.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
c860409da5 cleanup: Use object shorthand where possible
ES6 allows to omit property names where they match the name of the
assigned variable, which makes code less redunant and thus cleaner.
We will soon enforce that in our eslint rules, so make sure we use
the shorthand wherever possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
682bd7e97c cleanup: Don't shadow variables
Having variables that share the same name in overlapping scopes is
confusing and error-prone, and is best avoided.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
2c62e45168 st: Remove StBin's align properties
They are now completely unused, so remove them and stop the confusing
shadowing of ClutterActor's own x/y-align properties.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/803
2019-11-04 21:27:56 +01:00
Georges Basile Stavracas Neto
d0690c3952 util: Add wiggle helper
Add Util.wiggle(), which accepts the wiggle offset, duration,
and number of times, as parameters.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/768
2019-10-18 11:25:45 +00:00
Florian Müllner
252e694979 util: Handle trailing LTR/RTL markers in URLs
Some electron apps apparently spread those generously over their
notification text, so may sure to not include them accidentally
in URLs.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1614
2019-09-16 20:41:47 +00:00
Florian Müllner
743ce23fbc util: Separate statements with linebreak
Our eslint rules will soon forbid more than one statement per line.
We already follow that rule except for one lone offender; fix that.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/710
2019-09-11 20:59:31 +00:00
Florian Müllner
b6a2b2b8a5 cleanup: Remove left-over imports
Unfortunately this slipped through our CI tests, as the script
filters errors by lines that are modified by the corresponding
merge request.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/710
2019-09-11 20:59:31 +00:00
Florian Müllner
481490fdc7 util: Remove AppSettingsMonitor
It is now unused.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1158
2019-08-08 17:41:46 +02:00
Florian Müllner
b67c300484 js: Use Clutter transitions for adjustment changes
This concludes our quest of moving from Tweener to Clutter's
animation framework.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/669
2019-08-07 18:40:49 +02:00
Florian Müllner
476816732f cleanup: Use milliseconds for animation times
The different units - seconds for Tweener and milliseconds for
timeouts - are not a big issue currently, as there is little
overlap. However this will change when we start using Clutter's
own animation framework (which uses milliseconds as well), in
particular where constants are shared between modules.

In order to prepare for the transition, define all animation times
as milliseconds and adjust them when passing them to Tweener.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/663
2019-08-05 21:55:20 +00:00
Florian Müllner
e357559582 cleanup: Mark globals used from other modules as exported
eslint cannot figure out that those symbols are used from other modules
via imports, so they trigger unused-variable errors. To fix, explicitly
mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
71759a0769 cleanup: Mark unused (but useful) variables as ignored
While we aren't using those destructured variables, they are still useful
to document the meaning of those elements. We don't want eslint to keep
warning about them though, so mark them accordingly.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
0d035a4e53 cleanup: Prefer template strings
Template strings are much nicer than string concatenation, so use
them where possible; this excludes translatable strings and any
strings containing '/' (until we can depend on gettext >= 0.20[0]).

[0] https://savannah.gnu.org/bugs/?50920

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612
2019-07-05 11:32:31 +00:00
Florian Müllner
14d7897a93 style: Stop using braces for single-line arrow functions
Braces are optional for single-line arrow functions, but there's a
subtle difference:
Without braces, the expression is implicitly used as return value; with
braces, the function returns nothing unless there's an explicit return.

We currently reflect that in our style by only omitting braces when the
function is expected to have a return value, but that's not very obvious,
not an important differentiation to make, and not easy to express in an
automatic rule.

So just omit braces consistently as mandated by gjs' coding style.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
4c5206954a style: Use camelCase for variable names
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
8fda3116f0 style: Fix brace style
Opening braces should be on the same line as the associated statement,
and only be omitted if both surrounding blocks are one-liners.

Partially spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
7ac35c644e style: Fix stray/missing spaces
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
29b04fcbf2 style: Fix stray/missing semi-colons
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
f250643385 style: Use space after catch
We are currently inconsistent with whether or not to put a space
after catch clauses. While the predominant style is to omit it,
that's inconsistent with the style we use for any other statement.
There's not really a good reason to stick with it, so switch to
the style gjs/eslint default to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Marco Trevisan (Treviño)
1be933bc49 boxpointer: Don't use boxpointer actor, as it's now an actor itself
Remove this.actor = actor, since the class is now an actor itself.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/487
2019-04-17 21:32:18 +00:00
Florian Müllner
fd50b9a45e cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 07:39:20 +01:00
Florian Müllner
e68dfed1f7 cleanup: Port GObject classes to JS6 classes
GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
bacfdbbb03 cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can
replace our custom Lang.Class framework with the new syntax. Any
classes that inherit from GObject will need special treatment,
so limit the port to regular javascript classes for now.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Carmen Bianca Bakker
0f542c2e16 Remove padding from date strings
The padding is removed by using %-d instead of %e or %d.

Examples:

"%B %d %Y"  -> "October 04 2018"

"%B %e %Y"  -> "October  4 2018"

"%B %-d %Y" -> "October 4 2018"

https://gitlab.gnome.org/GNOME/gnome-shell/issues/666
2018-10-25 13:05:47 +02:00
Florian Müllner
5cc42b18b0 utils: Simplify URL regex to only support one layer of parentheses
The author of the original URL-matching regex warns[0] that the pattern may
cause certain regex engines to lock up with certain input, namely patterns
that contain parentheses. It turns out SpiderMonkey is affected, but rather
than switching to the author's improved version (that is still crazy), sim-
plify the pattern a bit by removing support for nested parentheses in URLs.
Even a single pair of parentheses is extremely rare, so this is unlikely to
make a noticeable difference (other than not locking up SpiderMonkey of
course) ...

[0] http://daringfireball.net/2010/07/improved_regex_for_matching_urls
2018-04-13 18:15:44 +00:00
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
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
6b71b79d28 Remove excess parameter to g_app_info_launch()
Commit 39a840e2c3 added an additional parameter to shell_app_launch().
When adjusting callers, the parameter was also added accidentally to
calls of the confusingly similar g_app_info_launch() ...
Remove those to fix some warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-17 16:24:21 +02:00
Florian Müllner
fdf988c04d util: Force text direction of time strings
While the string returned by formatTime() should follow the locale's
text direction as a whole, the actual time part is always expected
to put hours on the left and minutes to the right. It is possible to
enforce that by inserting a left-to-right mark, but so far this is
only done by the Hebrew translation. So in order to not require all
other RTL translations to be fixed individually, just insert the
mark into the returned string ourselves like gnome-desktop's WallClock
code does[0].

[0] https://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/gnome-wall-clock.c?h=gnome-3-24#n267

https://bugzilla.gnome.org/show_bug.cgi?id=784130
2017-07-05 16:49:04 +02:00
Florian Müllner
817ff52414 util: Always use 12h format if requested
Whether we show times in 12h format currently depends on:
 - the 'clock-format' desktop setting
 - the locale support for AM/PM

This was consist with other GNOME components, however both the
WallClock[0] and the Date+Time Settings panel[1] dropped the
second check after GDateTime started supporting AM/PM independently
from the locale, so we should follow suite.

[0] https://git.gnome.org/browse/gnome-desktop/commit?id=226fe725ef2cb2
[1] https://git.gnome.org/browse/gnome-control-center/commit?id=85cd910af

https://bugzilla.gnome.org/show_bug.cgi?id=782930
2017-05-22 15:41:29 +02:00
Allan Day
252dce1ec2 fix typos
The shell was crashing for me - these fixes from Debarshi seem to
fix it.
2017-03-01 16:24:35 +00:00
Florian Müllner
f3d1c78c7d calendar: Use relative times for notification timestamps
For notifications in the message list, it is usually less relevant
when exactly it occurred, but how long ago. So rather than showing
the exact time and expecting the user to figuring out the timespan
themselves, change the format to something human readable.

https://bugzilla.gnome.org/show_bug.cgi?id=775763
2017-03-01 10:55:21 +01:00
Florian Müllner
b5130c5943 util: Add AppSettingsMonitor
When integrating with optional components like Clocks, it is not safe
to access their GSettings right after the application became visible
to the AppSystem:
Installation is usually not atomic, so the .desktop file may appear
before the settings schema, in which case Gio will abort due to an
"invalid" schema ID.
To address this, add a small helper class that wraps the settings
access in a safe way.

https://bugzilla.gnome.org/show_bug.cgi?id=766410
2017-02-27 20:02:16 +01:00
Bastien Nocera
39a840e2c3 shell-app: Add "discrete_gpu" option when launching apps
And adapt existing callers to the new API. This will allow us to
implement a way to launch applications on the discrete GPU for systems
where an "Optimus" system exists.

https://bugzilla.gnome.org/show_bug.cgi?id=773117
2016-10-21 19:26:49 +02:00
Florian Müllner
8f424e7d96 util: Add createTimeLabel()
On locales that support it, time formats should follow the 12-hour/24-hour
preference, which implies that they should be updated when the setting
changes. So add another utility method which creates a label for a specific
time and keeps it in sync with the format setting.

https://bugzilla.gnome.org/show_bug.cgi?id=745111
2015-03-04 13:55:01 +01:00
Florian Müllner
60f6715228 util: Use GLib.DateTime in formatTime()
The world clock uses GLib.DateTime instead of the built-in Date type
because of the much superior timezone support, and therefore cannot
use the new formatTime() helper. To make this possible, modify the
method to support a parameter of either type.

https://bugzilla.gnome.org/show_bug.cgi?id=745111
2015-03-04 13:55:01 +01:00
Florian Müllner
ebf132770e util: Add formatTime() helper method
Displaying a time is more complex than it appears at first glance:
it should respect the user's choice regarding 12- our 24-hour format (but
only when supported by the locale) and follow the LC_TIME rather than the
LC_MESSAGES setting.
So rather than getting it more or less right in various places, it makes
sense to defer to a helper method which hopefully does the right thing. The
method added by this patch is based on _formatTimestamp in telepathyClient
with some minor tweaks:
 - there's an additional params parameter which allows enforcing
   a time-only format, even on dates other than the current one
 - only a single desktop settings object is created and shared between
   invocations

https://bugzilla.gnome.org/show_bug.cgi?id=745111
2015-03-04 13:55:01 +01:00
Jasper St. Pierre
f8bac5c197 util: Don't pass too many arguments to child_watch_add 2014-04-28 10:22:51 -04:00
Giovanni Campagna
3227d4f3ed ShellApp+ShellGlobal: unify app launch context code
Extend shell_global_create_app_launch_context() with the required
parameters and use that for shell_app_launch() too.

https://bugzilla.gnome.org/show_bug.cgi?id=669603
2014-01-19 18:51:48 +01:00
William Jon McCann
b2a65f809f Use recommended quotes
See https://wiki.gnome.org/Design/OS/Typography
2014-01-17 16:34:44 -05:00
Giovanni Campagna
6a7d184b7b NetworkMenu: make the settings launcher point to the right devices
Tell gnome-control-center to focus on the associated device when
launching it from one of the submenus.

https://bugzilla.gnome.org/show_bug.cgi?id=709246
2013-10-09 18:39:44 +02:00
Giovanni Campagna
255cb8edb1 AppFolderPopup: fix the position of close buttons
We need to adjust the offset of close buttons, in case the box
pointer has the arrow at the top. To do so, extend close buttons
to hook into a boxpointer (since that's the common use for them)
and automatically adjust their position.

https://bugzilla.gnome.org/show_bug.cgi?id=707842
2013-09-12 14:33:35 +02:00
Jasper St. Pierre
d10e3d8498 util: Remove unused killall function 2013-08-04 05:30:30 -04:00