Commit Graph

792 Commits

Author SHA1 Message Date
Astraeus-
61fed26400 LibGUI: Add ErrorOr wrapper for default icon creation 2021-12-17 13:09:54 -08:00
scwfri
fa94978a7e LibGUI: Add EngineType to EditingEngine classes
This will allow users of EditingEngine classes to determine current type
of EditingEngine (currently either vim or regular).
2021-12-09 21:31:06 +01:00
Sam Atkins
d95e50643e LibGUI: Cast unused smart-pointer return values to void 2021-12-05 15:31:03 +01:00
Sam Atkins
d2024f04bd Userland: Cast unused BackgroundAction::construct() results to void
User code does not need to keep this alive, so casting to void is safe.
But maybe a bit weird.
2021-12-05 15:31:03 +01:00
Martin Blicha
8fb52c6962 LibGUI: Make FilteringProxyModel reference-count its parent model
Before this change, the destructor of FilteringProxyModel
would crash if the parent model had been destroyed earlier.

This unifies the behaviour of FilteringProxyModel with
SortingProxyModel in this respect.
2021-12-02 22:43:54 +01:00
Erik Biederstadt
0cfe446d3f LibGUI: Allow double clicking on tabwidgets 2021-12-01 00:44:26 +03:30
scwfri
dbd40e4c2a LibGUI: Implement vim motions for LeftBrace and RightBrace
In VimEditingEngine, implemented vim motions for Key_LeftBrace and
Key_RightBrace
2021-11-30 10:55:19 +01:00
thankyouverycool
298a6b9937 LibGUI+FontEditor: Allow ComboBox on_change callback to be toggled
When calling set_selected_index() on ComboBox, allow its on_change
callback to be disabled. Fixes FontEditor window state erroneously
switching to modified when initializing between different slopes
and weights.
2021-11-30 10:51:51 +01:00
Andreas Kling
60c132d7d3 LibGUI: Move GUI::SettingsWindow setup out of the constructor
In order to propagate errors that occur during UI setup, we have to move
all that logic out of widget/window subclass constructors. This is a
first attempt at doing that, for GUI::SettingsWindow.
2021-11-28 08:54:22 +01:00
Andreas Kling
56c4f0aff5 LibGUI: Add fallible variants of the GUI::Layout add/insert APIs 2021-11-28 08:54:22 +01:00
Andreas Kling
45844f9338 LibGUI: Make GUI::SettingsWindow::add_tab() return ErrorOr
This allows us to use TRY() when creating settings UI.
2021-11-28 08:10:53 +01:00
Andreas Kling
8359975ff3 LibGUI: Make GUI::TabWidget tab creation APIs take String
Ultimately we'd like the caller to provide a String if possible (instead
of a StringView) as we're going to end up storing it.
2021-11-28 08:10:53 +01:00
kleines Filmröllchen
1e9554145e LibGUI: Add a cancel button callback to settings window tabs
Some settings tabs, like the ones on the upcoming terminal settings,
need to know when the cancel button is pressed to clean up things like
temporary live updates. Therefore, the SettingsWindow::Tab now features
a cancel_settings callback which does not need to be implemented.
2021-11-27 12:45:44 +01:00
Andreas Kling
e623e73f63 LibGUI: Add GUI::Toolbar::try_add_separator()
This is a fallible variant of add_separator() that returns ErrorOr.
2021-11-24 23:07:31 +01:00
Andreas Kling
a18631c5e7 LibGUI: Add GUI::Menu::try_add_submenu()
This is a fallible variant of add_submenu() that returns ErrorOr.
2021-11-24 23:07:31 +01:00
Andreas Kling
dbab20782e LibGUI: Make FilteringProxyModel factory function return ErrorOr 2021-11-24 13:52:01 +01:00
Andreas Kling
51c4de8774 LibGUI: Add GUI::Menu::try_add_action() and try_add_separator()
These are fallible variants that return ErrorOr. :^)
2021-11-24 13:52:01 +01:00
Andreas Kling
9b07e13fb6 LibGUI: Add GUI::Toolbar::try_add_action()
This is a fallible variant of add_action() that returns ErrorOr.
It's careful to not fail with a partially added action.
2021-11-24 13:52:01 +01:00
Andreas Kling
47b6339025 LibGUI: Add GUI::TabWidget::try_add_tab<T>(...)
This is a fallible variant of add_tab<T>(...) that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
dc47fce2d9 LibGUI: Add GUI::Window::try_set_main_widget<T>(...)
This is a fallible variant of set_main_widget<T>() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
bde9c2bc65 LibGUI: Add GUI::Window::try_add_menu()
This is a fallible variant of add_menu() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
6b79745aa4 LibGUI: Add GUI::Widget::try_set_layout<T>(...)
This is a fallible variant of set_layout<T>(...) that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
bc79be362d LibGUI: Add GUI::Menubar::try_add_menu()
This is a fallible variant of Menubar::add_menu() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Vyacheslav Pukhanov
2189cc6bf1 LibGUI: Reverse FilteringProxyModel update propagation flow
FilteringProxyModel is a narrowing projection of its parent model with
a filter applied. That means that updates of FilteringProxyModel should
not propagate to its parent model, but the opposite - updates happening
in the parent model should "trickle down" and trigger an update of the
filtering model.
2021-11-24 13:46:09 +01:00
Federico Guerinoni
221a32577e LibGUI: Support applying AutocompleteBox suggestions with mouse
Fixes: #8004
2021-11-23 13:43:11 +00:00
Andreas Kling
58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Mustafa Quraish
a0ef655451 LibGUI: Let Application constructor accept in Main::Arguments
Instead of manually passing in `arguments.argc` and `arguments.argv`,
we can now just pass in the arguments directly.
2021-11-22 21:13:42 -08:00
Andreas Kling
8e4eebe9b1 LibGUI: Use ErrorOr<T> in the file system thumbnail generator 2021-11-21 20:22:48 +01:00
Andreas Kling
5a79c69b02 LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
2021-11-21 20:22:48 +01:00
Ben Wiederhake
768915bbcd LibGUI: Make clipboard bitmap parsing more robust
In particular, malicious programs used to be able to set arbitrary
values as "format", which could cause UB (most likely a crash).

