Commit Graph

55 Commits

Author SHA1 Message Date
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
Monica Chelliah
608818fa9f Only recognize common url schemes in notification messages
Before the fix, the message tray highlighted all urls containing "://", even
invalid ones. This change fixes this by have the message tray highlight only
the urls with http, https, ftp schemes.

Credit goes to: Phuong Vu, Liye Fu, Monica Chelliah, Owen Taylor

https://bugzilla.gnome.org/show_bug.cgi?id=661225
2013-04-29 11:22:44 -04:00
Jasper St. Pierre
5870709fbc appDisplay: Move ensureIconVisible logic to util, make it more generic
In particular, make it work if we have multiple parents, like in the
search case.

https://bugzilla.gnome.org/show_bug.cgi?id=689681
2013-03-12 19:29:47 -04:00
Florian Müllner
f21b8206af messageTray: Move makeCloseButton() into Util
The function is useful for other modules as well, so move it to a
more generic place.

https://bugzilla.gnome.org/show_bug.cgi?id=694192
2013-02-20 00:08:11 +01:00
Giovanni Campagna
490206b5b2 NetworkMenu: rework multiple NIC support
Remove section titles for ethernet and mobile broadband, and replace
them with device status items that recognize if multiple devices are
installed in the same section, and if so automatically disambiguate.

https://bugzilla.gnome.org/show_bug.cgi?id=677142
2012-11-16 13:52:52 -05:00
Jasper St. Pierre
d11027e8c8 util: Don't pass too many arguments to GLib.spawn_async 2012-08-07 15:09:28 -03:00
Jasper St. Pierre
fd87468e36 util: Fix number of parameters passed to spawn_sync
We passed one too many

https://bugzilla.gnome.org/show_bug.cgi?id=680426
2012-07-24 06:11:21 -03:00
Jasper St. Pierre
76472b86ed util: Remove unused imports
https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-17 12:14:02 -04:00
Giovanni Campagna
317c6b77f3 Util: update trySpawn to new gjs GError mapping
Error rewriting code used an old version of the gjs GError support,
and set a readonly .message property.

https://bugzilla.gnome.org/show_bug.cgi?id=678502
2012-06-21 18:28:26 +02:00
Colin Walters
02e4726ba6 util: Don't double-fork when spawning from Alt-F2
This breaks polkit.

See http://bugzilla.redhat.com//show_bug.cgi?id=819275

https://bugzilla.gnome.org/show_bug.cgi?id=675789
2012-05-10 15:05:05 -04:00
Giovanni Campagna
bbdce159fa Util: fix binary search exit condition
The loop can exit with an interval of length one or one of
length zero. In the first case it is correct to check which side
of the interval to return, in the second case no comparison should
be made (since there is only one possible value).
In practice, this usually results in one comparison more than needed,
but in some cases (when the position was past the end of the array),
would call the comparator with undefined.

https://bugzilla.gnome.org/show_bug.cgi?id=666614
2011-12-20 22:44:03 +01:00
Giovanni Campagna
09ab13cf04 Array: add capability to insert while keeping a specific order
Adds two new functions, Util.lowerBound and Util.insertSorted,
that take an array, a value and a comparator, and find the
first position at which the value can be inserted without
violating the order, in optimal time.

https://bugzilla.gnome.org/show_bug.cgi?id=666429
2011-12-19 16:54:46 +01:00
Dan Winship
75b824d032 *.js: Make emacs modelines consistent
js2-mode is no longer developed and we recommend js-mode these days,
so switch the modelines to specify that, and make them consistent
across all files.

https://bugzilla.gnome.org/show_bug.cgi?id=660358
2011-10-11 08:05:12 -04:00
Dan Winship
e2898bea5c findUrl: be pickier about what can precede a URL
findUrl() was seeing strings like "You have 1 new message in
foo@example.com/Inbox" and finding the URL
"[http://]example.com/Inbox". Require that URLs either start at the
start of the string, or are preceded by whitespace or an open
paren/quote/etc.

