1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-28 20:49:55 +02:00
Commit Graph

839 Commits

Author SHA1 Message Date
Maarten ter Huurne
c2759f1263 Only allow empty sections to be deleted
Since not all links can be deleted, an action that deletes a section
and all the links it contains cannot be reliably implemented.
Therefore, the action will only be offered if all links have already
been deleted (or were never added in the first place).
2015-04-25 22:06:48 +02:00
Maarten ter Huurne
aeb9c12f5d Removed "gp2x.h" header
None of the definitions in it were used anymore.
2015-04-25 21:31:08 +02:00
Maarten ter Huurne
aeb9b0b2df Set a window title
This is useful when testing on PC.
2015-04-25 21:26:03 +02:00
Maarten ter Huurne
4159e6925b Declare "dirp" and "dptr" pointers just before they're needed 2015-04-25 15:41:58 +02:00
Maarten ter Huurne
510d67359c Cleaned up code that loads a manual from an OPK file
Most of it is for readability only, but there is also a leak that was
plugged: opk_close() is now called if extraction fails.
2015-04-25 15:35:11 +02:00
Maarten ter Huurne
00d3c3b570 Gave Layer class a protected constructor 2015-04-25 15:35:11 +02:00
Maarten ter Huurne
519387e38c Removed unused MMSP2ADC struct definition
A leftover from platform code that was removed long ago?
2015-04-25 15:35:11 +02:00
Maarten ter Huurne
9394a95a6c Fixed formatting string type mismatches
The "%zd" conversion specification seems to produce no warnings on both
32-bit and 64-bit systems.
2015-04-25 15:33:05 +02:00
Maarten ter Huurne
90a8d90e49 Removed unused methods in LinkApp class 2015-04-25 14:09:43 +02:00
Maarten ter Huurne
7b10f9448b Suppress Clang analyzer warnings about dead assignments
The last assignment in the series is indeed dead, but for consistency
I want to keep it around.
2015-04-24 18:41:10 +02:00
Maarten ter Huurne
cb1b26e5e6 Quit GMenu2X when window is closed in main screen
This helps when testing on PC.

I didn't bother to implement the same functionality for all dialog
event loops, since that would be a lot of extra work and not necessary
for the scenario that I need it for: clean exit when running under
Valgrind.
2015-04-24 18:07:10 +02:00
Maarten ter Huurne
ef6d378c5e Removed the "Rename section" option
This option is not compatible with section names being provided by
other sources than user-created links. Examples of other sources are
built-in action links, links installed by a distro in a read-only
directory and metadata from OPK files.
2015-04-24 14:46:27 +02:00
Nebuleon Fumika
2a2634b364 Remove all touch-screen-related code
It didn't work anymore, at all. Touchscreen polling occurred only
*after* waiting for a button had completed. So the touchscreen events,
if any, would be ignored until the user had pressed a button, possibly
firing off another action with that button press and forwarding the
touchscreen event to the next interface that got brought up as a
result.

Reusing this code and fixing it would require far more work than
rewriting everything anew with touchscreen devices in mind from the
beginning.

MtH: Resolved conflicts, mainly from the GMenu2X pointer to reference
     change I did on 2015-04-21.
2015-04-24 01:44:56 +02:00
Maarten ter Huurne
16aa3dd999 Removed include of <ini.h>
No functions from libini are used, so this line was probably left there
by accident.
2015-04-23 23:01:54 +02:00
Maarten ter Huurne
7eb377a857 Keep track of Link objects using unique_ptr
This ensures the memory is freed when the pointers are removed. While
there was an explicit delete loop in the destructor, memory leaks could
occur when links were removed from the menu.
2015-04-23 21:33:05 +02:00
Maarten ter Huurne
aa45ed9a74 Use const references to strings in Menu method arguments
This avoids unnecessary copying.

Removed sectionName argument to addLink(), since its only caller didn't
provide a value for it, meaning it always defaulted.
2015-04-23 17:28:22 +02:00
Maarten ter Huurne
9ca019ef51 Keep list of section names sorted at all times
Keeping it sorted when sections are inserted after startup improves the
user experience and if we have code for that already, we might as well
use it during startup too.
2015-04-22 19:58:28 +02:00
Maarten ter Huurne
fad68bfb6e Create sections for built-in action links if necessary
Previously, the built-in actions would only be added if their
respective sections already existed.

This also works around the fact that Menu::paint() crashes if there
are no sections present.
2015-04-22 19:58:28 +02:00
Maarten ter Huurne
08ecd7d8d9 Create section directory just before writing files to it
Previously, section directories would be created when the section was
added.
2015-04-22 19:57:47 +02:00
Maarten ter Huurne
9ac3351aa5 Look for data relative to prefix set by configure
This ensures that the data is searched for in the install location.
2015-04-22 10:24:11 +02:00
Maarten ter Huurne
3db955c471 Avoid crash on startup when no applications are found
The code cannot deal with there being no sections. After startup,
there will always be sections for the built-in actions. But before
those are added the lack of sections could be fatal.
2015-04-22 09:39:44 +02:00
Maarten ter Huurne
1a5da1fd94 Remove declaration of unimplemented method 2015-04-21 21:25:58 +02:00
Maarten ter Huurne
11ca8308b1 Pass GMenu2X instance by reference instead of pointer
This makes it explicit that null is not accepted.
2015-04-21 21:19:49 +02:00
Maarten ter Huurne
05a58e869c Don't crash if battery icon is not found
The icon pointer can be null, so don't convert it to a reference.
2015-04-21 19:29:26 +02:00
Maarten ter Huurne
9cfbc56bfa If font fails to open, log path tried 2015-04-21 18:28:37 +02:00
Maarten ter Huurne
b138b87fdc Disable cpufreq feature on PC
This feature is useful on selected platforms, but in general it is
better to have an on-demand governor select the right CPU speed.
2015-04-21 18:16:30 +02:00
Maarten ter Huurne
bb7775a326 Deduplicate default platform definition
Actually select "pc" instead of having a "default" platform that is
equivalent to "pc".
2015-04-21 18:12:30 +02:00
Maarten ter Huurne
0d26a2a456 Fixed compile when ENABLE_CPUFREQ is defined
There was some code inside an #ifdef that was overlooked during
refactoring.
2015-04-21 18:07:41 +02:00
Maarten ter Huurne
6418ff065f Updated SDL configure check
This check was copied from SDL 1.2.15's version of "sdl.m4".

This fixes a problem where "sdl.h" cannot be found on native compiles
because the output of the sdl-config script is ignored when compiling
the test program.
2015-04-21 17:43:26 +02:00
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