39 Commits

Author SHA1 Message Date
8586f095fc
Refactor: Reorder enable code and comment it, to make it more clear 2023-01-29 00:41:46 +01:00
d01fb434ee
Other: Remove unused typedef PositionAndBoxOverwrite 2023-01-29 00:34:53 +01:00
6e61014331
Refactor: Introduce #handleNewItemsAndOrderTopBar method
Introducing this method cleans up code, which did pretty much the same
thing, by replacing it with a call to this method.
2023-01-29 00:34:44 +01:00
c61776d8d4
Other: Remove unused typedef BoxOrders 2023-01-28 23:56:40 +01:00
8de94d6b01
Other: Add whitespace rules from GJS Style Guide and fix complaints
Add whitespace rules from GJS Style Guide to ESLint config and fix new
complaints.
See here for the GJS Style guide whitespace section:
https://gjs.guide/guides/gjs/style-guide.html#whitespace
2023-01-28 23:13:46 +01:00
4ba00915e0
Update: Don't have the not ready app indicators at the far right
Make sure unaccounted-for indicator containers (like the not ready app
indicator indicator containers) in the right panel box are on the left
of it, since the right panel box is logically right-to-left and to avoid
unnecessary shifting should they become accounted for.
2023-01-28 09:39:04 +01:00
843c5f0e1c
Fix: Support AppIndicator/KStatusNotifierItem item addition again
Do this by not acting upon a new AppIndicator/KStatusNotifierItem item
immediately (as in trying to position it properly and maybe saving it to
settings), but rather act once the app indicators "ready" signal emits
by simply saving new items to settings and ordering the top bar boxes.
2023-01-28 08:38:27 +01:00
644656d93a
Refactor: Merge AppIndi.KStat.ItemManager code into BoxOrderManager
Let `BoxOrderManager` do the relevant work itself and get rid of
`AppIndicatorKStatusNotifierItemManager`.
This is also in preparation to make the addition of
AppIndicator/KStatusNotifierItem items work again.
2023-01-28 08:27:45 +01:00
59d5665661
Refactor: Simplify #overwritePanelAddToPanelBox heavily
Simplify `#overwritePanelAddToPanelBox` heavily by just calling the
original function in the overwrite and ordering the top bar and handling
new items afterwards.
Note that AppIndicator/KStatusNotifierItems are still not supported with
this refactor.
2023-01-28 00:20:43 +01:00
d51703eb4e
Refactor: Introduce BoxOrderManager
Introduce new `BoxOrderManager` to basically act as a heavy wrapper
around the box orders stored in settings, so that the other extension
code has easy methods to get, set and interact with box orders.
Refactor most of the code initially with it in mind.
Note that `#overwritePanelAddToPanelBox` needs more refactoring to
properly make use of that new idea (and it also needs refactoring in
general).
2023-01-27 23:48:23 +01:00
ba373e9e49
Other: Mark AppIndicator/KStatusNotifierItem addition as broken 2023-01-27 21:44:59 +01:00
2ef16f310c
Fix: Null out this.settings on extension disable
See here for the relevant review:
https://extensions.gnome.org/review/38364
And for the relevant documentation:
https://gjs.guide/extensions/review-guidelines/review-guidelines.html#destroy-all-objects
2023-01-25 20:40:16 +01:00
2e5bcd4e81
Other: Move "use strict"; before ESLint config comment everywhere 2023-01-24 19:24:14 +01:00
e07411f9fd
Refactor: Use private instance methods instead of prefixing with _ 2023-01-22 20:35:13 +01:00
d383908d5f
Other: Remove license notice, since its unnecessary and annoying 2023-01-04 23:57:21 +01:00
03fb3355b4
Fix: Extension crashing, when no associatedRole can be found
There are situations, where no `associatedRole` for a given
`indicatorContainer` can be found (e.g. the GameMode GNOME Shell
Extension seems to cause such a situation, when you have it enabled and
lock and unlock GNOME).
Previously this would crash the extension. With this fix, those
`indicatorContainer`s just get ignored.
2021-07-05 10:06:51 +02:00
689a8107e2
Fix: Fix incorrect ordering
There was an issue where, when you started Gnome Shell, the icons
weren't corrently ordered. It seems that this issue was caused by a
combination of the following two things:

