Make the preferences usable again (and look good) by using an
`AdwPreferencesPage` as well as various other libadwaita features (like
`AdwPreferencesGroup`, style classes, ...).
Also get rid of some code, which now doesn't seem to be necessary
anymore (making sure no horizontal scrollbar shows and setting a default
size for the preferences window).
This change is marked as "Breaking", since I assume `AdwPreferencesPage`
doesn't work in Gnome Shell 40 and because I changed the supported Gnome
Shell version to 42 accordingly.
The Dropbox client appends its PID to the id, which gets used for the
application name in `handleAppIndicatorKStatusNotifierItemItem`. This
resulted in the creation of a new entry for the Dropbox client on
basically every Dropbox client start, which would fill up the extensions
settings and would also result in the user effectively not being able to
set the position for the Dropbox client permanently.
This commit fixes these issues by removing the PID (and the hypen before
it) for the Dropbox client application name.
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.
This forget action removes the top bar item from the top bar order
representation, which is present in the settings, and then saves the top
bar order.
This action is intended for forgetting top bar items, which aren't
present in the top bar anymore, so that the user can clean up their
settings.
So if an item isn't in the top bar at the time of action activation,
activating the action removes it from the saved top bar order. If an
item is in the top bar at the time of action activation, the item
position just gets lost (since it gets automatically re-added to the top
bar order).
Let `PrefsBoxOrderItemRow` handle the association of itself with an item
itself.
Doing so makes the code cleaner, since the association isn't done
externally anymore.
Move the logic for saving the box order represented by a
`PrefsBoxOrderListBox` (and its `PrefsBoxOrderItemRows`) to the
`PrefsBoxOrderListBox` class.
This makes the code cleaner and allows for easy reuse of the logic in
the future.
Create a custom class (`PrefsBoxOrderListBox`) for GtkListBoxes, which
are used in the preferences window for holding box order settings.
Having a custom class for these GtkListBoxes is useful, since it can
hold logic related to box order settings. Future commits will bring more
of this logic into this class.
Scroll the content of the preferences window on Drag-and-Drop, when the
mouse is in the upper or lower part of the content of the preferences
window.
This helps a user, who has e.g. a lot of items, but the preferences
window with a low height, to easily move any item to any position.
Previously it could happen that the preferences window got larger than
the height of the screen (e.g. when having a bunch of items and a low
vertical screen resolution).
Fix this, by making the preferences window content scrollable.
Also introduce a nice default window size.
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.
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`.
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.
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`.
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.
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.
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).
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.
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.