Commit Graph

137 Commits

Author SHA1 Message Date
Florian Müllner
467b7c1bca lookingGlass: Stop using eval()
Its use is not only strongly discouraged[0], we also rely on it injecting
variables into the global scope to get command-line-like behavior. That
behavior is incompatible with strict mode[1], and in extension with ES6
classes (which imply strict mode).

So to prepare for porting to ES6 classes, replace it with a somewhat less
evil construct that is compatible with strict mode.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Do_not_ever_use_eval!
[1]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#Simplifying_variable_uses

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/350
2019-01-22 21:33:46 +00:00
Georges Basile Stavracas Neto
b4c674900f
inspector: Stop using Shell.GenericContainer
No alarms and no surprises here.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
2018-10-08 22:43:01 -03: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
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
Florian Müllner
7e7e3ec016 lookingGlass: Use standard icon names for GC icon
Commit b929320d4 added a toolbar item to force garbage collection,
however it won't be visible for most users, as it uses a non-standard
legacy icon name (the default icon theme dropped it as far back as 2009).

https://bugzilla.gnome.org/show_bug.cgi?id=782982
2017-05-24 23:39:51 +02:00
Florian Müllner
9a38011e1e lookingGlass: Don't include telepathy import by default
It's hardly a common include nowadays, and removing it keeps all
telepathy usage contained in the telepathyClient component.

https://bugzilla.gnome.org/show_bug.cgi?id=779878
2017-03-13 16:23:08 +01:00
Florian Müllner
b4c8a00e38 lookingGlass: Remove ugly hack
We don't need to hard-code any magic offsets to hide the top corners
and border, we can just not add them in the first place.
2015-02-14 18:20:28 +01:00
Florian Müllner
e0eebc90e0 Rename KeyBindingMode to ActionMode
The keybinding mode is no longer used exclusively for actions triggered
by keybindings, so reflect this by a more generic name.

https://bugzilla.gnome.org/show_bug.cgi?id=740237
2014-12-19 11:39:50 +01: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
Bastien Nocera
68b2d5fcf0 LookingGlass: Correct timeout usage
Calling Mainloop.source_remove() on the timeout ID will not reset it,
and we're already removing the timeout by returning GLib.SOURCE_REMOVE
in the callback.
2014-04-10 21:08:49 +02:00
Bastien Nocera
cd2bd7685a js: Name all the timeouts and idles
With very uninventive names. Names now, good names later.

https://bugzilla.gnome.org/show_bug.cgi?id=727983
2014-04-10 21:08:16 +02:00
Giovanni Campagna
38750ba798 LookingGlass: add GObject and Gio to the ns available inline
Having to go through import.gi is awfully inconvenient when one
is using the looking glass as a quick gjs console, and we're
already importing all sorts of stuff there.

https://bugzilla.gnome.org/show_bug.cgi?id=725832
2014-03-06 16:57:41 +01: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
Florian Müllner
deb2f30b37 js: Use EVENT_PROPAGATE/EVENT_STOP constants in event handlers
Just as SOURCE_CONTINUE/SOURCE_REMOVE in source functions, these
constants increase code clarity over plain true/false.

https://bugzilla.gnome.org/show_bug.cgi?id=719567
2013-12-16 18:27:19 +01:00
Florian Müllner
751a3f0e94 js: Use SOURCE_CONTINUE/SOURCE_REMOVE constants in source functions
With support for boolean constants in g-i, we can finally use the
more readable constants instead of true/false.

https://bugzilla.gnome.org/show_bug.cgi?id=719567
2013-12-16 18:27:19 +01:00
Tim Lunn
b929320d4c lookingGlass: Remove Memory tab and add a gc Icon to toolbar
With js24 it won't be possible to access gjs memory stats from C code.

https://bugzilla.gnome.org/show_bug.cgi?id=711052
2013-10-30 07:44:34 +11:00
Florian Müllner
df5d5583eb lookingGlass: Fix position on multi-head
We currently assume that the primary monitor is located at (0, 0),
fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=707996
2013-09-13 00:03:24 +02:00
Jasper St. Pierre
9ba970b83d lookingGlass: Fix newline replacing
text.replace() returns the new string as strings in JS are immutable.
2013-09-11 15:02:32 -04:00
Adel Gadllah
d2709c681f lookingGlass: Avoid infinite animation time
Math.max(x / y, 0.5) will return infinite when y is 0. Fix that by using
Math.min() which was the actual intent of the patch.
2013-08-04 13:51:06 +02:00
Jasper St. Pierre
0e6625f719 lookingGlass: Ensure that we don't divide by zero
Cap the lower limit of the looking glass tween at 0.5.

