1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 21:24:32 +03:00
Commit Graph

136 Commits

Author SHA1 Message Date
Nebuleon Fumika
5758209170 Fix a crasher when launching an application whose icon is corrupt
It is possible for OPK links to refer to a missing icon or to an icon
that cannot be read as a PNG file, in which cases there is no fallback
to icons/generic.png and the icon is null.

Link::paint checks for this, but LinkApp::drawLaunch did not.

Obviously it is more desirable to properly fall back, but that would be
a very big change to many areas of the code, so this is a quick fix.
2014-08-19 09:25:26 +02:00
Maarten ter Huurne
482bd09d78 Avoid rewriting non-editable app settings
This is a workaround, see TODO in code for details.
2014-08-18 23:41:53 +02:00
Maarten ter Huurne
e827b2f18c For now, consider non-deletable applications to be immutable
In the future, we could make them editable by saving a companion file
in the home directory, similar to how OPKs can be customized.
2014-08-18 23:25:57 +02:00
Maarten ter Huurne
9f1827dc24 Make app setting file writes durable
The atomic write replaces the old with the new file, but unless we sync
the parent directory, that replacement is not permanent yet.
2014-08-18 15:56:14 +02:00
Maarten ter Huurne
fc4582a61f Write app settings files atomically
This is safer than the original code, which didn't use a temporary file
and could therefore leave partial files. Also it avoids a full sync(),
which can take a long time if for example a big file transfer is going
on or recently ended.
2014-08-18 15:35:56 +02:00
Maarten ter Huurne
956a9b6429 Pass file name as std::string to readFileAsString
For consistency, use C++ strings as much as possible in interfaces.
2014-08-18 14:22:18 +02:00
Maarten ter Huurne
07eefb219f If an app settings file is empty, remove it
Since only non-default values are saved, it was quite likely settings
files were empty, especially since the clock saving was fixed. We now
remove a settings file on save if the contents are empty, so we have
to load fewer files on startup.
2014-08-18 12:51:21 +02:00
Maarten ter Huurne
3694deecf6 Be resilient against zero or multiple "Categories" OPK metadata keys
For zero keys, the OPK file itself would be parsed as a settings file.
For multiple keys, all first categories would be appended to the path,
leading to a much too deep directory.
2014-08-17 20:37:15 +02:00
Maarten ter Huurne
7992d83e10 Pass C++ string to LinkApp constructor
All callers already had C++ strings and LinkApp wants a C++ string,
but because of the argument type the strings had to be converted.
2014-08-17 18:52:18 +02:00
Maarten ter Huurne
79ef176831 Disable delete context menu option for undeletable link files
Before this change, it was possible to delete for example a link that
is stored on a read-only file system and it would disappear after
deletion but reappear as soon as the menu restarts.
2014-08-17 18:43:02 +02:00
Maarten ter Huurne
88a4d1d911 Minor cleanups in Selector
Removed unused data member selRow.
Keep reference to LinkApp instead of pointer.
Call LinkApp::getSelectorBrowser once and store result.
Renamed fontheight to fontHeight.
Use iY consistently: store the item's y-coordinate in it.
2014-08-16 07:31:33 +02:00
Nebuleon Fumika
9b583f9b38 Rearrange calls to GMenu2X::drawButton from left to right
This breaks up large reversed call chains in a few places.
2014-08-16 07:11:30 +02:00
Maarten ter Huurne
fe0db484ec Removed "delegate.h"
The abstraction it provided was so thin that I think it is simpler to
just have the code use std::bind directly.
2014-08-16 07:07:41 +02:00
Maarten ter Huurne
3df841c150 Handle labelless icon positioning in GMenu2X::drawButton(Right)
Instead of correcting the returned coordinate with "- 10" externally,
omit the white space inside the methods.

Note that Font::getTextWidth, which was used until recently, considers
an empty string to have width 1, so 3 + getTextWidth("") + 6 == 10.