1. When determining the insertion index in `determineInsertionIndex` (in
   `getPositionAndBoxOverwrite` in `_overwritePanelAddToPanelBox`) the
   `boxOrder` got set to `boxOrders.something`, which doesn't make much
   sense considering that the `index` was determined by using
   `resolvedBoxOrders.something`.
   So set `boxOrder` to `resolvedBoxOrders.something` instead, to obtain
   an `insertionIndex`, which makes sense.
2. Ordering the `right` panel box from right to left (in
   `_orderTopBarItems`) seemed to cause issues (, which are probably
   caused by the indices not making sense with the children box counts
   at insertion time).
   Therefore and also because the regular (left-to-right) ordering seems
   to work just fine even for the case described in the comment (, which
   provides the reason for right-to-left ordering,) just use regular
   ordering for all boxes.

Fixing these two things may also fix other incorrect ordering behaviour
at other times.
2021-06-22 00:00:04 +02:00
0eee0e8ef9
Other: Wrap comments longer than 80 characters at 80 characters 2021-06-21 21:37:58 +02:00
d4514219ed
Fix: Use correct child count when ordering right box
Previously the `panelBoxChildCount` would just be the child count of the
right box before new items got added, which would result in incorrect
indices for new child insertions being used (in
`panel.insert_child_at_index`), since `panelBoxChildCount` would just
account for the current children, not for new ones.

This resulted in the following issue:
When you used the settings to move an item from e.g. the middle box to
the right box, the right box would get ordered incorrectly.

So fix this issue by getting the max of the right boxes current children
and the `validBoxOrder.length`.
2021-06-21 21:26:26 +02:00
49c46bf33f
Update: Don't create object as result of init() being called
Create `this.settings` on enable instead of on init/creation, so that no
objects get created as a result of `init()` being called.

See here for the relevant review:
https://extensions.gnome.org/review/25308
And for the relevant documentation:
https://wiki.gnome.org/Projects/GnomeShell/Extensions/Review#Only_use_.60init.28.29.60_for_initialization
2021-06-21 18:46:34 +02:00
569fc6a683
Update: Set Panel._originalAddToPanelBox to undefined on disable
Clean up more on disable by setting `Panel._originalAddToPanelBox` to
`undefined`.
2021-06-19 22:47:07 +02:00
e69997b487
Refactor: Move logic for creation of special box orders into own class
Move the logic for the creation of special box orders
(`createValidBoxOrder` and `createRestrictedValidBoxOrder`) into an own
class.
Moving this logic into an own class makes the `Extension` class lighter.
2021-05-27 06:44:36 +02:00
158a4b584e
Refactor: Move AppIndicator/KStatusNotifierItem logic into an own class
Move the AppIndicator/KStatusNotifierItem logic
(`handleAppIndicatorKStatusNotifierItemItem`, `createResolvedBoxOrder`
and `_applicationRoleMap`) into an own class.
Moving this logic into an own class makes the `Extension` class lighter.

Introduce for the new file a new directory `src/extensionModules`.
2021-05-27 01:25:54 +02:00
a3f5ad96f4
Fix: Consider all boxes, when adding items to box orders
Fix the following issues:

1. Let's assume we have a default (reduced) Gnome Shell top bar like
   this:
   - left box: activities, appMenu
   - center box: dateMenu
   - right box: keyboard, aggregateMenu
   And now assume, we changed the (reduced) configured box orders to
   define the top bar like this (while the extension wasn't running for
   this test case):
   - left box: activites, keyboard, appMenu
   - center box: dateMenu
   - right box: aggreateMenu
   Now for the old version of this extension, the following would
   happen:
   The extension would put the "keyboard" into the configured right box
   order on extension start, despite it being already in the configured
   left box order.
   This would happen, because the extension would look at each box
   individually at startup to determine if new items should be added to
   its box order.
   And therefore it would add "keyboard" to the configured right box
   order, leading to the (reduced) corrupted box orders looking like
   this:
   - left box: activites, keyboard, appMenu
   - center box: dateMenu
   - right box: keyboard, aggreateMenu
   And then, since the extension orders the top bar initially on start,
   the extension would put the "keyboard" item into the right box (since
   the right box would get ordered after the left box).
   (And even if the config situation were different, so that the
   originally configured box would have been ordered after the wrongly
   configured box, the configured box orders would have still been
   corrupted.)

   Fix this issue by considering all top bar boxes in
   `_createUpdatedBoxOrder/s`.

