1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-25 19:05:11 +02:00
Commit Graph

810 Commits

Author SHA1 Message Date
Maarten ter Huurne
51685e4758 Fixed blanking state set by PowerSaver
Previously 1 was written to the sysfs "blank" pseudo-file, but that
selects blanking state FB_BLANK_NORMAL, which does not power down the
display. Instead, we should write 4 for FB_BLANK_POWERDOWN.

Note that in the OpenDingux kernel, any non-zero blanking state would
power down the display, so we got the desired behavior in practice,
but this is not according to spec.
2014-10-15 02:19:32 +02:00
Maarten ter Huurne
7e2bdcc922 Remove #include in the middle of browsedialog.cpp
This was probably debug code that was only partially removed before
commit.
2014-10-04 08:56:43 +02:00
Maarten ter Huurne
f0f3684826 Clean up split() utility function
Remove fourth argument, which was never used and had a confusing name.
Change return type to void, since the returned value was never used.
Simplify the actual splitting code.
Add documentation comment.
2014-10-04 08:56:42 +02:00
Maarten ter Huurne
a03f8957aa Rewrote empty line stripping in manual display
The original code was incorrect: it used erase() on the end() iterator.
Also, it only checked for an initially empty page, but could not deal
with a page containing only empty lines, which will become an empty
page during the empty line removal.

The check for a line being empty is now done by searching the line for
non-whitespace characters instead of by trimming it. This avoids
creating new string objects that are only used to check whether they
are empty.
2014-09-17 14:30:22 +02:00
Maarten ter Huurne
4997438c11 Fixed code that removes comma at end of extensions list
In C++, the end() iterator points to the point after the last element,
not the last element itself. It is therefore not a valid target for
erase().
2014-09-17 14:00:16 +02:00
Maarten ter Huurne
e7248ae008 Removed unused include
When compiling with musl, I got a warning that <fcntl.h> should be used
instead of <sys/fcntl.h>, but it seems neither is necessary.

The comment suggested the battery code needed the header, but the code
that was moved to battery.cpp only uses functions from <stdio.h>.
2014-09-17 13:03:03 +02:00
Maarten ter Huurne
d27ebabc67 Fix build with musl libc
Add missing #include <climits>, needed for NAME_MAX.
2014-09-11 06:51:58 +02:00
Alexandre Vicenzi
289d0e7644 Added Brazilian Portuguese translation 2014-08-29 02:15:31 +02:00
Paul Cercueil
8364e11898 Fix extremely rare and extremely weird bug
Under certain conditions, it was possible to get orderLinks() trigger a
segmentation fault or a SIGBUS; even if all the Link* and Linkapp*
pointers where correct, the compare_links() function would eventually
end up receiving an invalid pointer.

Apparently, the std::sort function *requires* that the assertion
compare_links(a, b) != compare_links(b, a) is always true, which was not
the case previously when a link was compared with itself.
2014-08-21 04:18:50 +02:00
Maarten ter Huurne
7b2c26cc3c Don't apply realpath() to entered subdirs in Selector
This way, symlinks stay in the path, so when we go up a level we end
up in the previous directory instead of in the linked directory's
parent.
2014-08-20 14:57:17 +02:00
Maarten ter Huurne
c7a5b874f1 Don't assume that all non-directories are regular files
Other types are not very likely, but if we do encounter them it is best
to just skip them.
2014-08-20 13:09:49 +02:00
Maarten ter Huurne
3eb3a8ed7a If directory entry is a symbolic link, fall back on stat()
Unlike d_type, stat() will return the type of the target of the link
rather than the link itself.
2014-08-20 13:07:11 +02:00
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
b938c41067 Provide file permissions for newly created file
Since O_CREAT is passed, we have to provide permission flags too.
2014-08-19 00:12:05 +02:00
Maarten ter Huurne
4550eebc90 Make system calls restart on signals instead of handling EINTR
This leads to simpler code and probably fewer bugs.
2014-08-18 23:49:09 +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
5805d7889f Don't use file system write permissions to determine "deletable"
Instead, consider the installation location non-deletable and the home
directory deletable. This makes the "deletable" property follow the
purpose of the directory rather than its implementation details.
2014-08-18 23:17:27 +02:00
Maarten ter Huurne
fe790b1c8d Improved handling of platform specific open flags
There was support for platforms without O_DIRECTORY, but O_CLOEXEC
is also Linux specific and was hardcoded, making the whole thing not
portable.
2014-08-18 23:16:36 +02:00
Maarten ter Huurne
e12c896b99 Make writeStringToFile resilient against short writes
There are various situations in which write() might write less than
the requested amount. In that case, if any progress was made (more
than 0 bytes written), try again, otherwise consider it an error.