There is a difference in how buttons that have neither a label nor an
icon are positioned in the new code, but that is a situation that
should not occur in practice. Plus I'd argue that the new behavior is
actually better in that case.
2014-08-15 18:49:58 +02:00
Maarten ter Huurne
60aaf5954a Show a file selector in OPK links only if Exec requires a file
Previously, if a user installed a new version of an OPK with the same
name as one that had a link configuration file, GMenu2X could request
a file for an application whose new version required no files to
launch.

In practice, this transition would occur only once per OPK application,
when its developer decided to use a custom browser after having used
GMenu2X's file browser. This bug would then show GMenu2X's file browser
to request a file that would not even be passed to the application.

Thanks to Nebuleon for analyzing the problem and the above description.
2014-08-14 02:08:51 +02:00
Nebuleon Fumika
82ac7ef44b Set the clock to 0 before reading application link files
0 is the default clock value, which doesn't get written to link files
if it's not changed. The clock was previously uninitialised before
reading link files, so it would get written with a random value if
there was none before.
2014-08-13 07:39:37 +02:00
Maarten ter Huurne
60183e539d Removed most uses of naked Surface pointers
However, SurfaceCollection remains a very important user.
2014-08-10 14:21:14 +02:00
Maarten ter Huurne
4bd1c799bd Created separate subclasses for output and off-screen surfaces
There are a few exclusive operations for each type. Also we no longer
need the freeWhenDone flag since the class now determines whether the
surface should be freed or not.
2014-08-10 13:25:54 +02:00
Maarten ter Huurne
aff5f53f7d Don't pass around naked Surface pointers when drawing
Use references instead.
2014-08-10 04:26:59 +02:00
Maarten ter Huurne
7c4fa5d77a Launch application after destructing menu
This allows all destructors to do their job before we pass control to
a new process.
2014-08-10 02:09:34 +02:00
Maarten ter Huurne
303ecf298a Moved console bind+activate code into Launcher
This way, we can launch console applications from the Explorer.
2014-08-08 02:04:05 +02:00
Maarten ter Huurne
dc23718f7f Enable "Display Console" flag for all platforms
Applications with this flag will not have their stdout/stderr
redirected to a log file when logging is enabled. That is a useful
feature also on platforms where we don't micromanage the console.
2014-08-08 01:35:51 +02:00
Maarten ter Huurne
3e34124e68 Added Launcher class
Currently the launched application is exec-ed from deep within the menu
code. This means a lot of destructors are never run and as a result
for example file descriptors from the menu remain open in the launched
process.

This is a first step to move the launch invocation from a deep call
stack to the top level.
2014-08-07 16:48:30 +02:00
Maarten ter Huurne
902145b698 Removed Surface::write method
All it did was redirect to Font::write, so it's better to call that
method directly.
2014-07-31 23:16:51 +02:00
Maarten ter Huurne
485bab3b48 Made text file reading more efficient and robust
Instead of reading the file line by line and then concatenating those
lines, just load the entire thing in one go. And pay more attention to
error conditions.
2014-07-24 10:41:20 +02:00
Nebuleon Fumika
d0de870180 Use Font::wordWrap in TextDialog and TextManualDialog
The constructors of those classes now accept a string to be wrapped, instead
of a vector to be modified with split lines inserted into its middle.