Furthermore, we do not transmit palette data, so an application sending
an indexed bitmap cannot possibly expect the other side to receive a
useful image. Therefore, we refuse to build a bitmap.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Ben Wiederhake
06f140a025 LibGUI: Avoid access to Clipboard server, clipboard text is never empty
The clipboard cannot reasonably contain the empty string. The clipboard
can be empty (i.e. cleared), sure, but that this check was about whether
the clipboard contained the empty string.

This cannot easily happen for two reasons:
- TextEditor GUI elements disable their copy actions when the selection
  is empty.
- Clipboard::set_data, through which all text-copying operates,
  implicitly forbids empty strings, because Process::sys$anon_create
  forbids empty anonymous files.
- Even if it were sent (e.g. by creating a non-empty anonymous file and
  sending it manually to the Clipboard server), it would not be
  received, because decode(Decoder&, Core::AnonymousBuffer&) goes
  through mmap() with a size of 0, which also is forbidden by the
  Kernel.

In other words, if the clipboard is never the empty text, therefore
checking this condition is pointless, and we can save a roundtrip to the
Clipboard server.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
c80dcc4671 LibGUI: Make paste access to Clipboard atomic
This avoids data race issues and saves a synchronous request to the
ClipboardServer.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
b6419f2cf2 LibGUI: Make clipboard-as-bitmap parsing less data-race-y
This encourages the caller to first fetch data and type atomically, and
then parse that, instead of potentially making multiple requests.
2021-11-21 11:49:06 +00:00
Sam Atkins
23341f35cb LibGUI: Add SettingsWindow class
The FooSettings apps have quite a lot of boilerplate just around
creating a tabbed window with the same styling and the same row of
buttons along the bottom. So, let's extract that out into a class we can
reuse! :^)

You create a SettingsWindow instead of a regular Window, passing a title
and a flag to determine if a "Defaults" button is shown. Then call
add_tab() to add tabs to it. Tabs are widgets extending
SettingsWindow::Tab, which has methods for saving and resetting the
values.
2021-11-20 21:05:20 +00:00
Andreas Kling
2b866e3c9b LibGfx: Remove ImageDecoderPlugin::bitmap() in favor of frame(index)
To encourage proper support for multi-frame images throughout the
system, get rid of the single-frame convenience bitmap() API.
2021-11-18 21:11:30 +01:00
Andreas Kling
216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling
587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Andrew January
c0d6e37ab3 LibGUI: Add support for Ctrl+Delete in TextEditor
Allow deleting the word after the cursor using Ctrl+Delete in a similar
manner to how Ctrl+Backspace deletes the word before the cursor.
2021-11-13 12:53:29 +01:00
Andrew January
22e80bae29 LibGUI: Change delete key handling from action to keydown_event
Having the delete key handling be done via an action limits our ability
to support key modifiers (e.g. ctrl+delete deleting the word in front of
the cursor).

The fact that it was an action _did_ allow us to have a delete button in
the TextEditor UI. However, this is an odd choice in the first place
that isn't common in other text editors, so I just removed it.
2021-11-13 12:53:29 +01:00
Andreas Kling
d21dc1f451 Everywhere: Replace "virtual desktop" => "workspace" 2021-11-13 12:48:43 +01:00
Andreas Kling
62ce7653cb LibGUI: Use PNGImageDecoderPlugin for ELF icon extraction
Getting rid of all the remaining calls to load_png_from_memory() and the
related wrappers for each decoder.
2021-11-13 00:55:07 +01:00
Andreas Kling
80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
6e255b262f LibGfx: Use ErrorOr<T> for try_create_from_serialized_byte_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Andreas Kling
2da4cfcc80 LibGfx: Use ErrorOr<T> for Bitmap::clone() 2021-11-08 00:35:27 +01:00
Andreas Kling
83d1460ee8 LibGfx: Use ErrorOr<T> for Bitmap::try_create_wrapper() 2021-11-08 00:35:27 +01:00