~ubuntu-branches/ubuntu/precise/htop/precise

« back to all changes in this revision

Viewing changes to FunctionBar.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-07-09 11:32:08 UTC
  • mfrom: (2.1.8 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090709113208-ts9xcebsg5kyyx1b
Tags: 0.8.3-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #385862)
  - debian/patches/910-ubuntu-64bit-ram-alignment.patch
    + Refresh patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define FUNCTIONBAR_CLASS NULL
37
37
#endif
38
38
 
39
 
static char* FunctionBar_FKeys[10] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10"};
40
 
 
41
 
static char* FunctionBar_FLabels[10] = {"      ", "      ", "      ", "      ", "      ", "      ", "      ", "      ", "      ", "      "};
42
 
 
43
 
static int FunctionBar_FEvents[10] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
44
 
 
45
 
FunctionBar* FunctionBar_new(int size, char** functions, char** keys, int* events) {
 
39
static char* FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL};
 
40
 
 
41
static char* FunctionBar_FLabels[] = {"      ", "      ", "      ", "      ", "      ", "      ", "      ", "      ", "      ", "      ", NULL};
 
42
 
 
43
static int FunctionBar_FEvents[] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
 
44
 
 
45
FunctionBar* FunctionBar_new(char** functions, char** keys, int* events) {
46
46
   FunctionBar* this = malloc(sizeof(FunctionBar));
47
47
   Object_setClass(this, FUNCTIONBAR_CLASS);
48
48
   ((Object*) this)->delete = FunctionBar_delete;
49
49
   this->functions = functions;
50
 
   this->size = size;
51
50
   if (keys && events) {
52
51
      this->staticData = false; 
53
 
      this->functions = malloc(sizeof(char*) * size);
54
 
      this->keys = malloc(sizeof(char*) * size);
55
 
      this->events = malloc(sizeof(int) * size);
56
 
      for (int i = 0; i < size; i++) {
 
52
      this->functions = malloc(sizeof(char*) * 15);
 
53
      this->keys = malloc(sizeof(char*) * 15);
 
54
      this->events = malloc(sizeof(int) * 15);
 
55
      int i = 0;
 
56
      while (i < 15 && functions[i]) {
57
57
         this->functions[i] = String_copy(functions[i]);
58
58
         this->keys[i] = String_copy(keys[i]);
59
59
         this->events[i] = events[i];
 
60
         i++;
60
61
      }
 
62
      this->size = i;
61
63
   } else {
62
64
      this->staticData = true;
63
65
      this->functions = functions ? functions : FunctionBar_FLabels;
64
66
      this->keys = FunctionBar_FKeys;
65
67
      this->events = FunctionBar_FEvents;
66
 
      assert((!functions) || this->size == 10);
 
68
      this->size = 10;
67
69
   }
68
70
   return this;
69
71
}