Along with this conversion, manuals for applications stored in OPK packages
are now transferred into a string without garbage at the end.
2014-07-24 09:00:22 +02:00
Zear
cdf4ef1bf4 Introduced custom application launch text
This can be used to override weird automatically constructed messages
such as "Launching Power Off".
2014-07-19 01:09:16 +02:00
Nebuleon Fumika
349e758b3b Load previews from the previews/ subdir of the current dir in selectors.
This does away with per-link selector directories in link files. It is assumed
that, if a user has access to write files to be launched by an application at
some location, he or she also has access to write files in the previews/
subdirectory under it.
2014-07-17 02:02:23 +02:00
Maarten ter Huurne
bb7a30d697 Simplify iteration over tokens using std::array 2014-07-17 01:19:18 +02:00
Paul Cercueil
c72266d771 Remove the 'Selector alias file' feature
Who seriously used that?
2014-07-15 14:25:17 +02:00
Paul Cercueil
92a6453ff8 Re-insert proper detection of the %f tokens for OPK apps 2014-04-18 09:10:01 +02:00
Paul Cercueil
c19e78951d Fix launching non-OPK apps with files with special characters 2014-02-23 16:55:14 +01:00
Paul Cercueil
55a6528cde Revert to launching in the shell for non-OPK apps 2014-02-05 16:26:00 +01:00
Paul Cercueil
a7f0fef059 linkapp.cpp: remove dead/useless code 2014-02-05 14:53:46 +01:00
Paul Cercueil
1a1f891a4d Fix launching OPKs with a file containing spaces 2014-02-05 14:33:45 +01:00
Paul Cercueil
2ab44489a1 Execute the links directly, don't use the shell
This breaks one thing: the "params" option of the links must be
only one parameter (without spaces). The only way to actually
set this option being to edit the config files manually, it is
pretty safe to assume it will never contain two parameters.
2013-12-11 12:34:01 +01:00
Paul Cercueil
6ef3f3b190 Redirect to log by redefining stdout and stderr 2013-12-11 12:34:01 +01:00
Paul Cercueil
7c1af3a03b Use 'opkrun' to execute OPK files 2013-12-11 12:34:01 +01:00
Paul Cercueil
53ba01c40a Don't set called programs as group leaders
The comment of this code indicates that it is needed for
SDL apps to work correctly.

However, I don't see any valid reason for the apps we
launch to be running in a different group.

Removing it didn't make any apparent difference, so unless
I'm proven wrong, it'll stay gone from now on.
2013-12-11 12:31:47 +01:00
Paul Cercueil
31ad27f2bd Do not try to change the permissions of the executables 2013-12-11 12:31:29 +01:00
Paul Cercueil
246fd8630c Output log to /var/log/gmenu2x.log 2013-11-08 11:27:34 +01:00
Paul Cercueil
b73391486f Simplify again the prototype of LinkApp as gmenu2x->input is public 2013-09-05 19:20:54 -04:00
Paul Cercueil
1ff17d83c9 Add function GMenu2X::getTouchscreen(), to simplify Link and LinkApp prototypes 2013-09-05 19:19:16 -04:00
Maarten ter Huurne
965340a39c Fixed bug with launch screen and double buffering
LinkApp::drawRun() assumes the layers below are already painted when
it is called, but this was not the case. With single buffering, the
previous frame was still there so it still looked good, but with
double buffering the buffer typically contains an outdated screen.

Long term I think the launch should happen at the outermost scope,
so all destructors get a chance to run. This commit is a small step
in that direction, by exiting the main loop before launching.
2013-08-16 10:41:16 +02:00
Maarten ter Huurne
8d38decc82 Pass full path to LinkApp::launch 2013-08-16 09:46:16 +02:00
Maarten ter Huurne
d6deb29ba0 Eliminated selectedDir argument to LinkApp::launch() 2013-08-16 09:38:16 +02:00
Maarten ter Huurne
6c80a663e1 Check for empty strings using empty() instead of comparing to "" 2013-08-16 09:16:04 +02:00
Maarten ter Huurne
8472acc26c Removed checks for manuals and screenshots in JPEG and BMP format
Support for loading JPEG and BMP images was removed a long time ago,
so there is no point in looking for files in those formats.
2013-08-14 13:30:17 +02:00
Maarten ter Huurne
1ffae36004 Made Surface argument to drawTopBar/drawBottomBar() mandatory 2013-08-14 11:47:29 +02:00
Maarten ter Huurne
ea85b10d31 Reduce use of HAVE_LIBOPK inside LinkApp class as well
In commit de30b3f9 several outside uses were removed by always defining
isOpk(), this commit does the same for LinkApp itself.
2013-08-14 11:47:29 +02:00