https://bugzilla.gnome.org/show_bug.cgi?id=704448
2013-08-04 05:47:50 -04:00
Florian Müllner
11215374ff lookingGlass: Use uiGroup as parent instead of panelBox
Currently lookingGlass relies on some odd BoxLayout behavior, which
allows children to use fixed positioning without affecting the parent's
size request. As this behavior is scheduled for removal, add the
looking glass dialog directly to Main.uiGroup.

https://bugzilla.gnome.org/show_bug.cgi?id=703808
2013-07-09 23:19:20 +02:00
Jasper St. Pierre
938b1ff06a lookingGlass: Remove a useless container
https://bugzilla.gnome.org/show_bug.cgi?id=699975
2013-05-09 09:49:12 -04:00
Jasper St. Pierre
ecd838bf01 lookingGlass: Remove an unused separator between results
At one time, this may have had styling, but it's not there now,
and I don't see a reason to add it back.

https://bugzilla.gnome.org/show_bug.cgi?id=699975
2013-05-09 09:49:12 -04:00
Alban Crequy
a8a4a85dac lg: add a reference to lookingGlass in the Extensions tab.
When the user clicks on "View Source" or "Web Page" in the "Extensions" tab of
looking glass, the callback _onViewSource() or _onWebPage() is called and they
try to close looking glass: this._lookingGlass.close();

But it does not work and generate the exception "this._lookingGlass is
undefined". This patch fixes that.

https://bugzilla.gnome.org/show_bug.cgi?id=693814
2013-02-20 23:14:53 +00:00
Jasper St. Pierre
a43be186d3 lookingGlass: Remove old hack for static functions on interfaces
This has been fixed with the addition of interfaces in Gjs.
2013-02-08 14:31:08 -05:00
Florian Müllner
b682c8e052 main: Move KeybindingMode into Shell
Having the definition in C instead of Javascript allows sharing
the corresponding header with gnome-settings-daemon.

https://bugzilla.gnome.org/show_bug.cgi?id=643111
2013-02-04 16:48:40 +01:00
Jasper St. Pierre
fa1420b384 lookingGlass: Move to an inspect() function
Rather than add invalid results to the place where you enter JavaScript
commands when you use the eyedropped, add an inspect() function and add
a fake call to it.

https://bugzilla.gnome.org/show_bug.cgi?id=690726
2012-12-28 03:20:37 -05:00
Florian Müllner
b58f502dd6 main: Add optional keybindingMode parameter to pushModal()
For now we just use it to assign an identifier to modal modes in
which we want to allow some keybindings, but we don't use it for
any actual filtering; we'll start doing this shortly.

https://bugzilla.gnome.org/show_bug.cgi?id=688202
2012-11-17 01:44:22 +01:00
Jasper St. Pierre
0d62ec5b03 lookingGlass: Fix object inspector for multi-monitor scenarios
Otherwise the object inspector appears off-screen.

https://bugzilla.gnome.org/show_bug.cgi?id=683982
2012-09-16 17:38:18 -03:00
Jasper St. Pierre
e616877fd2 js: Fix up for Clutter.Color changes
Spotted by darkxst on IRC.

https://bugzilla.gnome.org/show_bug.cgi?id=683073
2012-08-31 16:43:51 -03:00
Jasper St. Pierre
c21b1e5fe0 st: Remove StIconType
GTK+ works by explicitly specifying a -symbolic suffix for all icons.
Do the same here.

https://bugzilla.gnome.org/show_bug.cgi?id=682540
2012-08-29 16:41:09 -03:00
Jasper St. Pierre
66197b18b6 lookingGlass: Don't pass too many arguments to Clutter.ungrab_*
https://bugzilla.gnome.org/show_bug.cgi?id=680426
2012-08-03 14:25:35 -03:00
Jasper St. Pierre
360e6e790a lookingGlass: Use one red border effect
This makes the code a bit cleaner, and reduces the chances of
having a border effect "leaking", or having two at the same time.

https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-16 20:39:55 -04:00
Jasper St. Pierre
d0807c8276 lookingGlass: Don't use a global
As part of wanting to reuse some of the looking glass components,
don't use Main.lookingGlass, but instead pass the parent around.
Don't adjust the evaluator just yet, though. We'll split it into
a separate class soon.