Thanks to Nebuleon for reviewing.
2014-08-18 22:51:58 +02:00
Maarten ter Huurne
104d749513 Don't start Monitor on non-existant paths
The check I removed earlier today was redundant for readPackages() but
not so much for the Monitor: it starts a thread and it logs an error,
both of which are better avoided when possible.

Also cleaned up implementation of readPackages() a bit.
2014-08-18 16:42:02 +02:00
Maarten ter Huurne
4740e274ed Add more detail in error message from Monitor::run() 2014-08-18 16:29:18 +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
23205dc7e6 Removed redundant exists check from Menu::openPackagesFromDir 2014-08-18 11:44:45 +02:00
Maarten ter Huurne
98f15d7419 Implement fileExists() using access() instead of open/close 2014-08-18 11:35:40 +02:00
Maarten ter Huurne
d82ebce770 Create LinkApp objects in Menu::readLinksOfSection()
This avoids having to store the paths in an intermediate vector. Also
it allows us to do the writability check once per directory instead of
once per file.
2014-08-17 22:23:17 +02:00
Maarten ter Huurne
e39447ee64 Have Menu::readLinks() sort using orderLinks()
Previously, it sorted before Link instances were created. Using
readLinks() ensures consistency and it might be more efficient if
a significant number of link files are rejected.

Also modernized the body of orderLinks() and removed unnecessary
special case for 1-link sections.
2014-08-17 22:02:33 +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
c3df9c4517 Removed ".empty" files for non-empty directories
Git doesn't track directories, just files, so dummy files are necessary
to preserve empty directories. These directories were not empty though.
Removing the dummy files avoids GMenu2X scanning them on startup.
2014-08-17 17:12:33 +02:00
Maarten ter Huurne
fe0c7c2e8d When going up a level in the selector, put cursor on old dir
This adds a sense of continuity to the navigation.
2014-08-17 11:15:21 +02:00
Maarten ter Huurne
bb30dedd09 When selector goes up from the root directory, stay in the root
Previously the selector would exit, but I don't see the logic in that.
2014-08-17 10:25:28 +02:00
Maarten ter Huurne
ba09d2599d Avoid out-of-range lookup when FileLister::browse is passed empty string
When the path is the empty string, it is handled as the current working
directory, which is consistent with how relative paths are handled.
2014-08-17 10:22:09 +02:00
Maarten ter Huurne
20725fcdda Do not list ".." as a subdirectory of the root directory
In Linux "/.." exists and loops back onto the root. But for the user
it is confusing to see a ".." entry listed that does nothing when
selected, so hide it.
2014-08-17 10:20:22 +02:00
Maarten ter Huurne
0b0e278459 Deal gracefully with the selector being started on a non-existent dir
If directory browsing is enabled, fall back to the closest existing
parent directory. If directory browsing is disabled, show empty list.
2014-08-17 10:05:21 +02:00
Maarten ter Huurne
9e22b0328f Made new "no items" text in Selector translatable 2014-08-17 08:41:09 +02:00
Maarten ter Huurne
e2382e11fd Made SettingsDialog::exec() return whether a setting was changed
Previously, exec() always returned true and a separate edited() method
would indicate whether any settings were changed.
2014-08-16 17:11:18 +02:00
Maarten ter Huurne
faf2495727 Use unique_ptr to make ownership of MenuSettings explicit 2014-08-16 17:01:04 +02:00
Maarten ter Huurne
8a1bb5694f Renamed SettingsDialog::voices to settings
I have no idea where that original name came from, but it didn't make
any sense to me.
2014-08-16 16:43:26 +02:00
Maarten ter Huurne
dc39fcc01f Make Selector robust against an empty file list
This can happen on a directory with 0 file matches when directories are
not being shown (otherwise there is either ".." or a subdir).

Since there is nothing to be selected, the Accept button is disabled
and no cursor is shown.
2014-08-16 15:50:16 +02:00
Maarten ter Huurne
3cce71284a Redistribute any leftover vertical space in Selector 2014-08-16 15:42:33 +02:00
Maarten ter Huurne
ffb736d80f Log surface load failures at DEBUG level instead of ERROR
Since we no longer check file existance before attempting a load,
load failures are often not errors. For example a missing preview
image is harmless.
2014-08-16 15:42:33 +02:00
Maarten ter Huurne
d16cb902b3 Improved Selector's handling of the folder icon
Renamed fontHeight to lineHeight, since it is computed using both the
font's line spacing and the height of the folder icon. For the latter,
use the actual icon height plus two pixels spacing instead of the
hardcoded value of 20 (16 height + 4 pixels spacing).

Fixed recently introduced bug where "top" is added to the folder icon
y-coordinate twice. Also center the icon vertically when a large font
is used.

Don't crash if the folder icon is missing. This could only happen on
broken installations though. Also don't search for the icon twice:
SurfaceCollection::skinRes already calls addSkinRes internally when
there is no cached surface for the key.
2014-08-16 15:41:06 +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