2. Let's assume we have the default (reduced) configured box orders like
   this:
   - left box:
   - center box:
   - right box: appindicator-kstatusnotifieritem-KeePassXC
   And now assume, we changed the (reduced) configured box orders to
   define the top bar like this (while the extension and the
   "KStatusNotifierItem/AppIndicator Support" extension weren't running
   for this test case):
   - left box: appindicator-kstatusnotifieritem-KeePassXC
   - center box:
   - right box:
   Now we would first start this extension and then the
   "KStatusNotifierItem/AppIndicator Support" extension.
   For the old version of this extension, the following would happen:
   The extension would have put the KeePassXC
   KStatusNotifierItem/AppIndicator into the configured right box order
   and the right box, leading to the (reduced) corrupted configured box
   orders looking like this:
   - left box: appindicator-kstatusnotifieritem-KeePassXC
   - center box:
   - right box: appindicator-kstatusnotifieritem-KeePassXC
   This would happen, because the logic for the `Panel._addToPanelBox`
   overwrite assumed that the new item should be added to the box the
   item addition initiator requested (even tho the item might be
   configured to go into another box).

   Fix this issue by considering all top bar boxes for the
   `Panel._addToPanelBox` overwrite.

One can see based on those two test cases, how those two issues create
problems.
So fix the issues as explained above and fix them together in this one
commit, since they are related.
2021-05-21 04:15:20 +02:00
4faf976155
Update: Handle permutations of outdated box orders getting saved better 2021-05-17 19:44:00 +02:00
c2c4237bd3
Refactor: Move creation of updated box order into own method
Move the creation of an updated box order into an own method, so that
this method can be used elsewhere in the future to easily get an updated
box order.
2021-05-17 19:37:05 +02:00
c55b9e2648
Feature: Make it possible to move items to other top bar boxes 2021-05-17 18:09:06 +02:00
b938d7a28f
Other: Introduce ESLint for code linting 2021-05-17 17:45:22 +02:00
0c845336e6
Other: License this project
License this project under the GNU General Public License version 3.
2021-05-17 14:37:57 +02:00
0b7a15e55c
Breaking: Handle AppIndicator/KStatusNotifierItem items better
Handle AppIndicator/KStatusNotifierItem items differently (and better)
for the following reasons:
- These items have a role, which isn't very helpful for identifying the
  associated application.
- These roles seem to be different for each application run.
- There can be multiple AppIndicator/KStatusNotifierItem items for the
  same application (multiple instances of that application running).
2021-05-17 13:16:29 +02:00
572c6b69c1
Refactor: Group "private" methods
Group "private" methods to make their purpose clearer.
2021-05-17 11:38:17 +02:00
a73ed96bda
Feature: Handle changes of configured box orders
Handle changes of configured box orders, by ordering the relevant top
bar items according to the configured box order, which changed.
2021-05-16 21:32:30 +02:00
fd21ecb189
Refactor: Move individual top bar box ordering into own method
Move the individual top bar box ordering into own method, so that this
method can be used elsewhere in the future to easily order a single box.
2021-05-16 20:17:17 +02:00
2f0ecddfc8
Other: Add .editorconfigs
Add `.editorconfig`s, to help maintain a consistent coding style.
Also apply the new style to existing files.
2021-05-16 20:05:58 +02:00
f581935f85
New: Overwrite Panel._addToPanelBox
Overwrite `Panel._addToPanelBox` of Gnome Shell `js/ui/panel.js` with a
custom method, which handles top bar item additions to make sure that
they are added in the correct position.
2021-05-14 13:19:27 +02:00
0fc62ae465
Refactor: Move valid box order creation into own method
Move the valid box order creation into an own method.
This makes the `_orderTopBarItems` method cleaner and allows other
methods to easily create valid box orders as well in the future.
2021-05-14 13:19:20 +02:00
0f3e1608a9
New: Order top bar items on enable
Order top bar items on extension enable according to the saved box
orders.
2021-05-14 13:18:35 +02:00
f8488a97f4
New: Add new top bar items to box orders on enable
Introduce box orders, which allow this extension to save the order top
bar items should be in.
On extension enable, save new top bar items to those box orders.
2021-05-14 13:18:35 +02:00
821d849668
New: Add initial bare-bones extension source code
I'm using version 1 for the first development phase (like what major
version zero (0.y.z) is in Semantic Versioning 2.0.0), so that the first
production version then gets version 2.
2021-05-14 13:18:35 +02:00