https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-16 20:39:55 -04:00
Jasper St. Pierre
75d0362cd8 link: Remove
The looking glass is the only consumer of the Link, and it's such a
basic wrapper around a button that it's not worth it.

https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-16 20:39:55 -04:00
Jasper St. Pierre
4f7c554d8d lookingGlass: Remove old signal handler
This 'selected' signal is from the days of the "Heirarchy" tab, before
it was replaced by the "Windows" tab. Those were the days.

https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-16 20:39:55 -04:00
Jasper St. Pierre
8b81f23caf lookingGlass: Use a more standard chevron
'>>>' is used by the REPL history (as well as plenty of other REPLs).
Using 'js>>>' to enter things makes the history look unaligned and strange.

https://bugzilla.gnome.org/show_bug.cgi?id=679944
2012-07-16 20:39:55 -04:00
Cosimo Cecchi
e756c2dbce js: use System.gc() instead of shell_global_gc()
gjs now offers a gc() method in the System module, no need to use our
own.

https://bugzilla.gnome.org/show_bug.cgi?id=679832
2012-07-12 20:11:38 -04:00
Jasper St. Pierre
a1837dde68 lookingGlass: Don't use a signal callback on 'paint' to draw the border
Instead, use a ClutterEffect, the proper API that has existed for since 1.0.
The 'paint' signal will go away for Clutter 2.0.

https://bugzilla.gnome.org/show_bug.cgi?id=679464
2012-07-05 14:20:50 -04:00
Jasper St. Pierre
c9296191a8 js: Remove unnecessary versions of clutter_actor_get_children
clutter_actor_get_children requires making a temporary GSList from
a linked list structure, and then creating a JS Array from that GSList.
For simple cases like the number of children, use clutter_actor_get_n_children.

https://bugzilla.gnome.org/show_bug.cgi?id=677426
2012-06-11 13:10:25 -04:00
Jasper St. Pierre
78e894c6f2 lookingGlass: Remove the "Errors" tab
We already have one too many logging systems. Remove the errors tab
and make global.log/global.logError point to window.log/window.logError
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=675104
2012-04-29 17:12:07 -04:00
Jasper St. Pierre
348044bc8a lookingGlass: Sort introspected property names
https://bugzilla.gnome.org/show_bug.cgi?id=673187
2012-03-30 11:57:45 -04:00
Rui Matos
aa5d352a06 Remove the shell_get_event_state() wrapper
The bug that this wrapper was working around has been fixed for quite some
time: https://bugzilla.gnome.org/show_bug.cgi?id=650329.
2012-02-28 18:11:36 +01:00
Jasper St. Pierre
a8b081661c st-box-layout: Remove insert_actor/insert_before
Now that 'insert_child_at_index' and 'insert_child_below' exist
on ClutterActor, these aren't necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=670034
2012-02-22 17:00:44 -05:00
Giovanni Campagna
6ca0d4a5ef Looking Glass: fix error line when there are no errors
The No error code path still used the old metadata object.

https://bugzilla.gnome.org/show_bug.cgi?id=669694
2012-02-08 23:29:44 +01:00
Jasper St. Pierre
a622aba7eb extensionUtils: Create and allow access to a new "extension" object
The "extension" object is what I previously called the "helper" object.
It contains the extension importer object as well as the metadata object.
Things that were previously added on to the metadata (state, path, dir, etc.)
are now part of this new "extension" object.

With the new importer changes brought on by the extension prefs tool,
extensions are left without a way to import submodules at the global scope,
which would make them rely on techniques like:

  var MySubModule;

  function init(meta) {
      MySubModule = meta.importer.mySubModule;
  }

That is, there's now a lot more meaningless boilerplate that nobody wants
to write and nobody wants to reivew.

Let's solve this with a few clever hacks.
Allow extensions to get their current extension object with:

  let extension = imports.misc.extensionUtils.getCurrentExtension();

As such, extensions can now get their own extension object before the
'init' method is called, so they can import submodules or do other things
at the module scope:

  const MySubModule = extension.imports.mySubModule;
  const dataPath = GLib.build_filenamev([extension.path, 'awesome-data.json']);

https://bugzilla.gnome.org/show_bug.cgi?id=668429
2012-02-07 16:00:37 -05:00