(Since JS doesn't have look-behind assertions like perl does, we have
to actually match the URL-preceding character in the regex, and then
adjust the result findUrl returns accordingly.)

https://bugzilla.gnome.org/show_bug.cgi?id=636252
2011-09-08 09:07:03 -04:00
Dan Winship
563221698c findUrl: don't match non-:// URLs
Although "x:5" could theoretically be a URL with scheme "x" and path
"5", it probably isn't. Only URLify strings that use the "authority"
syntax ("foo://"). (No one ever types out "mailto:" URLs in ordinary
text, so we don't want to match those either.)

https://bugzilla.gnome.org/show_bug.cgi?id=636252
2011-09-08 09:06:39 -04:00
Dan Winship
92a85071bc findUrl: document the URL-matching regex
Explode the regex onto multiple lines, and add comments explaining the
pieces. Also, change ()s to (?:)s (non-capturing groups) where
appropriate, and replace the UTF-8 characters with \u escapes so that
they actually work.

https://bugzilla.gnome.org/show_bug.cgi?id=636252
2011-09-08 09:02:15 -04:00
Marc-Antoine Perennou
4c5f3aa971 utils: follow up to previous commit
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2011-06-24 00:13:59 +02:00
Florian Müllner
6fc49b79a4 utils: Adjust trySpawnCommandLine() to gjs changes
(out) arrays now no longer return the array length separately, adjust
to this change.
2011-06-24 00:00:34 +02:00
Dan Winship
898b2b903d environment: put gettext stuff into global environment
Rather than defining _() as a local function in every module, put it
into the global environment (along with C_() and ngettext()).

https://bugzilla.gnome.org/show_bug.cgi?id=649203
2011-05-16 14:57:21 -04:00
Giovanni Campagna
b2b685e46d NetworkMenu: fixup device descriptions
Fix some bugs in Util.fixupPCIDescription(), that caused all device
descriptions to be empty.

https://bugzilla.gnome.org/show_bug.cgi?id=646074
2011-04-11 10:38:00 -04:00
Giovanni Campagna
650f35c1f3 Util: use the right function name when reporting errors.
It's Main.notifyError, not Main.notifyProblem.

https://bugzilla.gnome.org/show_bug.cgi?id=645248
2011-03-19 19:57:08 +01:00
Colin Walters
fea8b6da2f Remove broken ShellAppSystem API and all consumers
In commit 9bd22dc0, I introduced an API to load an arbitrary
.desktop file, not necessarily from the menu path.  It turns
out this function was broken because it created ShellApp instances
that were *different* from ones that were cached normally.

As far as I can tell, we didn't initially use it.  Then later
Util.spawnDesktop was created which used this function.

Remove this broken function and all callers; if we're loading
.desktop files from *outside* the menu path, we can look at
readding.

This patch also kills off Util.spawnDesktop in favor of callers
talking to ShellAppSystem directly, now that the latter reports
errors.

https://bugzilla.gnome.org/show_bug.cgi?id=644402
2011-03-16 15:07:22 -04:00
Colin Walters
b4f16c4df8 Add shell_global_report_error()
Move the "system notification error" handling out of
util.js, and add it to ShellGlobal so we can start
calling it from across the codebase better (including
C).

https://bugzilla.gnome.org/show_bug.cgi?id=644402
2011-03-16 15:07:21 -04:00
Giovanni Campagna
c8ac3fd4f5 Status area: add NetworkManager indicator
Adds an implementation of nm-applet in javascript. Uses the new
introspection from NetworkManager, and temporarily requires
nm-applet to be running for the secret service.
Features a renewed interface, with each device controllable through
a switch, which if toggled off disconnects, and if toggled on
connects to the most recently used valid connection. More esoteric
features like creation of ad-hoc networks have been moved to the
control center panel.

https://bugzilla.gnome.org/show_bug.cgi?id=621707
2011-03-16 15:59:34 +01:00