summaryrefslogtreecommitdiffstats
path: root/FunctionBar.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-04-09 18:02:50 -0300
committerHisham Muhammad <hisham@gobolinux.org>2014-04-09 18:02:50 -0300
commit19b438de1009047ee425d1f36207c20b9c80d43a (patch)
tree003a45252e211016edb8ec71518efb321fd5aced /FunctionBar.c
parentaf4c412ebf4ba96973fb6ea3e9ee8f59fe751769 (diff)
Improve discoverability of the expand/collapse feature.
It is now accessible via F6 when on tree view (as a bonus, it is now also reachable via the mouse). The function bar now dynamically changes to reflect the toggle nature of the tree-view mode (F5) and the F6 key serves as expand/collapse when on tree mode, and its previous behavior of bringing up the "Sort By" menu (which only made sense on non-tree mode). Users wishing to go to the "Sort By" menu straight from Tree View can still do so with the "<" and ">" keys (the top-compatible keys for sort selection).
Diffstat (limited to 'FunctionBar.c')
-rw-r--r--FunctionBar.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/FunctionBar.c b/FunctionBar.c
index 66b9843f..1c6066ae 100644
--- a/FunctionBar.c
+++ b/FunctionBar.c
@@ -40,15 +40,19 @@ ObjectClass FunctionBar_class = {
FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events) {
FunctionBar* this = AllocThis(FunctionBar);
- this->functions = (char**) functions;
+ this->functions = calloc(16, sizeof(char*));
+ if (!functions) {
+ functions = FunctionBar_FLabels;
+ }
+ for (int i = 0; i < 15 && functions[i]; i++) {
+ this->functions[i] = strdup(functions[i]);
+ }
if (keys && events) {
this->staticData = false;
- this->functions = malloc(sizeof(char*) * 15);
this->keys = malloc(sizeof(char*) * 15);
this->events = malloc(sizeof(int) * 15);
int i = 0;
while (i < 15 && functions[i]) {
- this->functions[i] = strdup(functions[i]);
this->keys[i] = strdup(keys[i]);
this->events[i] = events[i];
i++;
@@ -56,7 +60,6 @@ FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* eve
this->size = i;
} else {
this->staticData = true;
- this->functions = (char**)( functions ? functions : FunctionBar_FLabels );
this->keys = (char**) FunctionBar_FKeys;
this->events = FunctionBar_FEvents;
this->size = 10;
@@ -66,12 +69,14 @@ FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* eve
void FunctionBar_delete(Object* cast) {
FunctionBar* this = (FunctionBar*) cast;
+ for (int i = 0; i < 15 && this->functions[i]; i++) {
+ free(this->functions[i]);
+ }
+ free(this->functions);
if (!this->staticData) {
for (int i = 0; i < this->size; i++) {
- free(this->functions[i]);
free(this->keys[i]);
}
- free(this->functions);
free(this->keys);
free(this->events);
}
@@ -79,7 +84,6 @@ void FunctionBar_delete(Object* cast) {
}
void FunctionBar_setLabel(FunctionBar* this, int event, const char* text) {
- assert(!this->staticData);
for (int i = 0; i < this->size; i++) {
if (this->events[i] == event) {
free(this->functions[i]);

© 2014-2024 Faster IT GmbH | imprint | privacy policy